如下图所示,一些选项似乎不受其范围的限制(例如,线条粗细和虚线),而其他选项则受到限制。(使用包backgrounds
。)规则是什么?另外,请注意箭头大小的奇怪后果。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[x=1in,y=1in]
\draw[ultra thick,blue] (0,1) -- (2,1);
\begin{scope}[on background layer]
\draw (0,2) -- (2,0);
\end{scope}
\begin{scope}[on background layer={ultra thick,red,dashed,->,>=latex}]
\draw (0,0) -- (2,2);
\end{scope}
\end{tikzpicture}
%
\begin{tikzpicture}[x=1in,y=1in]
\draw[ultra thick,blue] (0,1) -- (2,1);
\begin{scope}[on background layer={red,dashed,ultra thick}]
\draw (0,0) -- (2,2);
\end{scope}
\begin{scope}[on background layer={->,>=latex}]
\draw (0,2) -- (2,0);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[x=1in,y=1in]
\draw[ultra thick,blue] (0,1) -- (2,1);
\begin{scope}[on background layer]
\draw (0,2) -- (2,0);
\end{scope}
\begin{scope}[on background layer={ultra thick,red,dashed,->,>=latex}]
\draw (0,0) -- (2,2);
\end{scope}
\end{tikzpicture}
%
\begin{tikzpicture}[x=1in,y=1in]
\draw[ultra thick,blue] (0,1) -- (2,1);
\begin{scope}[on background layer={red,dashed,ultra thick}]
\draw (0,0) -- (2,2);
\end{scope}
\begin{scope}[on background layer={ultra thick,dashed,->,>=latex}]
\draw (0,2) -- (2,0);
\end{scope}
\end{tikzpicture}
\end{document}