TikZ“标记连接节点”仅适用于第一个节点标记

TikZ“标记连接节点”仅适用于第一个节点标记

以下代码失败,错误 ! Package pgf Error: No shape named `B' is known.为 没有错误mark connection node=A。似乎唯一可访问的节点是第一个定义的节点。这是预期的吗?

\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}

答案1

令人惊讶的是,用相同的名称命名两个节点是有效的。

\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}

在此处输入图片描述

更新:我已经向 报告了此事pgf-tikz,请参阅https://github.com/pgf-tikz/pgf/issues/1024

相关内容