6

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: enter image description here 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{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} \end{equation}

\end{document}

Sebastiano
  • 54,118
nolatos
  • 163

4 Answers4

7

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{equation} \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{equation}

\end{document}

enter image description here

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).

egreg
  • 1,121,712
3

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.

screenshot

\documentclass[border=5mm]{standalone}
%\usepackage[utf8]{inputenc}%<-- useless always loaded 
%\usepackage[english]{babel}
%\usepackage{amsthm}
%\usepackage{amsfonts}
%\usepackage{amsmath}
%\usepackage{xfrac}
\usepackage{tikz-cd}

\begin{document} % \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 %-- 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{equation}

\end{document}

AndréC
  • 24,137
  • Yes, that works thank you. Out of curiosity, what was wrong with my original code? – nolatos Oct 25 '20 at 08: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 '20 at 09:03
2

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*}.

enter image description here

\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}

Sebastiano
  • 54,118
  • 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 '20 at 04:53
  • I'm sorry :-( I have not understood well your question..hence. If you prefer I remove my answer. – Sebastiano Oct 29 '20 at 21:53
0

While drawing (and thereby specifying) the crossing-over arrow later it might be useful – for simple cases – to specify that an arrow should be drawn in the background (this would also mean behind cells/labels).

So instead of \ar or \arrow you use \bgar or \bgarrow.

I didn't add the shortcut variants \bgrar, etc.

Code

\documentclass{article}
\usepackage[english]{babel}
\usepackage{tikz-cd}
\usetikzlibrary{backgrounds}
\makeatletter
\let\tikzcd@ar@new@orig\tikzcd@ar@new
\def\tikzcd@ar@new@bg[#1]{%
  \pgfutil@g@addto@macro\tikzcd@savedpaths{%
    \pgfonlayer{background}\path[/tikz/commutative diagrams/.cd,every arrow,#1]%
    (\tikzcd@ar@start\tikzcd@startanchor)to(\tikzcd@ar@target\tikzcd@endanchor);
    \endpgfonlayer}\let\tikzcd@ar@new\tikzcd@ar@new@orig}
\tikzcdset{every diagram/.append code=%
  \def\bgarrow{\let\tikzcd@ar@new\tikzcd@ar@new@bg\tikzcd@arrow}%
  \let\bgar\bgarrow}
\makeatother
\begin{document}
\begin{equation}
\begin{tikzcd}[column sep={3.5em,between origins}]
  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              \bgarrow[rr] % ← \bgarrow
      && I^0 \oplus J^0 \bgarrow[rr] % ← \bgarrow
        && J^0          \bgarrow[rr] % ← \bgarrow
          && 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{equation}
\end{document}

Output

enter image description here

Qrrbrbirlbel
  • 119,821