6

I want vertically centered text in a simple table like this:

\documentclass{article}
\usepackage{array}
\newcolumntype{Z}{>{\centering\arraybackslash}m{0.2cm}}

\begin{document}
\begin{tabular}{|Z|Z|Z|Z|}
\hline
 4 & 3 & 2 & 1 \\
\hline
\end{tabular}

\end{document}

but the text is not vertically centered, it almost touches the upper hline. What should I do to fix this?

6

The paragraph box containing the cells is vertically centred (using \vcenter) But that isn't the same thing as centring the digits in the actual content, note that a line box is the same height whether the content is ( or 1 or .

You can add

\setlength\extrarowheight{2pt}

before the table to get a better appearance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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