Change the Paper Size in the Middle of A Document in LaTeX

May. 23, 2025 • Updated May. 25, 2025

In LaTeX, we can use the \newgeometry command to change the page layout in the middle of a document, and then use the \restoregeometry command to restore the layout specified in the preamble. Both of these two commands are from the geometry package1, and here is an example from the documentation of the package.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
\documentclass{article}
\usepackage[hmargin=3cm]{geometry}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{lipsum}

\begin{document}

\lipsum[1-6]

\newgeometry{left=3cm,right=1cm,bottom=0.1cm}
\lipsum[1-6]
\restoregeometry

\newgeometry{margin=1cm,includefoot}
\lipsum[1-6]
\restoregeometry

\lipsum[1-6]

\end{document}

However, the \newgeometry command doesn’t support changing paper size and other papersize-related options:

\newgeometry is almost similar to \geometry except that \newgeometry disables all the options specified in the preamble and skips the papersize-related options: landscape, portrait and paper size options (such as papersize, paper=a4paper and so forth).1

The options for the layout size are available in \newgeometry, so that you can change the layout size in the middle of the document. The paper size itself can’t be changed though.2

So, if we want to the change paper size in the middle of a document, we should look for other methods. David Carlisle provides one3, and based on his method, I realized changing the paper size from a4paper to b4paper as below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
\documentclass{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{lipsum}

\begin{document}
\lipsum

\clearpage
\edef\hmm{\pdfpagewidth=\the\pdfpagewidth \pdfpageheight=\the\pdfpageheight\relax}

% ISO B4
\pdfpagewidth=250mm
\pdfpageheight=353mm
\newgeometry{margin=0.1in,top=1in,textwidth=240mm,textheight=330mm}
\oddsidemargin=0mm

\lipsum\lipsum\lipsum
 
\restoregeometry
\hmm

\lipsum

\end{document}

where \edef4 and \relax56 are two TeX macros.


Besides, we can make the orientation of above B4 papers as landscape7:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
\documentclass{article}
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[x11names]{xcolor}
\pagecolor{AntiqueWhite1}
\usepackage{lipsum}
\usepackage{pdflscape}

\begin{document}
\lipsum

\clearpage
\edef\hmm{\pdfpagewidth=\the\pdfpagewidth \pdfpageheight=\the\pdfpageheight\relax}

% ISO B4
\pdfpagewidth=250mm
\pdfpageheight=353mm
\newgeometry{margin=0.1in,top=1in,textwidth=240mm,textheight=330mm}
\oddsidemargin=0mm

\begin{landscape}
	\lipsum\lipsum\lipsum
\end{landscape}

\restoregeometry
\hmm

\lipsum

\end{document}


References