[Tex/LaTex] Problem with the geometry package reset option

geometrymargins

Page 11 of the geometry package manual says that the reset option

sets back the layout dimensions and switches to the settings before geometry is loaded.

On page 30 there is a slightly different description:

The [reset] option cancels all the options specified before reset, except pass.

However, the following code

\documentclass{article}
\showthe\textwidth
\usepackage[textwidth=50pt,reset]{geometry}
\showthe\textwidth

produces the output

> 345.0pt.
l.2 \showthe\textwidth

> 430.00462pt.
l.4 \showthe\textwidth

So, \textwidth doesn't return to the value it had before geometry was loaded. What am I doing wrong?

Best Answer

In addition to some other flags, geometry stores the page configuration upon package load in the macro \Gm@restore@org. For the standard article document class (your minimal example) this contains:

\csname paperwidth\endcsname =614.295pt\relax
\csname paperheight\endcsname =794.96999pt\relax
\csname textwidth\endcsname =345.0pt\relax
\csname textheight\endcsname =550.0pt\relax
\csname evensidemargin\endcsname =62.0pt\relax
\csname oddsidemargin\endcsname =62.0pt\relax
\csname topmargin\endcsname =16.0pt\relax
\csname headheight\endcsname =12.0pt\relax
\csname headsep\endcsname =25.0pt\relax
\csname topskip\endcsname =10.0pt\relax
\csname footskip\endcsname =30.0pt\relax
\csname baselineskip\endcsname =12.0pt\relax
\csname marginparwidth\endcsname =65.0pt\relax
\csname marginparsep\endcsname =11.0pt\relax
\csname columnsep\endcsname =10.0pt\relax
\csname hoffset\endcsname =0.0pt\relax
\csname voffset\endcsname =0.0pt\relax
\csname Gm@layouthoffset\endcsname =0.0pt\relax
\csname Gm@layoutvoffset\endcsname =0.0pt\relax
\@twocolumnfalse
\@twosidefalse
\@mparswitchfalse
\@reversemarginfalse

This is overwritten at the start of the document to

\csname paperwidth\endcsname =614.295pt\relax
\csname paperheight\endcsname =794.96999pt\relax
\csname textwidth\endcsname =430.00462pt\relax
\csname textheight\endcsname =556.47656pt\relax
\csname evensidemargin\endcsname =19.8752pt\relax
\csname oddsidemargin\endcsname =19.8752pt\relax
\csname topmargin\endcsname =-13.87262pt\relax
\csname headheight\endcsname =12.0pt\relax
\csname headsep\endcsname =25.0pt\relax
\csname topskip\endcsname =10.0pt\relax
\csname footskip\endcsname =30.0pt\relax
\csname baselineskip\endcsname =12.0pt\relax
\csname marginparwidth\endcsname =65.0pt\relax
\csname marginparsep\endcsname =11.0pt\relax
\csname columnsep\endcsname =10.0pt\relax
\csname hoffset\endcsname =0.0pt\relax
\csname voffset\endcsname =0.0pt\relax
\csname Gm@layouthoffset\endcsname =0.0pt\relax
\csname Gm@layoutvoffset\endcsname =0.0pt\relax
\@twocolumnfalse
\@twosidefalse
\@mparswitchfalse
\@reversemarginfalse

To restore the page and text dimensions to what it was before geometry was called, you can make an explicit call to \Gm@restore@org before \begin{document}:

\usepackage[...]{geometry}% http://ctan.org/pkg/geometry
\makeatletter
\Gm@restore@org
\makeatother