开发者

Is it possible to vertically center multiple columns in a table?

开发者 https://www.devze.com 2023-01-15 00:07 出处:网络
I\'ve found an exam开发者_开发技巧ple here but that only centers one column and I can\'t really adapt it to my needs. What I\'d like is something like this:

I've found an exam开发者_开发技巧ple here but that only centers one column and I can't really adapt it to my needs. What I'd like is something like this:

Is it possible to vertically center multiple columns in a table?


You'll need \usepackage{array} to do this.

From what I can gather, you're looking at the m{} alignment, which wraps a paragraph at the specified point value, and vertically aligns the text to the middle of the field. For example, something like this:

\begin{tabular}{|m{2cm}|m{1ex}|m{1ex}|m{1ex}} \hline
           & x1 & x2 & x3 \\\hline
Long Label & 1  & 0  & 1  \\\hline
Long Label & 0  & 1  & 1  \\\hline
\end{tabular}


Try this:

\begin{tabular}{|m{3.5em}|b{1em}|b{1em}|b{1em}|}
\hline
%% row 1

&x1
&x2
&x3
\\\hline
%% row 2
Long Label
&1
&0
&1
\\\hline
%% row 3
Long Label
&1
&0
&1
\\\hline
\end{tabular}

For more info on table formatting see http://en.wikibooks.org/wiki/LaTeX/Tables

EDIT: changed c to b{}

0

精彩评论

暂无评论...
验证码 换一张
取 消