我设法得到了下面的两张图片。我想我必须旋转直线并将其末端连接到数字 615,以便它看起来像字母 rho (ρ)。我该怎么做?请随意提出一种完全不同的方法。
请注意直线的箭头与循环中的箭头相比太小了。我也希望看到一种使这些箭头大小相似的方法。如果我必须输入每个节点,那也没关系——只要定义它们的位置是一个合理的过程。我相信你想出的任何方法都会比我今天能做的更好——因为我只读了 TikZ 手册的前几页。
% A simple cycle
% Author : Jerome Tremblay
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def \n {11}
\def \radius {3.5cm}
\def \margin {8} % margin in angles, depends on the radius
%% \draw[step=.5cm,gray,very thin] (-7,-7) grid (7,7);
%% \draw (0,0) circle (0.1cm);
%% --8<---------------cut here---------------start------------->8---
%% the tail
%% \path
%% (0,0) node [shape=circle,draw,minimum width=1cm]{$2$}
%% (1,0) node [shape=circle,draw,minimum width=1cm]{$12$}
%% (2,0) node [shape=circle,draw,minimum width=1cm]{$152$}
%% (3,0) node [shape=circle,draw,minimum width=1cm]{$1223$}
%% (4,0) node [shape=circle,draw,minimum width=1cm]{$1031$}
%% (5,0) node [shape=circle,draw,minimum width=1cm]{$2916$}
%% (6,0) node [shape=circle,draw,minimum width=1cm]{$751$}
%% (7,0) node [shape=circle,draw,minimum width=1cm]{$1149$};
%% --8<---------------cut here---------------end--------------->8---
% the cycle
\def \s {1}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$456$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {2}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$1562$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {3}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$792$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {4}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$1872$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {5}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$2152$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {6}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$25$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {7}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$441$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {8}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$615$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {9}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$2993$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {10}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$2329$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\def \s {11}
\node[draw=none] at ({360/\n * -(\s - 1)}:\radius) {$2031$};
\draw[<-, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
\end{tikzpicture}
\begin{tikzpicture}[node distance=1.5cm,minimum width=1.2cm]
\node(n0) [draw=none] at (-15,0) {$2$};
\node (n1) [draw=none,right of=n0]{$12$};
\node (n2) [draw=none,right of=n1]{$152$};
\node (n3) [draw=none,right of=n2]{$1223$};
\node (n4) [draw=none,right of=n3]{$1031$};
\node (n5) [draw=none,right of=n4]{$2916$};
\node (n6) [draw=none,right of=n5]{$751$};
\node (n7) [draw=none,right of=n6]{$1149$};
\draw [->] (n0) to (n1);
\draw [->] (n1) to (n2);
\draw [->] (n2) to (n3);
\draw [->] (n3) to (n4);
\draw [->] (n4) to (n5);
\draw [->] (n5) to (n6);
\draw [->] (n6) to (n7);
\end{tikzpicture}
\end{document}
答案1
您的圆圈和直线可以编码得更短,这也使您可以非常轻松地更改各个节点的位置。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{chains,positioning}
\begin{document}
\begin{tikzpicture}[node distance=1.5cm]
\node[circle,minimum width=7cm] (circ) {};
\foreach \X [count=\Y] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{\node (cn\Y) at ({-(\Y-2.5)*360/11}:3.5) {$\X$}; }
\foreach \Y [remember=\Y as \LastY (initially 11)]in {1,...,11}
{\draw[-latex,shorten >=4pt,shorten <=4pt] (cn\LastY) to[bend left=10] (cn\Y);}
\begin{scope}[start chain = going below,every node/.append style={on chain},
every join/.style=-latex]]
\node[below=of cn8] (n0) {2};
\draw[-latex] (cn8) -- (n0);
\node[join] (n1) {$12$};
\node[join] (n2) {$152$};
\node[join] (n3) {$1223$};
\node[join] (n4) {$1031$};
\node[join] (n5) {$2916$};
\node[join] (n6) {$751$};
\node[join] (n7) {$1149$};
\end{scope}
\end{tikzpicture}
\end{document}
只是为了好玩:乳胶的直线\rho
的角度大约为 76 度。
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}
\node[scale=15]{$\rho$};
\draw[white,thick,double=blue] (-0.5,0.6) -- (-1.05,-1.6)
node[midway,left=5mm,scale=3,blue]{\pgfmathparse{atan2(0.6+1.6,1.05-0.5)}%
$\pgfmathprintnumber{\pgfmathresult}^\circ$};
\end{tikzpicture}
\end{document}
这就提出了一个问题:是否可以制造出具有这个角度的链条?答案是可以的。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{chains,positioning}
\begin{document}
\begin{tikzpicture}[node distance=1.5cm]
\node[circle,minimum width=7cm] (circ) {};
\foreach \X [count=\Y] in {456,1562,792,1872,2152,25,441,615,2993,2329,2031}
{\node (cn\Y) at ({-(\Y-2.5)*360/11}:3.5) {$\X$}; }
\foreach \Y [remember=\Y as \LastY (initially 11)]in {1,...,11}
{\draw[-latex,shorten >=4pt,shorten <=4pt] (cn\LastY) to[bend left=10] (cn\Y);}
\begin{scope}[start chain = going below,every node/.append style={on chain,
,xshift=-{cot(76)*1.5cm}},
every join/.style=-latex]
\node[below=of cn8] (n0) {2};
\draw[-latex] (cn8) -- (n0);
\node[join] (n1) {$12$};
\node[join] (n2) {$152$};
\node[join] (n3) {$1223$};
\node[join] (n4) {$1031$};
\node[join] (n5) {$2916$};
\node[join] (n6) {$751$};
\node[join] (n7) {$1149$};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
这不是真正的答案(因为我迟到了一分钟),只是向@marmot 说明我如何想象\rho
“尾巴”成圆圈......
\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{chains, positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 4mm and 6mm,
start chain = going below left,
box/.style = {minimum width=5ex, inner xsep=0pt,
on chain, join=by latex-}
]
\def \n {11}
\def \radius {3.5cm}
\def \margin {8} % margin in angles, depends on the radius
% the cycle
\foreach \s [count=\i from 0,
count=\j from 1] in {456, 1562, 792, 1872, 2152,
25, 441, 615, 2993, 2329, 2031}
{
\node (s\j) at (-\i*360/\n:\radius) {$\s$};
\draw[latex-] (\i*360/\n + \margin:\radius)
arc (\i*360/\n +\margin:\j*360/\n -\margin:\radius);
}
\node (d1) [box, below left=of s8] {$2$};
\node[box] {$12$};
\node[box] {$152$};
\node[box] {$1223$};
\node[box] {$1031$};
\node[box] {$2916$};
\node[box] {$751$};
\node[box] {$1149$};
\draw[red,-latex] (d1) -- (s8);
\end{tikzpicture}
\end{document}
大家可以看出,代码之间的差异可以忽略不计...线的斜率可以用调整node distance
。例如,我宁愿从圆上的节点“441”开始,使斜率更具阶梯性:
node distance = 5mm and -2.5ex,
和带尾巴的星星:
\node (d1) [box, below left=of s7] {$2$};
对于红色箭头,我不确定是否需要(所以它是红色的)