我有以下代码:
\documentclass[12pt, a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{bm}
\usepackage{nccmath}
\usepackage{amsfonts, graphicx, verbatim, mathtools,amssymb, amsthm, mathrsfs}
\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,arrows}
\newcommand\tikznode[3][]{%
\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
% \board[optional scale factor, default 1.0]{list of triples angle/number/mark}
\newcommand\board[2][1.0]{%
\begin{tikzpicture}[baseline={(0,0)},scale=#1]
\draw (0,0) circle (1);
% radial lines at angles 30°, 150° and 270°
\foreach \a in {30, 150, 270}
\draw (\a:0.8) -- (\a:1.2);
% label A/B/C outside of circle at angles 90°, 210° and 330°
\foreach \a/\l in {90/A,210/B,330/C}
\node at (\a:1.4) {\scriptsize$\l$};
% draw game positions
% \a ... angle, \n ... number 1/2/3, \m ... mark
\foreach \a/\n/\m in {#2} {
% node
\node[circle,draw,minimum size=1em,inner sep = 0,fill=white] at (\a:1) {\m};
% number inside of circle
\node at (\a:0.6) {\scriptsize$\n$};
}
\end{tikzpicture}%
}
\newcommand\cross{$\times$}
\section{Case 1}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,B),(s,A),(i,B)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/2/,190/1/\cross,230/3/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/2/,190/1/R,230/3/\cross}\\
Status
\end{tabular}
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X) edge[bend left] node[right]{$P_{XY}=p/8$} (Y);
\end{tikzpicture}
\paragraph{Time 2}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=i$ in $A$\\
$3=r$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,A),(i,C),(r,C)]=Z$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/2/,350/3/\cross}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/2/\cross ,350/3/R}\\
Status
\end{tabular}
\paragraph{Time 3}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=r$ in $A$\\
$3=r$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,C),(r,B),(r,A)]=Q$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/R,210/2/\cross,330/1/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/R,210/2/R,330/1/R}\\
Status
\end{tabular}
At time 3, the epidemic stops since all personnel are recovered.
\section{Case 2}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,B),(s,A),(i,B)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,210/1/\cross,330/2/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,210/1/R,330/2/}\\
Status
\end{tabular}
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X) edge[bend left] node[right]{$P_{XY}=1/8$} (Y);
\end{tikzpicture}
At time 1, the epidemic stops since all personnel are recovered.
\section{Case 3}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $C$\\
$2=i$ in $C$\\
$3=s$ in $A$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,C),(i,C),(s,A)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,310/1/\cross,350/2/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,310/3/R,350/2/\cross}\\
Status
\end{tabular}
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X) edge[bend left] node[right]{$P_{XY}=p/8$} (Y);
\end{tikzpicture}
\paragraph{Time 2}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=r$ in $B$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,B),(r,B),(i,B)]=Z$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{210/2/\cross,245/3/,175/1/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{210/2/R,245/3/\cross,175/1/R}\\
Status
\end{tabular}
\paragraph{Time 3}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $A$\\
$2=r$ in $C$\\
$3=r$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,A),(r,C),(r,C)]=Q$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/3/\cross,350/2/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/3/R,350/2/R}\\
Status
\end{tabular}
At time 3, the epidemic stops since all personnel are recovered.
\section{Case 4}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=s$ in $A$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,B),(s,A),(s,A)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{70/3/,210/1/\cross,110/2/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{70/3/,210/1/R,110/2/}\\
Status
\end{tabular}
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X) edge[bend left] node[right]{$P_{XY}=1/8$} (Y);
\end{tikzpicture}
At time 1, the epidemic stops since all personnel are recovered.
\section{Case 5}
\end{document}
我希望放置箭头,例如“X”到“Y”到“Y”到“Z”以及“Z”到“Q”。有什么想法吗?此外,在情况 3 和 4 中,箭头存在问题,它会穿过整个页面,我该如何修复?
答案1
确保
\tikznode
每个此类命令后面的名称都是不同的。确保
\tikznodes
出现在同一个页面的所有内容tikzpicture
都在同一页上。LaTeX 应该如何连接不同页面上的点?
为了避免分页,请将属于同一部分的文本和绘图放在一个环境中,使它们可以移动到有足够空间的地方。否则,您必须自己控制它,如下例所示,通过重新排列文本,使空间合理填充,并通过或figure
强制分页。\newpage
\clearpage
\documentclass[12pt, a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{bm}
\usepackage{nccmath}
\usepackage{amsfonts, graphicx, verbatim, mathtools,amssymb, amsthm, mathrsfs}
\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,arrows}
\newcommand\tikznode[3][]{%
\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
% \board[optional scale factor, default 1.0]{list of triples angle/number/mark}
\newcommand\board[2][1.0]{%
\begin{tikzpicture}[baseline={(0,0)},scale=#1]
\draw (0,0) circle (1);
% radial lines at angles 30°, 150° and 270°
\foreach \a in {30, 150, 270}
\draw (\a:0.8) -- (\a:1.2);
% label A/B/C outside of circle at angles 90°, 210° and 330°
\foreach \a/\l in {90/A,210/B,330/C}
\node at (\a:1.4) {\scriptsize$\l$};
% draw game positions
% \a ... angle, \n ... number 1/2/3, \m ... mark
\foreach \a/\n/\m in {#2} {
% node
\node[circle,draw,minimum size=1em,inner sep = 0,fill=white] at (\a:1) {\m};
% number inside of circle
\node at (\a:0.6) {\scriptsize$\n$};
}
\end{tikzpicture}%
}
\newcommand\cross{$\times$}
\begin{document}
\section{Case 1}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X1}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y1}{$[(r,B),(s,A),(i,B)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/2/,190/1/\cross,230/3/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/2/,190/1/R,230/3/\cross}\\
Status
\end{tabular}
\paragraph{Time 2}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=i$ in $A$\\
$3=r$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Z1}{$[(r,A),(i,C),(r,C)]=Z$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/2/,350/3/\cross}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/2/\cross ,350/3/R}\\
Status
\end{tabular}
\paragraph{Time 3}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=r$ in $A$\\
$3=r$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Q1}{$[(r,C),(r,B),(r,A)]=Q$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/R,210/2/\cross,330/1/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/R,210/2/R,330/1/R}\\
Status
\end{tabular}
At time 3, the epidemic stops since all personnel are recovered.
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X1) edge[bend left] node[right]{$P_{XY}=p/8$} (Y1);
\draw[->] (Y1) edge[bend left] node[right]{$P_{XY}=p/8$} (Z1);
\draw[->] (Z1) edge[bend left] node[right]{$P_{XY}=p/8$} (Q1);
\end{tikzpicture}
\newpage
\section{Case 3}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X3}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $C$\\
$2=i$ in $C$\\
$3=s$ in $A$
\end{tabular}
$\longrightarrow$
\tikznode{Y3}{$[(r,C),(i,C),(s,A)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,310/1/\cross,350/2/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,310/3/R,350/2/\cross}\\
Status
\end{tabular}
\paragraph{Time 2}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=r$ in $B$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Z3}{$[(r,B),(r,B),(i,B)]=Z$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{210/2/\cross,245/3/,175/1/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{210/2/R,245/3/\cross,175/1/R}\\
Status
\end{tabular}
\paragraph{Time 3}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $A$\\
$2=r$ in $C$\\
$3=r$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{Q3}{$[(r,A),(r,C),(r,C)]=Q$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/3/\cross,350/2/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/3/R,350/2/R}\\
Status
\end{tabular}
At time 3, the epidemic stops since all personnel are recovered.
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X1) edge[bend left] node[right]{$P_{XY}=p/8$} (Y1);
\draw[->] (Y1) edge[bend left] node[right]{$P_{XY}=p/8$} (Z1);
\draw[->] (Z1) edge[bend left] node[right]{$P_{XY}=p/8$} (Q1);
\end{tikzpicture}
\newpage
\section{Case 2}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X2}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y2}{$[(r,B),(s,A),(i,B)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,210/1/\cross,330/2/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/,210/1/R,330/2/}\\
Status
\end{tabular}
At time 1, the epidemic stops since all personnel are recovered.
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X3) edge[bend left] node[right]{$P_{XY}=1/8$} (Y3);
\end{tikzpicture}
\section{Case 4}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
\tikznode{X4}{$[(i,A),(s,B),(s,C)]=X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=s$ in $A$
\end{tabular}
$\longrightarrow$
\tikznode{Y4}{$[(r,B),(s,A),(s,A)]=Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{70/3/,210/1/\cross,110/2/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{70/3/,210/1/R,110/2/}\\
Status
\end{tabular}
At time 1, the epidemic stops since all personnel are recovered.
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X4) edge[bend left] node[right]{$P_{XY}=1/8$} (Y4);
\end{tikzpicture}
\newpage
\section{Case 5}
\end{document}
答案2
\documentclass[12pt, a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{bm}
\usepackage{nccmath}
\usepackage{amsfonts, graphicx, verbatim, mathtools,amssymb, amsthm, mathrsfs}
\usepackage{color}
\usepackage{array}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,positioning,arrows}
\newcommand\tikznode[3][]{%
\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
% \board[optional scale factor, default 1.0]{list of triples angle/number/mark}
\newcommand\board[2][1.0]{%
\begin{tikzpicture}[baseline={(0,0)},scale=#1]
\draw (0,0) circle (1);
% radial lines at angles 30°, 150° and 270°
\foreach \a in {30, 150, 270}
\draw (\a:0.8) -- (\a:1.2);
% label A/B/C outside of circle at angles 90°, 210° and 330°
\foreach \a/\l in {90/A,210/B,330/C}
\node at (\a:1.4) {\scriptsize$\l$};
% draw game positions
% \a ... angle, \n ... number 1/2/3, \m ... mark
\foreach \a/\n/\m in {#2} {
% node
\node[circle,draw,minimum size=1em,inner sep = 0,fill=white] at (\a:1) {\m};
% number inside of circle
\node at (\a:0.6) {\scriptsize$\n$};
}
\end{tikzpicture}%
}
\newcommand\cross{$\times$}
\begin{document}
\paragraph{Time 0}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=i$ in $A$\\
$2=s$ in $B$\\
$3=s$ in $C$
\end{tabular}
$\longrightarrow$
{$[(i,A),(s,B),(s,C)]=\tikznode{X}X$}
\board[0.9]{90/1/\cross,210/2/,330/3/}
\paragraph{Time 1}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=s$ in $A$\\
$3=i$ in $B$
\end{tabular}
$\longrightarrow$
{$[(r,B),(s,A),(i,B)]=\tikznode{Y}Y$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/2/,190/1/\cross,230/3/}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/2/,190/1/R,230/3/\cross}\\
Status
\end{tabular}
\begin{tikzpicture}[remember picture,overlay,>=stealth',shorten <=2pt,shorten >=2pt]
\draw[->] (X) edge[bend left] node[right]{$P_{XY}=p/8$} (Y);
\end{tikzpicture}
\paragraph{Time 2}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=i$ in $A$\\
$3=r$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,A),(i,C),(r,C)]=Z$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/2/,350/3/\cross}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/1/R,310/2/\cross ,350/3/R}\\
Status
\end{tabular}
\paragraph{Time 3}\mbox{}\\
\begin{tabular}{@{}p{5em}@{}}
$1=r$ in $B$\\
$2=r$ in $A$\\
$3=r$ in $B$
\end{tabular}
$\longrightarrow$
\tikznode{Y}{$[(r,C),(r,B),(r,A)]=Q$}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/R,210/2/\cross,330/1/R}\\
Move
\end{tabular}
\begin{tabular}[t]{@{}c@{}}
\board[0.9]{90/3/R,210/2/R,330/1/R}\\
Status
\end{tabular}
\end{document}