这里的 step 应该是相邻两个 mark 的间距,在
between positions 0 and 1 step <x> with ...中,参数 <x> 会被 \pgfmathparse 处理,参数 <x> 的两个特征:(1)正负号,(2)是否带有长度单位,都对间距有影响。例如 0.2, 那么间距就是 0.2*L, 其中的 L 是被装饰路径的总长度。作为装饰的 mark 是逐个创建的,在创建过程中,如果剩余的、尚未被装饰的路径长度小于 0.2*L, 那么就不做装饰。详细情况参考《pgflibrarydecorations.markings.code.tex》。
如果希望 mark 出现在被装饰路径的末端,那么应注意路径长度与 mark 间距相搭配,就是说,L/间距 应该是个整数。
如果不搭配,还想把一个 mark 放在路径的末端,可以这么做
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\tikzset{
  zhuangding A/.style={
    decorate,
    decoration={
      markings,
      mark=between positions 0 and 1 step 15mm with
        {\node[circle,draw=black,fill=white]{};},
    },
  },
  zhuangding B/.style={
    decorate,
    decoration={
      markings,
      mark=at position 1 with
        {\node[circle,draw=black,fill=white]{};},
    },
  },
}
\begin{document}
\begin{tikzpicture}
  \draw[postaction={zhuangding A},postaction={zhuangding B}](0,0)--(11,0);
  \draw[red,postaction={zhuangding A},postaction={zhuangding B}](0,-3)--(16,-3);
\end{tikzpicture}
\end{document}我大略查了一下,如果想单纯获取一个路径的长度,可以这么做:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations}
\begin{document}
\begin{tikzpicture}
  \draw [save path=\aaaa] (0,0) arc [start angle=60,end angle=180,x radius=2,y radius=1];
\end{tikzpicture}
\makeatletter
\pgf@decorate@parsesoftpath\aaaa\bbbb
\meaning\pgf@decorate@totalpathlength
\meaning\bbbb
\makeatother
\end{document}其中的 \pgf@decorate@totalpathlength 就是路径的总长度。





问 tikz沿路径装饰的一个问题