The geometry package

Hideo Umeki

                    hideo.umeki@toshiba.co.jp

1998/04/08 (v2.0a)

Abstract

This package provides an easy and flexible user interface to customize page layout. It implements auto-centering and auto-balancing mechanisms so that the users have only to give the least description for the page layout.

Contents

1 Preface to Version 2 1

2 Introduction 2

3 Page Geometry 2 3.1 Layout Dimensions . . . . . . . 2 3.2 Completion Algorithm . . . . . 4

4 User Interface 4 4.1 General Features . . . . . . . . 4 4.2 Option Types . . . . . . . . . . 6

5 Option List 7 5.1 Boolean Options . . . . . . . . 7 5.2 Single-Valued Options . . . . . 8 5.3 Two-Valued Options . . . . . . 9

5.4 Three-Valued Options . . . . . 9

6 Relations Between Options 10 6.1 Option Priority . . . . . . . . . 10 6.2 Order Dependence . . . . . . . 10 6.3 dvips and pdftex . . . . . . . . . 10

7 Default Settings 11 7.1 Default Option . . . . . . . . . 11 7.2 Configuration File . . . . . . . 11

8 Examples 11

9 Acknowledgements 12

10 The Code 12

1 Preface to Version 2

This new release contains three major changes:

• The geometry options using the keyval scheme can be set in the optional argument to the \usepackage command as well as in the (mandatory) argument of the \geometry macro. Therefore, you can go

      \usepackage[scale={0.7,0.8},nohead]{geometry}

instead of

      \usepackage{geometry}
      \geometry{scale={0.7,0.8}, nohead}.

• Multiple use of \geometry macro is allowed. In the previous version \geometry command initialized layout dimensions before reading its options. In this release, however, \geometry just appends its options to the previously specified ones. Therefore,

      \usepackage[width=10cm, left=3cm]{geometry}
      \geometry{left=5cm}
      \geometry{vscale=0.8,nohead}

is equivalent to

         \usepackage[width=10cm, left=5cm, vscale=0.8, nohead]{geometry}.

If you want to reset layout dimensions and modes, you can use ‘reset’ option.

• The shortened control sequences for \paperwidth and \paperheight, \w and \h respectively, were removed.

2 Introduction

To set dimensions for page layout in L^{A}TEX is not straightforward. You need to adjust several L^{A}TEX dimensions to place a text area where you want. If you want to center the text area in the paper you use, for example, you have to specify L^{A}TEX dimensions as follows:

     \usepackage{calc}
     \setlength\textwidth{8in}
     \setlength\textheight{11in}
     \setlength\oddsidemargin{(\paperwidth-\textwidth)/2 - 1in}
     \setlength\topmargin{(\paperheight-\textheight
                            -\headheight-\headsep-\footskip)/2 - 1in}.

Without calc package, the above example would need more tedious settings. The geometry package provides an easy way to set page layout parameters. In this case, what you have to do is just

     \usepackage[body={8in,11in}]{geometry}.

In addition to this centering problem, setting margins from each edge of the paper is also troublesome. However, with geometry package, you can go

     \usepackage[margin=1.5in]{geometry}

if you want to set each margin 1.5in from each edge of the paper. In both cases, the remnant dimensions to be specified will be automatically determined. The package will be also useful when you have to set page layout obeying the following strict instructions: for example,

The total allowable width of the text area is 6.5 inches wide by 8.75 inches high. The first line on each page should begin 1.2 inches from the top edge of the page. The left margin should be 0.4 inch from the left edge.

In this case, using geometry package you can go

     \usepackage[body={6.5in,8.75in},
                 top=1.2in, left=0.4in, nohead]{geometry}.

Setting a text area on the paper in document preparation system has some analogy to placing a window on the background in the window system. The name ‘geometry’ comes from the -geometry option used for specifying a size and location of a window in X Window System.

3 Page Geometry

3.1 Layout Dimensions

To realize a straightforward setting for page layout, the following page structure is introduced: A paper contains a total body (printable area) and margins. The total body consists of a body (text area), a header, a footer and a marginal note which is optional. There are four margins: left-, right-, top- and bottom-margin.

paper : total-body (printable area) and margins
total-body : head, body(text area), foot and marginal notes (option)
margins : left-, right-, top- and bottom-margin

Dimension names used in this package

Parts  Horizontal  Vertical

                    paper  paperwidth          paperheight
                 total-body  width or totalwidth  height or totalheight
                     body  textwidth           textheight

left margin  left or lmargin  —
right margin  right or rmargin  —
top margin  —  top or tmargin
bottom margin  —  bottom or bmargin

                     head  —  headheight and
                                                  headsep

                      foot  —  footskip

marginal notes marginparwidth and

                              marginparsep

—

Table 1: Page geometry parts and dimension names used in this package.

     [figure: paper; total body; height; width; paperwidth; paperheight; top; bottom; left; right; total body; textwidth; headheight; headsep; textheight; footskip; head; body; foot]

Figure 1: Dimension names for page geometry. If includemp is false (default), width=textwidth.

Each margin is measured from the corresponding edge of a paper. For example, left-margin means a horizontal distance between the left edge of the paper and that of the total body. Therefore the left-margin and top-margin defined in the geometry package are different from the ordinary L^{A}TEX dimensions \leftmargin and \topmargin. The size of a body (text area) can be modified by

\textwidth and \textheight.

The layout parts and the corresponding dimension names used in this package are listed in Table 1 and showed schematically in Figure 1. The dimensions for paper, total body and margins have the following relations.

                        paperwidth = left + width + right  (1)
                       paperheight = top + height + bottom  (2)

The dimensions of the total body, width and height, are defined as follows:

               width := textwidth (+marginparsep + marginparwidth)  (3)
              height := textheight + headheight + headsep + footskip  (4)

Each of the seven dimensions in the right-hand side of Equations (3) and (4) corresponds to the ordinary L^{A}TEX control sequence with the same name.

Table 2 shows layout modes defined in the geometry package, which are used to control layout dimensions and change relations between them. Figure 2 illustrates various layouts of total body with different layout modes. For example, when includemp mode is on, width takes account of lengths for marginal notes (marginparsep and marginparwidth) in the Equation (3) (See Figure 2(b)).

Modes  Effects

         nohead  sets headheight=0pt, headsep=0pt.
         nofoot  sets footskip=0pt.
         noheadfoot  equals nohead and nofoot

includemp takes account of the dimensions for marginal notes when determining width:

                       width := textwidth + marginparsep + marginparwidth

reversemp makes the marginal notes appear in the left margin

                       and sets includemp unless includemp=false exists.

reversemarginpar results in the same effect.

Table 2: Layout modes defined in this package and their effects.

