如何将具有不同长度的子标题的图像对齐?

如何将具有不同长度的子标题的图像对齐?

我有三张水平对齐的 tikz 图片,但它们的标题长度不同,这导致标题较长的图像上升而不是与其他图像对齐,如下所示(图像 c 未与其他图像对齐):

在此处输入图片描述

该图像的源代码是:

\begin{figure}
    \begin{subfigure}[b]{0.32\textwidth}
        \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \node[black, fit={(0.5,0.5) (3.2,1.2)}, inner sep=0pt, draw] (a) {\small Error detection};
                \node[black, fit={(0.5,1.2) (3.2,1.9)}, inner sep=0pt, draw] (b) {\small Error correction};

                \draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
                (0.5,0.5) -- (0.5,1.9) node [black,midway,xshift=-0.6cm] {\small SW};
            \end{tikzpicture}
        }
        \caption{Software-only fault tolerance architecture.}
        \label{fig:swonly}
    \end{subfigure}
    \begin{subfigure}[b]{0.32\textwidth}
    \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \node[black, fit={(0.5,0.5) (3.2,1.2)}, inner sep=0pt, draw] (a) {\small Error detection};
                \node[black, fit={(0.5,1.2) (3.2,1.9)}, inner sep=0pt, draw] (b) {\small Error correction};

                \draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
                (0.5,0.5) -- (0.5,1.9) node [black,midway,xshift=-0.6cm] {\small HW};
            \end{tikzpicture}
        }
        \caption{Hardware-only fault tolerance architecture.}   
        \label{fig:hwonly}
    \end{subfigure}
    \begin{subfigure}[b]{0.32\textwidth}
        \centering
        \resizebox{\linewidth}{!}{
            \begin{tikzpicture}
                \node[black, fit={(0.5,0.5) (3.2,1.2)}, inner sep=0pt, draw] (a) {\small Error detection};
                \node[black, fit={(0.5,1.2) (3.2,1.9)}, inner sep=0pt, draw] (b) {\small Error correction};

                \draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
                (0.5,0.5) -- (0.5,1.2) node [black,midway,xshift=-0.6cm] {\small HW};
                \draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
                (0.5,1.2) -- (0.5,1.9) node [black,midway,xshift=-0.6cm] {\small SW};
            \end{tikzpicture}
        }
        \caption{Hardware/Software cross-layer fault tolerance architecture.}
        \label{fig:hwsw}
    \end{subfigure}
\caption{Fault tolerance architecture approaches.} 
\label{fig:architectures}
\end{figure}

我想让所有图片对齐,但我不知道该怎么做。此外,我希望节点内的文本垂直居中。如果你能帮忙,我将不胜感激。

答案1

在此处输入图片描述

\begin{figure}
\begin{subfigure}[t]{0.3\textwidth}
\begin{tikzpicture}
\node[black, fit={(0.5,0.5) (3.2,1.2)}, inner sep=0pt, draw] (a) {\small Error detection};
\node[black, fit={(0.5,1.2) (3.2,1.9)}, inner sep=0pt, draw] (b) {\small Error correction};
\draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
(0.5,0.5) -- (0.5,1.9) node [black,midway,xshift=-0.6cm] {\small SW};
\end{tikzpicture}
\caption{Software-only fault tolerance architecture.}
\label{fig:swonly}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\node[black, fit={(0.5,0.5) (3.2,1.2)}, inner sep=0pt, draw] (a) {\small Error detection};
\node[black, fit={(0.5,1.2) (3.2,1.9)}, inner sep=0pt, draw] (b) {\small Error correction};

\draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
(0.5,0.5) -- (0.5,1.9) node [black,midway,xshift=-0.6cm] {\small HW};
\end{tikzpicture}
\caption{Hardware-only fault tolerance architecture.}
\label{fig:hwonly}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\node[black, fit={(0.5,0.5) (3.2,1.2)}, inner sep=0pt, draw] (a) {\small Error detection};
\node[black, fit={(0.5,1.2) (3.2,1.9)}, inner sep=0pt, draw] (b) {\small Error correction};

\draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
(0.5,0.5) -- (0.5,1.2) node [black,midway,xshift=-0.6cm] {\small HW};
\draw [decorate,decoration={brace,amplitude=0.8mm},xshift=-4pt,yshift=0pt]
(0.5,1.2) -- (0.5,1.9) node [black,midway,xshift=-0.6cm] {\small SW};
\end{tikzpicture}
\caption{Hardware/Software cross-layer fault tolerance architecture.}
\label{fig:hwsw}
\end{subfigure}
\caption{Fault tolerance architecture approaches.}
\label{fig:architectures}
\end{figure}

附录:

离题的绘画练习tikzpicture:-)

\documentclass{article}
\usepackage{geometry}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,
                calligraphy,
                fit,
                shapes.multipart}

\begin{document}
\begin{figure}[htb]
\tikzset{
every node/.append style={font=\small},
box/.style = {rectangle split, rectangle split parts=2,
              draw, %text width=26mm, 
              inner sep=3mm, outer ysep=0},
 BC/.style = {decorate,
              decoration={calligraphic brace, amplitude=4pt,
              pre =moveto, pre  length=1pt,
              post=moveto, post length=1pt,
              raise=1mm},
              thick,
              pen colour={black}},
        }

\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\node (a) [box] {\nodepart{one} Error detection
                 \nodepart{two}  Error correction};
\draw [BC] (a.south west) -- node[left=2mm] {SW} (a.north west);
\end{tikzpicture}
\caption{Software-only fault tolerance architecture.}
\label{fig:swonly}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\node (a) [box] {\nodepart{one} Error correction
                 \nodepart{two}  Error detection};
\draw [BC] (a.south west) -- node[left=2mm] {HW} (a.north west);
\end{tikzpicture}
\caption{Hardware-only fault tolerance architecture.}
\label{fig:hwonly}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.3\textwidth}
\centering
\begin{tikzpicture}
\node (a) [box] {\nodepart{one} Error correction
                 \nodepart{two}  Error detection};
\draw [BC] (a.south west) -- node[left=2mm] {HW} (a.one split west);
\draw [BC] (a.one split west) -- node[left=2mm] {SW} (a.north west);
\end{tikzpicture}
\caption{Hardware/Software cross-layer fault tolerance architecture.}
\label{fig:hwsw}
\end{subfigure}
\caption{Fault tolerance architecture approaches.}
\label{fig:architectures}
\end{figure}
\end{document}

在此处输入图片描述

注意:这两种解决方案都不适用于llncs,因为这个文档类不适用于captionsubcaption包。所以我想知道,您是否真的使用这个文档类的 id 来生成显示图像。

答案2

另一个选择是\subcaptionbox。我也稍微修改了你制作图表的方式。

代码输出

\documentclass{article}    
\usepackage{tikz}
\usepackage{subcaption}
\usetikzlibrary{fit,decorations.pathreplacing}
\begin{document}
\begin{figure}
\tikzset{
  box/.style={black,draw,font=\small,minimum height=7mm,minimum width=2.6cm, outer ysep=0},
  my brace/.style={decorate,decoration={brace,amplitude=0.8mm,mirror,raise=2pt}}
}
\subcaptionbox{%
  Software-only fault tolerance architecture. \label{fig:swonly}
}[0.32\linewidth]{%
            \begin{tikzpicture}
                \node[box] (a) {Error detection};
                \node[box,anchor=north west,at={(a.south west)}] (b) {Error correction};

                \draw [my brace]
                (a.north west) -- (b.south west) node [midway,xshift=-0.6cm] {\small SW};
            \end{tikzpicture}%
}
\hfill
\subcaptionbox{%
  Hardware-only fault tolerance architecture.\label{fig:hwonly}
}[0.32\linewidth]{%
            \begin{tikzpicture}
                \node[box] (a) {Error correction};
                \node[box,anchor=north west,at={(a.south west)}] (b) {Error detection};

                \draw [my brace]
                (a.north west) -- (b.south west) node [midway,xshift=-0.6cm] {\small HW};
            \end{tikzpicture}%
}
\hfill
\subcaptionbox{
Hardware/Software cross-layer fault tolerance architecture.\label{fig:hwsw}
}[0.32\linewidth]{%
           \begin{tikzpicture}
                \node[box] (a) {Error correction};
                \node[box,anchor=north west,at={(a.south west)}] (b) {Error detection};

                \draw [my brace]
                (a.north west) -- (a.south west) node [midway,xshift=-0.6cm] {\small SW};
                \draw [decorate,decoration={brace,amplitude=0.8mm,mirror,raise=1pt}]
                (b.north west) -- (b.south west) node [midway,xshift=-0.6cm] {\small HW};
            \end{tikzpicture}%
}


\caption{Fault tolerance architecture approaches.} 
\label{fig:architectures}
\end{figure}
\end{document}

相关内容