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

How can I calculate a maximum of lengths? I am aware of pgfmath's function max(x_1,x_2,...)



But what if I have lengths instead of numbers?






\pgfmathresult doesn't have a unit of measurement.

share|improve this question
up vote 6 down vote accepted

The result is actually a length in points (pt) without the unit. You can simply add this unit again:

\setlength{\qux}{\pgfmathresult pt}

There is also the \pgfmathsetlength macro:

share|improve this answer
That's great, thanks! – ipavlic Feb 25 '11 at 14:09

I also found a solution with calc package:


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.