26
\begin{table}[ht]
\makebox[\textwidth][c]{
    \begin{tabular}{ccccc}
        \hline
        \hline
        [] & [] & [] & [] & []\\
        [] & [] & [] & [] & []\\
        \hline
        \hline
    \end{tabular}
}
\caption{test}
\end{table}

I cannot run the above code, latex returned an error about missing number, but I can't see anything I am missing.

And the weirdest thing is that

\begin{table}[ht]
\makebox[\textwidth][c]{
    \begin{tabular}{ccccc}
        \hline
        \hline
        [] & [] & [] & [] & []\\
        \hline
        \hline
    \end{tabular}
}
\caption{test}
\end{table}

This code works.

Anyone have any idea?

0

2 Answers 2

31

Since \\ allows an optional argument, the [ in the following line is mistaken for it.

......         \\\relax
[whatever] ... \\
3
  • Thanks!! I was fighting against this error for half an hour.
    – Benjamin
    Nov 11, 2011 at 10:48
  • I thought about this myself, and, as a workaround, tried to put a comment % after \\. To my surprise, it did not work. Could you enlighten me, why putting \\% does not solve this issue?
    – Matsmath
    May 21, 2021 at 6:17
  • 1
    @Matsmath When \\ is seen, TeX will look whether * follows, gobbling spaces. Then it will look whether [ follows, still gobbling spaces. An endline is converted to a space, but with % it’s not even seen. Worse, in amsmath environments, the space gobbling fearure is disabled, so \\<newline>[ works, but ``\\%<newline>[` wouldn’t.
    – egreg
    May 21, 2021 at 8:40
10

Another option is to add brackets around, like this:

{[} .... {]}
1
  • 1
    ...or add the braces before the next line, as in {} [...]. In this case, either would work, but in some math situations, the spacing could come out differently. May 31, 2018 at 10:09

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.