5

I'm trying to go from xypic to tikz but there are a number of xypic features that I don't seem to be able to find in tikz.

In tikz you can easily draw double-arrows, which is about the same as using \ar@2 in xypic. I also use triple and quadruple arrows in xypic, with ar@3 and ar@4 (the last one is a custom shaft).

My question is: How is it possible to draw triple/quadruple arrows in Tikz?

I am willing to try and define custom arrow shafts if need be, but I can't find how to do that in the tikz manual (which is quite formidable by the way).

3
  • You can stick an arrowhead on the end of any line, so the question is how do I make triple or quadruple lines? Feb 25, 2015 at 15:49
  • @JohnKormylo Yes it is. Feb 25, 2015 at 16:02
  • A third solution is provided in this answer. Aug 19, 2019 at 9:20

2 Answers 2

2

This should be more general. The optional arguments handle the left and right fudge factors for hiding the smaller arrowheads.

arrows

\documentclass{article}
\usepackage{xargs}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}

\newlength{\myline}% line thickness
\setlength{\myline}{1pt}
\newcommandx*{\triplearrow}[4][1=0, 2=1]{% #1 = shorten left (optional), #2 = shorten right (optionsl),
% #3 = draw options (must contain arrow type), #4 = path
  \draw[line width=\myline,double distance=3\myline,#3] #4;
  \draw[line width=\myline,shorten <=#1\myline,shorten >=#2\myline,#3] #4;
}
\newcommandx*{\quadarrow}[4][1=0, 2=2.5]{% #1 = shorten left (optional), #2 = shorten right (optionsl),
% #3 = draw options (must contain arrow type), #4 = path
  \draw[line width=\myline,double distance=5\myline,#3] #4;
  \draw[line width=\myline,double distance=\myline,shorten <=#1\myline,shorten >=#2\myline,#3] #4;
}
\begin{document}
\begin{tikzpicture}
\triplearrow{arrows={-Implies}}{(0,0) -- (1,1)}
\quadarrow[2.5]{arrows={Implies-Implies}}{(1,0) to[bend right] (2,1)}
\end{tikzpicture}
\end{document}
4
  • Thank you very much. Is there a way to make the arrowheads thinner? Feb 26, 2015 at 12:21
  • Yes, but the thick one is actually covering up two smaller arrowheads. Feb 26, 2015 at 16:06
  • One could make the smaller arrowheads invisible using, for example, arrows={-Implies[white]}, but right now the macro offers a lot of flexibility that you would lose. Feb 26, 2015 at 16:16
  • Finally figured out how to get shorten to work. Feb 27, 2015 at 0:47
3

This is incredibly hacky and hard coded. But it gives you much flexibility in changing the look to your taste. The only bad thing: Curved arrows look bad, as the bending radius does not adapt properly. Try to use small curvature.

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\tikzcdset{%
    triple line/.code={\tikzset{%
        double equal sign distance, % replace by double distance = 'measure' 
        double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}},
    quadruple line/.code={\tikzset{%
        double equal sign distance, % replace by double distance = 'measure'
        double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}},
    Rrightarrow/.code={\tikzcdset{triple line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}},
    RRightarrow/.code={\tikzcdset{quadruple line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}}
}    
\newcommand*{\tarrow}[2][]{\arrow[Rrightarrow, #1]{#2}\arrow[dash, shorten >= 0.5pt, #1]{#2}}
\newcommand*{\qarrow}[2][]{\arrow[RRightarrow, #1]{#2}\arrow[equal, double distance = 0.25pt, shorten >= 1.28pt, #1]{#2}}

\begin{document}
\begin{tikzcd}
    \arrow{r}{1}\arrow{d}[swap]{1} 
    & \null \arrow[Rightarrow]{r}{2}\arrow[Rightarrow]{d}[swap]{2} 
    & \null \tarrow["3"]{r}\tarrow[swap, "3"]{d} 
    & \null\qarrow["4"]{r}\qarrow[swap, "4"]{d} 
    & \null \\
    \null\arrow[bend right]{dr} 
    & \null\arrow[crossing over]{dl}\arrow[Rightarrow, bend right]{dr} 
    & \null\arrow[Rightarrow, crossing over]{dl}\tarrow[bend right]{dr} 
    & \null\tarrow{dl}\qarrow[bend right]{dr}  % crossing over not working with this command. has to be done manually
    & \null\qarrow{dl} \\ % crossing over not working with this command. has to be done manually
    \null & \null & \null & \null & \null \\
\end{tikzcd}
\end{document}

enter image description here


If you prefer the xy look, you can just set the shaft thickness to bigger values:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\tikzcdset{%
    triple line/.code={\tikzset{%
        double distance = 3pt, 
        double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}},
    quadruple line/.code={\tikzset{%
        double distance = 5.3pt, 
        double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}},
    Rrightarrow/.code={\tikzcdset{triple line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}},
    RRightarrow/.code={\tikzcdset{quadruple line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}}
}
\newcommand*{\tarrow}[2][]{\arrow[Rrightarrow, #1]{#2}\arrow[dash, shorten >= 0.5pt, #1]{#2}}
\newcommand*{\qarrow}[2][]{\arrow[RRightarrow, #1]{#2}\arrow[equal, double equal sign distance, shorten >= 3.3pt, #1]{#2}}

\begin{document}
\begin{tikzcd}
    \arrow{r} & \null \arrow[Rightarrow]{r} & \null \tarrow{r} & \null\qarrow{r} & \null
\end{tikzcd}
\end{document}

enter image description here


A compromise for the bending problem would be to define own commands for the bent arrows which have their inner line shortened by 2.2pt. This would look like this:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\tikzcdset{%
    triple line/.code={\tikzset{%
            double equal sign distance, % replace by double distance = 'measure' 
            double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}},
    quadruple line/.code={\tikzset{%
            double equal sign distance, % replace by double distance = 'measure'
            double=\pgfkeysvalueof{/tikz/commutative diagrams/background color}}},
    Rrightarrow/.code={\tikzcdset{triple line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}},
    RRightarrow/.code={\tikzcdset{quadruple line}\pgfsetarrows{tikzcd implies cap-tikzcd implies}}
}    
\newcommand*{\tcurvedarrow}[2][]{\arrow[Rrightarrow, #1]{#2}\arrow[dash, shorten >= 2.2pt, #1]{#2}}
\newcommand*{\qcurvedarrow}[2][]{\arrow[RRightarrow, #1]{#2}\arrow[equal, double distance = 0.25pt, shorten >= 2.2pt, #1]{#2}}

\begin{document}
    \begin{tikzcd}[column sep=2]
        \null\arrow[bend right]{dr} 
        & \null\arrow[Rightarrow, bend right]{dr} 
        & \null\tcurvedarrow[bend right]{dr} 
        & \null\qcurvedarrow[bend right]{dr}
        & \null \\ 
        & \null & \null & \null & \null \\
    \end{tikzcd}
\end{document}

enter image description here

1
  • Thank you. I could do without curved quadruple arrows, but I really need curved triple arrows (that is actually the reason why I consider changing from xy to tikz). Feb 26, 2015 at 12:23

You must log in to answer this question.

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