# Aligning both tikz pictures and their captions

I am using two tikz pictures in subfigures. The baseline parameter allows aliging the subfigures via the nodes, however the caption (b) is much above the caption (a) in such case. If I don't you baseline, then the caption are aligned, but not the figures. Is that possible to match the alignment for both simultaneously?

\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}
}
\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}

-

You have to measure the bigger picture.

\documentclass[10pt, a4paper]{amsart}
\usepackage{graphicx, subfig}
\usepackage{graphics}
\usepackage{tikz}
\usepackage[all]{xy}
\usetikzlibrary{arrows,automata}
\usetikzlibrary{shapes,snakes}
\usetikzlibrary{positioning}

\newsavebox{\bigpicture}
\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[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}


Please, note that subfigure has been obsolete and deprecated for several years. Either use subfig as I did here (changing \subfigure to \subfloat) or subcaption.

In \sbox{\bigpicture}{...} you save the bigger picture (not necessarily the first one), and use \adapttobigpicture in the smaller one. The \sbox{\bigpicture}{...} part must go before using \adapttobigpicture, better as the first object in the figure environment. If you have more than one row of subfigures, you can reuse the save box at the start of each row.

-
Thank you, I'll try this. – Ilya Jul 22 '14 at 13:23