[Tex/LaTex] Length of arrow in tikz-cd

tikz-cdtikz-pgf

Looking at the code

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.markings,intersections}  
\begin{document}
\begin{tikzcd}[scale=10]
    F_n \otimes M \arrow{r}[name=U]{\phi_n \otimes M} & F_{n-1}\otimes M  \\
    F_n\otimes L \arrow[hookrightarrow]{u}{\tilde{\iota}_n} \arrow[swap]{r}[name=D]{\phi_n \otimes L} & F_{n-1}\otimes L \arrow[hookrightarrow,swap]{u}{\tilde{\iota}_{n-1}}
\end{tikzcd}
\end{document}

we get the commutative diagramm

enter image description here

How is it possible lengthen the arrows?

Best Answer

You can lengthen the arrows with the parameters row sep and column sep which define the distance between two nodes/cells in your diagram.

Here a quote from the excellent documentation:

enter image description here

In your case, large or huge would do the trick if you want to stick to predefined values (nice for consistency): enter image description here

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}
\parindent0pt

\begin{document}
    \texttt{row sep=large, column sep=large}\\
    \begin{tikzcd}[row sep=large, column sep = large]
        F_n \otimes M \arrow{r}[name=U]{\phi_n \otimes M} & F_{n-1}\otimes M  \\
        F_n\otimes L \arrow[hookrightarrow]{u}{\tilde{\iota}_n} \arrow[swap]{r}[name=D]{\phi_n \otimes L} & F_{n-1}\otimes L \arrow[hookrightarrow,swap]{u}{\tilde{\iota}_{n-1}}
    \end{tikzcd}\\
    \texttt{row sep=huge, column sep=huge}\\
    \begin{tikzcd}[row sep=huge, column sep = huge]
        F_n \otimes M \arrow{r}[name=U]{\phi_n \otimes M} & F_{n-1}\otimes M  \\
        F_n\otimes L \arrow[hookrightarrow]{u}{\tilde{\iota}_n} \arrow[swap]{r}[name=D]{\phi_n \otimes L} & F_{n-1}\otimes L \arrow[hookrightarrow,swap]{u}{\tilde{\iota}_{n-1}}
    \end{tikzcd}
\end{document}

You can go further by setting any other measure like row sep=5cm. It is considered good practise to stick to relative lengths. This would be em for horizontal (e.g. column sep=10em) and ex for vertical (e.g. row sep=10ex) values.

If you prefer to set the distance between the node centres (not between their edges), you might choose something like \begin{tikzcd}[row sep={40,between origins}, column sep={40,between origins}]. This example uses the TikZ unit (1cm is default, I believe).


In case you just want to change the length between two columns resp. rows, you can do this like the following:

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
    A \rar &[20em] B \rar & C \\
    D \rar & E \rar & F
\end{tikzcd}
\end{document}

enter image description here

or

\begin{tikzcd}
    A \dar & B \dar \\[20ex]
    C \dar & D \dar \\
    E & F
\end{tikzcd}

enter image description here


If you want to change the length of single arrows, you have to shorten them. You can do this in negative direction (elongation) as well.

% arara: pdflatex

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
     A \rar[shorten <= 2em]\dar[shorten <= 2ex] & B \rar[shorten >= 2em]\dar[shorten >= 2ex] & C \rar[shorten <= 1em, shorten >= 1em]\dar[shorten <= 1ex, shorten >= 1ex] & D\dar[shorten <= -.7ex, shorten >= -.7ex] \\
     E \rar[shorten <= -.5em] & F \rar[shorten >= -.4em] & G \rar[shorten <= -.5em, shorten >= -.5em] & H 
\end{tikzcd}
\end{document}

enter image description here