演示tikz中文字沿路径摆放:
%演示文字沿路径摆放
\begin{tikzpicture}
\path decorate [decoration={text along path,
text={some text along a path}}]{ (0,2) .. controls (2,2) and (1,0) .. (3,0) };
\draw (0,2) .. controls (2,2) and (1,0) .. (3,0);
\end{tikzpicture} 效果如下:

但是tikz没有封装命令\decorate,但是下面的用法是可以的:
\tikz \draw decorate[decoration=zigzag] {(0,0) -- (3,0)};对于decoration的定义示例如下:
\pgfdeclaredecoration{stars}{initial}{
\state{initial}[width=15pt]
{
\pgfmathparse{round(rnd*100)}
\pgfsetfillcolor{yellow!\pgfmathresult!orange}
\pgfsetstrokecolor{yellow!\pgfmathresult!red}
\pgfnode{star}{center}{}{}{\pgfusepath{stroke,fill}}
}
\state{final}
{
\pgfpathmoveto{\pgfpointdecoratedpathlast}
}
}
\tikz\path[decorate, decoration=stars, star point ratio=2, star points=5,
inner sep=0, minimum size=rnd*10pt+2pt]
(0,0) .. controls (0,2) and (3,2) .. (3,0)
.. controls (3,-3) and (0,0) .. (0,-3)
.. controls (0,-5) and (3,-5) .. (3,-3);效果如下:


本文介绍如何使用 LaTeX 的 TikZ 包实现文字沿指定路径排布的效果,并提供了具体的代码示例。此外还展示了如何自定义装饰样式,如星星图案。
198

被折叠的 条评论
为什么被折叠?



