Consider the following piece of LaTeX code:
\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 the left? Note that I want to make sure that the widths of my columns are fixed, so I cannot use the "c" position attribute instead of "p{.1in}" to center my cell contents.
If you want to horizontally center all contents inside of a p type column, it is easier to use >{\centering\arraybackslash}p{5cm} instead of adding \centering to every single cell.
When you're using \begin{center} and end{center} the whole environment will be centered. The c in the tabular environment specify that the content inside a cell should be centered.
Select your table. On the Layout tab, in the Cell Size group, click AutoFit. Click Fixed Column Width.
\usepackage{array}
in the preamble
then this:
\begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}
note that the "m" for fixed with column is provided by the array package, and will give you vertical centering (if you don't want this just go back to "p"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With