LaTeX-Package-Repositories / geometry

Updating Hideo Umeki's geometry package for LaTeX page dimensions
38 stars 5 forks source link

unexpected result with \newgeometry in curly brackets #14

Closed mathqjye closed 2 years ago

mathqjye commented 2 years ago

Hi, David. I seems to find a bug. The MWE is as follows:

\documentclass{article}
\usepackage[paperwidth=3in,paperheight=3in]{geometry}
\begin{document}
First page
\clearpage
{
    \newgeometry{left=1in,bottom=1in}
    Second page
    \clearpage
}
Third page
\clearpage
Fourth page
\end{document}

QQ截图20220417105045

As you can see, the position of the footer in Page 3 is not corrected and the others are corrected.

By reading the document of the geometry package, I have known that I should code as follows and the result is corrected. But I still curious why the previous code leads to the unexpected result. Thanks.

\documentclass{article}
\usepackage[paperwidth=3in,paperheight=3in]{geometry}
\begin{document}
First page
\clearpage
\newgeometry{left=1in,bottom=1in}
Second page
\clearpage
\restoregeometry
Third page
\clearpage
Fourth page
\end{document}
davidcarlisle commented 2 years ago

\newgeometry is making settings in the pdf back end to set the page size (as well as TeX-level settings) TeX grouping doesn't really make sense at that level and the back end settings are not restored at the end of the group, you need an explicit restore.