问:
为什么tabu
如果段落的第二行太高,是否在单元格内容的第一行之前添加额外的垂直空间?
下面的 MWE 包含三个用例:
输出:
评论
每个单元格中的每个段落都应顶部对齐,即文本的第一行和公式的第一行应排版在同一基线上。第一个变体(使用tabular
)看起来不错。第三个变体(使用tabu
和空的方括号)看起来也不错。但第二个排版在第一行之前有额外的垂直空间。
梅威瑟:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tabu}
\pagestyle{empty}
\begin{document}
\begin{table}[ht]
\caption{\texttt{tabular} approach}
\begin{tabular}{p{0.3\linewidth} p{0.3\linewidth} p{0.3\linewidth}}
\hline
\raggedright\arraybackslash
Left column. A few lines of text
& \raggedright\arraybackslash
$ a = b \times$
\newline
$ \times
\max
\left\lbrace
\begin{array}{c}
\\[-2ex]
\left[
\cfrac{c^{-1}_\text{D} - e}{\tilde{f}^{2}_{0}}
\right]
\\\\[-2ex]
\left[
\cfrac{\hat{g}^{3}_\text{H} + 2}{k^{}_\text{L}}
\right]
\\\\[-2ex]
\end{array}
\right\rbrace$
& \raggedright\arraybackslash
Right column. A few lines of text
\\
\hline
\end{tabular}
\end{table}
\begin{table}[ht]
\caption{\texttt{tabu} approach}
\begin{tabu} to \linewidth {X[1,l] X[1,l] X[1,l]}
\hline
Left column. A few lines of text
& $ a = b \times$
\newline
$ \times
\max
\left\lbrace
\begin{array}{c}
\\[-2ex]
\left[
\cfrac{c^{-1}_\text{D} - e}{\tilde{f}^{2}_{0}}
\right]
\\\\[-2ex]
\left[
\cfrac{\hat{g}^{3}_\text{H} + 2}{k^{}_\text{L}}
\right]
\\\\[-2ex]
\end{array}
\right\rbrace$
& Right column. A few lines of text
\\
\hline
One more line
& $ a = b \times$
\newline
$ \times
\max
\left\lbrace
\begin{array}{c}
\\[-2ex]
\left[
\,
\right]
\\\\[-2ex]
\left[
\,
\right]
\\\\[-2ex]
\end{array}
\right\rbrace$
& This is correct
\\
\hline
\end{tabu}
\end{table}
\end{document}