Question has been written above.

2 Answers 2


TeX notation versus LaTeX notation.

\newdimen\myDim \myDim=5cm+\linewidth does not work

\newdimen\myDim \myDim=\dimexpr5cm+\linewidth\relax works with etex

\newlength\myLen \setlength\myLen{5cm+\linewidth} works with package calc

\newlength\myLen \setlength\myLen{\dimexpr5cm+\linewidth} works with etex

myDim=5cm plus 1em does not work, must be a skip instead \newskip\mySkip

\setlength\myLen{5cm plus 1em minus .2ex} works, a LaTeX length is always a skip register

  • thanks for this answer. I will revisit this tomorrow again. It is a bit confusing to read. It is time to sleep. :-) Dec 26, 2010 at 19:40

To elaborate a bit on what Herbert says, LaTeX 'lengths' are what TeX calls 'skips': lengths with a rubber component. They can therefore be set using the TeX syntax

\fboxsep=1 cm

or the LaTeX syntax

\setlength{\fboxsep}{1 cm}

There are a couple of points to watch here. First, LaTeX inserts a \relax to prevent the code accidentally picking up a 'plus' or 'minus' part. For example

\Oops{1 cm} plus some space

will lead TeX is complain that a number is missing, as the 'plus' is interpreted as a stretch component for the skip. The LaTeX solution, which inserts a \relax, is safe. The same can of course be done in TeX macros without LaTeX:

\Safe{1 cm} plus some space

Here the 'plus' is not mis-interpreted.

Herbert also points out that the calc package allows calculations as part of the length setting. Personally, I tend to use e-TeX for this:


In this, the calculation is done by the engine, which is usually a better plan than using macros. (Note though that \glueexpr only does basic arithmetic using (, ), +, -, x and /. The calc package has 'max' and 'min' functions.)

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.