26

I am using the ACM SIG template and trying to create a table of 4 columns.

I get the error mentioned in the title of the question. I know the standard reasons why this error can occur.

But my question is: Is it possible that the template or .cls file is controlling the maximum number of columns in a table ? If it were, would I get a different error than this?

migrated from stackoverflow.com Dec 4 '11 at 18:46

This question came from our site for professional and enthusiast programmers.

36

The error can be reproduced by

\documentclass{article}

\begin{document}

\begin{tabular}{c|c}
one & two & three \\
\hline
one & two 
\end{tabular}
\end{document}

The problem is caused by the extra column you try to insert. The tabular environment expects two columns but three is inserted.

  • 1
    that's precisely what was happening. in TexShop on mac, the characters for | and l look exactly same. – euphoria83 Oct 18 '10 at 19:46
3

Not all extra alignment tab has been changed to \cr errors are found via Google or Bing. Something as simple as defining a macro with arguments and forgetting the argument before the first \\ will reproduce the error.

Same thing with \newcommand.

e.g.,

\def\test#1#2{$\hbox to 4cm{#1}}$}
\begin{tabular}{cccc}
Oh & \test{tested}{} & Oh & \test{Oh} \\
   & \test{testing}{} &   & \test{Ohh}{} \\
\end{tabular} 
  • That is the very same error as in the other cases, because you are trying to typeset 8 columns, but only four are expected. – Johannes_B May 15 '16 at 10:12
  • @Johannes_B You've been around with TeX for a while now. Could you point me to a relevant piece of information either through tug or any other book or material where the newcommand and this error have been co related with one another? .... The error so far, to my understanding points to a very broad concept I wasn't able to find it but just trough trial and error. – doed May 15 '16 at 10:21
  • Your definition wants two arguments, in the first row, the last \test doesn't have a second and uses what comes next. That means the double backslash gets (partly) eaten up and LaTeX doesn't have the information that the line should be broken. Hence it complains that two many columns are used. – Johannes_B May 15 '16 at 10:25
  • Try \test{Wombat}\\ Wombat or even use \def\test#1#2{#1\typeout{This is shown in the terminal: #2}} to see that the double backslash is eaten up completely. – Johannes_B May 15 '16 at 10:29
  • But @Johannes_B ok, it complains that two many columns are used.... vague to say the least. And if the information out there is vague then it just defeats the purpose. Who wrote or came up with the idea to have the error extra alignment tab has been changed to \cr then? – doed May 15 '16 at 11:20
2

Hi,I had the same question and googled to this page. At last, I solved this problem by add one more c, the correct case should like below:

\documentclass{article}

\begin{document}

\begin{tabular}{c|c|c}
one & two & three \\
\hline
one & two 
\end{tabular}
\end{document}
  • I just copy-pasted a beautiful array from stackoverflow, where it displays great, and I too had to add a c to make it display in a standard LaTeX system. Not sure what's going on... – PatrickT Mar 4 '18 at 14:48
1

Here's another way you can get this error (the error is still that there are too many columns, but if you're as stupid as I am that isn't obvious):

I was using && instead of & for some reason. So I had twice as many columns as I thought. I couldn't figure out what was wrong for a long time, because all the answers here said "this error is caused by having too many columns!" and I was like, "I don't have too many columns!".

So if anyone out there shares my && disability, hopefully this answer will help you :)

0

Another possible reason is using a \cline{2-3} with {2-3} defining which columns need to be covered by the line. If you have less columns (here: less than 3) than you define in the \cline command, you get this error.

Example with error:

\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{ll}
\hline
\textbf{Column 1} & \textbf{Column 2} \\ \hline
Content           & Content           \\ \cline{2-3} % <-- this causes the error
Content           & Content           \\ \hline
\end{tabular}
\end{table}

Example without error:

\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{ll}
\hline
\textbf{Column 1} & \textbf{Column 2} \\ \hline
Content           & Content           \\ \cline{2-2}
Content           & Content           \\ \hline
\end{tabular}
\end{table}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.