如何在tabularnewline之后更改内容的垂直位置?

时间:2021-12-23 23:16:59

I have some trouble with tables in LaTeX. My table has 4 columns. The are too broad to fit the \textwidth, so I searched for a line break and found \tabularnewline. Now the content in the first column breaks into 2 lines but the content in the other 3 columns is now at the bottom of the cell. I would like to center it in the column, or at least it should be at the ceiling. How can I do that?

我在LaTeX中遇到了一些问题。我的桌子有4列。它太宽而不适合\ textwidth,所以我搜索换行符并找到\ tabularnewline。现在,第一列中的内容分为2行,但其他3列中的内容现在位于单元格的底部。我想把它放在列中,或者至少它应该在天花板上。我怎样才能做到这一点?

I tried tabular, tabular* and tabularx. I would like to write as little commands as possible. Is there maybe a way to do it similarly easily as in HTML?

我尝试了表格,表格*和tabularx。我想写尽可能少的命令。是否有一种方法可以像在HTML中一样轻松地完成它?

3 个解决方案

#1


\usepackage{array} in your preamble

你的序言中有\ usepackage {array}

then you can use \begin{tabular}{c c m} -- the 'm' will give you vertical middle alignment. also: 't' will give you top alignment, and 'b' will give you bottom.

然后你可以使用\ begin {tabular} {c c m} - 'm'将给你垂直中间对齐。另外:'t'会给你顶部对齐,'b'会给你底部。

#2


Not as easy as I hoped it would be but \multirow does exactly what I wanted.

并不像我希望的那样容易,但是\ multirow完全符合我的要求。

#3


Did you try using the paragraph format specifier for one or more of the columns?

您是否尝试将段落格式说明符用于一个或多个列?

That is p{<length>} as in:

那是p { },如:

\begin{tabular}{|rrp{4.5cm}l|}
  ...

Multirow seems like overkill for most of the use cases I am envisioning.

对于我想象的大多数用例来说,Multirow似乎有点矫枉过正。

NB: The "length" can be computed from other values as is 0.4\textwidth, but is always a constant. Don't know off hand how rubber reacts in this case.

注意:“长度”可以从其他值计算,如0.4 \ textwidth,但始终是常量。在这种情况下,不知道橡胶如何反应。

#1


\usepackage{array} in your preamble

你的序言中有\ usepackage {array}

then you can use \begin{tabular}{c c m} -- the 'm' will give you vertical middle alignment. also: 't' will give you top alignment, and 'b' will give you bottom.

然后你可以使用\ begin {tabular} {c c m} - 'm'将给你垂直中间对齐。另外:'t'会给你顶部对齐,'b'会给你底部。

#2


Not as easy as I hoped it would be but \multirow does exactly what I wanted.

并不像我希望的那样容易,但是\ multirow完全符合我的要求。

#3


Did you try using the paragraph format specifier for one or more of the columns?

您是否尝试将段落格式说明符用于一个或多个列?

That is p{<length>} as in:

那是p { },如:

\begin{tabular}{|rrp{4.5cm}l|}
  ...

Multirow seems like overkill for most of the use cases I am envisioning.

对于我想象的大多数用例来说,Multirow似乎有点矫枉过正。

NB: The "length" can be computed from other values as is 0.4\textwidth, but is always a constant. Don't know off hand how rubber reacts in this case.

注意:“长度”可以从其他值计算,如0.4 \ textwidth,但始终是常量。在这种情况下,不知道橡胶如何反应。