编辑

编辑

如何使用 TikZ 像这样沿着圆周对齐文本?请忽略图标。我尝试使用路径和装饰,但我不知道如何将文本限制到每个扇区。

这是我用来绘制圆圈和扇区的代码

\begin{tikzpicture}
    \draw[thick] (0cm,0cm) circle(3cm);
    \foreach \x in {0,45,...,360} {
            % lines from center to point
            \draw[black] (0cm,0cm) -- (\x:3cm);
                              }
     \end{tikzpicture}

在此处输入图片描述

答案1

Metapost 会给出更好的结果,但如果你想使用 TikZ,decorations.text它提供了多种选择。

例如:

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
  \draw [thick] (0,0) circle (3cm);
  \foreach \i/\j/\k in {0/something/tadpole,45/anything/cauldron,90/another/bread soup,135/whatever/rock candy,180/whenever/lollipop,225/whoever/Bell of Bow,270/why ever/seesaw,315/nothing/roundabout} {
    \draw [black] (0,0) -- (\i:3cm);
    \path [decorate, decoration={text along path, text=\j, text align=center}] (\i:27.5mm) arc (\i:{\i+45}:27.5mm);
    \path [decorate, decoration={text along path, text=\k, text align=center}] (\i:24mm) arc (\i:{\i+45}:24mm);
  }
\end{tikzpicture}
\end{document}

弧形文字

编辑

为了使文本在不同方向上很好地对齐,最好使用text effects along path。 这样速度较慢,但​​可以垂直对齐每个字符。 例如:

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}
  [
    arc text/.style={%
      decorate,
      decoration={%
        text effects along path,
        text={#1},
        text align=center,
        text effects/.cd,
        text along path,
        characters={anchor=mid},
      }
    }
  ]
  \draw [thick] (0,0) circle (3cm);
  \foreach \i/\j/\k [evaluate=\i as \m using {\i < 180 ? \i+45 : \i }, evaluate=\i as \n using { \i < 180 ? \i : \i+45 } ] in {0/something/tadpole,45/anything/cauldron,90/another/bread soup,135/whatever/rock candy,180/whenever/lollipop,225/whoever/Bell of Bow,270/why ever/seesaw,315/nothing/roundabout} {
    \draw [black] (0,0) -- (\i:3cm);
    \path [arc text/.expanded=\j] (\m:27.5mm) arc (\m:\n:27.5mm);
    \path [arc text/.expanded={\k}] (\m:24mm) arc (\m:\n:24mm);
  }
\end{tikzpicture}
\end{document}

相反方向

相关内容