7

I'm drawing some commutative diagrams, and some of my diagonal arrows are crossing nodes on their way. I would like to have a sort of "crossing under", to force the arrow not to show while crossing the node.

I copy the code here:

\begin{tikzcd}
%first row
A \ar[rr] \ar[dd] \ar[dr]
& 
& B \ar[dd] \ar[dr]
& 
\\
%second row
& E \ar[rr] \ar[dd]
& 
& F \ar[dd]
\\
%third row
C \ar[rr] \ar[dr] \ar[uurr]
& 
& D \ar[dr]
& 
\\
%forth row
& G \ar[rr] \ar[uurr]
& 
& H
\end{tikzcd}

enter image description here

As you can see, it is very unelegant! It would be nicer if the arrows "interrupted" and started again after the node.

Thanks!

3 Answers 3

7

Splitting into multiple arrows:

\documentclass{article}

\usepackage{tikz-cd}
\usepackage{xcolor}

\begin{document}

\begin{tikzcd}
%first row
A \ar[rr] \ar[dd] \ar[dr]
& 
& B \ar[dd] \ar[dr]  \ar[from=dl]
& 
\\
%second row
& E \ar[rr] \ar[dd] \ar[-,dl]
& 
& F \ar[dd]
\\
%third row
C \ar[rr] \ar[dr]
& 
& D \ar[dr] \ar[ur]
& 
\\
%forth row
& G \ar[rr] \ar[-,ur]
& 
& H
\end{tikzcd}

\end{document}

enter image description here

Avoiding the nodes:

\documentclass{article}

\usepackage{tikz-cd}
\usepackage{xcolor}

\begin{document}

\begin{tikzcd}
%first row
A \ar[rr] \ar[dd] 
& 
& B \ar[dd] \ar[dr] \ar[from=ddll,bend left=30]
& 
\\
%second row
& E \ar[rr] \ar[dd] \ar[from=ul,crossing over]
& 
& F \ar[dd]
\\
%third row
C \ar[rr] \ar[dr] 
& 
& D \ar[dr]
& 
\\
%forth row
& G \ar[rr] \ar[from=uurr,bend left=30,crossing over]
& 
& H
\end{tikzcd}
\end{document}

enter image description here

2
  • Thank you for both suggestions, but my diagrams are growing more an more complicated, so I prefer to avoid adding or bending arrows. Thank you again! Commented Jun 9, 2019 at 11:34
  • Do you have a modification where the arrows go from $B \to C$ and $F\to G$ instead, and the arrow $E\to G$ crosses over the arrow $C\to D$?
    – ThePuix
    Commented May 4, 2021 at 13:16
7

Just for fun: an attempt to give a 3D impression.

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{backgrounds}
\usepackage{contour}
\contourlength{1pt}
\begin{document}
\[\begin{tikzcd}[execute at end picture={
\begin{scope}[on background layer]
 \draw[->] (C) -- (B);
\end{scope}
 \draw[preaction={draw,line width=2.4pt,white},->] (G) -- (F);
}]
%first row
A \ar[rr] \ar[dd] \ar[dr]
& 
& |[alias=B]| B \ar[dd] \ar[dr]
& 
\\
%second row
& \contour{white}{$E$} \ar[rr] \ar[dd]
& 
&|[alias=F]| F \ar[dd]
\\
%third row
|[alias=C]| C \ar[rr] \ar[dr] %\ar[uurr]
& 
& D \ar[dr]
& 
\\
%forth row
& |[alias=G]| G \ar[rr] %\ar[uurr]
& 
& H
\end{tikzcd}\]
\end{document}

enter image description here

3
  • Oh, that is really nice. I'm so sorry my diagrams are getting too involuted for that! Thank you, I sincerely appreciated the effort! Commented Jun 10, 2019 at 7:48
  • @BarbaraGiunti Honestly I think you should accept the answer by user190633. The currently accepted answer is very fragile. Think of newcomers who may think that the accepted answer may be the "best" one. Of course, this is just my opinion, and you can do what you want.
    – user121799
    Commented Jun 10, 2019 at 16:56
  • I think you're right, it was working for me, so I didn't notice the problem either. Thanks for the suggestions, I'm a newcomer myself! Commented Jun 11, 2019 at 13:46
6

This does what you want:

\documentclass[pdf]{article}
\usepackage{tikz-cd}

\begin{document}

\[ 
\begin{tikzcd}
%first row
A \ar[rr] \ar[dd] \ar[dr]
&
& B \ar[dd] \ar[dr]
&
\\
%second row
& E \ar[rr] \ar[dd]
&
& F \ar[dd]
\\
%third row
C \ar[rr] \ar[dr] \ar[uurr, "\textstyle E" description]
&
& D \ar[dr]
&
\\
%forth row
& G \ar[rr] \ar[uurr, "\textstyle D" description]
&
& H
\end{tikzcd}
    \]

\end{document} 

enter image description here

7
  • Thanks! That was exactly what I wanted! Commented Jun 9, 2019 at 11:32
  • This is very fragile. Replace e.g. B by \displaystyle\int_0^1.
    – user121799
    Commented Jun 9, 2019 at 19:55
  • @marmot: ??? I see no problem on compiling.
    – Bernard
    Commented Jun 10, 2019 at 0:01
  • @Bernard Really? How does the bottom the E look like when you compile it? I get a fragment of the E that lies underneath on my just updated TeXLive2019 distribution when compiling this with pdflatex and B replaced by \displaystyle\int_0^1. If you give things some reduced opacity by saying \begin{tikzcd}[opacity=0.5] ... you understand why.
    – user121799
    Commented Jun 10, 2019 at 0:49
  • @marmot: I hadn't noticed it – I must say I didn't zoom out. A workaround seems to replace $E$ and $D$ (the nodes, not the ‘descriptions’) with \phantom{E/D} – unless you find out another problem with this way. I'll update the code in a moment, with some improvements.
    – Bernard
    Commented Jun 10, 2019 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .