5

I already checked this post in this site: Vertical centering of text within a table

What I am asking is quite similar to that question:

  1. I want all the cells to be vertically centered. This can be achieved by using the array package and the m{20em} descriptor.

  2. I want to add extra space to the rows; namely, I want the heights of the rows to be larger than default. This can be done by using

    \renewcommand{\arraystretch}{3}
    

    or

    \setlength{\extrarowheight}{3em}
    

Each of the above two requirements can be easily satisfied separately. However, if I want both effects, problems occur. The cells are not vertically centered, and the table looks really awkward as a whole!

To see the problem, the \extrarowheight needs to be set to a large value, 3em for example.

Any suggestions are welcome!

Here is an example:

\documentclass{article}
\usepackage{array}

\begin{document}

\setlength{\extrarowheight}{3em} 

%without the above command, the table looks fine.

\begin{center}

\begin{tabular}{r m{6em}}

\hline

Item 0 & bla bla \\
\\    
Item 1 & Long description of item 1 blaaaaaa blaaaaaaa blaaaaaaaa blaaaaaaaa blaaaaa blaaa blaaaaaaaaaa \\
\\
Item 2 & blaaaaaaaaaaaa blaaaaaaa blaaaaaaaaaa \\
\\    
\hline

\end{tabular}

\end{center}

\end{document}
David Carlisle
  • 757,742

1 Answers1

3
\documentclass{article}
\usepackage{calc,array}
\newcommand{\cellstart}{\rule{0pt}{\heightof{A}+2ex}}
\newcommand{\cellfinish}{\rule[-2ex]{0pt}{2ex}}

\begin{document}


\begin{center}

\begin{tabular}{r >{\cellstart}m{6em}<{\cellfinish}}
\hline
Item 0 & bla bla \\
\hline
Item 1 & Long description of item 1 blaaaaaa blaaaaaaa blaaaaaaaa blaaaaaaaa blaaaaa blaaa
blaaaaaaaaaa \\
\hline
Item 2 & blaaaaaaaaaaaa blaaaaaaa blaaaaaaaaaa \\
\hline
\end{tabular}

\end{center}

\end{document}

Change the 2ex into what suits you.

However, I find that, in general, such a vertical centering doesn't help the readability of a table, particularly if an entry in the second column is very long.

Moriambar
  • 11,466
egreg
  • 1,121,712
  • Wow! That's great! It works! Thank you very much! Also thanks to @Thorsten (and maybe other guys) for editing my post!

    By the way, the thing I am editing is not really a table; it is actually the cover page of a document; I just want to use the tabular environment to make sure things are well-aligned.

    – user789977 Nov 29 '11 at 09:03