1

I'm trying to make a 3d colored box with text in it.

So far, I have this long code below:

\documentclass[aspectratio=169]{beamer}
\usepackage{fontspec}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows, positioning,3d}

\begin{document}

\begin{frame}[t]{Why is it important?}

\begin{tikzpicture}[thick,scale=3] \coordinate (A1) at (0, 0); \coordinate (A2) at (0, 0.5); \coordinate (A3) at (2, 0.5); \coordinate (A4) at (2, 0); %\coordinate (B1) at (0.3, 0.3); \coordinate (B2) at (0.1, 0.6); \coordinate (B3) at (2.1, 0.6); \coordinate (B4) at (2.1, 0.1);

\draw[very thick] (A1) -- (A2);
\draw[very thick] (A2) -- (A3);
\draw[very thick] (A3) -- (A4);
\draw[very thick] (A4) -- (A1);

\draw[very thick] (A2) -- (B2);
\draw[very thick] (B2) -- (B3);
\draw[very thick] (A3) -- (B3);
\draw[very thick] (A4) -- (B4);
\draw[very thick] (B4) -- (B3);


\draw[fill=black!20,opacity=0.5] (A1) -- (A2) -- (A3) -- (A4);
\draw[fill=blue,opacity=0.6] (A3) -- (B3) -- (B4) -- (A4);
\draw[fill=green,opacity=0.6] (A2) -- (B2) -- (B3) -- (A3);
\node[anchor=center,xshift=1.15in,yshift=0.255in]{{\Large\fontspec{QTFuture} New research questions!}};

\end{tikzpicture} \end{frame}

\end{document}

Unfortunately, I could only fit the text {\Large\fontspec{QTFuture} New research questions!} and box manually so that it fits somewhat into the front grey area \draw[fill=black!20,opacity=0.5].

Is there another way of fitting the text perfectly into the front gray area.

Maybe there is another tikz method i.e. \node that can make a 3d textbox.

The screenshots look like this: Entire slide

Textbox

AlexLee
  • 151

1 Answers1

2

You could draw the text in a node and then add the sides based on the corners of the node:

\documentclass[aspectratio=169]{beamer}
%\usepackage{fontspec}
%\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{frame} \begin{tikzpicture}[thick,scale=3,line join=bevel] \node[fill=black!10,inner sep=0.5cm,draw=black] (foo) {{\Large New research questions!}}; \fill[blue!40,draw=black] (foo.south east) -- ++(0.15cm,0.15cm) -- ($(foo.north east)+(0.15cm,0.15cm)$) -- (foo.north east) -- cycle; \fill[green!40,draw=black] (foo.north west) -- ++(0.15cm,0.15cm) -- ($(foo.north east)+(0.15cm,0.15cm)$) -- (foo.north east) -- cycle; \end{tikzpicture}

\vfill

\begin{tikzpicture}[thick,scale=3,line join=bevel] \node[fill=black!10,inner sep=0.5cm,draw=black] (foo) {{\Large Quack!}}; \fill[blue!40,draw=black] (foo.south east) -- ++(0.15cm,0.15cm) -- ($(foo.north east)+(0.15cm,0.15cm)$) -- (foo.north east) -- cycle; \fill[green!40,draw=black] (foo.north west) -- ++(0.15cm,0.15cm) -- ($(foo.north east)+(0.15cm,0.15cm)$) -- (foo.north east) -- cycle; \end{tikzpicture} \end{frame}

\end{document}

enter image description here