不同水平长度的子图的垂直对齐

不同水平长度的子图的垂直对齐

我通过subcaption包和\subfigure环境将四张不同的 tikzpicture 合并为一张图。但是,这些图的水平长度不同,因此我无法获得正确的垂直对齐。 图片

与此相反,我想让每个框的中心与其他框的中心以及子标题垂直对齐,即(a),(b)...

如果必须重新缩放某些内容(以适应线宽),我不会介意,但请注意,每个子图都应进行相应的重新缩放,以使所有框都具有相同的大小。

这是我的代码:

\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage{subcaption}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
  \begin{subfigure}{\linewidth}
    \centering
    \begin{tikzpicture}[>=latex]
      \node (a) [] {$c_k\delta_{\Delta}(t-k\Delta)+c_j\delta_{\Delta}(t-j\Delta)$};
      \node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) [right=of a] {\texttt{SISO-L}};
      \node (c) [right=of b] {$c_kh_{k\Delta}(t)+c_jh_{j\Delta}(t)$};
      \path [->,thick] (a) edge (b)
                     (b) edge (c);
    \end{tikzpicture}
  \caption{}
\label{fig:}
\end{subfigure}\\[.5cm]
\begin{subfigure}{\linewidth}
  \centering
  \begin{tikzpicture}[>=latex]
    \node (a) [] {$\displaystyle \sum_{k=-\infty}^{\infty}u(k\Delta)\delta_{\Delta}(t-k\Delta)\Delta$};
    \node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) [right=of a] {\texttt{SISO-L}};
    \node (c) [right=of b] {$\displaystyle \sum_{k=-\infty}^{\infty}u(k\Delta)h_{k\Delta}(t)$};
    \path [->,thick] (a) edge (b)
                     (b) edge (c);
  \end{tikzpicture}
\caption{}
\label{fig:}
\end{subfigure}\\[.5cm]
\begin{subfigure}{\linewidth}
  \centering
  \begin{tikzpicture}[>=latex]
      \node (a) [] {$\delta(t-\tau)$};
    \node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) [right=of a] {\texttt{SISO-L}};
    \node (c) [right=of b] {$h_{\tau}(t)$};
    \path [->,thick] (a) edge (b)
                     (b) edge (c);
  \end{tikzpicture}
\caption{}
\label{fig:}
\end{subfigure}\\[.5cm]
\begin{subfigure}{\linewidth}
\centering
  \begin{tikzpicture}[>=latex]
    \node (a) [] {$\displaystyle u(t)=\int_{-\infty}^{\infty}u(\tau)\delta(t-\tau)\,\mathrm{d}\tau$};
    \node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) [right=of a] {\texttt{SISO-L}};
    \node (c) [right=of b] {$\displaystyle y(t)=\int_{-\infty}^{\infty}u(\tau)h_{\tau}(t)\,\mathrm{d}\tau$};
    \path [->,thick] (a) edge (b)
                     (b) edge (c);
  \end{tikzpicture}
\caption{}
\label{fig:}
\end{subfigure}
\caption{}
\label{fig:}
\end{figure}
\end{document}

提前致谢。

答案1

另一种解决方案(基于OP代码):\linewidth只有当足够大以使图形不会产生过满时,这种方法才有效。

我所做的是确保所有链在中心节点的左侧和右侧具有相同的宽度。

所以我插入了(四位数字)一些假节点(删除draw后面的)宽度恒定。

\node[minimum width=5cm,draw] (lfake) [left= of b]{};
\node[minimum width=5cm,draw] (rfake) [right=of b]{};

在此处输入图片描述

\begin{tikzpicture}[>=latex]
\node (a)  {$c_k\delta_{\Delta}(t-k\Delta)+c_j\delta_{\Delta}(t-j\Delta)$};
\node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) [right=of a] {\texttt{SISO-L}};
\node (c) [right=of b] {$c_kh_{k\Delta}(t)+c_jh_{j\Delta}(t)$};
\node[minimum width=5cm,draw] (lfake) [left=of b]{};
\node[minimum width=5cm,draw] (rfake) [right=of b]{};
\path [->,thick] (a) edge (b) (b) edge (c);
\end{tikzpicture}

答案2

您必须发现如何调整框和标题(两者都是节点)之间的垂直距离(例如,节点(a)及其标题节点(acap))。

\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{graphicx}
\usepackage{lipsum} %% dummy text
\begin{document}

