因此,我创建了一些表格,并尝试使用数组包来垂直对齐某些列中的文本。不幸的是,无论我使用还是p{xcm}
,列始终与单元格顶部对齐。m{xcm}
d{xcm}
我的代码是这样的
\begin{center}
\begin{tabularx}{\textwidth}{|m{4cm} X|}
\hline
Text that should center align & Lorem ipsum dolor sit amet,
eros elitr dolore sea et, vel ut enim vocent eligendi, quem maluisset urbanitas in
mei. Cu mea stet vivendum. Vis agam salutatus laboramus no.
Usu natum laboramus ullamcorper an.
Lorem ipsum dolor sit amet, eros elitr dolore sea et, vel
ut enim vocent eligendi, quem maluisset urbanitas in mei.
Cu mea stet vivendum. Vis agam salutatus laboramus no. Usu natum
laboramus ullamcorper an. \bigstrut \tabularnewline
\hline
\end{tabularx}
\end{center}
正如您所看到的,每行的大小(在我的示例中只有一行以节省空间)会膨胀以增加行的高度,并且我希望左侧列垂直居中对齐,但如果没有功能齐全的数组包,这就不会发生。
答案1
您必须重新定义\tabularxcolumn
以使用m
位置;这可以在环境中本地完成center
,因此它只会影响tabularx
同一环境。
\documentclass{article}
\usepackage{array,tabularx}
\begin{document}
\begin{center}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\begin{tabularx}{\textwidth}{|m{4cm} X|}
\hline
Text that should center align & Lorem ipsum dolor sit amet,
eros elitr dolore sea et, vel ut enim vocent eligendi, quem maluisset urbanitas in
mei. Cu mea stet vivendum. Vis agam salutatus laboramus no.
Usu natum laboramus ullamcorper an.
Lorem ipsum dolor sit amet, eros elitr dolore sea et, vel
ut enim vocent eligendi, quem maluisset urbanitas in mei.
Cu mea stet vivendum. Vis agam salutatus laboramus no. Usu natum
laboramus ullamcorper an. \\
\hline
\end{tabularx}
\end{center}
\end{document}