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

I'd like to use the geometry package to auto-crop the output of my LaTeX (so that it looks bigger on-screen as I'm editing). I have found a way to remove the margins completely and brutally:

\geometry{paperwidth=\textwidth,  paperheight = \textheight, margin=0cm}

However, I'd like to be somewhat more gentle. I tried the following, but it does not work:

\geometry{paperwidth=\textwidth + 1cm,  paperheight = \textheight+1cm, margin=1cm}

The reason is that arithmetic does not work inside these arguments. (LaTeX doesn't seem smart enough to do the addition).

What is the correct way to achieve this effect?

share|improve this question
up vote 14 down vote accepted

It works if you load the calc package.




\geometry{paperwidth=\textwidth+1cm,paperheight=\textheight+1cm, margin=1cm}




share|improve this answer
This works wonderfully! Thank you! – user21952-is-a-great-name Jul 31 '12 at 19:08

\dimexpr allows for expression-like addition/subtraction of dimensions:

\usepackage{geometry}% http://ctan.org/pkg/geometry
  paperwidth=\dimexpr\textwidth + 1cm\relax,

calc automates this process through a redefinition of the length/dimension-related macro (\setlength, \addtolength, etc.).

share|improve this answer
Thank you! Apparently, I need another two reputation points to vote up, but I'm sure others will do it for me. – user21952-is-a-great-name Jul 31 '12 at 19:10
@user21952-is-a-great-name You should be able to upvote soon enough. :-) – lockstep Jul 31 '12 at 19:13
Just for information for those who do know it that division by floating point number is not allowed in , for example, \dimexpr\textwidth/3.14\relax. – kiss my armpit Jul 31 '12 at 20:04
@HiggsBoson: Perhaps, but multiplication is fine: 0.3183\textwidth where 0.3183 ~ 1/π. – Werner Jul 31 '12 at 20:12
@Werner: Yes. I agree. But fp is more expressive. :-) – kiss my armpit Jul 31 '12 at 20:15

\dimexpr...\relax is not flexible enough because you cannot do division by a floating point number. \dimexpr\textwidth/3.141592654\relax, for example, is not possible!

That is why I prefer using the fp package because it can do any calculation.


\FPeval{Width}{round(pow(0.5,2)*10*sin(pi/2):3)}% $10\sqrt(2)$ in 3 digits
%     after decimal point
\FPeval{Height}{round(pow(0.5,3)*10+cos(pi/2):3)}% $10\sqrt(3)$ in 3 digits
%    after decimal point

    paperwidth=\Width cm,
    paperheight=\Height cm,




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.