tikz-cd shorten in combination with squiggly

I want to draw a shortened squiggly arrow, like the following:

However, when I use shorten in combination with squiggly, I get a strange effect, where the shortened segment is drawn both as squiggly and as a straight line (rather than not drawn at all):

The code is:

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzcd}
\bullet && \bullet
\arrow[shorten <=10pt, shorten >=10pt, squiggly, from=1-1, to=1-3]
\end{tikzcd}
\end{document}


Is there a way to work around this issue?

You'll need to shorten the decoration itself in addition to the path. Found an old reference to this in http://pgf-and-tikz.10981.n7.nabble.com/shorten-and-decoration-td2248.html, and seems it still applies. Hence, you need to say squiggly={pre length=10pt, post length=10pt} in addition to the shortens.

\documentclass[border-5mm]{standalone}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzcd}
\bullet && \bullet
\arrow[shorten <=10pt, shorten >=10pt,
squiggly={
pre length=10pt, post length=10pt
},
from=1-1, to=1-3]
\end{tikzcd}
\end{document}

• The amplitude/contraction of your squiggly is different of the first image. Is it possible to change?+1 for you excellent work. Jun 6, 2021 at 20:25
• @Sebastiano The code I added didn't change anything about the amplitude and wavelength. But yes, you can change those things if you want to, add e.g. segment length=2mm, amplitude=2mm in the argument to squiggly, along with pre length and post length. Jun 6, 2021 at 20:32
• Thank you very much for the addition of explanation. Jun 6, 2021 at 20:34
• Perfect, thanks! Jun 7, 2021 at 11:07

Another possibility could be replace the shortens by start anchor and end anchor

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{decorations.pathmorphing}

\begin{document}
\begin{tikzcd}
\bullet && \bullet
\arrow[squiggly, start anchor={[xshift=10pt]}, end anchor={[xshift=-10pt]}, from=1-1, to=1-3]
\end{tikzcd}
\end{document}


• Very very good. +1 for your code. Jun 6, 2021 at 20:35
• Thanks, although it would be nice not to have to change shorten key as in Torbjørn T answer Jun 6, 2021 at 20:40
• Thanks, this is a simple solution for vertical or horizontal arrows, though becomes a little trickier with diagonals where the offset has to be calculated manually. Jun 7, 2021 at 11:09