我想在表格行后逐行添加额外的垂直空间。考虑以下 MWE:
\documentclass{article}
\begin{document}
\begin{tabular}{p{3cm}p{5cm}}
Here... & ... it works. \\[2ex]
And... & ... here \newline it does too! \\[2ex]
But\newline here... & ... it does not. \\[2ex]
Some more text. & Even more text.
\end{tabular}
\end{document}
在前两行中,一切都很好。然而,在第三行中,多行左列吞噬了额外的空间。我希望这一行看起来就像\vspace{2ex}
在后面添加了一行一样here...
。
我认为可选参数\\
会在整行之后添加垂直空间,而不仅仅是在最后一个单元格之后。如何在不知道哪一列最高的情况下在行下方添加空间,并且不影响其他行?
答案1
使用以下解决方案booktabs
:
% arara: pdflatex
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{p{3cm}p{5cm}}
Here... & ... it works. \\\addlinespace[2ex]
And... & ... here \newline it does too! \\\addlinespace[2ex]
But\newline here... & ... it does not. \\\addlinespace[2ex]
Some more text. & Even more text.
\end{tabular}
\end{document}
答案2
使用\noalign{\vspace{2ex}}
\documentclass{article}
\begin{document}
\begin{tabular}{p{3cm}p{5cm}}
Here... & ... it works. \\[2ex]
And... & ... here \newline it does too! \\[2ex]
But\newline here... & ... it does not. \\\noalign{\vspace{2ex}}
Some more text. & Even more text.
\end{tabular}
\end{document}
答案3
您可以使用arraystretch
命令来更改行间距。对于您的情况:
\documentclass{article}
\begin{document}
\renewcommand\arraystretch{2}
\begin{tabular}{p{3cm}p{5cm}}
Here... & ... it works. \\
And... & ... here \newline it does too! \\
But\newline here... & ... it does not. \\
Some more text. & Even more text.
\end{tabular}
\end{document}
这将产生以下内容(booktabs
添加@LaRiFaRi 解决方案以供参考):