# Compiler error “Extra alignment tab has been changed to \cr” when using a multicolumn

I have a problem with an error latex, so

I have this table, with a title, to build a title I'm using the \multicolumn but I have this error

Extra alignment tab has been changed to \cr


This is a minimal example

\documentclass[11pt]{toptesi}

\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{booktabs}

\begin{document}

\begin{table}[ht]
\centering\small
\begin{tabular}{cc}
\toprule
& \multicolumn{2}{c}{\large Transaction input} \\
\midrule
$int32\_t$ & nVersion   \\
$uint256$ & hashPrevBlock \\
$uint256$ & hashMerkleRoot \\
$uint32\_t$ & nTime \\
$uint32\_t$ & nBits \\
$uint32\_t$ & nNonce \\
\bottomrule
Type & Name \\
\end{tabular}
\caption{Rappresentazione struttura delle transazione d’input in Bitcoin.\label{tab:inputtransaztionbitcoin}}
\end{table}

\end{document}

• Remove the & before \multicolumn. But the table will not be pretty at all. – egreg Oct 9 at 9:53
• The caption text is ungrammatical. – egreg Oct 9 at 10:02

The error is due to the & in front of \multicolumn{2}, which is asking for a three-column row.

I see no reason to state \small, but if you prefer that, in no way should the table title be \large. Also the column headers should go on top, not at the bottom.

I added \usepackage[T1]{fontenc}, which is necessary if you use pdflatex (not if you use XeLaTeX or LuaLaTeX).

I also fixed the grammar in the caption: “transaction input” is “input di transazione”, not “transazione di input”.

The items in the first column should use either \mathrm (as I did here) or \mathit, not just math mode. An underscore seems quite unusual in math, so I changed it to mean a subscript.

\documentclass[11pt]{toptesi}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[italian]{babel}
\usepackage{booktabs}

\begin{document}

\begin{table}[ht]
\centering

\begin{tabular}{ll}
\toprule
\multicolumn{2}{c}{Transaction input} \\
\cmidrule(lr){1-2}
\multicolumn{1}{c}{Type} & \multicolumn{1}{c}{Name} \\
\midrule
$\mathrm{int}32_t$  & nVersion   \\
$\mathrm{uint}256$  & hashPrevBlock \\
$\mathrm{uint}256$  & hashMerkleRoot \\
$\mathrm{uint}32_t$ & nTime \\
$\mathrm{uint}32_t$ & nBits \\
$\mathrm{uint}32_t$ & nNonce \\
\bottomrule
\end{tabular}
\caption{Rappresentazione della struttura degli input di transazione in
Bitcoin.\label{tab:inputtransaztionbitcoin}}
\end{table}

\end{document}


• @vincenzopalazzo Do the way it's used in your field. Maybe it's \mathrm, maybe different. – egreg Oct 9 at 12:39

& is a column separator, which means that this line

  & \multicolumn{2}{c}{\large Transaction input} \\


will be interpreted as "take one column (the one before the &), then do a cell spanning two columns", essentially trying to cram three columns into the table which is defined to have only 2 columns. This throws the error your encountered.

Delete your & in that line.