1

What is wrong with this table, please? It is giving an error Extra alignment tab has been changed to \cr Where is the mistake in the number of &?

\documentclass[11pt,a4paper]{report}

\usepackage{multirow, tabularx}

\begin{document}
\begin{table}[h!]
\centering
\small
\caption{Comparison}
\label{comp}
\begin{tabularx}{\textwidth}{cccc|cccc}
\hline\hline\noalign{\smallskip}

\multicolumn{4}{c}{\textbf{A}} &&&& \multicolumn{4}{c}{\textbf{B}} &&&\\

\hline
 
\end{tabularx}
\end{table}

1 Answer 1

1

There are two serious issues with the table.

  • First, the tabularx environment is defined to have 8 columns, yet the instruction

    \multicolumn{4}{c}{\textbf{A}} &&&& \multicolumn{4}{c}{\textbf{B}} &&& \\
    

    requires the table to be defined as having 14 [!] columns. If the table is meant to have just 8 columns, you should probably write

    \multicolumn{4}{c}{\textbf{A}} & \multicolumn{4}{c}{\textbf{B}} \\
    

    That's the immediate cause of the -- admittedly somewhat cryptic -- message "Extra alignment tab has been changed to \cr".

  • Second, employing a tabularx environment makes no sense unless you actually employ the X column type for at least one of the columns. If you intend to employ a centered version of the X type for all 8 columns, I suggest using the following code

    %% in the preamble:
    \usepackage{tabularx}
    \newcolumntype{C}{>{\centering\arraybackslash}X}
    ...
    %% in the body of document:
    \begin{table}
    \begin{tabularx}{\textwidth}{CCCC|CCCC}
    \multicolumn{4}{c}{\textbf{A}} & \multicolumn{4}{c}{\textbf{B}} \\
    \hline
    ...
    \end{tabularx}
    \end{table}
    
2
  • To be a bit more explicit: \multicol{4}... means that you should omit 4-1 & symbols from this row.
    – Teepeemm
    Jul 31, 2022 at 18:45
  • @Teepeemm - Nicely put!
    – Mico
    Jul 31, 2022 at 18:47

You must log in to answer this question.

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