Latex - Change margins of only a few pages
I have a Latex document where I need to change the margins of only a few pages (the pages where I'm adding a lot of graphics).
In particular, I'd like to change the top margins (\voffset
). I've tried doing:
\addtolength{\voffset}{-4cm}
% Insert images here
\addtolength{\voffset}{4cm}
but it didn't work. I've seen references to the geometry package, but I haven't found how to use it for a bunch of pages, and not for the whole document.
Any hints?
Solution 1:
Use the "geometry" package and write \newgeometry{left=3cm,bottom=0.1cm}
where you want to change your margins. When you want to reset your margins, you write \restoregeometry
.
Solution 2:
I've used this in beamer
, but not for general documents, but it looks like that's what the original hint suggests
\newenvironment{changemargin}[2]{%
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\listparindent}{\parindent}%
\setlength{\itemindent}{\parindent}%
\setlength{\parsep}{\parskip}%
}%
\item[]}{\end{list}}
Then to use it
\begin{changemargin}{-1cm}{-1cm}
don't forget to
\end{changemargin}
at the end of the page
I got this from Changing margins “on the fly” in the TeX FAQ.
Solution 3:
I was struggling a lot with different solutions including \vspace{-Xmm} on the top and bottom of the page and dealing with warnings and errors. Finally I found this answer:
You can change the margins of just one or more pages and then restore it to its default:
\usepackage{geometry}
...
...
...
\newgeometry{top=5mm, bottom=10mm} % use whatever margins you want for left, right, top and bottom.
...
... %<The contents of enlarged page(s)>
...
\restoregeometry %so it does not affect the rest of the pages.
...
...
...
PS:
1- This can also fix the following warning:
LaTeX Warning: Float too large for page by ...pt on input line ...
2- For more detailed answer look at this.
3- I just found that this is more elaboration on Kevin Chen's answer.
Solution 4:
\par\vfill\break % Break Last Page
\advance\vsize by 8cm % Advance page height
\advance\voffset by -4cm % Shift top margin
% Start big page
Some pictures
% End big page
\par\vfill\break % Break the page with different margins
\advance\vsize by -8cm % Return old margings and page height
\advance\voffset by 4cm % Return old margings and page height