将两个 parbox 与表格顶部对齐

将两个 parbox 与表格顶部对齐

我正在寻找一个两列解决方案:左列包含一个表,右列包含几个表。我考虑使用parboxes 如下:

\parbox[t]{2cm}{\vspace{0pt}
\begin{tabular}{ccc}
x & x & x\\
x & x & x\\
x & x & x\\
x & x & x\\
x & x & x
\end{tabular}}
\hfill 
\parbox[t]{2cm}{\vspace{0pt}
\begin{tabular}{ccc}
x & x & x\\
x & x & x
\end{tabular}\\[1em]
\begin{tabular}{ccc}
x & x & x 
\end{tabular}}

但这会在两列之前的内容之间产生令人讨厌的空格。如果没有\vspace{0pt},两列中的前两个表格就不会顶部对齐。我正在寻找一个顶部对齐的解决方案,而两列之前没有多余的空格。

答案1

抑制\vspace{0pt}命令并使用可选参数来控制 s 的位置tabular

\documentclass{article}

\begin{document}

text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\noindent\parbox[t]{2cm}{%
  \begin{tabular}[t]{ccc}
    x & x & x\\
    x & x & x\\
    x & x & x\\
    x & x & x\\
    x & x & x
  \end{tabular}
}\hfill
\parbox[t]{2cm}{%
  \begin{tabular}[t]{ccc}
    x & x & x\\
    x & x & x
  \end{tabular}\\[1em]
  \begin{tabular}{ccc}
    x & x & x 
  \end{tabular}
}

\end{document}

在此处输入图片描述

相关内容