所包含图形的排列可以通过 和其他实用程序轻松完成minipage
。subfloat
这里有一组由三个TikZ
生成的图形和一个表格:
\documentclass{article}
\usepackage{tikz}
\usepackage{caption}
\usetikzlibrary{arrows, automata, positioning}
\begin{document}
\begin{figure}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_0$};
\node[state] (s_1) [right=of s_0] {$s_1$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{1st}
\end{figure}
\begin{table}[h]
\caption{Table}
\begin{tabular}{| c || c | c | c | c |}
\hline & $s_0$ & $s_1$ & $s_2$ & $s_3$\\
\hline $0$ & $s_1$ & $s_1$ & $s_1$ & $s_1$\\
\hline $1$ & $s_3$ & $s_2$ & $s_3$ & $s_3$\\
\hline
\end{tabular}
\end{table}
\begin{figure}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_6$};
\node[state] (s_1) [right=of s_0] {$s_4$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{2nd}
\end{figure}
\begin{figure}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_08$};
\node[state] (s_1) [right=of s_0] {$s_7$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{3rd}
\end{figure}
\end{document}
如何以任意网格形式排列 tikzpictures 和表格?
例如:
[tikzpicture][tikzpicture][tikzpicture]
[table]
,
[tikzpicture][tikzpicture]
[tikzpicture] [table]
或任何其他定位。
更新:
以下是当前版本的代码subcaption
:
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usetikzlibrary{arrows, automata, positioning}
\begin{document}
\begin{figure}
\begin{subfigure}[b]{0.49\textwidth}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_0$};
\node[state] (s_1) [right=of s_0] {$s_1$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\subcaption{1st}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\begin{table}
\caption{Table}
\begin{tabular}{| c || c | c | c | c |}
\hline & $s_0$ & $s_1$ & $s_2$ & $s_3$\\
\hline $0$ & $s_1$ & $s_1$ & $s_1$ & $s_1$\\
\hline $1$ & $s_3$ & $s_2$ & $s_3$ & $s_3$\\
\hline
\end{tabular}
\end{table}
\end{subfigure}\hfill
\end{figure}
\begin{figure}
\begin{subfigure}[b]{0.49\textwidth}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_6$};
\node[state] (s_1) [right=of s_0] {$s_4$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{2nd}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.49\textwidth}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_08$};
\node[state] (s_1) [right=of s_0] {$s_7$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{3rd}
\end{subfigure}\hfill
\end{figure}
\end{document}
存在错误,如下所示:! LaTeX Error: Not in outer par mode.
答案1
您不能将 a 放在table
a 内部figure
,因为它们都是浮点数,尽管您可以轻松地tabulars
在表格中放入数字和图像。
此外,asubfigure
只是一种美化minipage
。您只需具体说明您想要哪种标题即可。
\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usetikzlibrary{arrows, automata, positioning}
\begin{document}
\begin{figure}
\begin{minipage}[c]{0.49\textwidth}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_0$};
\node[state] (s_1) [right=of s_0] {$s_1$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\subcaption{1st}
\end{minipage}\hfill
\begin{minipage}[c]{0.49\textwidth}
\captionof{table}{Table}
\begin{tabular}{| c || c | c | c | c |}
\hline & $s_0$ & $s_1$ & $s_2$ & $s_3$\\
\hline $0$ & $s_1$ & $s_1$ & $s_1$ & $s_1$\\
\hline $1$ & $s_3$ & $s_2$ & $s_3$ & $s_3$\\
\hline
\end{tabular}
\end{minipage}
\end{figure}
\begin{figure}
\begin{minipage}[b]{0.49\textwidth}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_6$};
\node[state] (s_1) [right=of s_0] {$s_4$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{2nd}
\end{minipage}\hfill
\begin{minipage}[b]{0.49\textwidth}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial,accepting] (s_0) {$s_08$};
\node[state] (s_1) [right=of s_0] {$s_7$};
\path[->]
(s_0) edge [loop above] node {$\alpha$} ()
edge node {$\beta$} (s_1)
(s_1) edge [loop above] node {$\alpha, \beta$} ();
\end{tikzpicture}
\caption{3rd}
\end{minipage}
\end{figure}
\end{document}