Settings  Results
left  width  right  left  width  right
top  height bottom  top  height bottom
*       *       *  m  ℓ  m  Default
A  *       *  A  R_{1}  A  Balancing
*       *  A  A  R_{1}  A  Balancing
*  A  *  ⟹  R_{2}  A  R_{2}  Centering
A  B  *  A  B  R_{3}
A  *  B  A  R_{3}  B
*  A  B  R_{3}  A  B
A  C  B  A  R_{3}  B  Margins win.

Table 3: Dimension completion rules. The mark ‘*’ denotes the dimensions not spec- ified. Each unspecified dimension will be given a proper value according the completion rule. See text for explanation of other symbols.

The dimensions for a header and a footer can be controlled by nohead or nofoot mode, as well as direct specification. The geometry package can also deal with standard layout modes (options), i.e.,

landscape, portrait, twoside and paper size.

3.2 Completion Algorithm

The automatic completion of layout dimension is a distinguishing feature of this package. Suppose that the paper size is pre-defined in Equation (1) or (2), if two dimensions out of three in the righthand side of each equation are given, the remnant dimension will be determined automatically. In addition, even when only one of three is given, the rest of dimensions will be determined using autobalancing or auto-centering scheme. The completion rules are shown in Table 3 and Equation (5). In Table 3, R_{n} (n=1, 2, 3) are the remnant lengths which can be determined by A, B and L (paperwidth or paperheight) according the following relations.

R_{1} = L − 2A  ⋯ auto-balancing
R_{2} = (L − A)/2 ⋯ auto-centering
R_{3} = L − A − B ⋯ obvious completion

(5)

If none of three dimensions is specified in each direction, the default setting is used: ℓ and m in horizontal direction are 80% and 10% of paperwidth respectively, 90% and 5% of paperheight vertically.

4 User Interface

4.1 General Features

The geometry options using the keyval interface ‘⟨key⟩=⟨value⟩’ can be set either in the optional argument to the \usepackage command, or in the argument of the \geometry macro. This macro, if necessary, should be placed in the preamble, i.e., before \begin{document}. In either case, the

             (a) default total body textwidth     headheight headsep textheight footskip head body foot  (b) includemp total body head body  marginal note foot textwidth   marginparwidth marginparsep (c) nohead total body textheight footskip body foot textwidth  (d) nohead,includemp total body body  marginal note foot textwidth   marginparwidth marginparsep

Figure 2: Sample layouts of total body with different layout modes. (a) default, (b) includemp, (c) nohead, and (d) nohead and includemp. Marginal note can be changed its placement from the right-hand to the left-hand side of the total body by reversemp. If both twoside and includemp are effective, marginal note will appear on the left (odd pages) and the right (even pages) by turns. Note that marginal notes can be printed even by default or includemp=false, but then the width of total body will not include that of marginal notes. argument consists of a list of comma-separated keyval options. The main features of setting options are listed below.

• Multiple lines are allowed. (But blank lines are not allowed.)

• Any spaces between words are ignored.

• Options are basically order-independent.

(There are some exceptions. See Section 6.2 for details.)

For example,

\usepackage[ a5paper ,  hmargin = { 3cm,
                .8in } , height
         =  10in ]{geometry}

is equivalent to

\usepackage[height=10in,a5paper,hmargin={3cm,0.8in}]{geometry}

Note that the order of values in the sub-list (e.g., hmargin={3cm,0.8in}) is significant. The above setting is equivalent to the followings:

\usepackage{geometry}
\geometry{height=10in,a5paper,hmargin={3cm,0.8in}}

or

\usepackage[a5paper]{geometry}
\geometry{hmargin={3cm,0.8in},height=8in}
\geometry{height=10in}.

Thus, multiple use of \geometry just appends options.

The geometry package supports the calc package^{1}. For example,

\usepackage{calc}
\usepackage[textheight=20\baselineskip+10pt]{geometry}

4.2 Option Types

There are five types of options:

1. Boolean type

takes a boolean value (true or false). If no value, true is set for default.

    ⟨key⟩=true false.

⟨key⟩ with no value is equivalent to ⟨key⟩=true.

Examples: verbose=true, nohead, twoside=false.

Paper name is the exception. The preferred paper name should be set with no values. Whatever value is given, it is ignored. For instance, a4paper=XXX is equivalent to a4paper.

2. Single-valued type

takes a mandatory value.

⟨key⟩=⟨value⟩.

Examples: width=8in, left=1.25in, footskip=1cm, height=.86\paperheight.

3. Two-valued type

takes a pair of comma-separated values in braces. The two values can be shortened to one value if they are identical.

⟨key⟩= {⟨value1 ⟩,⟨value2 ⟩}.

⟨key⟩=⟨value⟩ is equivalent to ⟨key⟩= {⟨value⟩,⟨value⟩}.

1CTAN:macros/latex/contrib/support/calc

Examples: hmargin={1.5in,1in}, scale=0.8, body={7in,10in}.

4. Three-valued type

takes three mandatory, comma-separated values in braces.

⟨key⟩= {⟨value1 ⟩,⟨value2 ⟩,⟨value3 ⟩}

Each value must be a dimension or null. When you give an empty value or ‘*’, it means null and leaves the appropriate value to the auto-calculation mechanism. One needs to specify at least one dimension, typically two dimensions. You can set nulls for all the values, but it makes no sense. Examples:

hdivide={2cm,*,1cm}, vdivide={3cm,19cm, }, divide={1in,*,1in}.

5 Option List

5.1 Boolean Options

Boolean options are also called ‘modes’. One can change various modes for page geometry. The boolean options are listed below.

verbose typeouts warnings and a list of resulted page parameters. landscape switches the paper orientation to landscape mode. portrait switches the paper orientation to portrait mode. This is equivalent to

landscape=false.

twoside switches on two-sided printing. includemp takes account of spaces for margin notes (\marginparwidth and \marginparsep)

when adjusting horizontal partition.

reversemp  reversemarginpar

makes the marginal notes appear in the left margin and sets includemp=true unless includemp=false has been set explicitly.

nohead eliminates spaces for the head of page, which is equivalent to \headheight=0pt and

\headsep=0pt.

nofoot eliminates spaces for the foot of page, which is equivalent to \footskip=0pt. noheadfoot eliminates spaces for the head and foot of page, which is equivalent to nohead and

nofoot, i.e., \headheight=0pt, \headsep=0pt and \footskip=0pt.

dvips writes the paper size in the PostScript output with the \special macro. If you use dvips as a DVI-to-PS driver, this option is very useful. For example, to print a document with \geometry{a3paper,landscape} on A3 paper in landscape mode, you don’t need options “-t a3 -t landscape” to dvips. This option is ineffective

