在 TikZ 中绘制一个由数​​字包围的圆圈

在 TikZ 中绘制一个由数​​字包围的圆圈

我想使用 LaTeX 中的 TikZ 绘制下图,要求如下:

  1. 数字均匀分布在圆圈周围。
  2. 我可以控制圆圈的大小。
  3. 数字的大小也可以修改。

编辑:按照评论之后,我得到了一些有用的方法。

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\tikzstyle{every node}=[font=\large]
\def\numofpoints{9}
\def\labelpatt{{2,3,1,8,7,9,0,6,4,5}}

\node[circle,draw,minimum width=2cm] (bigc) {};
\foreach \x in {0,...,\numexpr\numofpoints-1\relax}
{
\node (l-\x) at (360/\numofpoints*\x+90:1.2cm)    
{\pgfmathparse{\labelpatt[\x]}$\pgfmathresult$};
}
\end{tikzpicture}

\end{document}

输出

答案1

如果允许使用 PSTricks,您可以使用以下内容:

\documentclass{article}

\usepackage{pstricks}
\usepackage{xfp}

\newcommand*\Number[2]{\uput[#1](\radius;#1){\large #2}}
% The first argument sets how many degrees the number is moved relative to 0 (anticlockwise).
% The second argument is the number.

% The following is to automatically get the correct bounding box around the drawing.
\newcommand*\RadiusA{\fpeval{\radius+0.25}}
\newcommand*\RadiusB{\fpeval{\radius+0.45}}

% Radius of the circle.
\def\radius{2}

\begin{document}

\begin{pspicture}(-\RadiusA,-\RadiusB)(\RadiusA,\RadiusB)
  \pscircle(0,0){\radius}
  \Number{18}{1}
  \Number{54}{3}
  \Number{90}{2}
  \Number{126}{5}
  \Number{162}{4}
  \Number{198}{6}
  \Number{234}{0}
  \Number{270}{9}
  \Number{306}{7}
  \Number{344}{8}
\end{pspicture}

\end{document}

输出

答案2

TikZ 方法中\deg\p\r\f是变量:

在此处输入图片描述

代码

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{fit,calc,arrows,positioning}
\begin{document}


\def\deg{36}              % phase angle  
\def\p{10}                % vertices
\def\r{1}                 % radius
\def\f{\small}            % tiny small large, Large, huge, Huge
\begin{center}
\begin{tikzpicture}[scale=1]
\draw [thick](0,0) circle (\r);
\foreach \t/\x in {1/0*\deg, 3/1*\deg, 2/2*\deg, 5/3*\deg, 4/4*\deg, 6/5*\deg,0/6*\deg, 9/7*\deg, 7/8*\deg,8/9*\deg}
{\draw[thick,->]  node[] (\t) at (\x:1) {};
\node[anchor=center] at (\x:{\r+0.2}) {\f$\t$};}
\end{tikzpicture}

\def\deg{36}              % phase angle  
\def\p{10}                % vertices
\def\r{1.5}               % radius
\def\f{\Huge}             % tiny small large, Large, huge, Huge
\begin{tikzpicture}[scale=2]
\draw [thick](0,0) circle (\r);
\foreach \t/\x in {1/0*\deg, 3/1*\deg, 2/2*\deg, 5/3*\deg, 4/4*\deg, 6/5*\deg,0/6*\deg, 9/7*\deg, 7/8*\deg,8/9*\deg}
{\draw[thick,->]  node[] (\t) at (\x:1) {};
\node[anchor=center] at (\x:{\r+0.2}) {\f$\t$};}
\end{tikzpicture}
\end{center}
\end{document}

相关内容