Skip to content

unexpected result with \geometry in the preamble (but not with \newgeometry) #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
komascript opened this issue Aug 27, 2018 · 1 comment

Comments

@komascript
Copy link

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?

@davidcarlisle
Copy link
Member

Thanks, I setup this github to do some "emergency updates" but I don't really have a feel yet for what geometry should do for various combinations of options. So I can certainly add to the documentation as suggested but I'd be wary of changing the code at present. But if I find time to work out what's happening here or what the compatibility issues are with any changes, I'll come back to this issue.

thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants