Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
Error with table

I'm writing a table with 4 columns and 1 row. The first column starts with a bracket. It compiles without issues:

\documentclass{article}
\begin{document}
\begin{tabular}{l l l l}
[k]bbb & `def' & [h]bbb & `def' \\
\end{tabular}
\end{document}

If I add another row like that, on the other hand, I receive an error message.

\documentclass{article}
\begin{document}
\begin{tabular}{l l l l}
[k]bbb & `def' & [h]bbb & `def' \\
[k]ccc & `def' & [h]ccc & `def' \\
\end{tabular}
\end{document}

! Missing number, treated as zero.

I can avoid the issue by adding some curly braces to the first column, but I'm curious what's going on with LaTeX and brackets in tables here.

share|improve this question

marked as duplicate by Werner, egreg, Seamus, David Carlisle, Peter Grill Jul 20 '12 at 17:49

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.

1 Answer 1

up vote 4 down vote accepted

LaTeX sees the [ (from the second row) as the beginning of the optional argument for \\ and expects a length to follow; since the following token is k, an error is triggered. To prevent this, you can use braces:

\documentclass{article}
\begin{document}
\begin{tabular}{l l l l}
{[k]}bbb & `def' & [h]bbb & `def' \\
{[k]}ccc & `def' & [h]ccc & `def' \\
\end{tabular}
\end{document}

With only one row there's no problem (in fact, the braces around the [k] of the first row in my example can be suppressed) since there's no \\ before the character [.

share|improve this answer
    
Why doesn't this problem arise when there is only one row, though? –  Sverre Jul 20 '12 at 16:02
    
@Sverre With one row you dont have \\ before the [. –  Gonzalo Medina Jul 20 '12 at 16:02
4  
@Sverre It's the second [ that causes the issue: the first one cannot be an optional argument as there is no preceding \\ . –  Joseph Wright Jul 20 '12 at 16:03

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