# TikZ “mark connection node” only works for first node mark

The following code fails with the error ! Package pgf Error: No shape named B' is known. There is no error for mark connection node=A. Seemingly the only accessible node is the one defined first. Is this expected?

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={
markings,
mark=at position .33 with {\node [draw] (A) {A};},
mark=at position .66 with {\node [draw] (B) {B};},
mark connection node=B,
}
]
\draw [help lines] grid (3,2);
\draw decorate { (0,0) -- (3,2) };
\end{tikzpicture}
\end{document}


• And if I add a "phantom node" \node (B) {}; in the body of the tikzpicture, i.e. right before the grid, then code works AND the mark node breaks the path (the behavior I wanted originally). Strange. – tsj Jun 13 at 18:38

Surprisingly, naming the two nodes with the same name, works.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={
markings,
mark connection node=A,
mark=at position .33 with {\node [draw] (A) {A};},
mark=at position .66 with {\node [draw] (A) {B};}, % <<< name it with "A"
}
]
\draw [help lines] grid (3,2);
\draw decorate { (0,0) -- (3,2) };
\end{tikzpicture}
\end{document}


Update: I've reported this to pgf-tikz`, see https://github.com/pgf-tikz/pgf/issues/1024.