5

I want to label a circle in and out, like this sketch:

A sketch

I have also tried to form the circle in my own very simple way as follows:

\documentclass{article}
\usepackage{tikz}
\begin{document}
    \begin{tikzpicture} 
        \draw[|-|] (90.0:3.0) arc(90.0:67.5:3.0); 
        \draw[|-|] (67.5:3.0) arc(67.5:45.5:3.0);
        \draw[|-|] (45.0:3.0) arc(45.0:22.5:3.0);
        \draw[|-|] (22.5:3.0) arc(22.5:00.0:3.0);
        \draw[|-|] (00.0:3.0) arc(00.0:-22.5:3.0); 
        \draw[|-|] (-22.5:3.0) arc(-22.5:-45.0:3.0);
        \draw[|-|] (-45.0:3.0) arc(-45.0:-67.5:3.0);
        \draw[|-|] (-67.5:3.0) arc(-67.5:-90.0:3.0);
        \draw[|-|] (-90.0:3.0) arc(-90.0:-112.5:3.0); 
        \draw[|-|] (-112.5:3.0) arc(-112.5:-135.0:3.0);
        \draw[|-|] (-135.0:3.0) arc(-135.0:-157.5:3.0);
        \draw[|-|] (-157.5:3.0) arc(-157.5:-180.0:3.0);
        \draw[|-|] (-180.0:3.0) arc(-180.0:-202.5:3.0); 
        \draw[|-|] (-202.5:3.0) arc(-202.5:-225.0:3.0);
        \draw[|-|] (-225.0:3.0) arc(-225.0:-247.5:3.0);
        \draw[|-|] (-247.5:3.0) arc(-247.5:-270.0:3.0);
    \end{tikzpicture}
    
\end{document}

What I want

I want my already-drawn circle (through the TikZ code) to be labelled as the image I provided and not you coming up with different code for a different circle as I may not be able to understand your style.

Note

I want an improvement on this my simple style of code that will simply add block of codes to it to make the labels visible and not the one you will come up with a different style. If you come up with different style I will not be able to improve on your answer to use it for what I want.

2 Answers 2

9

If I compile this:

\documentclass{article}
\usepackage{xcolor,tikz}
\begin{document}
\begin{tikzpicture}
    \draw[|-|] (90.0:3.0) arc(90.0:67.5:3.0); 
    \draw[|-|] (67.5:3.0) arc(67.5:45.0:3.0);
    \draw[|-|] (45.0:3.0) arc(45.0:22.5:3.0);
    \draw[|-|] (22.5:3.0) arc(22.5:00.0:3.0);
    \draw[|-|] (00.0:3.0) arc(00.0:-22.5:3.0); 
    \draw[|-|] (-22.5:3.0) arc(-22.5:-45.0:3.0);
    \draw[|-|] (-45.0:3.0) arc(-45.0:-67.5:3.0);
    \draw[|-|] (-67.5:3.0) arc(-67.5:-90.0:3.0);
    \draw[|-|] (-90.0:3.0) arc(-90.0:-112.5:3.0); 
    \draw[|-|] (-112.5:3.0) arc(-112.5:-135.0:3.0);
    \draw[|-|] (-135.0:3.0) arc(-135.0:-157.5:3.0);
    \draw[|-|] (-157.5:3.0) arc(-157.5:-180.0:3.0);
    \draw[|-|] (-180.0:3.0) arc(-180.0:-202.5:3.0); 
    \draw[|-|] (-202.5:3.0) arc(-202.5:-225.0:3.0);
    \draw[|-|] (-225.0:3.0) arc(-225.0:-247.5:3.0);
    \draw[|-|] (-247.5:3.0) arc(-247.5:-270.0:3.0);
    \foreach \i in {1,...,16} \node at ({112.5-22.5*\i}:3.45) {\color{blue}{$x_{\i}$}};
    \foreach \i in {17,...,21} \node at ({112.5-22.5*\i}:2.55) {\color{red}{$x_{\i}$}};
\end{tikzpicture}
\end{document}

then I get this:

enter image description here

A quite shorter code that will give you the same output is:

\documentclass{article}
\usepackage{xcolor,tikz}
\begin{document}
\begin{tikzpicture}
  \foreach \i in {1,...,16} {\draw[|-|] ({22.5*\i}:3) arc({22.5*\i}:{22.5*(\i+1)}:3);
    \node at ({112.5-22.5*\i}:3.45) {\color{blue}{$x_{\i}$}};}
  \foreach \i in {17,...,21} \node at ({112.5-22.5*\i}:2.55) {\color{red}{$x_{\i}$}};
\end{tikzpicture}
\end{document}
1
  • Based on your first code, I will like this \foreach \i in {1, 2, 3, \cdots, i, i+1, i+2, n+l-1, n+l-2, n+l-3, n-l, n-l+1, n-l+2, n-l+3, $n$} \node at ({112.5-22.5*\i}:3.45) {\color{blue}{$x_{\i}$}}; instead of this \foreach \i in {1,...,15,$n$} \node at ({112.5-22.5*\i}:3.45) {\color{blue}{$x_{\i}$}};. I noticed that your foreach can only take numbers and not alpabets or symbols like \cdots Commented May 18, 2023 at 22:26
5

You may not like an even quicker way to do this, just for fun:

label circle

\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
    \begin{tikzpicture}
        \newcommand{\R}{3}
        \newcommand{\p}{3 pt}
        \draw (0,0) circle (\R cm);
        \foreach \i [count=\j from 17] in {1,...,16}
            {
            \draw (112.5-22.5*\i:\R cm-\p)--(112.5-22.5*\i:\R cm+\p) node[blue,pos=2.5] {$x_{\i}$} \ifnum\j<22 node[red,pos=-1.5] {$x_{\j}$} \fi;
            }
    \end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .