8

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.

1 Answer 1

11

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

2
  • 5
    This doesn't actually produce the image depicted and hence no longer works. Perhaps this is a solution for an older version of the tabu package? Jun 13, 2018 at 13:00
  • 2
    @RichardTorres Just for the record, v.2.10 of tabu (currently not yet on CTAN but here: github.com/tabu-fixed/tabu) seems to fix the tabu problem with m columns.
    – bonanza
    Jan 28, 2019 at 11:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .