I would like to define an environment, that inserts a page with different margins than defined in the preamble.
I tried using the following LaTeX code.
\documentclass[a4paper,10pt]{article}
\usepackage[left=5.2cm,top=2cm,right=1.5cm,bottom=2cm,nohead,nofoot]{geometry}
\usepackage{blindtext}
\newenvironment{myenv}{
\newgeometry{left=1.5cm,top=20cm,right=1.5cm,bottom=2cm,nohead,nofoot}
\blindtext[2]
}{
\newpage
\restoregeometry
}
\begin{document}
\begin{myenv}
\end{myenv}
\blindtext[10]
\end{document}
Unfortunately on the second page there is an unexpected page break after a few lines. The following code produces the desired result.
\documentclass[a4paper,10pt]{article}
\usepackage[left=5.2cm,top=2cm,right=1.5cm,bottom=2cm,nohead,nofoot]{geometry}
\usepackage{blindtext}
\newenvironment{myenv}{
\newgeometry{left=1.5cm,top=20cm,right=1.5cm,bottom=2cm,nohead,nofoot}
\blindtext[2]
}{
\newpage
}
\begin{document}
\begin{myenv}
\end{myenv}
\restoregeometry
\blindtext[10]
\end{document}
However I do not want to write \restoregeometry
manually each time I use myenv
. Can anyone explain me the difference between the two code pieces above and provide a solution for this problem? Thanks.