我正在尝试制作一个带有文字的 3d 彩色框。
到目前为止,我有以下这段长代码:
\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}
不幸的是,我只能手动调整文本{\Large\fontspec{QTFuture} New research questions!}
和框,以使其稍微适应前面的灰色区域\draw[fill=black!20,opacity=0.5]
。
是否有其他方法可以让文本完美地适合前面的灰色区域。
也许有另一种 tikz 方法,即\node
可以制作 3d 文本框。
答案1
您可以在节点中绘制文本,然后根据节点的角添加边:
\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}