How to focus the contents of a cell in a LaTeX table whose columns have a fixed width?

Consider the following code snippet LaTeX:

\begin{tabular}{p{1in}p{1in}} A & B\\ C & D\\ \end{tabular} 

How can I make the contents of each cell aligned in the center of the cell, rather than left? Note that I want to make sure the width of my columns is fixed, so I cannot use the position attribute "c" instead of "p {.1in}" to center the contents of my cell.

+55
alignment latex tabular
Aug 31 '09 at 14:41
source share
2 answers

\usepackage{array} in the preamble

that is:

 \begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |} 

note that the β€œm” for the fixed column is provided by the array package and will give you vertical centering (unless you want it to just go back to β€œp”

+78
Aug 31 '09 at 16:11
source share
β€” -

You can use \centering with your password for this.

More details here and here .

(Sorry for the Google cache link, the original I had doesn't work anymore.)

+7
Aug 31 '09 at 14:47
source share



All Articles