Consider the following snippet from etoolbox:


Maybe I do not understand the differences between \numexpr, \dimexpr, \glueexpr and \muglueexpr (e-TeX expressions), but I suspected the use of \dimexpr in the definition of \deflength just like \numexpr is used in the definition of \defcounter Can someone explain the difference?

  • 1
    latex lengths are skips (glue) not dimens. Apr 14, 2015 at 7:24

1 Answer 1


The following should answer the question:


\mylenA=5pt plus 2pt
\showthe\mylenA % \mylenA = 5pt plus 2pt

\showthe\mylenB % \mylenB = 5pt plus 2pt

\showthe\mylenB % \mylenB = 5pt (no glue)

\showthe\mylenB % \mylenB = 5pt plus 2pt


The .log outputs:

> 5.0pt plus 2.0pt.
l.7 \showthe\mylenA

> 5.0pt plus 2.0pt.
l.10 \showthe\mylenB

> 5.0pt.
l.13 \showthe\mylenB

> 5.0pt plus 2.0pt.
l.16 \showthe\mylenB

If you set a length using \dimexpr<len> you lose any glue. Using \glueexpr<len> the glue is kept.

  • By <len> I refer to a length macro, not an actual length.
    – Werner
    Apr 14, 2015 at 6:00
  • 1
    The important thing you don't mention is that latex's \newlength defines a skip register not a dimen register. that is it is based on \newskip not \newdimen Apr 14, 2015 at 7:21
  • @DavidCarlisle I see. As you mentioned, the main reason must be that \newlength defines a skip instead of a dimen. Apr 15, 2015 at 1:52

You must log in to answer this question.

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