如何将文本置于图像的前面?下面的代码将其置于图像后面。我告诉 tikz 节点在前面,但它仍然在后面?
\begin{figure}
\centering
\begin{tikzpicture}
\node[draw,front] at (0,0) {some text};
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.8\columnwidth,trim={0 3cm 0 0},clip]{figures/intro/intro1.png}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[fill=white, ultra thick, rounded corners] (0.5,0.2) rectangle (0.9,0.05);
\end{scope}
\end{tikzpicture}
\end{figure}
答案1
切换语句的顺序,以便最后设置文本;项目在代码中按顺序绘制:
\documentclass{article}
\usepackage{graphicx,tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.8\columnwidth,trim={0 3cm 0 0},clip]{example-image}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[fill=white, ultra thick, rounded corners] (0.5,0.2) rectangle (0.9,0.05);
\end{scope}
\node[draw] at (0,0) {some text};
\end{tikzpicture}
\end{figure}
\end{document}