and forced false if pdftex is true.
pdftex  sets \pdfoutput=1 and sets \pdfpagewidth and \pdfpageheight properly in the

\begin{document} if pdflatex command is used for typeset. When you use latex command with pdftex=true, this option is ineffective and forced to be false. If \pdfoutput=1 is already specified, this option is initialized to be true. You can set pdftex=false explicitly to output DVI, not PDF, when pdflatex is used. This option has priority over dvips.

a0paper, a1paper, a2paper, a3paper, a4paper, a5paper,
b0paper, b1paper, b2paper, b3paper, b4paper, b5paper,
letterpaper, executivepaper, legalpaper

specifies paper name. They must be used with no values. Note that whatever value (even false) is given to this option, the value will be ignored and the paper name is used. For example, the followings have the same effect: a5paper, a5paper=true,

a5paper=false and a5paper=XXXX.

reset initializes modes and layout dimensions to their defaults. Note that this option is ineffective against paper size (ex., a4paper) and lengths for header, footer and

marginal notes (ex., head, footskip, marginparwidth and so on). reset=false has

no effect and cannot cancel the previous reset(=true) if any.

Some of the above options may be given as document class options. For example, you can set

\documentclass[a4paper,landscape]{article}, then a4paper and landscape are processed in

the geometry package as well.

5.2 Single-Valued Options

The single-valued options with a mandatory value are listed below.

paper  papername

specifies a paper name. The available paper names are defined in the geometry package. paper=⟨paper name⟩. For example paper=a4paper, which is equivalent to just a4paper (see above).

paperwidth width of the paper. paperwidth=⟨paper width⟩. paperheight height of the paper. paperheight=⟨paper height⟩.

width  totalwidth

width of the total body. width=⟨width⟩ or totalwidth=⟨width⟩. This dimension should not be confused with textwidth. Generally, width ≥ textwidth because width includes the width of marginal notes when includemp or dimensions for marginal notes is set. If textwidth and width are specified at the same time, width is ignored.

height  totalheight

height of the total body (including header and footer). height=⟨height⟩ or totalheight=⟨height⟩. If both textheight and height are specified, height will be ignored.

left  lmargin

left margin of the total body. In other words, the distance between the left edge of the paper and that of the total body. left=⟨left margin⟩.

right  rmargin

right margin of the total body. right=⟨right margin⟩.

top  tmargin

top margin of the total body. top=⟨top margin⟩.

bottom  bmargin

bottom margin of the total body. bottom=⟨bottom margin⟩.

hscale ratio of width of the total body to \paperwidth. hscale=⟨h-ratio⟩. hscale=0.8 is

equivalent to width=0.8\paperwidth.

vscale ratio of height of the total body to \paperheight. vscale=⟨v-ratio⟩. vscale=0.9 is

equivalent to height=0.9\paperheight.

textwidth modifies \textwidth, width of text (body). textwidth=⟨width⟩. textheight modifies \textheight, height of text (body). textheight=⟨height⟩.

marginparwidth  marginpar

modifies \marginparwidth, width of the marginal notes. When this option is set, includemp is also set true automatically. marginparwidth=⟨length⟩.

marginparsep

modifies \marginparsep, separation between body and marginal notes. includemp is also set true automatically. marginparsep=⟨length⟩.

headheight  head

modifies \headheight, height of header. headheight=⟨length⟩ or head=⟨length⟩.

headsep modifies \headsep, separation between header and text (body). headsep=⟨length⟩.

footskip  foot

modifies \footskip, distance separation between baseline of last line of text and baseline of footer. footskip=⟨length⟩ or foot=⟨length⟩.

hoffset  modifies \hoffset. hoffset=⟨length⟩.
voffset  modifies \voffset. voffset=⟨length⟩.

[figure: paper; total body; -twosideshift; twosideshift; even pages; odd pages]

Figure 3: twosideshift option.

twosideshift

specifies extra space which is added to left-margin of odd-numbered pages and subtracted from that of even-numbered pages. twoside mode is also set. twosideshift=⟨length⟩. The default is 20pt. See Figure 3.

5.3 Two-Valued Options

The following list shows keys taking two values in braces or one value for short.

papersize width and height of the paper.

papersize= {⟨width⟩,⟨height⟩} or papersize=⟨length⟩.

total width and height of the total body.

total= {⟨width⟩,⟨height⟩} or total=⟨length⟩.

body text textwidth and textheight of the body of page.

body= {⟨width⟩,⟨height⟩} or body=⟨length⟩.

scale ratio of the total body length to the paper’s.

scale= {⟨h-ratio⟩,⟨v-ratio⟩} or scale=⟨ratio⟩.

hmargin left and right margin.

hmargin= {⟨left margin⟩,⟨right margin⟩} or hmargin=⟨length⟩.

vmargin top and bottom margin.

vmargin= {⟨top margin⟩,⟨bottom margin⟩} or vmargin=⟨length⟩.

margin      margin= {A,B} is equivalent to hmargin= {A,B} and vmargin= {A,B}. margin=A

is automatically expanded to hmargin=A and vmargin=A.

offset horizontal and vertical offset.

offset= {⟨hoffset⟩,⟨voffset⟩} or offset=⟨length⟩.

5.4 Three-Valued Options

The keys taking three comma-separated values in braces are listed below.

hdivide horizontal partitions (left,width,right).

hdivide= {⟨left margin⟩,⟨width⟩,⟨right margin⟩}. Note that you should not specify all of the three parameters. The best way of using this option is to specify two of three and leave the rest with null(nothing) or ‘*’. For example, when you set hdivide={2cm,15cm, }, the margin from the rightside edge of page will be determined calculating paperwidth-2cm-15cm.

vdivide vertical partitions (top,height,bottom).

vdivide= {⟨top margin⟩,⟨height⟩,⟨bottom margin⟩}.

divide      divide= {A,B,C} is interpreted as hdivide= {A,B,C} and vdivide= {A,B,C}.

6 Relations Between Options

6.1 Option Priority

low ⟶ high (priority)

                   • \{ \begin{matrix}hscale \\ vscale \end{matrix} \} < \{ \begin{matrix}width \\ height \end{matrix} \} < \{ \begin{matrix}textwidth \\ textheight \end{matrix} \} ,

                   • \{ \begin{matrix}head(height) \\ headsep \\ foot(skip) \end{matrix} \} < \{ \begin{matrix}nohead \\ nofoot \\ noheadfoot \end{matrix} \} ,

                   • dvips < pdftex.

For example,

     \usepackage[hscale=0.8, textwidth=7in, width=18cm]{geometry}

is the same as

     \usepackage[textwidth=7in]{geometry}.

6.2 Order Dependence

