使用 TikZ 标记圆圈

使用 TikZ 标记圆圈

我想标记一个圆圈的进出,就像这张草图一样:

草图

我也尝试用自己的非常简单的方法画出圆圈,如下:

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

我想要的是

我希望我已经绘制的圆圈(通过 TikZ 代码)被标记为我提供的图像,而不是你为不同的圆圈想出不同的代码,因为我可能无法理解你的风格。

笔记

我想改进一下我的简单代码风格,只需添加代码块即可使标签可见,而不是你想出的不同风格。如果你想出不同的风格,我将无法改进你的答案来满足我的需要。

答案1

如果我编译这个:

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

然后我得到这个:

在此处输入图片描述

一个更短的代码可以给你相同的输出:

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

答案2

您可以不是就像一个更快的方法,只是为了好玩:

标签圈

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

相关内容