![在路径上的指定点放置标记](https://linux22.com/image/478140/%E5%9C%A8%E8%B7%AF%E5%BE%84%E4%B8%8A%E7%9A%84%E6%8C%87%E5%AE%9A%E7%82%B9%E6%94%BE%E7%BD%AE%E6%A0%87%E8%AE%B0.png)
我想在一条极为复杂的道路上做个标记:
标记应位于距起点 0.1 的位置:
我尝试:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (1, 3);
\coordinate (C) at (2, -1);
\coordinate (D) at (3, 0.5);
\draw plot [smooth] coordinates { (A) (B) (C) (D) };
\path [
postaction={decorate},
decoration={
markings,
mark = at position {0.1\dimexpr\pgfdecoratedpathlength\relax} with {fill = red circle (0.5cm)}
}
] plot [smooth] coordinates { (A) (B) (C) (D) };
\end{tikzpicture}
\end{document}
当我编译时出现错误:
! Dimension too large.
<to be read again>
\relax
怎么了?
答案1
如果你只是说0.1
,这被理解为装饰路径长度的 10%。另外,\pgfdecoratedpathlength
不是长度,只是一个宏。你需要添加正常的 Ti钾类似的 Z 命令\draw
,而不仅仅是 pgf 键。
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}
\coordinate (A) at (0,0);
\coordinate (B) at (1, 3);
\coordinate (C) at (2, -1);
\coordinate (D) at (3, 0.5);
\draw plot [smooth] coordinates { (A) (B) (C) (D) };
\path [
postaction={decorate},
decoration={
markings,
mark = at position 0.1 with {\fill[red] circle[radius=0.5cm];}
}
] plot [smooth] coordinates { (A) (B) (C) (D) };
\end{tikzpicture}
\end{document}