# What do “-to” and “pre=moveto” do in TikZ arrows?

On page 61/1318 TikZ manual there is an example which I simplify and change it a little bit to create the following picture:

Here is my code:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary {arrows.meta}
\usetikzlibrary {decorations.pathmorphing}
\begin{document}

\begin{tikzpicture}
%\draw [->,-to, thick, decorate,
\draw [shorten >=1mm,-to, thick, decorate, red,
decoration={snake,amplitude=.4mm,segment length=2mm, pre=moveto, pre length=1mm, post length=2mm}]
(0,0) -- (3,0)
node [above=1mm,align=center,midway, text width=3 cm]
{
replacement of\\
the \textcolor{black}{capacity}\\
by \textcolor{black}{two places}
};
\draw [|-|] (2.8,0) -- (3,0);
\draw [|-|] (0,0) -- (.1,0);
\end{tikzpicture}
\end{document}


I have these questions:

1. What does -to do?
2. What does pre=moveto do?
3. Although post length=2mm according to the measurement using \draw [|-|] (2.8,0) -- (3,0); it looks post length is shorter.
4. shorten >=1mm is applied where and how it works with pre and post lengths?
• When you decorate a path, you can have the decoration start a little later to start by drawing a straight line on a few millimetres and then decorate it properly. moveto means to go to a certain place without drawing or colouring, it's a move. Here pre=moveto, pre length=1mm specifies that the first millimetre nothing will be drawn, the decoration does nothing and nothing will be drawn the first millimetre of the path. Translated with www.DeepL.com/Translator (free version) – AndréC Jul 30 '20 at 6:35
• -to is a now obsolete syntax initiated with the first versions of TikZ like 1.18 and to is the name of a predefined arrow. From now on, this is replaced by >. – AndréC Jul 30 '20 at 6:47
• -to is now replaced by -> – AndréC Jul 30 '20 at 6:53
• shorten is now obsolete, but no other command is equivalent in version 3.1 so it is still used. You can find its definition in the 1.18 manual which can be downloaded here tikz manual 1.18 – AndréC Jul 30 '20 at 7:00
• Regarding the post length, to get that accurate, you need a segment length appropriate to fit an integer number of "waves" in the available part of the path, see tex.stackexchange.com/questions/552354 for a similar case. – Torbjørn T. Jul 30 '20 at 8:54

It is customary here that there is only one question at a time. Nevertheless, I will answer only the first two questions, and I urge you to ask the other question again, which alone deserves further development.

# First question : What does -to do?

In TikZ and pgf Manual for version 1.18, on page 322, we learn that -to is an arrow.

Looking at its shape, we can see that it is the Computer Modern Rightarrow as shown on page 207 of the 3.1.5b manual. I quote:

Instead of a <arrow tip kind name>, you may also provide the name of a so-called shorthand. Shorthands look like normal arrow tip kind names and, indeed, you will often be using shorthands without noticing that you do. The idea is that instead of, say, Computer Modern Rightarrow you might wish to just write Rightarrow or perhaps just To or even just >.

# Second question: What does pre=moveto do?

When you decorate a path, you can have the decoration start a little later to start by drawing a straight line on a few millimetres and then decorate it properly. moveto means to go to a certain place without drawing or colouring, it's a move. Here pre=moveto, pre length=1mm specifies that the first millimetre nothing will be drawn, the decoration does nothing and nothing will be drawn the first millimetre of the path.

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

\begin{document}

\begin{tikzpicture}[nodes={font=\small\ttfamily, black, right}]
\draw[thick, red] (0, 0) -- (3, 0)
node {1.1 init with "thick, red"};

\draw[thick, red, shorten >=1mm, yshift=-.5cm]
(0, 0) -- (3, 0)
\draw[|-|, yshift=-.4cm] (2.9, 0) -- node[above, font=\tiny] {1mm} (3, 0);

\draw[thick, red, shorten >=1mm, -to, yshift=-1cm]
(0, 0) -- (3, 0)

\begin{scope}[yshift=-2cm]
\draw[thick, red] (0, 0) -- (3, 0)
node {2.1 the same as 1.1};

\draw[thick, red, decorate,
decoration={snake},
yshift=-.5cm,
] (0, 0) -- (3, 0)

\draw[thick, red, decorate,
decoration={snake, amplitude=.4mm, segment length=2mm},
yshift=-1cm,
] (0, 0) -- (3, 0)
node {2.3 add "decoration=\{..., amplitude=.4mm, segment length=2mm\}"};

\draw[thick, red, decorate,
decoration={
snake, amplitude=.4mm, segment length=2mm,
pre length=1mm, post length=2mm
},
yshift=-1.5cm,
] (0, 0) -- (3, 0)
node {2.4 add "decoration=\{..., pre length=1mm, post length=2mm\}"};
\draw[|-|, yshift=-1.4cm] (0, 0) -- node[above, font=\tiny] {1mm} (.1, 0);
\draw[|-|, yshift=-1.4cm] (2.8, 0) -- node[above, font=\tiny] {2mm} (3, 0);

\draw[thick, red, decorate,
decoration={
snake, amplitude=.4mm, segment length=2mm,
pre length=1mm, post length=2mm, pre=moveto
},
yshift=-2.0cm,
] (0, 0) -- (3, 0)
\draw[|-|, yshift=-1.9cm] (0, 0) -- node[above, font=\tiny] {1mm} (.1, 0);
\end{scope}

\begin{scope}[yshift=-5cm]
\draw[thick, red, shorten >=1mm, -to, decorate,
decoration={
snake, amplitude=.4mm, segment length=2mm,
}
] (0, 0) -- (3, 0)
node {3.1 combine 1.3 and 2.3, not good};

\def\x{\ \ \ \ }
\draw[thick, red, shorten >=5mm, -to, decorate,
decoration={
snake, amplitude=.4mm, segment length=2mm,
},
yshift=-.5cm,
] (0, 0) -- (3, 0)
node[yshift=-.6cm, align=left] {
3.2 combine 1.3 and 2.3 and \\
\x  use "shorten >=5mm" to show the real problem:\\
\x decoration is not shortened and a line is drawn \\
\x from real end (3, 0) to shortened end (2.5, 0).
};
\draw[|-|, yshift=-.4cm] (2.5, 0) -- node[above, font=\tiny] {5mm} (3, 0);

\draw[thick, red, shorten >=5mm, -to, decorate,
decoration={
snake, amplitude=.4mm, segment length=2mm,
post length=6mm, pre=moveto
},
yshift=-2.2cm,
] (0, 0) -- (3, 0)
node {3.2' add "decoration=\{..., post length=6mm, pre=moveto\}", ok};

\draw[thick, red, shorten >=1mm, -to, decorate,
decoration={
snake, amplitude=.4mm, segment length=2mm,
pre length=1mm, post length=2mm, pre=moveto
},
yshift=-2.7cm
] (0, 0) -- (3, 0)
node {3.3 combine 1.3 and 2.5, ok};
\draw[|-|, yshift=-2.6cm] (2.9, 0) -- node[above, font=\tiny] {1mm} (3, 0);
\end{scope}
\end{tikzpicture}

\end{document}