Hide or shorten part of an arrow when using double copy shadow
You can redraw the nodes in the correct order (I also added thick to the shadow style):
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,shadows}
\tikzset{
boxSolidLine/.style = { fill=white, draw=black, thick, centered },
shadowbox/.style={boxSolidLine, double copy shadow={shadow xshift=-1ex, shadow yshift=1ex}},
arrowshadow/.style = { thick, color=black, ->, >=Triangle,double copy shadow={thick,shadow xshift=-1ex, shadow yshift=1ex}},
}
\begin{document}
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[node distance = 1.5cm, auto]
% Place nodes
\node [shadowbox] (node1) {Node 1};
\node [shadowbox, right= of node1] (node2) {Node 2};
\node [shadowbox, right= of node2] (node3) {Node 3};
\draw [arrowshadow] (node2) -- (node3);
\node [shadowbox, right= of node1] (node2) {Node 2};
\draw [arrowshadow] (node1) -- (node2);
\node [shadowbox] (node1) {Node 1};
\end{tikzpicture}
\caption{Test figure.}
\end{center}
\end{figure}
\end{document}
As you said, using layers might be the way to go here.
Keep in mind that basically, although to calculate the locations of the objects we need to go 1 -> 2 -> 3. We would really love to be drawing everything backwards.
Therefore, I set 3 layers node1ground
, node2ground
, node3ground
, and I place the order of the layers using \pgfsetlayers
so that they are drawn ending with node1ground
on top of the other layers
Here is my solution using layers. No need to add any other package, no need to redraw things multiple times :)
(Note that foreground
and background
can be removed, but it makes it easier to see which one is on top and which one is on the bottom, since their names are self-explanatory)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,shadows}
\tikzset{
boxSolidLine/.style = { fill=white, draw=black, thick, centered },
shadowbox/.style={boxSolidLine, double copy shadow={shadow xshift=-1ex, shadow yshift=1ex}},
arrowshadow/.style = { thick, color=black, ->, >=Triangle,double copy shadow={shadow xshift=-1ex, shadow yshift=1ex}},
}
\pgfdeclarelayer{node3ground}
\pgfdeclarelayer{node2ground}
\pgfdeclarelayer{node1ground}
\pgfdeclarelayer{foreground}
\pgfdeclarelayer{background}
\pgfsetlayers{background,main,node3ground,node2ground,node1ground,foreground}
\begin{document}
\begin{figure}[h]
\begin{center}
\begin{tikzpicture}[node distance = 1.5cm, auto]
\begin{pgfonlayer}{node1ground} %On top
\node [shadowbox] (node1) {Node 1};
\end{pgfonlayer}
\begin{pgfonlayer}{node2ground} %On middle
\node [shadowbox, right= of node1] (node2) {Node 2};
\end{pgfonlayer}
\begin{pgfonlayer}{node3ground} %On bottom
\node [shadowbox, right= of node2] (node3) {Node 3};
\draw [arrowshadow] (node2) -- (node3);
\end{pgfonlayer}
\begin{pgfonlayer}{node2ground} %On middle, after node 2 is draw
\draw [arrowshadow] (node1) -- (node2);
\end{pgfonlayer}
\end{tikzpicture}
\caption{Test figure.}
\end{center}
\end{figure}
\end{document}