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.

2 Answers 2


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:


I also found a solution with calc package:



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.