add tag
CarLaTeX
I'm a little rusty with Ti*k*Z...

How to put the writing at the middle of the following arrow line?


```
\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{positioning, matrix}

\begin{document}

\begin{tikzpicture}
\matrix[matrix of nodes, nodes={draw, text width=30pt, align=center}, row sep=30pt] (mymatr) {
    A\\
    B\\
    C\\
    };
\draw[->] (mymatr-3-1) -- +(30pt,0)  |- node[anchor=west, align=center, midway] {Something to put\\ at the middle of the arrow line} (mymatr-1-1);
\end{tikzpicture}
\end{document}
```

![image.png](/image?hash=337e7dc68c57e821d0e9c322b11d66463c7d9e910ed7bb99cd493e690cbeae22)

Top Answer
marmot
In the `|-` and `-|`, midway refers to the corner, regardless of how long the horizontal and vertical stretches really are. You will need then `pos=0.25` or `pos=0.75` to put something in the middle of the vertical or horizontal stretches, respectively, i.e. `pos=0.25` in the example you posted. 
```
\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{positioning, matrix}

\begin{document}

\begin{tikzpicture}
\matrix[matrix of nodes, nodes={draw, text width=30pt, align=center}, row sep=30pt] (mymatr) {
    A\\
    B\\
    C\\
    };
\draw[->] (mymatr-3-1) -- +(30pt,0)  |- 
node[pos=0.25,anchor=west, align=center] {Something to put\\ at the middle of the arrow line} (mymatr-1-1);
\end{tikzpicture}
\end{document}
```
![Screen Shot 2021-04-11 at 7.39.49 AM.png](/image?hash=9372a29ea9f67fb78a46d7bf61e8c330d7fca43abe9a8148f333a45c2c4f921d)

Answer #2
joulev
With the help of `decorations.markings` you can add anything at any position along the path.

```
\documentclass{book}

\usepackage{tikz}
\usetikzlibrary{positioning, matrix, decorations.markings}

\begin{document}

\begin{tikzpicture}
\matrix[matrix of nodes, nodes={draw, text width=30pt, align=center}, row sep=30pt] (mymatr) {
    A\\
    B\\
    C\\
    };
\draw[->,postaction=decorate,
      decoration={
        markings,
        mark=at position 0.5 with {\node[anchor=west] {It is now at the middle!};}
      }] (mymatr-3-1) -- +(30pt,0)  |- node[anchor=west, align=center, midway] {Something to put\\ at the middle of the arrow line} (mymatr-1-1);
\end{tikzpicture}
\end{document}
```

![image.png](/image?hash=46c3a0a317d2eeb873f9bd05610bd44d45f7689520fa86c88a85984934e4e8ee)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.