我在子图中使用了两个 tikz 图片。基线参数允许通过节点对齐子图,但是在这种情况下,标题 (b) 远高于标题 (a)。如果我不设置基线,则标题会对齐,但图形不会对齐。是否可以同时匹配两者的对齐?
\documentclass[10pt, a4paper]{amsart}
\usepackage{graphicx, subfigure}
\usepackage{graphics}
\usepackage{tikz}
\usepackage[all]{xy}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{shapes,snakes}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}[h]
\centering
\subfigure[First SS]{
\begin{tikzpicture}[baseline=(b),->,>=stealth',shorten <= 2pt, shorten >= 2pt,auto,node distance= 2.2cm]
\tikzstyle{every state}=[draw,circle split,minimum width={2em}]
\node[state] (a1) {$a_1$ \nodepart{lower} $A$};
\node[state] (b) [below right = .3cm and 3.5cm of a1] {$b$ \nodepart{lower} $B$};
\node[state] (a2) [below left = .3cm and 3.5cm of b] {$a_2$ \nodepart{lower} $A$};
\path[->]
(a1) edge [loop above, below left] node {$\frac13\;$} (a1)
edge [bend left] node {$\frac13$} (b)
edge [bend right,left] node {$\frac13$} (a2)
(a2) edge [bend right, right] node {$\frac23$} (a1)
edge [bend right, below] node {$\frac13$} (b)
(b) edge [loop above, below right] node {$\;\;1$} (b)
;
\end{tikzpicture}
\label{fig:ss.example.a}
}
\qquad
\subfigure[Second SS]{
\begin{tikzpicture}[baseline=(-b),->,>=stealth',shorten <= 2pt, shorten >= 2pt,auto,node distance= 2.2cm]
\tikzstyle{every state}=[draw,circle split,minimum width={2em}]
\node[state] (-a) {$\bar a$ \nodepart{lower} $A$};
\node[state] (-b) [right = 3cm of -a] {$\bar b$ \nodepart{lower} $B$};
\path[->]
(-a) edge [loop above, below left] node {$\frac23\;$} (-a)
edge node {$\frac13$} (-b)
(-b) edge [loop above, below right] node {$\;\;1$} (-b)
;
\end{tikzpicture}
\label{fig:ss.example.b}
}
\caption{Example of two finite autonomous SSs.}
\label{fig:ss.example}
\end{figure}
\end{document}
答案1
你必须衡量更大范围。
\documentclass[10pt, a4paper]{amsart}
\usepackage{graphicx, subfig}
\usepackage{graphics}
\usepackage{tikz}
\usepackage[all]{xy}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{shapes,snakes}
\usetikzlibrary{positioning}
\newsavebox{\bigpicture}
\newcommand{\adapttobigpicture}{%
\vrule height\ht\bigpicture depth\dp\bigpicture width0pt
}
\begin{document}
\begin{figure}[h]
\centering
\sbox{\bigpicture}{%
\begin{tikzpicture}[baseline=(b),->,>=stealth',shorten <= 2pt, shorten >= 2pt,auto,node distance= 2.2cm]
\tikzstyle{every state}=[draw,circle split,minimum width={2em}]
\node[state] (a1) {$a_1$ \nodepart{lower} $A$};
\node[state] (b) [below right = .3cm and 3.5cm of a1] {$b$ \nodepart{lower} $B$};
\node[state] (a2) [below left = .3cm and 3.5cm of b] {$a_2$ \nodepart{lower} $A$};
\path[->]
(a1) edge [loop above, below left] node {$\frac13\;$} (a1)
edge [bend left] node {$\frac13$} (b)
edge [bend right,left] node {$\frac13$} (a2)
(a2) edge [bend right, right] node {$\frac23$} (a1)
edge [bend right, below] node {$\frac13$} (b)
(b) edge [loop above, below right] node {$\;\;1$} (b)
;
\end{tikzpicture}%
}
\subfloat[First SS]{\usebox{\bigpicture}\label{fig:ss.example.a}}\qquad
\subfloat[Second SS]{%
\adapttobigpicture
\begin{tikzpicture}[baseline=(-b),->,>=stealth',shorten <= 2pt, shorten >= 2pt,auto,node distance= 2.2cm]
\tikzstyle{every state}=[draw,circle split,minimum width={2em}]
\node[state] (-a) {$\bar a$ \nodepart{lower} $A$};
\node[state] (-b) [right = 3cm of -a] {$\bar b$ \nodepart{lower} $B$};
\path[->]
(-a) edge [loop above, below left] node {$\frac23\;$} (-a)
edge node {$\frac13$} (-b)
(-b) edge [loop above, below right] node {$\;\;1$} (-b)
;
\end{tikzpicture}%
\label{fig:ss.example.b}%
}
\caption{Example of two finite autonomous SSs.}
\label{fig:ss.example}
\end{figure}
\end{document}
请注意,subfigure
已经过时并弃用多年。 可以像subfig
我在这里所做的那样使用(更改\subfigure
为\subfloat
)或subcaption
。
保存\sbox{\bigpicture}{...}
较大的图片(不一定是第一个),并\adapttobigpicture
在较小的图片中使用。该\sbox{\bigpicture}{...}
部分必须在使用之前\adapttobigpicture
,最好作为环境中的第一个对象figure
。如果您有多行子图,您可以在每行的开头重复使用保存框。