15

I use subfig to show an array of tikz figures. Unfortunately these figures are sometimes of different height, so they don't show up properly aligned:

enter image description here

I'd like to see all nodes on the same line. I'm new to TikZ, so I'm wondering if it is possible to give all figures a minimum height. I tried to set a bounding box using \useasboundingbox (0,0) rectangle (5,2); but it was difficult for me to estimate the correct values. Is there a way to calculate that, or is it possible to render an invisible phantom edge (with label) that gives the figure a) the same height as figure b)? Or is there a way to do the alignment on subfig's side?

Below is a MWE:

\documentclass{article}
\usepackage{subfig}
\usepackage{amsmath}
\usepackage{tikz}

\usetikzlibrary{arrows}
\tikzstyle{state}=[circle,thick,draw=black!75,fill=black!20,minimum size=6mm, text=black]

\begin{document}


\begin{figure}
\centering
\subfloat[In-only]{\label{fig:in}
   \begin{tikzpicture}[node distance=2.8cm, bend angle=35,auto]
      \node [state] (v1) at (1,0) {$D$};
      \node [state] (v2) at (4,0) {$N$};
      \draw (v1) edge [<-, bend left] node {$M_\text{in}$} (v2);
    \end{tikzpicture}
}
\quad
\subfloat[In-only]{\label{fig:in}
   \begin{tikzpicture}[node distance=2.8cm, bend angle=35,auto]
      \node [state] (v1) at (1,0) {$D$};
      \node [state] (v2) at (4,0) {$N$};
      \draw (v1) edge [<-, bend left] node {$M_\text{in}$} (v2);
      \draw (v1) edge [->, bend right] node {$M_\text{out}$} (v2);
    \end{tikzpicture}
}

\end{figure}
\end{document}
vanto
  • 497

1 Answers1

16

For each TikZ picture, set the baseline option and refer to the node you would like to use for the alignment:

\begin{tikzpicture}[baseline=(nodename.base),...]
Stefan Kottwitz
  • 231,401