我试图在两张 tikzpicture 的背景中显示“禁止标志”(很像某种水印)。然而,在下面的 MWE 中,“禁止标志”在某条看似任意的水平线上被切断。
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{backgrounds,shapes}
\begin{document}
\noindent
\begin{tikzpicture}
\draw[green] (0.0, -5.0) rectangle (10.0, 0.0);
\end{tikzpicture}\\
\begin{tikzpicture}
\draw[blue] (0.0, -5.0) rectangle (10.0, 0.0);
\begin{pgfonlayer}{background}
\begin{scope}[opacity=0.5,transparency group,overlay]
\draw node[forbidden sign,
minimum size=5cm,
line width=2ex,
draw=red,
fill=white] at (5.0,0.0) {Test};
\end{scope}
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
你知道我该如何纠正这个问题吗?
答案1
似乎很难overlay
使用transparency group
\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{backgrounds,shapes}
\pgfdeclarelayer{myback}
\pgfsetlayers{myback,main}
\newsavebox{\mybox}
\begin{document}
\parindent=0pt
\savebox{\mybox}{%
\begin{tikzpicture}[transparency group,opacity=.5]
\node[forbidden sign,
minimum size=5cm,
line width=2ex,
draw=red,
fill=white] {};
\end{tikzpicture}}
\begin{tikzpicture}
\draw[green] (0.0, -5.0) rectangle (10.0, 0.0);
\end{tikzpicture}\\ \baselineskip=0pt
\begin{tikzpicture}[remember picture,overlay]
\draw[blue] (0.0, -5.0) rectangle (10.0, 0.0);
\begin{pgfonlayer}{myback}
\node[inner sep=0pt] (s) at (5,0){\usebox\mybox};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}