LaTeX-Package-Repositories / LaTeX-Package-Repositories/geometry

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

Open
#3 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
54
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the geometry package's existing "Known Problems" documentation and reproduce the supplied LaTeX example comparing \geometry with \newgeometry. Document that total does not override existing textwidth and textheight settings in the initial \geometry call, including the demonstrated workaround and warning behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.