The above code is a snippet from the answer of How to arrange the text and image in one beamer frame?.

  1. I know the \numexpr...\relax pair is for expression evaluation. The above \setcounter command doesn't have \relax (Does the end of the parenthesis after -1 in the code {\numexpr\number\value{numofboxes}-1} have the same effect?)
  2. what is the purpose of the command \number (if I don't use it, will something be wrong?)
  3. \number\value{numofgaps}\gapwidth means numofgaps multiply gapwidth, but why not add the * symbol stand for multiplication between \value{numofgaps} and \gapwidth.

1 Answer 1


The \number primitive is not needed in those contexts. But you need \dimexpr in \setlength, unless you load calc.




\setlength{\gapwidth}{10pt} % an easy number
\setlength{\textsectionwidth}{300pt} % an easy number
\setcounter{numofboxes}{11} % an easy number



\texttt{numofgaps = \thenumofgaps}

\texttt{\string\truetextsectionwidth = \the\truetextsectionwidth}


enter image description here

Inside \numexpr any <number> can be used, and \value{numofboxes} fits the syntax of <number>.

A length register can be multiplied by a <factor> which basically is a <number> or an explicit decimal number.

Note that inside \dimexpr, something like


would be illegal, because an integer multiplier must go after the length register; \gapwidth*\number\value{numofgaps} would be legal, but is not really needed.

The code \value{counter} expands to \csname c@counter\endcsname, so it's equivalent to \c@counter, where \c@counter is the name of the integer register allocated when \newcounter{counter} is processed. Inside \numexpr, any integer register name can be used directly. There's no need to make it into an explicit number by means of \number. The construction \number\value{counter} has its uses, but is not needed when TeX expects a <number>.

You must log in to answer this question.

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