When rendering documents in LaTeX, the document class determines the sizes of page borders etc. I do not want to change them.

However, during the editing process, one usually looks at a file only on screen. In these situations, all the white space around the actual content is a waste of screen space. Now some PDF viewers have a "zoom to content" feature, but even easier would be if the page borders simply were not there.

Of course I could use the geometry package to set the page borders to, say, 0.3mm, but that would change the whole page layout (e.g., make textwidth and textheight bigger). Of course I could further fiddle around to fix all of that until it works out again the way it originally was, but it would be a lot of work, and I would have to manually do this for every different article class, etc.

If this is at all possible it would be great to have a "universal" automatic solution instead: A simple command I add somewhere in the preamble which will "cut off" (most of) the page borders but leave everything else unchanged.

As long as I edit on screen I could leave this command active, and as soon as I want to render the final version of the PDF, I could out-comment it to get the page borders back.

Ideally this should work with all (or many) document classes.

Is there any hope to achieve such a thing? It would simplify screen editing quite a bit.

  • Probably not exactly what you're after, but you could run pdfcrop filename.pdf after compiling, to generate filename-crop.pdf with all whitespace along the edges cropped away. – Torbjørn T. Dec 17 '15 at 14:47
  • That works, but adds about 10 seconds of compilation time on my PC. A TeX-based solution should be much more effective. – Rupert Hölzl Dec 17 '15 at 15:02

This here should normally work fine if you use geometry anyway:




There can be a small rounding difference, but for drafts it shouldn't matter. (You can naturally adapt the border to include e.g. the head and footer)

  • 1
    Thanks. At first it looked good, but then I noticed that it changes where TeX puts pagebreaks, I ended up getting 4 more pages than before (on a 47 page document). – Rupert Hölzl Dec 17 '15 at 15:14
  • Did you previously used geometry? If not you should load it e.g. with \usepackage[textwidth=\textwidth,textheight=\textheight]{geometry} or it will change the layout. – Ulrike Fischer Dec 17 '15 at 15:19
  • Indeed, that was it! Just inserting the line \usepackage[textwidth=\textwidth,textheight=\textheight]{geometry}\geometry{paperwidth=\dimexpr\textwidth+8mm, paperheight=\dimexpr\textheight+8mm,margin=4mm} right before \begin{document} seems to do exactly what I want. Thanks a lot! – Rupert Hölzl Dec 17 '15 at 15:29

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.