4

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?

David Carlisle
  • 757,742
Josh
  • 113
  • 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 07 '11 at 09:01
  • and don't forget to load package array ... –  Jun 07 '11 at 09:26
  • @egreg Thanks, your suggestion got it working. – Josh Jun 07 '11 at 09:48
  • @Herbert: Josh is already using \extrarowheight, but I'll add it in my answer. – egreg Jun 07 '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 07 '11 at 12:05

1 Answers1

6

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.

egreg
  • 1,121,712