Is there a way to trim the margins of the entire document by LaTeX
? I need to do that temporarily, to make more comfortable my typesetting work. I figured out to pass this option by command line with the \AtBeginDocument
technique but a preamble solution is also welcome.
To better explain my purposes I'd like to get the same result that I can achieve with the bash
command (that here works because of the coloured page):
pdfcrop --margins '-50 -50 -50 -50' mydoc.pdf mydoc.pdf
E.g. for the code:
\documentclass[a4paper,11pt]{article}
%% \usepackage{xcolor}
%% \pagecolor[HTML]{E4EDE9}
\usepackage{blindtext}
\begin{document}
\section{Section}
\blindtext
\blindtext
\blindtext\footnote{\blindtext}
\end{document}
I want to change the layout from:
NOTE. I obtain this layout by passing the color option by command line:
pdflatex '\AtBeginDocument{\RequirePackage{xcolor} \pagecolor[HTML]{E4EDE9}} \input{Latex.tex}'
(I want to thank Thérèse for this very eye-relaxing background color)
to:
An okular specific solution is welcome but, since I use many viewers, I prefer a LaTeX solution.
NOTE2. I need a solution that does not change the text layout. I need only to trim the pdf
as it stands.
SOLUTION
I want to share the solution that works in my case (thanks to Steven B. Segletes). This is the code for a command line cropped and coloured compilation:
pdflatex '\AtBeginDocument{\newlength\DX \DX=3cm \paperwidth=\dimexpr\paperwidth-\DX\relax \hoffset=\dimexpr\hoffset-.5\DX\relax \newlength\DY \DY=3cm \paperheight=\dimexpr\paperheight-\DY\relax \voffset=\dimexpr\voffset-.1\DY-.5\footskip\relax \RequirePackage{xcolor} \pagecolor[HTML]{E4EDE9}} \nonstopmode\input{mydoc.tex}'
NOTE ADDED. After TeX Live 2020 October update this solution needs an update: Trim margins of the entire document by command line (after TeX Live 2020 update)
\pdfpageheight
and\pdfpagewidth
directlygeometry
package with my documents because it messes up my standard layout. With\pdfpageheight
and\pdfpagewidth
the document is not centered but trimmed on bottom and right margins. What is my mistake?\usepackge[a4paper]{geometry}
in my preamble my layout is messed up. How can I tell geometry to not do so?passthrough
or somesuch that says not to change anything, or of course you can use geometry rather than primitive length settings to set all your document. If you usea4paper
option that tells geometry to set the text block for 14 paper size so does set the typesetting related lengths.