[Tex/LaTex] Why does \newgeometry from the geometry package not change the papersize

geometrypaper-size

What technical reasons are behind this?

From manual of package geometry:

… paper size options (such as papersize,
paper=a4paper and so forth), which can’t be changed with \newgeometry.

Best Answer

I thank @DavidCarlisle and @UlrikeFischer for the support in providing this answer

paperwidth and paperheight are LaTeX lenghts, which are then ultimately converted in eg pdftex into the lenghts pdfpagewidth and pdfpageheight using this snippet:

\ifGin@setpagesize
\ifx\paperwidth\@undefined\else
  \AtBeginDocument{%
% If a package has changed \mag, assume it knows what it is doing
% and leave page size alone
\ifnum\mag=\@m
  \@ifundefined{stockwidth}{%
  \@ifundefined{paperwidth}{%
  }{%
    \ifdim\paperwidth>0pt\relax
      \ifdim\paperheight>0pt\relax
        \pdfpagewidth=\paperwidth
        \pdfpageheight=\paperheight
      \fi
    \fi
  }%
}{%
  \ifdim\stockwidth>0pt\relax
    \ifdim\stockheight>0pt\relax
      \pdfpagewidth=\stockwidth
      \pdfpageheight=\stockheight
    \fi
  \fi
}%
\fi
}

The "LaTeX" counterparts are discarded after the document has started (meaning they are not meaningful anymore), while the pdf counterparts are the ones ultimately used for setting.

Geometry sets the pdf lengths also at the begin of the document, possibly to maintain compatibility with the dvips drivers (which do not support multiple page sizes), so it does not allow them to be reset during the document, thus discarding the paper resizing options