2

I noticed a strange behaviour when using \multicolumn inside a tabu environment with X columns. Here is an example:

\documentclass[12pt]{report}

\usepackage{tabu}
\usepackage{booktabs}

\begin{document}

correct:
\begin{tabu} {rr} 
\toprule
\rowfont[c]{\itshape} \multicolumn{2}{c}{1--2}\\
\cmidrule{1-2} 
\rowfont[c]{\itshape} A & B \\
\midrule
100 & 200  \\
\bottomrule
\end{tabu}
wrong: 
\begin{tabu} to 4cm {X[r]X[r]} 
\toprule
\rowfont[c]{\itshape} \multicolumn{2}{c}{1--2} \\
\cmidrule{1-2} 
\rowfont[c]{\itshape} A & B \\
\midrule
100 & 200  \\
\bottomrule
\tabuphantomline
\end{tabu}

\end{document}

output

In the second table, the multicolumn is not centered correctly. Moreover, the rowfont formatting affects not just one, but all following lines. Adding a \tabuphantomline, as suggested in the tabu manual when dealing with multicolumns, did not help.

This behaviour seems to occur only when the table "starts" with a multicolumn. When I put a regular (single) column first, everything works fine.

I wonder if this is a bug or incompatibility or if I'm just missing out on something...

1 Answer 1

1

I would never use tabu!

Even though I am reluctant to investigate why it happens, the following works:

\documentclass[12pt]{report}

\usepackage{tabu}
\usepackage{booktabs}

\begin{document}

correct:
\begin{tabu} {rr}
\toprule
\rowfont[c]{\itshape} \multicolumn{2}{c}{1--2}\\
\cmidrule{1-2}
\rowfont[c]{\itshape} A & B \\
\midrule
100 & 200  \\
\bottomrule
\end{tabu}
wrong:
\begin{tabu} to 4cm {X[r]X[r]}
\toprule
\rowfont{\itshape} \multicolumn{2}{c}{1--2} \\
\cmidrule{1-2}
\rowfont[c]{\itshape} A & B \\
\midrule
\rowfont[c]{\normalfont} 100 & 200  \\
\bottomrule
\tabuphantomline
\end{tabu}

\end{document}

enter image description here

The problem is with \rowfont[c]

You must log in to answer this question.

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