\lipsum*[2]
\begin{figure}[h]
\begin{tikzpicture}[>=latex]
 \node[draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (a)  {\texttt{SISO-L}};
 \node (al) [left=of a] {$c_k\delta_{\Delta}(t-k\Delta)+c_j\delta_{\Delta}(t-j\Delta)$};
 \node (ar) [right=of a] {$c_kh_{k\Delta}(t)+c_jh_{j\Delta}(t)$};
 \node (acap) [below=5pt of a] {(a)};
 \path [->,thick] (al) edge (a) (a) edge (ar);
%%
 \node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) [below=1em of acap] {\texttt{SISO-L}};
 \node (bl) [left=of b] {$\displaystyle \sum_{k=-\infty}^{\infty}u(k\Delta)\delta_{\Delta}(t-k\Delta)\Delta$};
 \node (br) [right=of b] {$\displaystyle \sum_{k=-\infty}^{\infty}u(k\Delta)h_{k\Delta}(t)$};
 \node (bcap) [below=5pt of b] {(b)};
 \path [->,thick] (bl) edge (b) (b) edge (br);
%%
 \node [draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (c)  [below=1em of bcap] {\texttt{SISO-L}};
 \node (cl) [left=of c] {$\delta(t-\tau)$};
 \node (cr) [right=of c] {$h_{\tau}(t)$};
 \node (ccap) [below=5pt of c] {(c)};
 \path [->,thick] (cl) edge (c) (c) edge (cr);
\end{tikzpicture}
\caption{caption title}\label{key}
\end{figure}

Figure~\ref{key}(a) shows that\ldots 
\end{document}

在此处输入图片描述

答案3

这个想法类似于 Sigur 在他的“另一种解决方案”中提出的想法。如果每个子图都占据整个文本行 ( \linewidth),并且这个空间被分成三个片段,其中左右片段的长度相等,那么中间片段将居中。然后所有子图都将垂直对齐显示它们的中心部分。

下一个代码使用包X中的列tabularx自动计算左右片段的宽度,而中央片段则保持其自然宽度。TiKZ仅用于中央列,而左右片段与\raggedright和对齐\raggedleft

无需手动计算任何宽度。

\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\usepackage{tabularx}
\newcolumntype{Y}{>{\raggedleft\arraybackslash}X}
\newcolumntype{Z}{>{\raggedright\arraybackslash}X}
\usepackage{lipsum}

\begin{document}

\begin{figure}
\setlength{\tabcolsep}{2pt}
\begin{subfigure}{\linewidth}
\begin{tabularx}{\linewidth}{YcZ}
$c_k\delta_{\Delta}(t-k\Delta)+c_j\delta_{\Delta}(t-j\Delta)$
&
\tikz[baseline=(b.base)]{ \draw[->,thick] (0,0)--++(0:.5cm) node [anchor=west,draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) {\texttt{SISO-L}}; \draw[->,thick] (b.east)--++(0:.5cm);}
&
$c_kh_{k\Delta}(t)+c_jh_{j\Delta}(t)$ \tabularnewline
\end{tabularx}
\caption{This is the caption for the first subfigure}
\end{subfigure}

\begin{subfigure}{\linewidth}
\begin{tabularx}{\linewidth}{YcZ}
$\displaystyle \sum_{k=-\infty}^{\infty}u(k\Delta)\delta_{\Delta}(t-k\Delta)\Delta$
&
\tikz[baseline=(b.base)]{ \draw[->,thick] (0,0)--++(0:.5cm) node [anchor=west,draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) {\texttt{SISO-L}}; \draw[->,thick] (b.east)--++(0:.5cm);}
&
$\displaystyle \sum_{k=-\infty}^{\infty}u(k\Delta)h_{k\Delta}(t)$ \tabularnewline
\end{tabularx}
\caption{This is the caption for the second subfigure}
\end{subfigure}

\begin{subfigure}{\linewidth}
\begin{tabularx}{\linewidth}{YcZ}
$\delta(t-\tau)$
&
\tikz[baseline=(b.base)]{ \draw[->,thick] (0,0)--++(0:.5cm) node [anchor=west,draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) {\texttt{SISO-L}}; \draw[->,thick] (b.east)--++(0:.5cm);}
&
$h_{\tau}(t)$ \tabularnewline
\end{tabularx}
\caption{This is the caption for the third subfigure}
\end{subfigure}

\begin{subfigure}{\linewidth}
\begin{tabularx}{\linewidth}{YcZ}
$\displaystyle u(t)=\int_{-\infty}^{\infty}u(\tau)\delta(t-\tau)\,\mathrm{d}\tau$
&
\tikz[baseline=(b.base)]{ \draw[->,thick] (0,0)--++(0:.5cm) node [anchor=west,draw,thick,rectangle,minimum width=2cm,minimum height=1cm] (b) {\texttt{SISO-L}}; \draw[->,thick] (b.east)--++(0:.5cm);}
&
$\displaystyle y(t)=\int_{-\infty}^{\infty}u(\tau)h_{\tau}(t)\,\mathrm{d}\tau$ \tabularnewline
\end{tabularx}
\caption{This is the caption for the fourth subfigure}
\end{subfigure}

\caption{This is the main caption}
\end{figure}

\lipsum
\end{document}

在此处输入图片描述

相关内容