The geometry package

Hideo Umeki

                     hideo.umeki@toshiba.co.jp

1997/09/09 (v1.08)

Abstract

This package provides an easy and flexible user interface to customize page layout. It impliments auto-centering and auto-balancing mechanisms so that the users have only to give the least description for the page layout. This package requires the keyval package^{1}.

Contents

1 Introduction 1

2 Page Geometry 2

3 User Interface 3 3.1 General Features . . . . . . . . . 3 3.2 Option Types . . . . . . . . . . . 4

4 Option list 5 4.1 Boolean Options . . . . . . . . . 5 4.2 Single-Valued Options . . . . . . 6 4.3 Two-Valued Options . . . . . . . 7 4.4 Three-Valued Options . . . . . . 7 5 Relations Between Options 7 5.1 Option Priority . . . . . . . . . . 7 5.2 Order Dependence . . . . . . . . 8 5.3 dvips and pdftex . . . . . . . . . . 8

6 Default Settings 8 6.1 Page Size . . . . . . . . . . . . . 8 6.2 Default Options . . . . . . . . . . 8

7 Examples 8

8 Acknowledgements 10

9 The Code 10

1 Introduction

To set dimensions for page layout in L^{A}TEX is not straightforward. You will find a gap between comprehensible layout parameters and the L^{A}TEX dimensions to be specified, when you have to write a document according to the following layout 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, you need to specify

       \setlength\textwidth{6.5in}
       \setlength\textheight{8.75in}
       \setlength\topmargin{0.2in}
       \setlength\oddsidemargin{-0.6in}
       \setlength\headheight{0pt}
       \setlength\headsep{0pt}

This package allows L^{A}TEX 2ε users to customize the page layout (page size) in an easier way. One can realize the above page layout by putting, for example,

       \usepackge{geometry}
       \geometry{body={6.5in,8.75in}, top=1.2in, left=0.4in, nohead}

1CTAN:macros/latex/packages/graphics

in the preamble.

The name geometry comes from the -geometry option used for specifying a size and location of a window in X Window System. In the system one can set a window like

     -geometry 150x200+8-10

Setting a window on the root window corresponds to setting a total body (printable area) on the paper in this package, for example,

     \geometry{ width=6in, height=8in, left=0.8in, bottom=1in }

The previous version of the geometry package was called pagesize, but was renamed because the package is totally rewritten to use the keyval interface and to introduce a new algorithm for determining layout parameters. As a result, the package provides more flexible user interface and new specification for page layout while it does not work in the obsolete L^{A}TEX209 environment.

2 Page Geometry

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, 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, foot marginal notes (optional)
margins : left-, right-, top- and bottom-margin

Each margin is measured from the corresponding edge of a paper. For example, left-margin means a horizontal distance between the left edge of a paper and that of a 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. A body is also called a text area, size of which

can be modified by \textwidth and \textheight.

The layout parts and the corresponding dimension names in this package are listed below.

Dimension names

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

marginal notes marginparwidth and

                       marginparsep

—

              head  —  headheight and
                                           headsep

               foot  —  footskip

The dimensions for paper, total body and margins have the following relations.

                       paperwidth = left + width + right
                      paperheight = top + height + bottom

Suppose that the paper size is pre-defined, if two dimensions out of three in the right-hand side of each equation are given, the remnant dimension will be determined automatically. The partitioning patterns in each direction with auto-centering and auto-balancing mechanism are shown below.

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

The mark ‘*’ denotes the parameter not specified, which means the parameter will be automatically determined later. R_{n} (n=1, 2, 3) are remnant lengths which can be determined by α, β

and L (paperwidth or paperheight) :

\begin{aligned}R_{1} & = & L − 2α \\ R_{2} & = & (L − α)/2 \\ R_{3} & = & L − α − β \end{aligned}

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.

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

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

Each of the seven dimensions in the right-hand side of the above equations corresponds to the ordinary L^{A}TEX control sequence with the same name. You can include dimensions for marginal

notes (marginparsep and marginparwidth) in the width by includemp option. The dimensions

for a header and a footer can be also controlled by options (modes) as well as direct specification of lengths. These options are summarized below.

Modes  Effects

   nohead  sets headheight=0pt, headsep=0pt at the end.
   nofoot  sets footskip=0pt at the end.
   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.

includemp is forced true if either marginparwidth or marginparsep is explicitly set in

\geometry. See also Section 4.2.

Figure 1 illustrates the dimension names for page geometry.

3 User Interface

3.1 General Features

The \geometry macro takes one mandatory argument which specifies parameters for the page layout. The argument consists of a list of comma-separated options, which are specified by the keyval interface: ⟨key⟩=⟨value⟩. The \geometry argument has the following features:

• 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 5.2 for details.)

For example,

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

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

\geometry{  a5paper ,  hmargin = { 3cm,
                .1\w } , height
         =  10in }

is equivalent to

\geometry{height=10in,a5paper,hmargin={3cm,0.1\w}}

Note that when a value has a sub-list of values (e.g., hmargin={3cm,0.1\w}), the order of values in the sub-list is significant. Here \w and \h are defined as paperwidth and paperheight respectively in the \geometry argument.

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

