TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Question has been written above.

share|improve this question
up vote 12 down vote accepted

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

share|improve this answer
thanks for this answer. I will revisit this tomorrow again. It is a bit confusing to read. It is time to sleep. :-) – xport Dec 26 '10 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.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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