Why do I get the error "Missing number, treated as zero." for case A, while other cases are working? And how to avoid it?


% Case A (error)

% Case B (no error)

% Case C (no error)

% Case D (no error)

% Case E (no error)


  • 2
    You are missing \usepackage{calc}.
    – campa
    Jan 18, 2021 at 15:04
  • Thanks, that is helping. But why are the other cases working?
    – user233236
    Jan 18, 2021 at 15:06
  • 2
    they are all in error, you can not by default have expressions in \setlength Jan 18, 2021 at 16:22
  • actually, there is no error message for cases B to E. See explanation by Phelype Oleinik.
    – user233236
    Jan 18, 2021 at 17:28

1 Answer 1


\setlength is defined as:

\def\setlength#1#2{#1 #2\relax}

so it uses TeX's plain assignment \register1=\register2, omitting the optional = sign.

Your code then does, after the expansion of \setlength:

\newLen \columnwidth-\tabcolsep-\doublerulesep-\arrayrulewidth

which, newlines added for clarity, is the same as:

\arrayrulewidth=\relax % error

and the final \arrayrulewidth errors because it's misused there, and if you look at the PDF you'll see two - typeset. The other versions don't actually work: they just don't throw errors, but still typeset spurious -. They don't error because the number of registers is even, so none is misused.

The right way would be to tell TeX that is a dimension expression with \dimexpr:


or \usepackage{calc}, as campa said in the comment, which redefines \setlength to understand expressions and some other goodies not available with \dimexpr only (check out the documentation).

By the way, expl3's equivalent \dim_set:Nn already does \dimexpr on the argument (though it doesn't add the calc syntax):

\dim_set:Nn \newLen {\columnwidth-\tabcolsep-\doublerulesep-\arrayrulewidth}
  • @campa sorry :) Jan 18, 2021 at 15:18
  • It happens :-)
    – campa
    Jan 18, 2021 at 15:20

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.