# Overlapping arrow and twisted labels in tikz-cd

The tikz-cd code

\documentclass[standalone]{standalone}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{caption}
\usetikzlibrary{arrows}
\usetikzlibrary{cd}

\newcommand{\ctext}[1]{\text{\makebox[0pt]{#1}}}

\begin{document}
\begin{figure}[![enter image description here][1]][1]
\begin{tikzcd}
&&\sigma_{0}\arrow[r]&\vphantom{X} \\
\sigma_{init}\arrow[rru,"\ctext{cdsa\_in(1)}",sloped, start anchor=center,shorten <= .5em]\arrow[rrd,"\ctext{cdsa\_in(n)}", rotate=-1.25, sloped,start anchor=center, shorten <= .5em]&&& \\
&&\vphantom{X}\sigma_{n}\arrow[r]&\vphantom{X} \\
\end{tikzcd}
\end{figure}
\end{document}


creates the diagram

The use of the macro \ctext etc solve a problem of centering the labels and the key word rotate is used to better align cdsa_in with it's arrow.

• does an alternative exist that better align labeled with the associated arrow?
• The arrow is over the subscript init how can this be solved?

I think you're complicating your life.

Here a simpler code: nodes in empty cells allows to avoid phantoms, &[16pt] add some space between the first two columns, no need to create an empty one.

Off-topic: a figure environment in a standalone document has no sense.

\documentclass{standalone}
\usepackage{amsmath,mathtools}
\usepackage{amsfonts}
\usepackage{tikz}
\usepackage{caption}
\usetikzlibrary{arrows}
\usetikzlibrary{cd}

\newcommand{\ctext}[1]{\text{\makebox[0pt]{#1}}}

\begin{document}
\begin{tikzcd}[nodes in empty cells]
&[16pt] \sigma_{0}\arrow[r]& \\
\sigma_{init}\arrow[ru,"\ctext{cdsa\_in(1)}", sloped]\arrow[rd,"\ctext{cdsa\_in(n)}", swap, sloped]&& \\
&\sigma_{n}\arrow[r]&
\end{tikzcd}
\end{document}


• +1 for your initial comment :-). Oct 31, 2018 at 18:22