Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a table defined as:

\begin{table}
    \begin{center}
        \setlength{\extrarowheight}{3.0pt}
        \begin{tabular}{ | c | p{12.5cm} |}
            \hline
            \textbf{Item 1} & Long description of item 1 \\
            \hline
            % ... (etc)
        \end{tabular}
    \end{center}
\end{table}

I want the text in the first column to be both vertically and horizontally aligned. Given the code above, the text is only horizontally aligned. I have tried fixing this by changing the column alignment/width specifier from 'c' to 'm{2.5cm}', but to no avail.

How do I make the column centered both horizontally and vertically?

share|improve this question
    
With this setting, the "Item 1" will be aligned to the first line in column 2; if you want it to be vertically centered with respect to the second column, use m{12.5cm} for the second column specifier. –  egreg Jun 7 '11 at 9:01
    
and don't forget to load package array ... –  Herbert Jun 7 '11 at 9:26
    
@egreg Thanks, your suggestion got it working. –  Josh Jun 7 '11 at 9:48
    
@Herbert: Josh is already using \extrarowheight, but I'll add it in my answer. –  egreg Jun 7 '11 at 10:05
    
it's been said many times before ... rather than use the center environment, it's better to use \centering within a float. –  barbara beeton Jun 7 '11 at 12:05

1 Answer 1

Write

\begin{tabular}{|c|m{12.5cm}}

This requires loading the array package (that you're already loading, but other users might not know it).

Some comments
Each table has its particular features and it's quite difficult to state "universal rules". In general, however, vertical rules should be avoided as they make the table more difficult to read horizontally.

A generous amount of space between rows can visually separate them in a more pleasant way than with a rule.

Whether centering vertically the description in the first column depends on the table, but I feel it can be distracting.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.