我希望示例中的文本与圆圈对齐,我尝试decoration
在示例的注释行中这样做,但没有效果。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{center}
\begin{tikzpicture}
\foreach \x/\mes/\month[evaluate=\x as \y using \x*-30+120] in
{
1/Enero/January,
2/Febrero/February,
3/Marzo/March,
4/Abril/April,
5/Mayo/May,
6/Junio/June,
7/Julio/July,
8/Agosto/August,
9/Septiembre/September,
10/Octubre/October,
11/Noviembre/November,
12/Diciembre/December
} {
\draw (\y:5) -- ++(\y:0.4);
\node [anchor=west,rotate=\y-90] at (\y:5.2) {\month};
\node [anchor=west,rotate=\y-90] at (\y:5.6) {\mes};
\draw (\y:4.9) arc[start angle =\y, end angle=\y-20,radius=4.2];
% \draw (\y:4.9) arc[decorate,decoration={\month},start angle =\y, end angle=\y-20,radius=4.2];
}
\end{tikzpicture}
\end{center}
\end{document}
答案1
一个简单的角度校正,对圆弧的切线进行测试:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{center}
\begin{tikzpicture}
\foreach \x/\mes/\month[evaluate=\x as \y using \x*-30+120] in
{
1/Enero/January,
2/Febrero/February,
3/Marzo/March,
4/Abril/April,
5/Mayo/May,
6/Junio/June,
7/Julio/July,
8/Agosto/August,
9/Septiembre/September,
10/Octubre/October,
11/Noviembre/November,
12/Diciembre/December
} {
\draw (\y:5) -- ++(\y:0.4);
\node [anchor=south,rotate=\y-100] at (\y-10:5) {\month}; % <---
\node [anchor=south,rotate=\y-100] at (\y-10:5.4) {\mes}; % <---
\draw (\y:4.9) arc[start angle =\y, end angle=\y-20,radius=4.8];
}
\end{tikzpicture}
\end{center}
\end{document}
使用 TikZ 库decorations.text
可以用文本装饰路径:
编辑:文本现在左对齐,2pt
左侧有小缩进(),文本开头不接触径向线:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{center}
\begin{tikzpicture}[
decoration={text along path,
text align={left,left indent=2pt}}]
\foreach \x/\mes/\month[evaluate=\x as \y using \x*-30+120] in
{
1/Enero/January,
2/Febrero/February,
3/Marzo/March,
4/Abril/April,
5/Mayo/May,
6/Junio/June,
7/Julio/July,
8/Agosto/August,
9/Septiembre/September,
10/Octubre/October,
11/Noviembre/November,
12/Diciembre/December
} {
\draw (\y:5) -- ++ (\y:0.4);
\draw (\y:4.9) arc[start angle =\y, end angle=\y-20,radius=4.8];
\draw [decorate,
decoration={text={\mes}}]
(\y:5) arc [start angle =\y, end angle=\y-20,radius=4.8];
\draw [decorate,
decoration={text={\mes}}]
(\y:5.4) arc [start angle =\y, end angle=\y-20,radius=4.8];
}
\end{tikzpicture}
\end{center}
\end{document}