The options defined in the geometry package are basically order-independent, but there are some exceptions. When redundant, overlap specification is given, the last setting is adopted. For example,

     verbose=true, verbose=false

obviously results in verbose=false. If you set

     hmargin={3cm,2cm}, left=1cm

the left-margin is overwritten by left=1cm. As a result, it is equivalent to hmargin={1cm,2cm}. The reset option initializes all the modes and settings for page layout. If you set

     \documentclass[a4paper,landscape]{article}
     \usepackage[margins=1cm,nohead]{geometry}
     \geometry{reset, head=20pt}
then landscape, margins=1cm and nohead are ignored and head=20pt is set. Note that reset can’t

initialize paper size (a4paper in this case).

6.3 dvips and pdftex

The options dvips and pdftex are provided for driver support. They may be used for other packages that support them. In the geometry package, the pdftex option has priority over dvips. The table below shows relations between the typeset command, \pdfoutput and effective values for each driver option.

                             command  pdftex  dvips

latex  false any

                             pdflatex  true   false
                                         false any

where ‘any’ means that one can choose true or false. When pdflatex command is used for typeset, the default value of the pdftex option is dependent upon the value of \pdfoutput: true if

\pdfoutput=1, and false otherwise.

7 Default Settings

7.1 Default Option

The default option is

scale={0.8,0.9}.

Other layout parameters, such as paper size, orientation and lengths for header and footer, are set as defined in the documentclass you use. If you just go \usepackage{geometry} in the preamble, the package will set the default layout. Additional options will overwrite the layout dimensions. For example,

\usepackage[ hmargin=2cm ]{geometry}

will overwrite horizontal dimensions, but use the default for vertical layout.

7.2 Configuration File

You can set up a configuration file to make default options. To do this, produce a file geometry.cfg containing an \ExecuteOptions macro, for example,

\ExecuteOptions{a4paper,dvips}

and install it somewhere TEX can find it.

8 Examples

• Set the width of the total body to be 70% that of the paper. The total body is then centered horizontally. The following settings (each line) result in the same effect.

– hscale=0.7,
– width=0.7\paperwidth,
– hdivide={*,0.7\paperwidth,*},
– hmargin=0.15\paperwidth,
– left=0.15\paperwidth,
– left = .15\paperwidth, right= 0.15\paperwidth,
– rmargin= .15\paperwidth.

For vertical layout, in this case, the default is used: vscale=0.9.

• Set the height of the total body to be 10in, the bottom-margin 3cm, and the width default. Then the top-margin will be calculated in the package.

– height=10in,bottom=2cm,
– bmargin = 2cm ,totalheight= 10in,
– vdivide  = { *, 10in ,2cm },

and so on.

• Set the left-, right-, and top-margin 3cm, 2cm and 2.5in respectively. The page header is not used. The body is 40 lines of text in height.

– left=3cm,right=2cm, nohead,
               top=2.5in, textheight=40\baselineskip,
– hmargin={3cm, 2cm}, head=0pt, headsep=0pt
           tmargin=2.5in, textheight=40\baselineskip,

and so on.

• Modify the width of marginal notes to 3cm and include marginal notes when adjusting horizontal partition

– marginpar=3cm,
– marginparwidth=3cm.

In this case, includemp is not necessary because it is set automatically when dimension(s) for marginal note are specified.

– marginpar=3cm, reversemp

makes the marginal notes appear in the left margin.

• Use A5 paper in landscape mode and a full scale of the paper as the body.

– a5paper, landscape, scale=1.0 , noheadfoot,
– landscape = TRUE, paper=a5paper, noheadfoot,
             total={\paperwidth,\paperheight},

and so on.

• Get PDF output using pdflatex command for typeset.

% pdflatex foo

with

\documentclass[pdftex]{article}
\usepackage{geometry}

or

\documentclass{article}
\usepackage[pdftex]{geometry}

is equivalent to

% pdflatex '\pdfoutput=1 \input{foo}'

with

\documentclass{article}
\usepackage{geometry}.

9 Acknowledgements

I would like to thank Friedrich Flender, Piet van Oostrum and Keith Reckdahl for their pointing out bugs and suggesting improvements. I would like to thank Frank Bennett for many helpful comments.

10 The Code

1 ⟨∗package⟩

This package requires David Carlisle’s keyval package.

2 \RequirePackage{keyval}

Internal switches are declared here.

3 \newif\ifGeom@verbose
4 \newif\ifGeom@landscape
5 \newif\ifGeom@nohead
6 \newif\ifGeom@nofoot
7 \newif\ifGeom@includemp
8 \newif\ifGeom@passincmp
9 \newif\ifGeom@hbody
10 \newif\ifGeom@vbody
11 \newif\ifGeom@dvips
12 \newif\ifGeom@pdftex

\geom@cnth \geom@cntv Counters for horizontal and vertical partitioning patterns.

13 \newcount\geom@cnth
14 \newcount\geom@cntv

\geom@warning Macor for printing warning messages.

