I've already reported this to Hideo Umeki without any reaction. So once again:
It seems that geometry for \geometry prioritizes textwidth and textheight settings over total setting, but does not do so for \newgeometry in the document body. Look at this example:
\documentclass{article}
\usepackage[%
includehead=false,% default
includefoot=false,% default
includemp=false,% default
textwidth=400pt,
textheight=500pt,
]{geometry}
%\usepackage{xpatch}
%\xapptocmd{\geometry}{\newgeometry{#1}}{}{}
\geometry{a4paper,total={500pt,600pt}}
\begin{document}
\raggedright
first set: 400pt, 500pt\\
second: 500pt, 600pt\\
expect: 500pt, 600pt\\
got: \the\textwidth, \the\textheight
\newgeometry{total={500pt,600pt}}
After \verb|\newgeometry| inside document body:\\
expected: 500pt, 600pt\\
got: \the\textwidth, \the\textheight
\end{document}
It results in:
first set: 400pt, 500pt
second: 500pt, 600pt
expect: 500pt, 600pt
got: 400.0pt, 500.0pt
After \newgeometry inside document body:
expected: 500pt, 600pt
got: 500.0pt, 600.0pt
Output after \newgeometry is as expected. But the initial \geometry{a4paper,total={500pt,600pt}} does not change \textwidth and \textheight (only \paperwidth and \paperheight) as expected.
If you activate the two deactivated patch lines, you'll get the expected result:
first set: 400pt, 500pt
second: 500pt, 600pt
expect: 500pt, 600pt
got: 500.0pt, 600.0pt
After \newgeometry inside document body:
expected: 500pt, 600pt
got: 500.0pt, 600.0pt
but an additional warning because of usage of a4paper in \newgeometry. Same, if you replace \geometry by \newgeometry.
Note: The example is only for simplification. In true life the problem is due to default settings in a package that cannot be overwritten by the user using \geometry{total={…}}. I know, the user could use:
\geometry{a4paper,textwidth=500pt,textheight=600pt}
or
\geometry{a4paper}
\newgeometry{total={500pt,600pt}}
and each of them would work. But the user should know this.
I would not call this is a bug. But can you at least document it, e.g., in the "Known Problems" section?
I've already reported this to Hideo Umeki without any reaction. So once again:
It seems that geometry for
\geometryprioritizestextwidthandtextheightsettings over total setting, but does not do so for\newgeometryin the document body. Look at this example:It results in:
Output after
\newgeometryis as expected. But the initial\geometry{a4paper,total={500pt,600pt}}does not change\textwidthand\textheight(only\paperwidthand\paperheight) as expected.If you activate the two deactivated patch lines, you'll get the expected result:
but an additional warning because of usage of
a4paperin\newgeometry. Same, if you replace\geometryby\newgeometry.Note: The example is only for simplification. In true life the problem is due to default settings in a package that cannot be overwritten by the user using
\geometry{total={…}}. I know, the user could use:or
and each of them would work. But the user should know this.
I would not call this is a bug. But can you at least document it, e.g., in the "Known Problems" section?