我想在一条极为复杂的道路上做个标记:
标记应位于距起点 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}