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 learned tabu for a while and I can not solve a problem about vertical alignment with X[m]. Here is the minimal working example below.

\documentclass{article}
\usepackage[linegoal]{tabu}\tracingtabu=2

\begin{document}

  \begin{tabu} to\linewidth{|X[-2.5,c,m]|X[c]|X[c]|} \tabucline-
    This is a counterexample. This is a counterexample. This is a counterexample.
    This is a counterexample. This is a counterexample. This is a counterexample.
    & \texttt X & xyz \\ \tabucline-
  \end{tabu}

\end{document}

I want to put the contents of the second and third column in vertical center, but if I set m in the second and third column at the preamble of tabu, i.e.,

\begin{tabu} to\linewidth{|X[-2.5,c]|X[c,m]|X[c,m]|}

the result is strange because the contents in the second and third column is not vertical center.

But if I set m in the first column, i.e.,

\begin{tabu} to\linewidth{|X[-2.5,c,m]|X[c]|X[c]|}

then the result that I want comes.

I want to know why and how to solve it.

share|improve this question

1 Answer 1

up vote 5 down vote accepted

m means the baseline for relative alignment is in the middle. It doesn't mean the cell content is in the middle. In table cells, t, b and m are similar to the alignment parameter t, b or default (middle) of \parbox.

So, with |X[-2.5,c]|X[c,m]|X[c,m]| you get vertically top,middle,middle aligned cells, relative to each other, not to the cell. Would the content in column 2 and 3 be in the middle of the cell, the first cell content's top would have to be in the middle, for alignment - causing much white space above.

In contrast, |X[-2.5,m]|X[c,m]|X[c,m]| gives you the middle alignment because all cells in the row have it.

\begin{tabu} to\linewidth{|X[-2.5,c,m]|X[c,m]|X[c,m]|}
  \tabucline-
    This is a counterexample. This is a counterexample.
    This is a counterexample.
    This is a counterexample. This is a counterexample.
    This is a counterexample.
  & \texttt X & xyz \\ \tabucline-
\end{tabu}

enter image description here

share|improve this answer
    
Thanks for your reply! –  XIAO Lishun Aug 22 '11 at 2:55

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.