# alignment of multicolumn cell

Consider this table

\begin{tabular}{lr@{}l}
Bla & \multicolumn{2}{c}{A $\to$ B} \\
\hline
X   & 23.1&* \\
Y   & 7.5&
\end{tabular}


which produces

The second column heading appears to be left-aligned. What do I have to do to make it centred?

-

If a multicolumn entry is wider than the columns it spans then TeX's primitive \halign mechanism puts the extra space into the last spanned column, which is rarely what is wanted.

You can put some extra space into the earlier columns so that this does not occur, or here you may be better to use one of the packages for numeric alignment that keeps the numbers in a single column. I have used dcolumn here as I know it, but siunitx is newer with more features.

\documentclass{article}

\usepackage{dcolumn}

\begin{document}

1

\begin{tabular}{lr@{}l}
Bla & \multicolumn{2}{c}{A $\to$ B} \\
\hline
X   & 23.1&* \\
Y   & 7.5&
\end{tabular}

2

\begin{tabular}{lr@{}l}
Bla & \multicolumn{2}{c}{A $\to$ B} \\
\hline
Y   & 7.5&
\end{tabular}

3 (using a text mode * as suggested by @egreg's comment)

\begin{tabular}{lD{.}{.}{2.2}}
Bla & \multicolumn{1}{c}{A $\to$ B} \\
\hline
X   & 23.1\rlap{*} \\
Y   & 7.5
\end{tabular}

4 (or using a math mode superscript *)

\begin{tabular}{lD{.}{.}{2.2}}
Bla & \multicolumn{1}{c}{A $\to$ B} \\
\hline
X   & 23.1^{*} \\
Y   & 7.5
\end{tabular}

\end{document}


-
Maybe using \makebox[0pt][l]{*} in the second row will allow better visual centering (and the correct asterisk); \mbox{*} is at least necessary to avoid the math mode asterisk. –  egreg Apr 15 '12 at 14:47
@egreg, thanks answer updated –  David Carlisle Apr 15 '12 at 15:52

An easy way to work around this problem is to use the tabularew environment instead of the tabular environment. tabularew includes a macro, \spew, that controls how Excess Width is distributed among the columns. Here is a simple example:

\documentclass{article}

\usepackage{tabularew}

\begin{document}

\begin{tabularew}{l>{\spew{.5}{+1}}r@{.}l>{\spew{1}{+1}}r@{.}l}
Trace & \multicolumn{2}{c}{Property One} & \multicolumn{2}{c}{Property Two} \\
1 & 2 & 3 & 4 & 5
\end{tabularew}

\end{document}


The first column (Property One) centers the text. The second column (Property Two) right aligns the text.

The second argument to \spew is the column to modify. A preceding + or - means that the specification is relative to the current position. So, +1 means the next column. The first argument is the amount of excess width to put in this column. More details are in the manual: http://www.ctan.org/pkg/tabularew

-
Welcome to TeX.sx!. I have uploaded the image for your answer. –  Andrew Swann Nov 8 '12 at 9:43