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 created a post earlier on the same topic (Vertical alignment in tables). I got an answer but it triggered another question.

Below the solution that has been provided. I would expect vertical centering but the text goes on top of each cell. Playing with p, m, and b to align vertically doesn't seem to work here. I have probably missed something...

\documentclass{article}
\usepackage[english]{babel}
\usepackage{array}

\begin{document}

\begin{tabular}{ |m{2cm}|m{2cm}|m{2cm}|@{}l@{}}
   \hline
     x &
     x &
     x &\\[5mm]
   \hline
\end{tabular}

\end{document}
share|improve this question

1 Answer 1

up vote 2 down vote accepted

enter image description here

As seen in the second row, the m column type is giving vertical centering of the cells, however the extra space from \\[..] is added afterwards so if your entries are only one line b and p are the same thing (and m isn't very different). As I noted in a comment on the previous answer, because m cells typically have large depth, you typically need to use a large value in the optional argument of \\[] before increasing the depth of the strut makes any difference. Or better try to avoid using the optional argument of \\ in tables.

share|improve this answer
    
Thanks for the explanations. So \\[..] is added afterwards and therefore m doesn't take the full height into account. Is that correct ? Is there another way to specify the height that would be considered by the m ? –  ed82 Jan 21 '13 at 17:10
    
If you don't use \\[] and do use \arraystretch the strut is enlarged for all rows and in p/m/t columns the first column gets a strut with the height and the last row gets a strut with the depth, but often simpler is just in any cell of the row use \vspace*{2cm} before and/or after the main text of the entry, that has a more direct effect and the space probably increases in a way that is more predictable –  David Carlisle Jan 21 '13 at 17:14

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.