5

How can I align text along the circumference of a circle like this using TikZ? Please ignore the icons. I tried using paths and decorations, but I don't know how to constrain the text to each sector.

This is the code I used to draw the circles and the sectors

\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}

enter image description here

azetina
  • 28,884
lexxie
  • 379

1 Answers1

3

Metapost would give better results, but if you wish to use TikZ, decorations.text offers a variety of options.

For example:

\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}

arced text

EDIT

To align the text nicely with different directions, it is probably best to use text effects along path. This is slower, but it makes it possible to align each character vertically. For example:

\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}

opposite directions

cfr
  • 198,882
  • Love the text you've used. How can I change the way the text faces? i.e. Text turned inwards so that the upper quadrants are easier to read? – lexxie May 24 '16 at 04:39
  • You'd need to reverse the path of the arc by saying e.g. ({\i+45}:\i:27.5mm). So you probably want to split the \foreach into two else you'd need to test the value of \i within the loop. The text is just run along the path in the direction of that path, whatever the path happens to be. – cfr May 24 '16 at 10:08
  • @lexxie Please see edit. – cfr May 24 '16 at 10:46