With a special to path
You can do this with a special to path
. I am assuming that this will only be used on nodes (which is true for tikz-cd
).
I have included two implementations: One with the calc
library (called rl
), one without it with plain PGF macros (slightly faster).
The approach is the same. I extract the x and y value of the most right point of the path (the east
anchor), then I check which of both x values is greater (more to the right) and add the passed length. This will be the x value of the vertical line part.
The nodes are placed (only) on this vertical part (whereas with the rl
path operator below you could nodes along the whole path).
Code
\documentclass[tikz,convert=false]{standalone}
\usepackage{tikz-cd}
\usetikzlibrary{calc}
\makeatletter
\tikzset{
RL/.style={% without calc
rounded corners={#1-.1pt},
to path={% we asume that you use this path only on nodes (otherwise it will get tricky)
\pgfextra
\pgf@process{\pgfpointanchor{\tikztostart}{east}}%
\pgf@xa\pgf@x\pgf@ya\pgf@y
\pgf@process{\pgfpointanchor{\tikztotarget}{east}}%
\pgf@xb\pgf@x\pgf@yb\pgf@y
\ifdim\pgf@xb>\pgf@xa
\pgf@xa\pgf@xb
\fi
\pgfmathsetlength\pgf@xc{#1}%
\advance\pgf@xa\pgf@xc
\endpgfextra
-- (+\pgf@xa,+\pgf@ya) -- (+\pgf@xa,+\pgf@yb) \tikztonodes -- (\tikztotarget)
}
},
RL/.default=.5cm}
\makeatother
\tikzset{
rl/.style={% with calc
rounded corners={#1-.1pt},
to path={% we asume that you use this path only on nodes (otherwise it will get tricky)
let \p{@aux1}=(\tikztostart.east),
\p{@aux2}=(\tikztotarget.east),
\n{@aux@x}={#1+max(\x{@aux1},\x{@aux2})}
in
-- (+\n{@aux@x},+\y{@aux1}) -- (+\n{@aux@x},+\y{@aux2}) \tikztonodes -- (\tikztotarget)
}
},
rl/.default=.5cm,
}
\begin{document}
\begin{tikzcd}
A \arrow[RL]{ddd}\\
LongEntry \\
LongEntry \\
LongEntry
\end{tikzcd}
\begin{tikzcd}
A \arrow[rl]{ddd}\\
LongEntry \\
LongEntry \\
LongEntry
\end{tikzcd}
\end{document}
Path Operator rl
With my paths.ortho
(→ another answer) library you can do this very easily.
The path operator rl
means that both start and target of a line is connected by a combination of a horizontal, a vertical and a horizontal line. In this case (rl
instead of lr
) means that the vertical line is to the right of both nodes (or coordinates). I.e first to the r
ight, then down or up, then to the l
eft. The given distance is measured from the node/coordinate that is furthest to the right.
As the paths.ortho
already installs a rl
style that uses the rl
path operator, I’ll ad another RL
style that sets an appropriate amount for the rounded corners
radius and the rl distance
. The -.1pt
was necessary so that the arrow tip is placed correctly.
This does not take other nodes in account. So if you have another very long node between start and target you will need to make manual adjustments either way.
Code
\documentclass[tikz,convert=false]{standalone}
\usepackage{tikz-cd}
\usetikzlibrary{paths.ortho}
\tikzset{
RL/.style={
rounded corners={#1-.1pt},
rl distance={#1},
rl
},
RL/.default=.5cm
}
\usepackage[all]{xy}
\begin{document}
\begin{tikzcd}
A \arrow[RL]{ddd}\\
LongEntry \\
LongEntry \\
LongEntry
\end{tikzcd}
\end{document}
Outputs

\ar `/40pt[ddd] `/15pt[ddd] [ddd]
seems to do a pretty good job.