Is it possible to define the tikz-layer to draw on inside a path command, eg \node[on main layer] at (0,0) {foo};? It is a bit tedious to put single macros in a scope-environment.
Asked
Active
Viewed 118 times
3
Jürgen
- 2,160
1 Answers
5
Options behind path and in front of path allows to superpose nodes and lines that are drawn on the same command.
\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}
Ignasi
- 136,588
-
That's fine and I'll keep it in mind for tasks to come, but I think this does not fit my original question. I need to put something on top of other paths, drawn later. – Jürgen Feb 23 '18 at 08:28

\newcommand\Scope[2][]{\begin{scope}[#1]#2\end{scope}}and then use constructs like\Scope{\node at (0,0){foo};}and\Scope[rotate=30]{\node at (0,0){foo};}. – Feb 23 '18 at 07:28scopeslibrary you can use{[on background layer]\node {foo};}, i.e.,{...}instead of\begin{scope}...\end{scope}. – Ignasi Feb 23 '18 at 07:38\nodecommand. – Jürgen Feb 23 '18 at 07:40tikz-layerspackage define some more layers:behind,aboveandglass. – Ignasi Feb 23 '18 at 07:40scopeslibrary seems to be interesting. I will have a look at it. Thanks! – Jürgen Feb 23 '18 at 07:43