对齐 2 个图片的标题

对齐 2 个图片的标题

我设法将两个 Tikz 图形并排放置。Tikz 图形的垂直对齐很好,需要保持这种状态。但是,标题让我很烦,我希望它们都位于底部。

  \begin{figure}[!ht]
  \minipage{0.5\textwidth}
  \centering
\begin{tikzpicture}
  % Styles
  \tikzstyle{main}=[minimum size=5mm, very thick, draw=black!100]
  \tikzstyle{bolt}=[circle]
  \tikzstyle{connect}=[-latex, thick]
  % Bolts
  \node[main,bolt] (s)   at (0.0, 0.0) [label=above:Bolt S] { };
  \node[main,bolt] (t)   at (1.5, 0.0) [label=above:Bolt T] { };
  % lines
  \draw (s) edge [connect] (t);
\end{tikzpicture}
\caption{Cap 1}
  \endminipage\hfill
  \minipage{0.5\textwidth}
  \centering
\begin{tikzpicture}[remember picture]
  % Styles
  \tikzstyle{main}=[minimum size=5mm, very thick, draw=black!100]
  \tikzstyle{bolt}=[circle]
  \tikzstyle{connect}=[-latex, thick]
  % Bolt S
  \node[main,rounded corners=10pt] (S) [label=above:Bolt S] {
    \begin{tikzpicture}
      \node [main,bolt] (ai) at (0.0, 1.5) {};
      \node [main,bolt] (aii) at (0.0, 0.0) {};
    \end{tikzpicture}
  };
  % Bolt T
  \node[main,rounded corners=10pt,right=of S] (T) [label=above:Bolt T] {
    \begin{tikzpicture}
      \node [main,bolt] (bi) at (0.0, 3.0) {};
      \node [main,bolt] (bii) at (0.0, 1.5) {};
      \node [main,bolt] (biii) at (0.0, 0.0) {};
    \end{tikzpicture}
  };
  % Connect
  \draw (S) edge [connect] (T);
\end{tikzpicture}
\caption{Cap 2}
  \endminipage
  \end{figure}

目前看起来是这样的:

在此处输入图片描述

干杯!

答案1

感谢 Sigur,我找到了解决方案。我修改minipage为底部对齐,并使用不可见的网格来均衡大小。此外,我调整了第一个图中的相对定位,因此它与右边的类似:

  \begin{figure}[!ht]
  \minipage[b]{0.5\textwidth}
  \centering
\begin{tikzpicture}
  % Styles
  \tikzstyle{main}=[minimum size=5mm, very thick, draw=black!100]
  \tikzstyle{bolt}=[circle]
  \tikzstyle{connect}=[-latex, thick]
  % fake
  \draw[step=0.25cm,color=white!20] (0,-2) grid (0,2);
  % Bolts
  \node[main,bolt] (s) [label=above:Bolt S] { };
  \node[main,bolt,right=of s] (t) [label=above:Bolt T] { };
  % lines
  \draw (s) edge [connect] (t);
\end{tikzpicture}
\caption{Cap 1}
  \endminipage\hfill
  \minipage[b]{0.5\textwidth}
  \centering
\begin{tikzpicture}[remember picture]
  % Styles
  \tikzstyle{main}=[minimum size=5mm, very thick, draw=black!100]
  \tikzstyle{bolt}=[circle]
  \tikzstyle{connect}=[-latex, thick]
  % fake
  \draw[step=0.25cm,color=white] (0,-2) grid (0,2);
  % Bolt S
  \node[main,rounded corners=10pt] (S) [label=above:Bolt S] {
    \begin{tikzpicture}
      \node [main,bolt] (ai) at (0.0, 1.5) {};
      \node [main,bolt] (aii) at (0.0, 0.0) {};
    \end{tikzpicture}
  };
  % Bolt T
  \node[main,rounded corners=10pt,right=of S] (T) [label=above:Bolt T] {
    \begin{tikzpicture}
      \node [main,bolt] (bi) at (0.0, 3.0) {};
      \node [main,bolt] (bii) at (0.0, 1.5) {};
      \node [main,bolt] (biii) at (0.0, 0.0) {};
    \end{tikzpicture}
  };
  % Connect
  \draw (S) edge [connect] (T);
\end{tikzpicture}
\caption{Cap 2}
  \endminipage
  \end{figure}

现在看起来是这样的:

在此处输入图片描述

干杯!再次感谢 Sigur!

答案2

使用

\begin{minipage}[b]{.5\textwidth}
fooooo
\end{minipage}
\begin{minipage}[b]{.5\textwidth}
foooooooo
\end{minipage}

相关内容