15 \def\geom@warning#1{%
16 \ifGeom@verbose\PackageWarningNoLine{geometry}{#1}\fi}

\Geom@Dhscale \Geom@Dvscale \Geom@Dtwosideshift The default values for the horizontal and vertical scale, and twosideshift are defined.

17 \def\Geom@Dhscale{0.8}
18 \def\Geom@Dvscale{0.9}
19 \def\Geom@Dtwosideshift{20pt}

\geom@init The macro for initializing modes and flags is defined here. This macro is called when geometry package is loaded and when reset option is specified.

20 \def\geom@init{%
21 \Geom@hbodyfalse
22 \Geom@vbodyfalse
23 \let\Geom@width\undefined
24 \let\Geom@height\undefined
25 \let\Geom@textwidth\undefined
26 \let\Geom@textheight\undefined
27 \let\Geom@hscale\undefined
28 \let\Geom@vscale\undefined
29 \let\Geom@lmargin\undefined
30 \let\Geom@rmargin\undefined
31 \let\Geom@tmargin\undefined
32 \let\Geom@bmargin\undefined
33 \def\Geom@twosideshift{\Geom@Dtwosideshift}%
34 \@twosidefalse
35 \@mparswitchfalse
36 \Geom@verbosefalse
37 \Geom@landscapefalse
38 \Geom@noheadfalse
39 \Geom@nofootfalse
40 \Geom@includempfalse
41 \Geom@passincmpfalse
42 \Geom@dvipsfalse
43 \geom@initpdftex}

\geom@initpdftex This macro initializes Geom@pdftex switch, which appears in \geom@init macro.

44 \def\geom@initpdftex{%
45 \ifx\undefined\pdfpagewidth
46 \Geom@pdftexfalse
47 \else
48 \ifnum\pdfoutput=1\relax\Geom@pdftextrue\else\Geom@pdftexfalse\fi
49 \fi}

\geom@setbool Macro for setting boolean options.

50 \def\geom@setbool#1#2{%
51 \csname #2\ifx\relax#1\relax true\else#1\fi\endcsname}

\geom@checkbool Macro used in \geom@showparams to print ‘true’ or nothing.

52 \def\geom@checkbool#1{%
53 \csname ifGeom@#1\endcsname #1\space\else\fi}

\geom@detiv This macro determines the fourth length(#4) from #1(paperwidth or paperheight), #2 and #3. It is

used in \geom@detall macro.
54 \def\geom@detiv#1#2#3#4{% determine #4.
55 \setlength\@tempdima{\@nameuse{paper#1}}%
56 \setlength\@tempdimb{\@nameuse{Geom@#2}}%
57 \addtolength\@tempdima{-\@tempdimb}%
58 \setlength\@tempdimb{\@nameuse{Geom@#3}}%
59 \addtolength\@tempdima{-\@tempdimb}%
60 \ifdim\@tempdima<\z@
61  \geom@warning{`#4' results in NEGATIVE (\the\@tempdima).%
62  ^^J\@spaces Parameters of `#2' and `#3' should be shortened}%
63 \fi
64 \expandafter\edef\csname Geom@#4\endcsname{\the\@tempdima}}

\geom@detiiandiii This macro determines #2 and #3 from #1. The first argument can be width or height, which is expanded into dimensions of paper and total body. It is used in \geom@detall macro.

65 \def\geom@detiiandiii#1#2#3{% determine #2 and #3.
66 \setlength\@tempdima{\@nameuse{paper#1}}%
67 \setlength\@tempdimb{\@nameuse{Geom@#1}}%
68 \addtolength\@tempdima{-\@tempdimb}%
69 \divide\@tempdima\tw@
70 \ifdim\@tempdima<\z@
71  \geom@warning{`#2' and `#3' result in NEGATIVE (\the\@tempdima).%
72  ^^J\@spaces Parameter for `#1' should be shortened}%
73 \fi
74 \expandafter\edef\csname Geom@#2\endcsname{\the\@tempdima}%
75 \expandafter\edef\csname Geom@#3\endcsname{\the\@tempdima}}

\geom@detall This macro determines partition of each direction. The first argument is h or v.

76 \def\geom@detall#1#2#3#4{%
77 \@tempcnta\z@
78 \if#1h
79  \ifx\undefined\Geom@lmargin\else\advance\@tempcnta4\relax\fi
80  \ifGeom@hbody\advance\@tempcnta2\relax\fi
81  \ifx\undefined\Geom@rmargin\else\advance\@tempcnta1\relax\fi
82  \geom@cnth\@tempcnta
83 \else
84  \ifx\undefined\Geom@tmargin\else\advance\@tempcnta4\relax\fi
85  \ifGeom@vbody\advance\@tempcnta2\relax\fi
86  \ifx\undefined\Geom@bmargin\else\advance\@tempcnta1\relax\fi
87  \geom@cntv\@tempcnta
88 \fi
89 \ifcase\@tempcnta               % 0:(*,*,*)
90  \if#1h
91  \edef\Geom@width{\Geom@Dhscale\paperwidth}%
92  \else
93  \edef\Geom@height{\Geom@Dvscale\paperheight}%
94  \fi
95  \geom@detiiandiii{#2}{#3}{#4}%
96 \or                             % 1:(*,*,S) goto (5)
97  \geom@warning{`#3' was forced to equal `#4'}%
98  \expandafter\edef\csname Geom@#3\endcsname{\@nameuse{Geom@#4}}%
99  \geom@detiv{#2}{#3}{#4}{#2}%
100 \or\geom@detiiandiii{#2}{#3}{#4}% 2:(*,S,*)
101 \or\geom@detiv{#2}{#2}{#4}{#3}  % 3:(*,S,S)
102 \or                             % 4:(S,*,*) goto (5)
103  \geom@warning{`#4' was forced to equal `#3'}%
104  \expandafter\edef\csname Geom@#4\endcsname{\@nameuse{Geom@#3}}%
105  \geom@detiv{#2}{#3}{#4}{#2}%
106 \or\geom@detiv{#2}{#3}{#4}{#2}  % 5:(S,*,S)
107 \or\geom@detiv{#2}{#2}{#3}{#4}  % 6:(S,S,*)
108 \or                             % 7:(S,S,S) goto (5)
109  \geom@warning{Redundant specification in `#1'-direction.%
110  ^^J\@spaces `#2' (\@nameuse{Geom@#2}) is ignored}%
111  \geom@detiv{#2}{#3}{#4}{#2}%
112 \else\fi}

\geom@clean Macro for setting unspecified dimensions to be \undefined. This is used by \geometry macros.

113 \def\geom@clean{%
114 \ifnum\geom@cnth<4\let\Geom@lmargin\undefined\fi
115 \ifodd\geom@cnth\else\let\Geom@rmargin\undefined\fi
116 \ifnum\geom@cntv<4\let\Geom@tmargin\undefined\fi
117 \ifodd\geom@cntv\else\let\Geom@bmargin\undefined\fi
118 \ifGeom@hbody\else
119  \let\Geom@hscale\undefined
120  \let\Geom@width\undefined

121  \let\Geom@textwidth\undefined
122 \fi
123 \ifGeom@vbody\else
124  \let\Geom@vscale\undefined
125  \let\Geom@height\undefined
126  \let\Geom@textheight\undefined
127 \fi}
\geom@parse@divide Macro for parsing (h,v)divide options.
128 \def\geom@parse@divide#1#2#3#4{%
129 \def\Geom@star{*}%
130 \@tempcnta\z@
131 \@for\Geom@tmp:=#1\do{%
132  \expandafter\KV@@sp@def\expandafter\Geom@frag\expandafter{\Geom@tmp}%
133  \edef\Geom@value{\Geom@frag}%
134  \ifcase\@tempcnta\relax% cnta == 0
135  \edef\Geom@key{#2}%
136  \or    \edef\Geom@key{#3}%
137  \else  \edef\Geom@key{#4}%
138  \fi
139  \@nameuse{Geom@set\Geom@key false}%
140  \ifx\empty\Geom@value\else
141  \ifx\Geom@star\Geom@value\else
142  \setkeys{Geom}{\Geom@key=\Geom@value}%
143  \fi\fi
144  \advance\@tempcnta\@ne}%
145 \let\Geom@star\relax}

\geom@branch Macro for branching an option’s value into the same two values.

146 \def\geom@branch#1#2#3{%
147 \@tempcnta\z@
148 \@for\Geom@tmp:=#1\do{%
149  \KV@@sp@def\Geom@frag{\Geom@tmp}%
150  \edef\Geom@value{\Geom@frag}%
151  \ifcase\@tempcnta\relax% cnta == 0
152  \setkeys{Geom}{#2=\Geom@value}%
153  \or% cnta == 1
154  \setkeys{Geom}{#3=\Geom@value}%
155  \else\fi
156  \advance\@tempcnta\@ne}%
157 \ifnum\@tempcnta=\@ne
158  \setkeys{Geom}{#2=\Geom@value}%
159  \setkeys{Geom}{#3=\Geom@value}%
160 \fi}
\geom@setpaper
161 \def\geom@setpaper(#1,#2){\setlength\paperwidth{#1}%
162  \setlength\paperheight{#2}}

Various paper size are defined here.

163 \@namedef{Geom@a0paper}{\geom@setpaper(841mm,1189mm)}
164 \@namedef{Geom@a1paper}{\geom@setpaper(595mm,841mm)}
165 \@namedef{Geom@a2paper}{\geom@setpaper(420mm,595mm)}
166 \@namedef{Geom@a3paper}{\geom@setpaper(297mm,420mm)}
167 \@namedef{Geom@a4paper}{\geom@setpaper(210mm,297mm)}
168 \@namedef{Geom@a5paper}{\geom@setpaper(149mm,210mm)}
169 \@namedef{Geom@b0paper}{\geom@setpaper(1000mm,1414mm)}
170 \@namedef{Geom@b1paper}{\geom@setpaper(707mm,1000mm)}
171 \@namedef{Geom@b2paper}{\geom@setpaper(500mm,707mm)}
172 \@namedef{Geom@b3paper}{\geom@setpaper(353mm,500mm)}
173 \@namedef{Geom@b4paper}{\geom@setpaper(250mm,353mm)}
174 \@namedef{Geom@b5paper}{\geom@setpaper(176mm,250mm)}

175 \@namedef{Geom@letterpaper}{\geom@setpaper(8.5in,11in)}
176 \@namedef{Geom@legalpaper}{\geom@setpaper(8.5in,14in)}
177 \@namedef{Geom@executivepaper}{\geom@setpaper(7.25in,10.5in)}

The option keys are defined below.

`paper' paper takes paper name as its value. Available paper names are listed below.

178 \define@key{Geom}{paper}{\setkeys{Geom}{#1}}
`a[0-5]paper' `b[0-5]paper' `letterpaper' `legalpaper' `executivepaper' Thirteen standard paper names are available.
179 \define@key{Geom}{a0paper}[true]{\def\Geom@paper{a0paper}}
180 \define@key{Geom}{a1paper}[true]{\def\Geom@paper{a1paper}}
181 \define@key{Geom}{a2paper}[true]{\def\Geom@paper{a2paper}}
182 \define@key{Geom}{a3paper}[true]{\def\Geom@paper{a3paper}}
183 \define@key{Geom}{a4paper}[true]{\def\Geom@paper{a4paper}}
184 \define@key{Geom}{a5paper}[true]{\def\Geom@paper{a5paper}}
185 \define@key{Geom}{b0paper}[true]{\def\Geom@paper{b0paper}}
186 \define@key{Geom}{b1paper}[true]{\def\Geom@paper{b1paper}}
187 \define@key{Geom}{b2paper}[true]{\def\Geom@paper{b2paper}}
188 \define@key{Geom}{b3paper}[true]{\def\Geom@paper{b3paper}}
189 \define@key{Geom}{b4paper}[true]{\def\Geom@paper{b4paper}}
190 \define@key{Geom}{b5paper}[true]{\def\Geom@paper{b5paper}}
191 \define@key{Geom}{letterpaper}[true]{\def\Geom@paper{letterpaper}}
192 \define@key{Geom}{legalpaper}[true]{\def\Geom@paper{legalpaper}}
193 \define@key{Geom}{executivepaper}[true]{\def\Geom@paper{executivepaper}}
`papersize'
`paperwidth'
`paperheight'

194 \define@key{Geom}{papersize}{\geom@branch{#1}{paperwidth}{paperheight}}
195 \define@key{Geom}{paperwidth}{\setlength\paperwidth{#1}%
196  \let\Geom@paper\undefined}
197 \define@key{Geom}{paperheight}{\setlength\paperheight{#1}%
198  \let\Geom@paper\undefined}
`total' `width' `height'
199 \define@key{Geom}{total}{\geom@branch{#1}{width}{height}}
200 \define@key{Geom}{width}{\Geom@hbodytrue\edef\Geom@width{#1}}
201 \define@key{Geom}{height}{\Geom@vbodytrue\edef\Geom@height{#1}}
`body'
`textwidth'
`textheight'

202 \define@key{Geom}{body}{\geom@branch{#1}{textwidth}{textheight}}
203 \define@key{Geom}{textwidth}{\Geom@hbodytrue\edef\Geom@textwidth{#1}}
204 \define@key{Geom}{textheight}{\Geom@vbodytrue\edef\Geom@textheight{#1}}
`scale' `hscale' `vscale'
205 \define@key{Geom}{scale}{\geom@branch{#1}{hscale}{vscale}}
206 \define@key{Geom}{hscale}{\Geom@hbodytrue\edef\Geom@hscale{#1}}
207 \define@key{Geom}{vscale}{\Geom@vbodytrue\edef\Geom@vscale{#1}}
`margin'
`hmargin'
`vmargin'
`lmargin'
`rmargin'
`tmargin'
`bmargin'

208 \define@key{Geom}{margin}{\geom@branch{#1}{lmargin}{tmargin}%
209  \geom@branch{#1}{rmargin}{bmargin}}
210 \define@key{Geom}{hmargin}{\geom@branch{#1}{lmargin}{rmargin}}
211 \define@key{Geom}{vmargin}{\geom@branch{#1}{tmargin}{bmargin}}
212 \define@key{Geom}{lmargin}{\edef\Geom@lmargin{#1}}
213 \define@key{Geom}{rmargin}{\edef\Geom@rmargin{#1}}
214 \define@key{Geom}{tmargin}{\edef\Geom@tmargin{#1}}
215 \define@key{Geom}{bmargin}{\edef\Geom@bmargin{#1}}

`divide' `hdivide' `vdivide' Provide useful ways to partition each direction of paper.

216 \define@key{Geom}{divide}{\geom@parse@divide{#1}{lmargin}{width}{rmargin}%
217  \geom@parse@divide{#1}{tmargin}{height}{bmargin}}
218 \define@key{Geom}{hdivide}{\geom@parse@divide{#1}{lmargin}{width}{rmargin}}
219 \define@key{Geom}{vdivide}{\geom@parse@divide{#1}{tmargin}{height}{bmargin}}

`offset' `hoffset' `voffset'
220 \define@key{Geom}{offset}{\geom@branch{#1}{hoffset}{voffset}}
221 \define@key{Geom}{hoffset}{\setlength\hoffset{#1}}
222 \define@key{Geom}{voffset}{\setlength\voffset{#1}}
`headheight'
`headsep'
`footskip'

223 \define@key{Geom}{headheight}{\Geom@noheadfalse\setlength\headheight{#1}}
224 \define@key{Geom}{headsep}{\Geom@noheadfalse\setlength\headsep{#1}}
225 \define@key{Geom}{footskip}{\Geom@nofootfalse\setlength\footskip{#1}}
`marginparwidth'
`marginparsep'
226 \define@key{Geom}{marginparwidth}%
227  {\ifGeom@passincmp\else\Geom@includemptrue\fi%
228  \setlength\marginparwidth{#1}}
229 \define@key{Geom}{marginparsep}%
230  {\ifGeom@passincmp\else\Geom@includemptrue\fi%
231  \setlength\marginparsep{#1}}
`verbose'
`reset'
`includemp'
`reversemp'
`reversemarginpar'
`twoside'
`twosideshift'
`nohead'
`nofoot'
`noheadfoot'
`landscape'
`portrait'
`dvips'
`pdftex'

232 \define@key{Geom}{verbose}[true]{%
233  \lowercase{\geom@setbool{#1}}{Geom@verbose}}
234 \define@key{Geom}{reset}[true]{%
235  \lowercase{\expandafter\csname if#1\endcsname\geom@init\fi}}
236 \define@key{Geom}{includemp}[true]{%
237  \Geom@passincmptrue
238  \lowercase{\geom@setbool{#1}}{Geom@includemp}}
239 \define@key{Geom}{reversemp}[true]{%
240  \ifGeom@passincmp\else\Geom@includemptrue\fi%
241  \lowercase{\geom@setbool{#1}}{@reversemargin}}
242 \define@key{Geom}{reversemarginpar}[true]{%
243  \ifGeom@passincmp\else\Geom@includemptrue\fi%
244  \lowercase{\geom@setbool{#1}}{@reversemargin}}
245 \define@key{Geom}{twoside}[true]{%
246  \lowercase{\geom@setbool{#1}}{@twoside}%
247  \lowercase{\geom@setbool{#1}}{@mparswitch}}
248 \define@key{Geom}{twosideshift}{\@twosidetrue\def\Geom@twosideshift{#1}}
249 \define@key{Geom}{nohead}[true]{%
250  \lowercase{\geom@setbool{#1}}{Geom@nohead}}
251 \define@key{Geom}{nofoot}[true]{%
252  \lowercase{\geom@setbool{#1}}{Geom@nofoot}}
253 \define@key{Geom}{noheadfoot}[true]{%
254  \lowercase{\geom@setbool{#1}}{Geom@nohead}%
255  \lowercase{\geom@setbool{#1}}{Geom@nofoot}}
256 \define@key{Geom}{landscape}[true]{%
257  \lowercase{\geom@setbool{#1}}{Geom@landscape}}
258 \define@key{Geom}{portrait}[true]{%
259  \lowercase{\expandafter\csname if#1\endcsname
260  \Geom@landscapefalse\else\Geom@landscapetrue\fi}}
261 \define@key{Geom}{dvips}[true]{%
262  \lowercase{\geom@setbool{#1}}{Geom@dvips}}
263 \define@key{Geom}{pdftex}[true]{%
264  \lowercase{\geom@setbool{#1}}{Geom@pdftex}}
`papername' `totalwidth' `totalheight' `text' `left' `right' `top' `bottom' `head' `foot' `marginpar' The key aliases are defined.
265 \let\KV@Geom@papername\KV@Geom@paper
266 \let\KV@Geom@totalwidth\KV@Geom@width
267 \let\KV@Geom@totalheight\KV@Geom@height
268 \let\KV@Geom@text\KV@Geom@body
269 \let\KV@Geom@left\KV@Geom@lmargin
270 \let\KV@Geom@right\KV@Geom@rmargin
271 \let\KV@Geom@top\KV@Geom@tmargin
272 \let\KV@Geom@bottom\KV@Geom@bmargin

273 \let\KV@Geom@head\KV@Geom@headheight
274 \let\KV@Geom@foot\KV@Geom@footskip
275 \let\KV@Geom@marginpar\KV@Geom@marginparwidth

\geom@process The main macro processing specified layout dimensions is defined.

276 \def\geom@process{
277 \ifx\undefined\Geom@paper\else\@nameuse{Geom@\Geom@paper}\fi
278 \ifGeom@landscape
279  \setlength\@tempdima{\paperwidth}%
280  \setlength\paperwidth{\paperheight}%
281  \setlength\paperheight{\@tempdima}%
282 \fi
283 \ifGeom@nohead
284  \setlength\headheight{0pt}%
285  \setlength\headsep{0pt}%
286 \fi
287 \ifGeom@nofoot
288  \setlength\footskip{0pt}%
289 \fi
290 \ifGeom@hbody
291  \ifx\undefined\Geom@width
292  \ifx\undefined\Geom@hscale
293  \edef\Geom@width{\Geom@Dhscale\paperwidth}%
294  \else
295  \edef\Geom@width{\Geom@hscale\paperwidth}%
296  \fi
297  \fi
298  \ifx\undefined\Geom@textwidth\else
299  \setlength\@tempdima{\Geom@textwidth}%
300  \ifGeom@includemp
301  \addtolength\@tempdima{\marginparwidth}%
302  \addtolength\@tempdima{\marginparsep}%
303  \fi
304  \edef\Geom@width{\the\@tempdima}%
305  \fi
306 \fi
307 \ifGeom@vbody
308  \ifx\undefined\Geom@height%
309  \ifx\undefined\Geom@vscale%
310  \edef\Geom@height{\Geom@Dvscale\paperheight}%
311  \else
312  \edef\Geom@height{\Geom@vscale\paperheight}%
313  \fi
314  \fi
315  \ifx\undefined\Geom@textheight\else%
316  \setlength\@tempdima{\Geom@textheight}%
317  \addtolength\@tempdima{\headheight}%
318  \addtolength\@tempdima{\headsep}%
319  \addtolength\@tempdima{\footskip}%
320  \edef\Geom@height{\the\@tempdima}%
321  \fi
322 \fi
323 \geom@detall{h}{width}{lmargin}{rmargin}%
324 \geom@detall{v}{height}{tmargin}{bmargin}%
325 \setlength\textwidth{\Geom@width}%
326 \setlength\textheight{\Geom@height}%
327 \setlength\topmargin{\Geom@tmargin}%
328 \setlength\oddsidemargin{\Geom@lmargin}%
329 \ifGeom@includemp
330  \addtolength\textwidth{-\marginparwidth}%
331  \addtolength\textwidth{-\marginparsep}%
332  \if@reversemargin
333  \addtolength\oddsidemargin{\marginparwidth}%

334  \addtolength\oddsidemargin{\marginparsep}%
335  \fi
336 \fi
337 \addtolength\textheight{-\headheight}%
338 \addtolength\textheight{-\headsep}%
339 \addtolength\textheight{-\footskip}%
340 \addtolength\topmargin{-1in}%
341 \addtolength\oddsidemargin{-1in}%
342 \if@twoside
343  \setlength\evensidemargin{\Geom@rmargin}%
344  \addtolength\evensidemargin{-1in}%
345  \setlength\@tempdima{\Geom@twosideshift}%
346  \addtolength\oddsidemargin{\@tempdima}%
347  \addtolength\evensidemargin{-\@tempdima}%
348  \ifGeom@includemp
349  \if@mparswitch
350  \setlength\@tempdima{\marginparwidth}%
351  \addtolength\@tempdima{\marginparsep}%
352  \addtolength\evensidemargin{\@tempdima}%
353  \if@reversemargin
354  \addtolength\evensidemargin{-\marginparwidth}%
355  \addtolength\evensidemargin{-\marginparsep}%
356  \fi
357  \fi
358  \fi
359 \else
360  \setlength\evensidemargin{\oddsidemargin}%
361 \fi}

\geom@showparam The macro for typeout of geometry status and L^{A}TEX layout dimensions.

362 \def\geom@showparams{%
363 \typeout{----------------------- Geometry parameters^^J%
364 mode: %
365 \ifx\undefined\Geom@paper\else
366  \Geom@paper\space
367 \fi
368 \geom@checkbool{landscape}%
369 \geom@checkbool{nohead}%
370 \geom@checkbool{nofoot}%
371 \geom@checkbool{includemp}%
372 \if@reversemargin reversemp\space\fi%
373 \if@twoside twoside\space\fi%
374 \geom@checkbool{dvips}%
375 \geom@checkbool{pdftex}^^J%
376 h-parts: \Geom@lmargin, \Geom@width, \Geom@rmargin%
377 \ifnum\geom@cnth=\z@\space(default)\fi^^J%
378 v-parts: \Geom@tmargin, \Geom@height, \Geom@bmargin%
379 \ifnum\geom@cntv=\z@\space(default)\fi^^J%
380 \if@twoside
381  twosideshift: \Geom@twosideshift^^J%
382 \fi
383 ----------------------- Page layout dimensions^^J%
384 \string\paperwidth\space\space\the\paperwidth^^J%
385 \string\paperheight\space\the\paperheight^^J%
386 \string\textwidth\space\space\the\textwidth^^J%
387 \string\textheight\space\the\textheight^^J%
388 \string\oddsidemargin\space\space\the\oddsidemargin^^J%
389 \string\evensidemargin\space\the\evensidemargin^^J%
390 \string\topmargin\space\space\the\topmargin^^J%
391 \string\headheight\space\the\headheight^^J%
392 \string\headsep\@spaces\the\headsep^^J%
393 \string\footskip\space\space\space\the\footskip^^J%
394 \ifGeom@includemp

395  \string\marginparwidth\space\the\marginparwidth^^J%
396  \string\marginparsep\space\space\space\the\marginparsep^^J%
397 \fi
398 \string\hoffset\space\the\hoffset^^J%
399 \string\voffset\space\the\voffset^^J%
400 (1in=72.27pt, 1cm=28.45pt)^^J%
401 -----------------------}}

Paper size is initialized only once here.

402 \let\Geom@paper\undefined

\geom@setkey \ExecuteOptions is replaced with \geom@setkey to make it possible to deal with ‘key=value’ as its argument.

403 \def\geom@setkey{\setkeys{Geom}}
404 \let\geom@origExecuteOptions\ExecuteOptions
405 \let\ExecuteOptions\geom@setkey

reset option is executed.

406 \ExecuteOptions{reset}

A local configuration file may define more options. To set A4 paper as default, geometry.cfg needs

 to contain \ExecuteOptions{a4paper}.
407 \InputIfFileExists{geometry.cfg}{}{}

The original definition for \ExecuteOptions macro is restored.

408 \let\ExecuteOptions\geom@origExecuteOptions

\ProcessOptionsWithKV This macros can process package options using ‘key=value’ scheme. The code was borrowed from the hyperref package written by Sebastian Rahtz.

409 \def\ProcessOptionsWithKV#1{%
410 \let\@tempa\@empty
411 \@for\CurrentOption:=\@classoptionslist\do{%
412  \@ifundefined{KV@#1@\CurrentOption}%
413  {}{\edef\@tempa{\@tempa,\CurrentOption,}}}%
414 \edef\@tempa{%
415  \noexpand\setkeys{#1}{\@tempa\@ptionlist{\@currname.\@currext}}}%
416 \@tempa
417 \AtEndOfPackage{\let\@unprocessedoptions\relax}}

The optional arguments to \usepackage and \documentclass macros are processed here.

418 \ProcessOptionsWithKV{Geom}

Actual setting and calculation of layout dimensions are here.

419 \geom@process
    The verbose, pdftex and dvips options are checked in \AtBeginDocument.
420 \AtBeginDocument{%
421 \ifx\undefined\pdfpagewidth % latex command is used.
422  \Geom@pdftexfalse
423 \else                       % pdflatex command is used
424  \ifGeom@pdftex\Geom@dvipsfalse\fi
425 \fi
426 \ifGeom@dvips
427  \AtBeginDvi{\special{%
428  papersize=\the\paperwidth,\the\paperheight}}%
429 \fi
430 \ifGeom@pdftex
431  \pdfoutput=1\relax
432  \pdfpagewidth=\the\paperwidth
433  \pdfpageheight=\the\paperheight
434 \fi

if verbose, the page geometry parameters and options are displayed.

435 \ifGeom@verbose
436  \geom@showparams
437 \fi}

\geometry The user-interface macro \geometry is defined, which sets unspecified dimensions to be \undefined by \geom@clean, appends specified options to themselves, and determines layout dimensions by

\geom@process.
438 \def\geometry#1{%
439 \geom@clean
440 \setkeys{Geom}{#1}%
441 \geom@process}

442 ⟨/package⟩ 443 ⟨∗config⟩

444

445 %% You can uncomment and edit the line below to set default options.
446 %%\ExecuteOptions{a4paper,dvips}

447

448 ⟨/config⟩