Graphics, Figures & TablesSimple vertical and horizontal centering of cell text

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
choward
Posts: 6
Joined: Sat Sep 05, 2009 10:18 pm

Simple vertical and horizontal centering of cell text

Post by choward »

Hi. I'm a total LaTeX n00b. How do I adjust my table code so that text in the second column is centered both vertically and horizontally? I know this question has been asked before, but it seems like in all the previous posts I've found that the asker is trying to accomplish something much more complex (e.g., mix images and formulae and what not...)

One post I found helped me to get this far:

Code: Select all

\begin{center}

\begin{tabular}{| p{5cm} | >{\centering\arraybackslash}m{3cm} |}
\hline
Purchasing and Shipping Time & 1 month \\ \hline
Learning the NXT Interface\newline
and writing robot-side code & 1-2 months \\ \hline
Writing server-side code to\newline
integrate the new equipment\newline
into our web interface & 2-3 months \\ \hline
\end{tabular}

\end{center}
That is with "\usepackage{array}" at the beginning. But the text of the second column is only centered horizontally, not vertically. I'm not sure how to tweak this because I don't really understand what all the ">{\centering\arraybackslash}m{3cm}" nonsense is all about. (Any illustrative explanations would be well received!)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Simple vertical and horizontal centering of cell text

Post by gmedina »

Hi,

change p{5cm} to m{5cm} in the table format. The documentation of the array package explains the meaning of the commands used; in particular, the >{declaration} construct inserts declaration directly in front of the entry of the column.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply