
是否可以定義要在路徑命令內繪製的 tikz 層,例如\node[on main layer] at (0,0) {foo};
?將單一巨集放入作用域環境中有點乏味。
答案1
選項behind path
和in front of path
允許疊加在同一命令上繪製的節點和線。
\documentclass[tikz,border=2mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw[thick, draw=green] (0,0) --
node[pos=0.25, behind path, fill=red!30 ]{A}
node[pos=0.75, fill=red!30 ]{A} (2,0);
\path (1,1) node[fill=blue!20] {A}
node[fill=green, behind path, inner sep=3mm] {A}
node[fill=red, inner sep=1mm, in front of path] {};
\end{tikzpicture}
\end{document}