# “Crossing over” not working for down arrows in tikz-cd

Here's my code:

\begin{equation*}
\begin{tikzcd}
0 \arrow[rr] & & A\arrow{dd} \arrow[rd]\arrow[rr]&& B\arrow[rd]\arrow[rr]\arrow{dd} && C\arrow[rr]\arrow[rd] && 0\\
& 0 \arrow[crossing over]{rr} && A'\arrow[crossing over]{dd} \arrow[crossing over]{rr} && B'\arrow[crossing over]{dd}\arrow[crossing over]{rr} && C'\arrow[crossing over]{dd} \arrow[rr] && 0\\
0 \arrow{rr} & & I^0\arrow{rr}&& I^0 \oplus J^0\arrow{rr} && J^0\arrow{rr} && 0 \\
& 0 \arrow[crossing over]{rr} && I^{0'} \arrow[crossing over]{rr} && I^{0'}\oplus J^{0'}\arrow[crossing over]{rr} && J^{0'} \arrow[rr] && 0
\end{tikzcd}
\begin{equation*}


Unfortunately the diagram I have looks like this: As we can see, the down arrows from the second row to the fourth row are not obeying the crossing over command. Any ideas?

EDIT:

Here's my full code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{tikz-cd}

\begin{document}
$$\begin{tikzcd} 0 \arrow[rr] & & A\arrow{dd} \arrow[rd]\arrow[rr]&& B\arrow[rd]\arrow[rr]\arrow{dd} && C\arrow[rr]\arrow[rd] && 0\\ & 0 \arrow[crossing over]{rr} && A'\arrow[crossing over]{dd} \arrow[crossing over]{rr} && B'\arrow[crossing over]{dd}\arrow[crossing over]{rr} && C'\arrow[crossing over]{dd} \arrow[rr] && 0\\ 0 \arrow{rr} & & I^0\arrow{rr}&& I^0 \oplus J^0\arrow{rr} && J^0\arrow{rr} && 0 \\ & 0 \arrow[crossing over]{rr} && I^{0'} \arrow[crossing over]{rr} && I^{0'}\oplus J^{0'}\arrow[crossing over]{rr} && J^{0'} \arrow[rr] && 0 \end{tikzcd}$$

\end{document}

• Welcome to the community TeX.SE. – Sebastiano Oct 22 at 10:49
• I tried the code with TeX Live from 2013 up to 2020 and it works as expected, with crossing over active. Please, add a full compilable example that shows the issue. – egreg Oct 22 at 11:42
• @Sebastiano thanks :) – nolatos Oct 25 at 4:50
• @egreg Thanks for your reply, I'm not sure what you mean by a full compatible example? I have posted my full code just now – nolatos Oct 25 at 4:51
• @nolatos That's exactly what I asked for, thanks! Wrapping the original code in a standard document didn't show the issue. – egreg Oct 25 at 8:46

You need to delay the drawing of the crossing over arrows when the “under arrows” have already been drawn.

The simplest way is to define them in the target cell with from=.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{tikz-cd}

\begin{document}

