# problem adding additional column under multicolumn option in table [duplicate]

This question already has an answer here:

First part of the question: I have a table

\begin{document}
\begin{tabular}{|*9{c|}}\hline
A & \multicolumn{2}{c|}{B} & \multicolumn{2}{c|}{C} & \multicolumn{2}{c|}{D} & \multicolumn{2}{c|}{E} \\\cline{2-9}
& \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} \\\cline{2-9}
& U & V &  U & V & U & V & U & V \\\hline
y  & 7.23 & 6.39  & 7.76 &  6.93 & 2.81 &  2.54 & 0.59 &  0.55  \\ \hline
z  & 2.5503 &  2.2658  & 2.5345 &  2.3741 & 1.85 &  1.64 & 0.46 &  0.37   \\ \hline
$\sum{E^{i}_{U/V}}$  & & & & &  & & $\sim 1$ & $\sim 1$   \\ [1ex]  \hline
\end{tabular}

\end{document}

which nicely re-produce what I want.

But as I want to add 3rd column under B, it does not work and keep giving me error "illegal character in array.arg".

\begin{document}

\begin{tabular}{|*10{c|}}\hline
A & \multicolumn{3}{c|}{B} & \multicolumn{2}{c|}{C} & \multicolumn{2}{c|}{D} & \multicolumn{2}{c|}{E} \\\cline{2-10}
& \multicolumn{3}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} \\\cline{2-10}
& U & V & W &  U & V & U & V & U & V \\\hline
y  & 7.23 & 6.39 & X & 7.76 &  6.93 & 2.81 &  2.54 & 0.59 &  0.55  \\ \hline
z  & 2.5503 &  2.2658 & X  & 2.5345 &  2.3741 & 1.85 &  1.64 & 0.46 &  0.37   \\ \hline
$\sum{E^{i}_{U/V}}$  & & & & & &  & & $\sim 1$ & $\sim 1$   \\ [1ex]  \hline
\end{tabular}

\end{document}

can anyone help me solve the issue please.

Second part of the question:

How can I remove the column lines from the last row for the columns with empty entries?

Any help will be highly appreciated, thanks!

## marked as duplicate by David Carlisle tables StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Jun 9 '15 at 15:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

• *10 is 1 copy of 0. You meant *{10} for 10 copies. The documented syntax always has braces, although you can sometimes omit them in some cases eg single digits. – David Carlisle Jun 9 '15 at 15:08
• Please always make the examples complete starting from \documentclass{article} so people can easily reproduce the error. – David Carlisle Jun 9 '15 at 15:09
• wow, this is surprizing, *9 works but *10 doesn't !!! thanks! any insights for the second part of the question? – SAS Jun 9 '15 at 15:11
• Why is that surprising? It is same as \fbox ab just boxes a you need \fbox{ab} to box more than one token. – David Carlisle Jun 9 '15 at 15:12
• \multicolumn{1}{c}{} will make an entry with no vertical rule. – David Carlisle Jun 9 '15 at 15:13

## 1 Answer

The main issue here was that *10 is interpreted as "one time". Commands in LaTeX always look for the next character. If you need to handle more then one character, you have to put it in braces. *{10}. You can see the same for \textbf ab.

% arara: pdflatex

\documentclass{article}
\usepackage{showframe} % remove this. It just shows that the second table is too large.

\begin{document}
\noindent
\begin{tabular}{|*9{c|}}\hline
A & \multicolumn{2}{c|}{B} & \multicolumn{2}{c|}{C} & \multicolumn{2}{c|}{D} & \multicolumn{2}{c|}{E} \\\cline{2-9}
& \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} \\\cline{2-9}
& U & V &  U & V & U & V & U & V \\\hline
y  & 7.23 & 6.39  & 7.76 &  6.93 & 2.81 &  2.54 & 0.59 &  0.55  \\ \hline
z  & 2.5503 &  2.2658  & 2.5345 &  2.3741 & 1.85 &  1.64 & 0.46 &  0.37   \\ \hline
$\sum{E^{i}_{U/V}}$  & & & & &  & & $\sim 1$ & $\sim 1$   \\ [1ex]  \hline
\end{tabular}

\noindent % the table is still a bit to wide for this page...
\begin{tabular}{|*{10}{c|}}\hline % important to set 10 into braces. (and every other multi digits number)
A & \multicolumn{3}{c|}{B} & \multicolumn{2}{c|}{C} & \multicolumn{2}{c|}{D} & \multicolumn{2}{c|}{E} \\\cline{2-10} % 2-10, not 2-9, I guess...
& \multicolumn{3}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} & \multicolumn{2}{c|}{x} \\\cline{2-10}
& U & V &  W &  U & V & U & V & U & V \\\hline
y  & 7.23 & 6.39 & X & 7.76 &  6.93 & 2.81 &  2.54 & 0.59 &  0.55  \\ \hline
z  & 2.5503 &  2.2658 & X  & 2.5345 &  2.3741 & 1.85 &  1.64 & 0.46 &  0.37   \\ \hline
$\sum{E^{i}_{U/V}}$  & \multicolumn{2}{c}{}  & & \multicolumn{1}{c}{} & &\multicolumn{1}{c}{} & & $\sim 1$ & $\sim 1$   \\ [1ex]  \hline
\end{tabular}
\end{document}

It would not be helping with the horizontal width issue, but you could get rid of all those lines with use of the package booktabs. Here is a quick solution which might need some more tweaking.

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}

\begin{document}
\scriptsize\noindent
\begin{tabular}{c*{2}S[table-format=1.4]c*{2}S[table-format=1.4]*{4}S[table-format=1.2]}\toprule
A & \multicolumn{3}{c}{B} & \multicolumn{2}{c}{C} & \multicolumn{2}{c}{D} & \multicolumn{2}{c}{E} \\
& \multicolumn{3}{c}{x} & \multicolumn{2}{c}{x} & \multicolumn{2}{c}{x} & \multicolumn{2}{c}{x} \\\addlinespace
& U & V &  W &  U & V & U & V & U & V \\\cmidrule(lr){2-4}\cmidrule(lr){5-6}\cmidrule(lr){7-8}\cmidrule(lr){9-10}
y  & 7.23 & 6.39 & X & 7.76 &  6.93 & 2.81 &  2.54 & 0.59 &  0.55  \\
z  & 2.5503 &  2.2658 & X  & 2.5345 &  2.3741 & 1.85 &  1.64 & 0.46 &  0.37   \\\midrule
$\sum{E^{i}_{U/V}}$  & &  & &  & & & & {$\sim 1$} & {$\sim 1$}  \\\bottomrule
\end{tabular}
\end{document}