我有这个循环文本的代码,但我不知道如何将它们组合成线性组合。
\documentclass[tikz,border=2pt]{standalone}
\begin{document}
\begin{tikzpicture}[->]
\node (a) at (90:2cm) {Democrat};
\node (b) at (-30:2cm) {Republician};
\node (c) at (210:2cm) {Third};
\draw (-20:2cm) arc (-20:60:2cm) node[midway, right] {{\footnotesize 1}};
\draw (120:2cm) arc (120:200:2cm) node[midway, left] {{\footnotesize -1}};
\draw (220:2cm) arc (220:320:2cm) node[midway, below] {{\footnotesize 1}};
\end{tikzpicture}
\end{document}
答案1
每个tikzpicture
原子都可以是更大的数学结构中的一个原子。在这种情况下,我也习惯于\raisebox
获得更好的中心化。
\documentclass[border=2pt]{standalone}
\usepackage{tikz}
\begin{document}
$
5\cdot
\raisebox{-1.5cm}{\begin{tikzpicture}[scale=.6,->]
\node (a) at (90:2cm) {Democrat};
\node (b) at (-30:2cm) {Republician};
\node (c) at (210:2cm) {Third};
\draw (-20:2cm) arc (-20:60:2cm) node[midway, right] {{\footnotesize 5 voters}};
\draw (120:2cm) arc (120:200:2cm) node[midway, left] {{\footnotesize 7 voters}};
\draw (220:2cm) arc (220:320:2cm) node[midway, below] {{\footnotesize 1 voter}};
\end{tikzpicture}}
+4\cdot
\raisebox{-1.5cm}{\begin{tikzpicture}[scale=.6,->]
\node (a) at (90:2cm) {Democrat};
\node (b) at (-30:2cm) {Republician};
\node (c) at (210:2cm) {Third};
\draw (-20:2cm) arc (-20:60:2cm) node[midway, right] {{\footnotesize 5 voters}};
\draw (120:2cm) arc (120:200:2cm) node[midway, left] {{\footnotesize 7 voters}};
\draw (220:2cm) arc (220:320:2cm) node[midway, below] {{\footnotesize 1 voter}};
\end{tikzpicture}}
+\cdots + 2\cdot
\raisebox{-1.5cm}{\begin{tikzpicture}[scale=.6,->]
\node (a) at (90:2cm) {Democrat};
\node (b) at (-30:2cm) {Republician};
\node (c) at (210:2cm) {Third};
\draw (-20:2cm) arc (-20:60:2cm) node[midway, right] {{\footnotesize 5 voters}};
\draw (120:2cm) arc (120:200:2cm) node[midway, left] {{\footnotesize 7 voters}};
\draw (220:2cm) arc (220:320:2cm) node[midway, below] {{\footnotesize 1 voter}};
\end{tikzpicture}}
$
\end{document}
答案2
\documentclass{article}
\usepackage[left=1.5cm,right=1.5cm,
top=1.5cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{float}
\usepackage{array, makecell}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{pdflscape}
\usepackage{longtable, array}
\begin{document}
\begin{longtable}{@{} *{1}{m{0.4cm}}*{1}{m{2cm}} *{1}{m{0.8cm}}*{1}{m{2cm}} *{1}{m{1.8cm}}*{1}{m{3cm}}*{1}{m{3cm}} @{}}
5 $\cdot$& \begin{tikzpicture}[->,scale=.7]
\node (i) at (90:1cm) {$T$};
\node (j) at (-30:1cm) {$D$};
\node (k) at (210:1cm) {$R$};
\draw (70:1cm) arc (70:-10:1cm) node[midway, right] {{\footnotesize 1}};
\draw (-50:1cm) arc (-50:-130:1cm) node[midway, below] {{\footnotesize 1}};
\draw (190:1cm) arc (190:110:1cm) node[midway, left] {{\footnotesize -1}};
\end{tikzpicture}
&+ 4 $\cdot$& \begin{tikzpicture}[->,scale=.7]
\node (i) at (90:1cm) {$T$};
\node (j) at (-30:1cm) {$D$};
\node (k) at (210:1cm) {$R$};
\draw (70:1cm) arc (70:-10:1cm) node[midway, right] {{\footnotesize 1}};
\draw (-50:1cm) arc (-50:-130:1cm) node[midway, below] {{\footnotesize 1}};
\draw (190:1cm) arc (190:110:1cm) node[midway, left] {{\footnotesize -1}};
\end{tikzpicture}
&+ $ \ldots $ + 2 $\cdot$ & \begin{tikzpicture}[->,scale=.7]
\node (i) at (90:1cm) {$T$};
\node (j) at (-30:1cm) {$D$};
\node (k) at (210:1cm) {$R$};
\draw (70:1cm) arc (70:-10:1cm) node[midway, right] {{\footnotesize 1}};
\draw (-50:1cm) arc (-50:-130:1cm) node[midway, below] {{\footnotesize 1}};
\draw (190:1cm) arc (190:110:1cm) node[midway, left] {{\footnotesize -1}};
\end{tikzpicture} \\
\end{longtable}
\end{document}
答案3
欢迎来到 TeX.SE!!!
另一种方法是使用宏来处理循环文本:
\documentclass{article}
\usepackage {lipsum} % dummy text
\usepackage {tikz} % nice drawings
\newcommand{\cyclic}[3]% numbers: top right, bottom, top left
{%
\begin{tikzpicture}[->,baseline=(center.base)]% <-- to fix the baseline
\useasboundingbox (-1.4,-1.2) rectangle (1.2,1.2);
\node (center) at (0,0) {\strut};
\foreach[count=\ii]\i/\j in {D/#1,T/#2,R/#3}
{
\draw (120*\ii-20:1) arc (120*\ii-20:120*\ii+80:1);
\node at (120*\ii-30:1) {$\i$};
\node at (120*\ii+30:1.3) {\footnotesize\strut$\j\ifnum\j<0\hphantom{-}\fi$};
}% this provides some symmetry ^^^^^^^^^^^^^^^^^^^^^^^^
\end{tikzpicture}%
}
\begin{document}
\lipsum[1] See the following equation:
\[5\cdot\cyclic{-1}{1}{1}+4\cdot\cyclic{-1}{-1}{1}+\cdots+2\cdot\cyclic{1}{-1}{-1}.\]
\lipsum[2]
\end{document}
当然,如果您需要更改字母 D、T、R、大小等,您可以添加更多参数。