$$\begin{tikzcd}[column sep={between origins,3.5em}] 0 \arrow[rr] && A \arrow[dd] \arrow[rd] \arrow[rr] && B \arrow[rd] \arrow[rr] \arrow[dd] && C \arrow[rr]\arrow[rd] && 0 \\ % down arrows here are delayed & 0 \arrow[crossing over,rr] && A' \arrow[crossing over,rr] && B' \arrow[crossing over,rr] && C' \arrow[rr] && 0 \\ 0 \arrow[rr] && I^0\arrow[rr] && I^0 \oplus J^0 \arrow[rr] && J^0\arrow{rr} && 0 \\ & 0 \arrow[crossing over,rr] && I^{0'} \arrow[crossing over,rr] \arrow[from=uu,crossing over] && I^{0'}\oplus J^{0'} \arrow[crossing over,rr] \arrow[from=uu,crossing over] && J^{0'} \arrow[rr] \arrow[from=uu,crossing over] && 0 \end{tikzcd}$$

\end{document}


I made also a few adjustments to your code, uniformizing the syntax. I like not to have overlong lines so I can have the entire code for a row under control. More important, between origins avoids the different slopes of the diagonal arrows; the disadvantage is that the column separation has to be guessed, but such diagrams have to be looked at when typeset anyway and no “universal recipe” for the row or column spacing exists.

An arrow from C to J0 is probably missing (also in your sample code).

Like this ?

• I used the absolute placement of the arrows.
• I colored them blue so that you can see the changes more easily.
• I have commented the code that is useless to build this graph, without removing it so that you can see the changes more easily.

Some explanations:

• with tikz-cd, the crossing over style makes a thicker line, with color background color, to be drawn under the current arrow, simulating the effect of its passing over other arrows (see manual section 2.6 Three-dimensional diagrams).
• Since your cross over arrow is built first and the other one second, it has no effect. Arrows with a cross-over effect must always be built last. When it is not possible to do this in the usual way, you can always build them last with absolute placement.

\documentclass[border=5mm]{standalone}
%\usepackage[english]{babel}
%\usepackage{amsthm}
%\usepackage{amsfonts}
%\usepackage{amsmath}
%\usepackage{xfrac}
\usepackage{tikz-cd}

\begin{document}
%    $$\begin{tikzcd} 0 \arrow[rr] & & A\arrow{dd} \arrow[rd]\arrow[rr]&& B\arrow[rd]\arrow[rr]\arrow{dd} && C\arrow[rr]\arrow[rd] && 0\\ & 0 \arrow[crossing over]{rr} && A'%\arrow[crossing over]{dd} \arrow[crossing over]{rr} && B'%\arrow[crossing over]{dd} \arrow[crossing over]{rr} && C'%\arrow[crossing over]{dd} \arrow[rr] && 0\\ 0 \arrow{rr} & & I^0\arrow{rr}&& I^0 \oplus J^0\arrow{rr} && J^0\arrow{rr} && 0 \\ & 0 \arrow[crossing over]{rr} && I^{0'} \arrow[crossing over]{rr} && I^{0'}\oplus J^{0'}\arrow[crossing over]{rr} && J^{0'} \arrow[rr] && 0 %-- absolute placement of arrows --% \arrow[blue,from=2-4,to=4-4,crossing over] \arrow[blue,from=2-6,to=4-6,crossing over] \arrow[blue,from=2-8,to=4-8,crossing over] \end{tikzcd} %$$

\end{document}

• Yes, that works thank you. Out of curiosity, what was wrong with my original code? – nolatos Oct 25 at 8:26
• @nolatos This is because the arrows are built in the order they are written. With tikz-cd, the crossing over style makes a thicker line, with color background color, to be drawn under the current arrow, simulating the effect of its passing over other arrows (see manual section 2.6 Three-dimensional diagrams). Since your cross over arrow is built first and the other one second, it has no effect. Arrows with a cross-over effect must always be built last. When it is not possible to do this in the usual way, just use absolute placement. – AndréC Oct 25 at 9:03

I confirm that the command crossing over works correctly. As you can see from the comparison of your code I have positioned the crossings correctly. Check your code that have two \begin{equation*}.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
0 \arrow[rr] & & A\arrow{dd} \arrow[rd]\arrow[rr]&& B\arrow[rd]\arrow[rr]\arrow{dd} && C\arrow[rr]\arrow[rd] && 0\\
& 0 \arrow[crossing over]{rr} && A'\arrow{dd} \arrow[crossing over]{rr} && B'\arrow{dd}\arrow{rr} && C'\arrow{dd} \arrow[rr] && 0\\
0 \arrow{rr} & & I^0\arrow[crossing over]{rr}&& I^0 \oplus J^0\arrow[crossing over]{rr} && J^0\arrow[crossing over]{rr} && 0 \\
& 0 \arrow{rr} && I^{0'} \arrow{rr} && I^{0'}\oplus J^{0'}\arrow{rr} && J^{0'} \arrow[rr] && 0
\end{tikzcd}
\end{document}

• Thanks but unfortunately the arrow I'm interested in is the down arrow from A' to I^{0'}, not the horizontal one. – nolatos Oct 25 at 4:53
• I'm sorry :-( I have not understood well your question..hence. If you prefer I remove my answer. – Sebastiano Oct 29 at 21:53