\usepackage{calc,geometry}
\geometry{hmargin=\w/15+10pt}

3.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, namely dimension:

⟨key⟩=⟨value⟩.

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

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⟩}.

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

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

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}.

4 Option list

4.1 Boolean Options

Boolean options are also called ‘modes’. One can change various modes of page geometry. These options can appear not only in the argument of \geometry but also in the package option list of geometry with no values like,

\usepackage[verbose,landscape]{geometry}

which is equivalent to

\usepackage{geometry}
\geometry{verbose,landscape,· · ·}

The option reset is the only exception. It should not appear in the package option. 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 is used. Therefore, when you use latex 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.

reset initializes all the abovementioned modes except portrait to be false. This option, if necessary, must appear in the \geometry argument and precede any other options. Note that reset=false has no effect and cannot cancel the previous reset(=true) if any.

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.

The boolean options except for reset can be used as package options like

\usepackage[nohead,includemp,landscape]{geometry}.

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

interpreted in the geometry package as well.

4.2 Single-Valued Options

The single-valued options (key names) 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.

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\w, where \w is defined as an abbreviation of \paperwidth and valid in the \geometry argument.

vscale ratio of height of the total body to \paperheight. vscale=⟨v-ratio⟩. vscale=0.9 is equivalent to height=0.9\h, where \h is an abbreviation of

\paperheight within the \geometry argument.

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⟩.
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.

4.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= {α,β} is equivalent to hmargin= {α,β} and vmargin= {α,β}.

margin=α is automatically expanded to hmargin=α and vmargin=α.

offset horizontal and vertical offset.

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

4.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= {α,β,γ} is interpreted as hdivide= {α,β,γ} and vdivide= {α,β,γ}.

5 Relations Between Options

5.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,

     \geometry{hscale=0.8, textwidth=7in, width=18cm }
is the same as \geometry{textwidth=7in}.

5.2 Order Dependence

The options are basically order-independent, but there are some exceptions.

When redundant, overlap specification is given, the last setting is adopted. For example,

     \geometry{verbose=true, verbose=false}

obviously results in verbose=false. If you set

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

the left-margin is overwritten by left=1cm. As a result, it is equivalent to

     \geometry{hmargin={1cm,2cm}}

The reset option should precede all other options in the \geometry argument. If you set

     \geometry{nohead, reset}

then nohead takes no effect.

5.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 processing command, \pdfoutput and effective values for each driver option.

                      command \pdfoutput  dvips  pdftex

latex  —  T/F F
pdflatex 1  F  T/F
pdflatex 0  (T)/F T/F

‘T/F’ means one can choose true or false and the choice is effective. ‘F’ means it is always forced false. ‘(T)/F’ denotes that if pdftex is false the choice is effective, but otherwise it is forced false.

6 Default Settings

6.1 Page Size

Once you write \usepackage{geometry} in the preamble, the package will perform the default layout, namely scale={0.8, 0.9}, by internal execution of \geometry{}.

6.2 Default Options

You can set up a configuration file to make some boolean options effective in default. To do this, produce a file geometry.cfg ( like graphics.cfg of graphics package) containing, for example,

     \ExecuteOptions{a4paper,dvips}

and install it to the TEXINPUTS directory with geometry.sty.

7 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 result in the same effect.

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

In this case, the default is used for vertical layout: 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 is automatically calculated in the package.

