Linebreak inside label - tikzcd package
Use \substack
.
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[row sep=large]
A \arrow[d, "\substack{a \\ a}"] & % good
A \arrow[d,"a \\ a" align=left] & % bad
A \arrow[d,"\shortstack{a\\a}"] % ugly
\\
B & B & B
\end{tikzcd}
\end{document}
If the labels are textual, use \text
inside \substack
. The same code as before, but with \substack{\text{a} \\ \text{a}}
in the leftmost arrow yields
\documentclass{book}
\usepackage{tikz-cd,amsmath}
\begin{document}
\begin{tikzcd}[row sep=3cm]
A \arrow[d, "\shortstack{label 1\\label 2}"] \\
B
\end{tikzcd}
\end{document}
You only need to add align=left
(or something of that sort).
\documentclass{article}
\usepackage{tikz-cd,amsmath}
\begin{document}
\begin{tikzcd}[row sep=3cm]
A \arrow[d,"label1\\ label2"align=left] \\
B
\end{tikzcd}
\end{document}