11

It appears that tikzcd puts a transparent, but visible vertical line at both ends of an \arrow[equal] like this:

enter image description here

I find this somewhat irritating and would like to know if it is possible to make tikzcd produce proper "equal" arrows, i.e. without vertical ends, like the good old xy-pic does:

enter image description here

1 Answer 1

13

This is because tikz-cd uses double for that, which draws a white line on top. Here is a simple way to fix this, even with a free bonus. ;-)

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.markings}
\tikzset{double line with arrow/.style args={#1,#2}{decorate,decoration={markings,%
mark=at position 0 with {\coordinate (ta-base-1) at (0,1pt);
\coordinate (ta-base-2) at (0,-1pt);},
mark=at position 1 with {\draw[#1] (ta-base-1) -- (0,1pt);
\draw[#2] (ta-base-2) -- (0,-1pt);
}}}}
\begin{document}
Original:
\[
\begin{tikzcd}
X \ar[equal]{r} & Y \ar[mapsfrom]{r} & Z
\end{tikzcd}
\]

Fixed:
\[
\begin{tikzcd}
X \ar[-,double line with arrow={-,-}]{r} & Y \ar[mapsfrom]{r} & Z
\end{tikzcd}
\]

Bonus:
\[
\begin{tikzcd}
X \ar[-,double line with arrow={latex-,-latex}]{r} & Y \ar[mapsfrom]{r} & Z
\end{tikzcd}
\]

\end{document}

enter image description here

3
  • Thanks, that works great! An additional question if you don't mind: is it possible to actually overwrite the old "equal" style with the new "equal" style?
    – M.G.
    Commented Jul 24, 2018 at 13:59
  • 2
    @M.G. I do not think it is straightforward, at least I did not manage to do this with straightforward ways. And I would not recommend this either since it might backfire in a way that is hard to predict. However, you could do \tikzset{Equal/.style={-,double line with arrow={-,-}}} and then work with Equal instead of equal.
    – user121799
    Commented Jul 24, 2018 at 16:24
  • Thanks for looking into it! Indeed Equal does the job just as well, thanks for the excellent suggestion.
    – M.G.
    Commented Jul 24, 2018 at 16:30

You must log in to answer this question.

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