\geometry{height=10in,bottom=2cm},
\geometry{bmargin = 2cm ,totalheight= 10in },
\geometry{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.

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

and so on.

• Include marginal notes when adjusting horizontal partition.

\geometry{ includemp },
\geometry{ includemp = true },

and so on.

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

\geometry{ marginpar=3cm },
\geometry{ marginparwidth=3cm },
\geometry{ marginpar=3cm , includemp }.

In the last case includemp is not necessary.

\geometry{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.

\geometry{ a5paper, landscape, scale=1.0 , noheadfoot},
\geometry{ landscape = TRUE , paper =a5paper,
             noheadfoot , total={\w,\h} },

and so on.

• Get PDF output using pdflatex.

% 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}

When pdftex option is appeared as a class option, it will be used in the graphics package^{3} and other packages in which pdftex option is declared.

3for the graphics package on 1997/06/07 v1.0d or later.

8 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.

9 The Code

1 ⟨∗package⟩

This package requires David Carlisle’s keyval package.

 2 \RequirePackage{keyval}[1995/09/21]

\Geom@exclcode The catcode of exclamation mark is stored and explicitly changed ‘other’(12).

 3 \edef\Geom@exclcode{\catcode`\noexpand\!\the\catcode`\!\relax}
 4 \@makeother\!%

Internal switches are declared here.

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

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

15 \def\Geom@Dhscale{0.8}
16 \def\Geom@Dvscale{0.9}

\Geom@Dtwosideshift The default for twosideshift is defined.

17 \def\Geom@Dtwosideshift{20pt}

The modes and the flag are initialized here. But twoside should not be reset here because it may be inherited from the class option. \Geom@passincmp is just used for checking if includemp has been explicitly specified. \Geom@pdftex is true if \pdfoutput=1.

18 \Geom@verbosefalse
19 \Geom@landscapefalse
20 \Geom@noheadfalse
21 \Geom@nofootfalse
22 \Geom@includempfalse
23 \Geom@passincmpfalse
24 \Geom@dvipsfalse
25 \ifx\undefined\pdfpagewidth
26 \Geom@pdftexfalse
27 \else
28 \ifnum\pdfoutput=1\Geom@pdftextrue\else\Geom@pdftexfalse\fi
29 \fi

\Geom@reset The reset option can be used only as an argument of \geometry{}.

30 \def\Geom@reset{%
31 \@twosidefalse
32 \@mparswitchfalse
33 \Geom@verbosefalse
34 \Geom@landscapefalse
35 \Geom@noheadfalse
36 \Geom@nofootfalse
37 \Geom@includempfalse
38 \Geom@passincmpfalse
39 \Geom@dvipsfalse
40 \Geom@pdftexfalse}

\Geom@paper is initialized as {}(empty).

41 \providecommand\Geom@paper{}

The option keys are defined below.

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

42 \define@key{Geom}{paper}{\setkeys{Geom}{#1}}
`a[0-5]paper' `b[0-5]paper' `letterpaper' `legalpaper' `executivepaper' Thirteen standard paper names are available.
43 \define@key{Geom}{a0paper}[true]{\def\Geom@paper{a0paper}}
44 \define@key{Geom}{a1paper}[true]{\def\Geom@paper{a1paper}}
45 \define@key{Geom}{a2paper}[true]{\def\Geom@paper{a2paper}}
46 \define@key{Geom}{a3paper}[true]{\def\Geom@paper{a3paper}}
47 \define@key{Geom}{a4paper}[true]{\def\Geom@paper{a4paper}}
48 \define@key{Geom}{a5paper}[true]{\def\Geom@paper{a5paper}}
49 \define@key{Geom}{b0paper}[true]{\def\Geom@paper{b0paper}}
50 \define@key{Geom}{b1paper}[true]{\def\Geom@paper{b1paper}}
51 \define@key{Geom}{b2paper}[true]{\def\Geom@paper{b2paper}}
52 \define@key{Geom}{b3paper}[true]{\def\Geom@paper{b3paper}}
53 \define@key{Geom}{b4paper}[true]{\def\Geom@paper{b4paper}}
54 \define@key{Geom}{b5paper}[true]{\def\Geom@paper{b5paper}}
55 \define@key{Geom}{letterpaper}[true]{\def\Geom@paper{letterpaper}}
56 \define@key{Geom}{legalpaper}[true]{\def\Geom@paper{legalpaper}}
57 \define@key{Geom}{executivepaper}[true]{\def\Geom@paper{executivepaper}}
`papersize'
`paperwidth'
`paperheight'

58 \define@key{Geom}{papersize}{\Geom@branch{#1}{paperwidth}{paperheight}}
59 \define@key{Geom}{paperwidth}{\setlength\paperwidth{#1}%
60  \let\Geom@paper\empty}
61 \define@key{Geom}{paperheight}{\setlength\paperheight{#1}%
62  \let\Geom@paper\empty}
`total' `width' `height'
63 \define@key{Geom}{total}{\Geom@branch{#1}{width}{height}}
64 \define@key{Geom}{width}{\Geom@hbodytrue\edef\Geom@width{#1}}
65 \define@key{Geom}{height}{\Geom@vbodytrue\edef\Geom@height{#1}}
`body'
`textwidth'
`textheight'

66 \define@key{Geom}{body}{\Geom@branch{#1}{textwidth}{textheight}}
67 \define@key{Geom}{textwidth}{\Geom@hbodytrue\edef\Geom@textwidth{#1}}
68 \define@key{Geom}{textheight}{\Geom@vbodytrue\edef\Geom@textheight{#1}}
`scale' `hscale' `vscale'
69 \define@key{Geom}{scale}{\Geom@branch{#1}{hscale}{vscale}}
70 \define@key{Geom}{hscale}{\Geom@hbodytrue\edef\Geom@hscale{#1}}
71 \define@key{Geom}{vscale}{\Geom@vbodytrue\edef\Geom@vscale{#1}}
`margin'
`hmargin'
`vmargin'
`lmargin'
`rmargin'
`tmargin'
`bmargin'

72 \define@key{Geom}{margin}{\Geom@branch{#1}{lmargin}{tmargin}%
73  \Geom@branch{#1}{rmargin}{bmargin}}
74 \define@key{Geom}{hmargin}{\Geom@branch{#1}{lmargin}{rmargin}}
75 \define@key{Geom}{vmargin}{\Geom@branch{#1}{tmargin}{bmargin}}
76 \define@key{Geom}{lmargin}{\edef\Geom@lmargin{#1}}
77 \define@key{Geom}{rmargin}{\edef\Geom@rmargin{#1}}
78 \define@key{Geom}{tmargin}{\edef\Geom@tmargin{#1}}
79 \define@key{Geom}{bmargin}{\edef\Geom@bmargin{#1}}

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

80 \define@key{Geom}{divide}{\Geom@divideParser{#1}{lmargin}{width}{rmargin}%
81  \Geom@divideParser{#1}{tmargin}{height}{bmargin}}
82 \define@key{Geom}{hdivide}{\Geom@divideParser{#1}{lmargin}{width}{rmargin}}
83 \define@key{Geom}{vdivide}{\Geom@divideParser{#1}{tmargin}{height}{bmargin}}
`offset' `hoffset' `voffset'
84 \define@key{Geom}{offset}{\Geom@branch{#1}{hoffset}{voffset}}
85 \define@key{Geom}{hoffset}{\setlength\hoffset{#1}}
86 \define@key{Geom}{voffset}{\setlength\voffset{#1}}

`headheight'
`headsep'
`footskip'

 87 \define@key{Geom}{headheight}{\Geom@noheadfalse\setlength\headheight{#1}}
 88 \define@key{Geom}{headsep}{\Geom@noheadfalse\setlength\headsep{#1}}
 89 \define@key{Geom}{footskip}{\Geom@nofootfalse\setlength\footskip{#1}}
`marginparwidth'
`marginparsep'
 90 \define@key{Geom}{marginparwidth}%
 91  {\ifGeom@passincmp\else\Geom@includemptrue\fi%
 92  \setlength\marginparwidth{#1}}
 93 \define@key{Geom}{marginparsep}%
 94  {\ifGeom@passincmp\else\Geom@includemptrue\fi%
 95  \setlength\marginparsep{#1}}
`verbose'
`reset'
`includemp'
`reversemp'
`reversemarginpar'
`twoside'
`twosideshift'
`nohead'
`nofoot'
`noheadfoot'
`landscape'
`portrait'
`dvips'
`pdftex'

 96 \define@key{Geom}{verbose}[true]{%
 97  \lowercase{\Geom@setbool{#1}}{Geom@verbose}}
 98 \define@key{Geom}{reset}[true]{%
 99  \lowercase{\expandafter\csname if#1\endcsname\Geom@reset\fi}}
100 \define@key{Geom}{includemp}[true]{%
101  \Geom@passincmptrue
102  \lowercase{\Geom@setbool{#1}}{Geom@includemp}}
103 \define@key{Geom}{reversemp}[true]{%
104  \ifGeom@passincmp\else\Geom@includemptrue\fi%
105  \lowercase{\Geom@setbool{#1}}{@reversemargin}}
106 \define@key{Geom}{reversemarginpar}[true]{%
107  \ifGeom@passincmp\else\Geom@includemptrue\fi%
108  \lowercase{\Geom@setbool{#1}}{@reversemargin}}
109 \define@key{Geom}{twoside}[true]{%
110  \lowercase{\Geom@setbool{#1}}{@twoside}%
111  \lowercase{\Geom@setbool{#1}}{@mparswitch}}
112 \define@key{Geom}{twosideshift}{\@twosidetrue\def\Geom@twosideshift{#1}}
113 \define@key{Geom}{nohead}[true]{%
114  \lowercase{\Geom@setbool{#1}}{Geom@nohead}}
115 \define@key{Geom}{nofoot}[true]{%
116  \lowercase{\Geom@setbool{#1}}{Geom@nofoot}}
117 \define@key{Geom}{noheadfoot}[true]{%
118  \lowercase{\Geom@setbool{#1}}{Geom@nohead}%
119  \lowercase{\Geom@setbool{#1}}{Geom@nofoot}}
120 \define@key{Geom}{landscape}[true]{%
121  \lowercase{\Geom@setbool{#1}}{Geom@landscape}}
122 \define@key{Geom}{portrait}[true]{%
123  \lowercase{\expandafter\csname if#1\endcsname
124  \Geom@landscapefalse\else\Geom@landscapetrue\fi}}
125 \define@key{Geom}{dvips}[true]{%
126  \lowercase{\Geom@setbool{#1}}{Geom@dvips}}
127 \define@key{Geom}{pdftex}[true]{%
128  \lowercase{\Geom@setbool{#1}}{Geom@pdftex}}
`papername' `totalwidth' `totalheight' `text' `left' `right' `top' `bottom' `head' `foot' `marginpar' The key aliases are defined.
129 \let\KV@Geom@papername\KV@Geom@paper
130 \let\KV@Geom@totalwidth\KV@Geom@width
131 \let\KV@Geom@totalheight\KV@Geom@height
132 \let\KV@Geom@text\KV@Geom@body
133 \let\KV@Geom@left\KV@Geom@lmargin
134 \let\KV@Geom@right\KV@Geom@rmargin
135 \let\KV@Geom@top\KV@Geom@tmargin
136 \let\KV@Geom@bottom\KV@Geom@bmargin
137 \let\KV@Geom@head\KV@Geom@headheight
138 \let\KV@Geom@foot\KV@Geom@footskip
139 \let\KV@Geom@marginpar\KV@Geom@marginparwidth

\Geom@setbool Macros for setting boolean options.

140 \def\Geom@setbool#1#2{%
141 \csname #2\ifx\relax#1\relax true\else#1\fi\endcsname}

Package options are declared.

142 \DeclareOption{verbose}{\Geom@verbosetrue}
143 \DeclareOption{a0paper}{\setkeys{Geom}{a0paper}}
144 \DeclareOption{a1paper}{\setkeys{Geom}{a1paper}}
145 \DeclareOption{a2paper}{\setkeys{Geom}{a2paper}}
146 \DeclareOption{a3paper}{\setkeys{Geom}{a3paper}}
147 \DeclareOption{a4paper}{\setkeys{Geom}{a4paper}}
148 \DeclareOption{a5paper}{\setkeys{Geom}{a5paper}}
149 \DeclareOption{b0paper}{\setkeys{Geom}{b0paper}}
150 \DeclareOption{b1paper}{\setkeys{Geom}{b1paper}}
151 \DeclareOption{b2paper}{\setkeys{Geom}{b2paper}}
152 \DeclareOption{b3paper}{\setkeys{Geom}{b3paper}}
153 \DeclareOption{b4paper}{\setkeys{Geom}{b4paper}}
154 \DeclareOption{b5paper}{\setkeys{Geom}{b5paper}}
155 \DeclareOption{letterpaper}{\setkeys{Geom}{letterpaper}}
156 \DeclareOption{legalpaper}{\setkeys{Geom}{legalpaper}}
157 \DeclareOption{executivepaper}{\setkeys{Geom}{executivepaper}}
158 \DeclareOption{portrait}{\Geom@landscapefalse}
159 \DeclareOption{landscape}{\Geom@landscapetrue}
160 \DeclareOption{twoside}{\@twosidetrue}
161 \DeclareOption{nohead}{\Geom@noheadtrue}
162 \DeclareOption{nofoot}{\Geom@nofoottrue}
163 \DeclareOption{noheadfoot}{\Geom@noheadtrue\Geom@nofoottrue}
164 \DeclareOption{includemp}{\Geom@includemptrue}
165 \DeclareOption{reversemp}{\Geom@includemptrue\@reversemargintrue}
166 \DeclareOption{reversemarginpar}{\ExecuteOptions{reversemp}}
167 \DeclareOption{dvips}{\Geom@dvipstrue}
168 \DeclareOption{pdftex}{\Geom@pdftextrue}
169 \DeclareOption*{\PackageWarningNoLine{geometry}%
170  {Unknown option `\CurrentOption'}}

portrait is a default option.

171 \ExecuteOptions{portrait}

A local configuration file may define more options. If a site wants a default paper, it needs to

 put \ExecuteOptions{a4paper} in a geometry.cfg file.
172 \InputIfFileExists{geometry.cfg}{}{}

Options are processed in the order that they appear in the option-lists. First the global options, and then the local ones.

173 \ProcessOptions*\relax

\Geom@checkbool \Geom@checkdef Macros for printout of page layout parameters.

174 \def\Geom@checkbool#1{%
175  \csname ifGeom@#1\endcsname #1\space\else\fi}
176 \def\Geom@checkdef#1{%
177  \@ifundefined{Geom@#1}{---}{\@nameuse{Geom@#1}}}

\Geom@det@one Determine #4 by #1(paperwidth or paperheight), #2 and #3.

178 \def\Geom@det@one#1#2#3#4{% determine #4.
179  \setlength\@tempdima{\@nameuse{paper#1}}%
180  \setlength\@tempdimb{\@nameuse{Geom@#2}}%
181  \addtolength\@tempdima{-\@tempdimb}%
182  \setlength\@tempdimb{\@nameuse{Geom@#3}}%
183  \addtolength\@tempdima{-\@tempdimb}%
184  \ifdim\@tempdima<\z@
185  \Geom@warning{`#4' results in NEGATIVE (\the\@tempdima).%
186  ^^J\@spaces Parameters of `#2' and `#3' should be shortened}%
187  \fi
188  \expandafter\edef\csname Geom@#4\endcsname{\the\@tempdima}}

\Geom@det@two Determine #2 and #3 by #1(paperwidth or paperheight) and #1(width or height).

189 \def\Geom@det@two#1#2#3{% determine #2 and #3.
190  \setlength\@tempdima{\@nameuse{paper#1}}%
191  \setlength\@tempdimb{\@nameuse{Geom@#1}}%
192  \addtolength\@tempdima{-\@tempdimb}%
193  \divide\@tempdima\tw@
194  \ifdim\@tempdima<\z@
195  \Geom@warning{`#2' and `#3' result in NEGATIVE (\the\@tempdima).%

196  ^^J\@spaces Parameter for `#1' should be shortened}%
197  \fi
198  \expandafter\edef\csname Geom@#2\endcsname{\the\@tempdima}%
199  \expandafter\edef\csname Geom@#3\endcsname{\the\@tempdima}}

\Geom@det@all Determine directional partition.

200 \def\Geom@det@all[#1]#2#3#4{%
201  \@tempcnta\z@
202  \if#1h
203  \if!\Geom@lmargin!\else\advance\@tempcnta4\relax\fi
204  \ifGeom@hbody\advance\@tempcnta2\relax\fi
205  \if!\Geom@rmargin!\else\advance\@tempcnta1\relax\fi
206  \else
207  \if!\Geom@tmargin!\else\advance\@tempcnta4\relax\fi
208  \ifGeom@vbody\advance\@tempcnta2\relax\fi
209  \if!\Geom@bmargin!\else\advance\@tempcnta1\relax\fi
210  \fi
211  \ifcase\@tempcnta             % 0:(*,*,*)
212  \if#1h
213  \Geom@warning{Horizontal partition is set default\space
214  (hscale=\Geom@Dhscale)}%
215  \edef\Geom@width{\Geom@Dhscale\paperwidth}%
216  \else
217  \Geom@warning{Vertical partition is set default\space
218  (vscale=\Geom@Dvscale)}%
219  \edef\Geom@height{\Geom@Dvscale\paperheight}%
220  \fi
221  \Geom@det@two{#2}{#3}{#4}%
222  \or                               % 1:(*,*,S) goto (5)
223  \Geom@warning{`#3' was forced to equal `#4'}%
224  \expandafter\edef\csname Geom@#3\endcsname{\@nameuse{Geom@#4}}%
225  \Geom@det@one{#2}{#3}{#4}{#2}%
226  \or\Geom@det@two{#2}{#3}{#4}      % 2:(*,S,*)
227  \or\Geom@det@one{#2}{#2}{#4}{#3}  % 3:(*,S,S)
228  \or                               % 4:(S,*,*) goto (5)
229  \Geom@warning{`#4' was forced to equal `#3'}%
230  \expandafter\edef\csname Geom@#4\endcsname{\@nameuse{Geom@#3}}%
231  \Geom@det@one{#2}{#3}{#4}{#2}%
232  \or\Geom@det@one{#2}{#3}{#4}{#2}  % 5:(S,*,S)
233  \or\Geom@det@one{#2}{#2}{#3}{#4}  % 6:(S,S,*)
234  \or                               % 7:(S,S,S) goto (5)
235  \Geom@warning{Redundant specification in `#1'-direction.%
236  ^^J\@spaces `#2' (\@nameuse{Geom@#2}) is ignored}%
237  \Geom@det@one{#2}{#3}{#4}{#2}%
238  \else\fi}

\Geom@divideParser The macro for parsing (h,v)divide options.

239 \def\Geom@divideParser#1#2#3#4{%
240  \def\Geom@star{*}%
241  \@tempcnta\z@
242  \@for\Geom@tmp:=#1\do{%
243  \expandafter\KV@@sp@def\expandafter\Geom@frag\expandafter{\Geom@tmp}%
244  \edef\Geom@value{\Geom@frag}%
245  \ifcase\@tempcnta\relax% cnta == 0
246  \edef\Geom@key{#2}%
247  \or    \edef\Geom@key{#3}%
248  \else  \edef\Geom@key{#4}%
249  \fi
250  \@nameuse{Geom@set\Geom@key false}%
251  \ifx\empty\Geom@value\else
252  \ifx\Geom@star\Geom@value\else
253  \setkeys{Geom}{\Geom@key=\Geom@value}%
254  \fi\fi
255  \advance\@tempcnta\@ne

256 }%

257  \let\Geom@star\relax}

\Geom@branch The macro for branching an option’s value into the same two values.

258 \def\Geom@branch#1#2#3{%
259  \@tempcnta\z@
260  \@for\Geom@tmp:=#1\do{%
261  \KV@@sp@def\Geom@frag{\Geom@tmp}%
262  \edef\Geom@value{\Geom@frag}%
263  \ifcase\@tempcnta\relax% cnta == 0
264  \setkeys{Geom}{#2=\Geom@value}%
265  \or% cnta == 1
266  \setkeys{Geom}{#3=\Geom@value}%
267  \else\fi
268  \advance\@tempcnta\@ne

269 }

270  \ifnum\@tempcnta=\@ne
271  \setkeys{Geom}{#2=\Geom@value}%
272  \setkeys{Geom}{#3=\Geom@value}%
273  \fi}

Various paper size are defined.

274 \@namedef{Geom@a0paper}{\Geom@setpaper(841mm,1189mm)}
275 \@namedef{Geom@a1paper}{\Geom@setpaper(595mm,841mm)}
276 \@namedef{Geom@a2paper}{\Geom@setpaper(420mm,595mm)}
277 \@namedef{Geom@a3paper}{\Geom@setpaper(297mm,420mm)}
278 \@namedef{Geom@a4paper}{\Geom@setpaper(210mm,297mm)}
279 \@namedef{Geom@a5paper}{\Geom@setpaper(149mm,210mm)}
280 \@namedef{Geom@b0paper}{\Geom@setpaper(1000mm,1414mm)}
281 \@namedef{Geom@b1paper}{\Geom@setpaper(707mm,1000mm)}
282 \@namedef{Geom@b2paper}{\Geom@setpaper(500mm,707mm)}
283 \@namedef{Geom@b3paper}{\Geom@setpaper(353mm,500mm)}
284 \@namedef{Geom@b4paper}{\Geom@setpaper(250mm,353mm)}
285 \@namedef{Geom@b5paper}{\Geom@setpaper(176mm,250mm)}
286 \@namedef{Geom@letterpaper}{\Geom@setpaper(8.5in,11in)}
287 \@namedef{Geom@legalpaper}{\Geom@setpaper(8.5in,14in)}
288 \@namedef{Geom@executivepaper}{\Geom@setpaper(7.25in,10.5in)}
\Geom@setpaper
289 \def\Geom@setpaper(#1,#2){\setlength\paperwidth{#1}%
290  \setlength\paperheight{#2}}

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

291 \def\Geom@showParam{%
292  \typeout{----------------------- Geometry parameters^^J%
293  mode: %
294  \Geom@checkbool{landscape}%
295  \Geom@checkbool{nohead}%
296  \Geom@checkbool{nofoot}%
297  \Geom@checkbool{includemp}%
298  \if@reversemargin reversemp\space\fi%
299  \if@twoside twoside\space\fi%
300  \Geom@checkbool{dvips}%
301  \Geom@checkbool{pdftex}^^J%
302  \if!\Geom@paper!\else
303  paper: \Geom@paper^^J%
304  \fi
305  h-parts: \Geom@lmargin, \Geom@width, \Geom@rmargin^^J%
306  v-parts: \Geom@tmargin, \Geom@height, \Geom@bmargin^^J%
307  \if@twoside
308  twosideshift: \Geom@twosideshift^^J%
309  \fi
310  ----------------------- Page layout dimensions^^J%
311  \string\paperwidth\space\space\the\paperwidth^^J%
312  \string\paperheight\space\the\paperheight^^J%
313  \string\textwidth\space\space\the\textwidth^^J%
314  \string\textheight\space\the\textheight^^J%
315  \string\oddsidemargin\space\space\the\oddsidemargin^^J%
316  \string\evensidemargin\space\the\evensidemargin^^J%
317  \string\topmargin\space\space\the\topmargin^^J%

318  \string\headheight\space\the\headheight^^J%
319  \string\headsep\@spaces\the\headsep^^J%
320  \string\footskip\space\space\space\the\footskip^^J%
321  \ifGeom@includemp
322  \string\marginparwidth\space\the\marginparwidth^^J%
323  \string\marginparsep\space\space\space\the\marginparsep^^J%
324  \fi
325  \string\hoffset\space\the\hoffset^^J%
326  \string\voffset\space\the\voffset^^J%
327  (1in=72.27pt, 1cm=28.45pt)^^J%
328  -----------------------}}
    The verbose, pdftex and dvips options are checked in \AtBeginDocument.
329 \AtBeginDocument{%

Check effectiveness of dvips and pdftex options. For latex,

330  \ifx\undefined\pdfpagewidth
331  \ifGeom@dvips
332  \AtBeginDvi{\special{%
333  papersize=\the\paperwidth,\the\paperheight}}%
334  \fi
335  \Geom@pdftexfalse
336  \else

For pdflatex with \pdfouput=1, checking again if pdftex=false is set explicitly,

337  \ifnum\pdfoutput=1
338  \ifGeom@pdftex
339  \pdfpagewidth=\the\paperwidth
340  \pdfpageheight=\the\paperheight
341  \else
342  \pdfoutput=0
343  \fi
344  \Geom@dvipsfalse

For pdflatex with \pdfouput=0,

345  \else
346  \ifGeom@pdftex
347  \pdfoutput=1
348  \pdfpagewidth=\the\paperwidth
349  \pdfpageheight=\the\paperheight
350  \Geom@dvipsfalse
351  \else
352  \pdfoutput=0
353  \ifGeom@dvips
354  \AtBeginDvi{\special{%
355  papersize=\the\paperwidth,\the\paperheight}}%
356  \fi
357  \fi
358  \fi
359  \fi

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

360  \ifGeom@verbose
361  \Geom@showParam
362  \fi}

\geometry The user interface \geometry is defined here.

363 \def\geometry#1{%

{\w \atop \h} \w and \h are abbreviations for \paperwidth and \paperheight respectively. They are valid only in the argument of \geometry.

364  \@ifundefined{w}{\let\Geom@ow\relax}{\let\Geom@ow\w}%
365  \@ifundefined{h}{\let\Geom@oh\relax}{\let\Geom@oh\h}%
366  \let\w\paperwidth
367  \let\h\paperheight

Initialization of switches and dimensions.

368  \Geom@hbodyfalse

369  \Geom@vbodyfalse
370  \let\Geom@width\empty
371  \let\Geom@height\empty
372  \let\Geom@textwidth\empty
373  \let\Geom@textheight\empty
374  \let\Geom@hscale\empty
375  \let\Geom@vscale\empty
376  \let\Geom@lmargin\empty
377  \let\Geom@rmargin\empty
378  \let\Geom@tmargin\empty
379  \let\Geom@bmargin\empty
380  \def\Geom@twosideshift{\Geom@Dtwosideshift}

The argument of \geometry is processed here.

381  \setkeys{Geom}{#1}%

If paper option is specified, the predefined paper dimensions are used.

382  \if!\Geom@paper!\else\@nameuse{Geom@\Geom@paper}\fi

If landscape option is specified, the paper orientation is changed to landscape.

383  \ifGeom@landscape
384  \setlength\@tempdima{\paperwidth}%
385  \setlength\paperwidth{\paperheight}%
386  \setlength\paperheight{\@tempdima}%
387  \fi

If nohead option is specified, the vertical spaces for the head of page are all set to 0pt. If nofoot, the \footskip is set 0pt.

388  \ifGeom@nohead
389  \setlength\headheight{0pt}%
390  \setlength\headsep{0pt}%
391  \fi
392  \ifGeom@nofoot
393  \setlength\footskip{0pt}%
394  \fi

The width of the total body \Geom@width is determined here.

395  \ifGeom@hbody
396  \if!\Geom@width!%
397  \if!\Geom@hscale!%
398  \edef\Geom@width{\Geom@Dhscale\paperwidth}%
399  \else
400  \edef\Geom@width{\Geom@hscale\paperwidth}%
401  \fi
402  \fi
403  \if!\Geom@textwidth!\else
404  \setlength\@tempdima{\Geom@textwidth}%
405  \ifGeom@includemp
406  \addtolength\@tempdima{\marginparwidth}%
407  \addtolength\@tempdima{\marginparsep}%
408  \fi
409  \edef\Geom@width{\the\@tempdima}%
410  \fi
411  \fi

The height of the total body \Geom@height is determined here.

412  \ifGeom@vbody
413  \if!\Geom@height!%
414  \if!\Geom@vscale!%
415  \edef\Geom@height{\Geom@Dvscale\paperheight}%
416  \else
417  \edef\Geom@height{\Geom@vscale\paperheight}%
418  \fi
419  \fi
420  \if!\Geom@textheight!\else%
421  \setlength\@tempdima{\Geom@textheight}%
422  \addtolength\@tempdima{\headheight}%
423  \addtolength\@tempdima{\headsep}%
424  \addtolength\@tempdima{\footskip}%
425  \edef\Geom@height{\the\@tempdima}%

426  \fi
427  \fi

The horizontal and vertical partitionings are determined here.

428  \Geom@det@all[h]{width}{lmargin}{rmargin}%
429  \Geom@det@all[v]{height}{tmargin}{bmargin}%
 \textwidth, \textheight, \topmargin, \oddsidemargin and \evensidemargin are calculated

below.

430  \setlength\textwidth{\Geom@width}%
431  \setlength\textheight{\Geom@height}%
432  \setlength\topmargin{\Geom@tmargin}%
433  \setlength\oddsidemargin{\Geom@lmargin}%
434  \ifGeom@includemp
435  \addtolength\textwidth{-\marginparwidth}%
436  \addtolength\textwidth{-\marginparsep}%
437  \if@reversemargin
438  \addtolength\oddsidemargin{\marginparwidth}%
439  \addtolength\oddsidemargin{\marginparsep}%
440  \fi
441  \fi
442  \addtolength\textheight{-\headheight}%
443  \addtolength\textheight{-\headsep}%
444  \addtolength\textheight{-\footskip}%
445  \addtolength\topmargin{-1in}%
446  \addtolength\oddsidemargin{-1in}%
447  \if@twoside
448  \setlength\evensidemargin{\Geom@rmargin}%
449  \addtolength\evensidemargin{-1in}%
450  \setlength\@tempdima{\Geom@twosideshift}%
451  \addtolength\oddsidemargin{\@tempdima}%
452  \addtolength\evensidemargin{-\@tempdima}%
453  \ifGeom@includemp
454  \if@mparswitch
455  \setlength\@tempdima{\marginparwidth}%
456  \addtolength\@tempdima{\marginparsep}%
457  \addtolength\evensidemargin{\@tempdima}%
458  \if@reversemargin
459  \addtolength\evensidemargin{-\marginparwidth}%
460  \addtolength\evensidemargin{-\marginparsep}%
461  \fi
462  \fi
463  \fi
464  \else
465  \setlength\evensidemargin{\oddsidemargin}%
466  \fi

The local abbreviations \w and \h are replaced by the original definitions or \relax if these are not predefined.

467  \let\w\Geom@ow
468  \let\h\Geom@oh

469 }

A hack for silent execution of the default geometry setting.

470 \let\Geom@warning\@gobble

The default geometry command is executed in silent mode.

471 \geometry{}

\Geom@warning The macro for typeout of warning is defined.

472 \def\Geom@warning#1{%
473  \ifGeom@verbose
474  \typeout{Geometry warning:\space #1.}%
475  \fi}

The catcode of exclamation mark is restored here.

476 \Geom@exclcode
477 \let\Geom@exclcode\relax

478 ⟨/package⟩ 479 ⟨∗config⟩

480

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

483

484 ⟨/config⟩