Upload
vukiet
View
225
Download
1
Embed Size (px)
Citation preview
The geometry package
Hideo [email protected]
2008/12/21 v4.2
Abstract
This package provides a flexible and easy interface to page dimensions. You can set the pagelayout with intuitive parameters. For instance, if you want to set a margin to 2cm from each edgeof the paper, you can go just \usepackage[margin=2cm]{geometry}.
Contents
1 Preface to version 4 1
2 Preface to version 3 2
3 Introduction 3
4 Page geometry 44.1 Layout dimensions . . . . . . . . 44.2 Auto-completion scheme . . . . . 5
5 User interface 75.1 General features . . . . . . . . . 75.2 Option types . . . . . . . . . . . 8
6 Option specification 96.1 Paper size . . . . . . . . . . . . . 96.2 Body size . . . . . . . . . . . . . 96.3 Margin size . . . . . . . . . . . . 116.4 Native dimensions . . . . . . . . 116.5 drivers . . . . . . . . . . . . . . . 13
6.6 Other options . . . . . . . . . . . 13
7 Default settings 147.1 Default layout . . . . . . . . . . . 147.2 Configuration file . . . . . . . . . 14
8 Relations between options 148.1 Order dependence . . . . . . . . 148.2 Priority . . . . . . . . . . . . . . 15
9 Examples 15
10 Known problems 17
11 Acknowledgments 17
12 Implementation 17
13 Config file 37
14 Sample file 37
1 Preface to version 4
Many improvements to the code and documentation were made according to suggestions and commentsfrom users. Main changes are listed below.
• More robust driver detection.
The driver detection method has been totally rewritten so that it can automatically detect thedriver appropriate for the typesetting program in use. Therefore, explicit driver setting is nolonger needed in most cases, except for the driver dvipdfm. This improvement makes geometrywork more robustly for typesetting programs under eTEX, XeTEX and VTEX as well as normalTEX environment. The packages ifpdf and ifvtex are used, which are available in CTAN. SeeSection 6.5 for details. Note that ifvtex package v1.3 (2007/09/09) had a bug (a typo) that madethe detection of VTeX wrong. So make sure ifvtex v1.4 or later is being used.
• New option: resetpaper.
This option disables explicit paper setting in geometry and uses the paper size specified beforegeometry. This option may be useful to print nonstandard sized documents with normal printersand papers.
1
• Added adjustment to topskip.
When lines option and large font sizes are specified, \topskip can be adjusted so that theformula “\textheight = (lines − 1) × \baselineskip + \topskip” to be correct. To do this,\topskip is set to \ht\strutbox, if \topskip is smaller than \ht\strutbox.
• Added ANSI paper sizes.
New paper size definitions for ANSI A to E are added.
• Fixed wrong ISO paper sizes.
The paper sizes for A1,A2,A5 and A6 were wrong (by 1mm).
• Fixed pdfTEX magnification problem.
PDF paper offset is adjusted properly when magnification is set by mag option with pdfTEX.
• Changed package source organization.
Files geometry.ins and geometry-samples.tex as well as geometry.sty are integrated intogeometry.dtx so that they can be generated from geometry.dtx by ‘tex’ command. Documen-tation can be also generated directly from geometry.dtx by ‘(pdf)latex’ command.
2 Preface to version 3
The geometry package becomes even more flexible and powerful with the release of version 3. This newrelease contains major changes and enhancements in user interface, calculation schemes and the defaultsettings of the page dimensions.
• New default layout.
The ‘automatic’ centering is no longer default layout. Instead of centering, the idea of marginratio and common values for default settings are introduced: the ratio of left (inner) marginto right (outer) margin is set 1:1 (2:3 for twoside), and the ratio of top to bottom is set 2:3.The margin ratios can be specified by newly introduced options, e.g. marginratio (see Sec-tion 4.2 and 6.3 for the detail). In addition, the spaces for the head and foot of the pageare disregarded in calculating the placement of the text area by default. Furthermore the de-fault scale of the type area is set to 0.7 with 70% of the width and height of the paper. Ifyou want to use the old default layout of version 2.3 or earlier, add compat2 as a first op-tion, e.g., \usepackage[compat2,left=1.5in]{geometry}, which sets the old default options[scale={0.8,0.9}, centering, includeheadfoot] and allows the subsequent options to be-have as if they are used in the old version. See also Section 7.1 for the detail of the defaultlayout.
• Option twosideshift is obsoleted.
twoside and other geometry options can substitute for it. A new option bindingoffset mightbe also helpful to control margins for oneside/twoside. For the detail, see Section 6.3.
• Option includemp becomes independent of marginparwidth and marginparsep.
In the previous version, marginparwidth or marginparsep automatically set includemp=true.Now if you want includemp mode, includemp should be set explicitly.
• Options nohead, nofoot and noheadfoot become order-dependent and overwritable
In the previous version, these options was order-independent: nohead,headsep=10pt resulted injust nohead (\headsep=0pt, \headheight=0pt), for example. But now they are overwritable bysubsequent options. The above case results in \headheight=0pt and \headsep=10pt.
• A complete set of options ignore* and include* for head, foot and marginpar.
The previous version has only includemp, which denotes that the width of marginpar is includedin the total body width. Now ignore{head, foot, headfoot, mp, all} and include{head, foot,headfoot, all} are newly added. If one of these ignore* is set, the corresponding space(s) aredisregarded in auto-completion calculation. In version 3, ignoreall is set by default. So if youneed to include the spaces for the head, foot and marginpar, the corresponding include* shouldbe set explicitly. In addition, unlike the previous version, neither reversemp, marginparwidthnor marginparsep sets includemp automatically.
2
• New option lines.
The option enables users to specify \textheight by the number of lines included in \textheight,e.g., lines=20.
• New option heightrounded.
The option rounds \textheight to n-times (n: an integer) of \baselineskip plus \topskip toavoid “underfull vbox” in some cases.
• New option screen.
To make presentation with PC and video projector, geometry option screen,centering with‘slide’ documentclass would be the best choice.
• New option asymmetric.
The option implements a twosided layout in which margins are not swapped on alternate pagesand the marginal notes stay always on the same side.
• New option showframe.
The option displays visible frames for the text area and page, and lines for the head and foot tocheck layout in detail. Therefore showframe.sty is excluded from the geometry package distri-bution.
• New option pass.
The option disables auto-layout and all of the geometry settings except verbose and showframe.It can be used for checking out the page layout of the documentclass, other packages and manualsettings without geometry.
See the text for the detail. All the new and modified options in this release are marked with ‘?3’ and‘†3’ respectively.
3 Introduction
To set dimensions for page layout in LATEX is not straightforward. You need to adjust several LATEXnative dimensions to place a text area where you want If you want to center the text area in the paperyou use, for example, you have to specify native dimensions as follows:
\usepackage{calc}\setlength\textwidth{7in}\setlength\textheight{10in}\setlength\oddsidemargin{(\paperwidth-\textwidth)/2 - 1in}\setlength\topmargin{(\paperheight-\textheight
-\headheight-\headsep-\footskip)/2 - 1in}.
Without package calc, the above example would need more tedious settings. Package geometry providesan easy way to set page layout parameters. In this case, what you have to do is just
\usepackage[text={7in,10in},centering]{geometry}.
Besides centering problem, setting margins from each edge of the paper is also troublesome. Butgeometry also make it easy. If you want to set each margin 1.5in, you can go
\usepackage[margin=1.5in]{geometry}
In both cases, the unspecified dimensions are automatically determined. The package will be also usefulwhen 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 topmargin on each page should be 1.2 inches from the top edge of the page. The left marginshould be 0.9 inch from the left edge. The footer with page number should be at the bottomof the text area.
In this case, using geometry you can go
3
paper
total body
height
width
paperwidth
paperheight
top
bottom
left(inner)
right(outer)
?
?
6
6
-� -�
total body
head headheightheadsep
textheight
textwidth
footskip
body
foot
Figure 1: Dimension names used in the geometry package. width=textwidth andheight=textheight by default. left, right, top and bottom are margins. If marginson verso pages are swapped by twoside option, margins specified by left and right
options are used for the inside and outside margins respectively. inner and outer arealiases of left and right respectively.
\usepackage[total={6.5in,8.75in},top=1.2in, left=0.9in, includefoot]{geometry}.
Setting a text area on the paper in document preparation system has some analogy to placing awindow on the background in the window system. The name ‘geometry’ comes from the -geometryoption used for specifying a size and location of a window in X Window System.
4 Page geometry
4.1 Layout dimensions
To realize a straightforward setting for page layout, the following page structure is introduced: A papercontains a total body (printable area) and margins. The total body consists of a body (text area) withoptional a header, a footer and marginal notes (marginpar). There are four margins: the left, right,top and bottom margins. For twosided documents, horizontal margins should be called the inner andouter margins.
paper : total body and marginstotal body : body (text area) (optional head, foot and marginpar)
margins : left(inner), right(outer), top and bottom
Each margin is measured from the corresponding edge of a paper. For example, left margin (innermargin) means a horizontal distance between the left (inner) edge of the paper and that of the totalbody. Therefore the left and top margins defined in geometry are different from the native 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 showed schemat-ically 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)
In Equation (3), width:=textwidth by default, but marginparsep and marginparwidth are includedin width if includemp option is set true. In Equation (4), height:=textheight by default. If
4
(a) default
paper
6
textheight
?
head
body
foot
?
?
6
6
top
bottom
(b) includehead and includefoot
paper
6
textheight
?
head
body
��
�total body
foot
?
?
6
6
top
bottom
Figure 2: includehead and includefoot include the head and foot respectively into total body.(a) height = textheight (default). (b) height = textheight + headheight +headsep + footskip if includehead and includefoot. If the top and bottom marginsare fixed, includehead and includefoot make textheight shorter than default.
includehead is set to true, headheight and headsep are considered as a part of height in the thevertical completion calculation. In the same way, includefoot includes footskip. Note that optionsignore* just exclude the corresponding spaces from textheight, but do not change those lengthsthemselves. Figure 2 shows how these options work. Each of the seven dimensions in the right-handside of Equations (3) and (4) corresponds to the ordinary LATEX control sequence with the same name.
Figure 3 illustrates various layouts with different layout modes. The dimensions for a header anda footer can be controlled by nohead or nofoot mode, which sets each length to 0pt directly. On theother hand, options ignore* do not change the corresponding native dimensions.
4.2 Auto-completion scheme
Suppose that the paper size is pre-defined in Equation (1) or (2), if two dimensions out of the threedimensions in the right-hand side of each equation are specified, the rest of the dimensions can bedetermined by the specified ones. However, when none or only one of the three dimensions is specified,the rest of the dimensions can’t generally be determined without some assumptions.
The geometry package has an auto-completion scheme with some default parameters to determinethe unspecified dimensions independently for each direction. If the size of total body (i.e., width inthe horizontal direction) is specified, the margins (left and right) can be determined with a defaultratio of one margin to the other (left/right). If one margin is specified, the rest of dimensions canalso be determined by the default margin ratio. Page margin setting by margin ratio was introducedin KOMA script1.
The default vertical margin ratio is 2/3, namely,
top : bottom = 2 : 3 default. (5)
As for the horizontal margin ratio, the default value depends on whether the document is onesided ortwosided,
left (inner) : right (outer) ={
1 : 1 default for oneside,2 : 3 default for twoside. (6)
Obviously the default horizontal margin ratio for oneside is ‘centering’.For example, if one specifies right=2.4cm with a twosided layout in A4 paper (21.0cm×29.7cm),
unspecified left and width are automatically determined using the default horizontal margin ratio(2/3) as follows:
left = 〈horizontal-margin-ratio〉 × right
= 2/3× 2.4cm = 1.6cm (7)
1CTAN: macros/latex/contrib/koma-script by Frank Neukam and Markus Kohm.
5
(a) includeheadfoot
total body
textwidth
headheight
headsep
textheight
footskip
head
body
foot
(b) includeall
total body
head
body marginalnote
foot
textwidth
marginparwidth
marginparsep
(c) includefoot
total body
textheight
footskip
body
foot
textwidth
(d) includefoot,includemp
total body
body marginalnote
foot
textwidth
marginparwidth
marginparsep
Figure 3: Sample layouts for total body with different switches. (a) includeheadfoot, (b)includeall, (c) includefoot and (d) includefoot,includemp. If reversemp is set totrue, the location of the marginal notes are swapped on every page. Option twoside
swaps both margins and marginal notes on verso pages. Note that the marginal notes areprinted on the page, even when ignoremp or includemp=false, but can fall off the pagein some cases.
6
Settings Resultsleft width right left width righttop height bottom top height bottom
* * * σM(0.7L) 0.7L M(0.7L)* A * σM(A) A M(A)A * * A R(A + A/σ) A/σ* * A =⇒ σA R(A + σA) AA B * A B R(A + B)* A B R(A + B) A BA * B A R(A + B) BA C B A R(A + B) B
Table 1: Auto-completion rules. The mark ‘*’ in each row (left table) denotes the dimensions notspecified explicitly, which can be determined as the corresponding Results (right table). σdenotes the value of margin ratio. FunctionsR(x) andM(x) are defined in Equation (12).The bottom case shows over-specification, which gives in the same result as the A-*-Bcase.
width = paperwidth− left− right
= 21.0cm− 1.6cm− 2.4cm = 17.0cm. (8)
In this case, the vertical dimensions top, height and bottom are determined by the default verticalmargin ratio with 2:3 and the default size of total body with 70% of the paper height:
height = 0.7× paperheight
= 0.7× 29.7cm = 20.79cm (9)
top =〈vertical-margin-ratio〉
1 + 〈vertical-margin-ratio〉× (paperheight− height)
=2
2 + 3× (29.7cm− 20.79cm)
= 0.4× 8.91cm = 3.564cm (10)
bottom = 0.6× 8.91cm = 5.346cm (11)
The auto-completion rules are shown in Table 1 and Equation (12). A, B and C in Table 1 areuser-specified values, ∗ denotes unspecified ones. The right-hand side table shows the correspondingresults of auto-completion. The unspecified values can be determined by A, B and L (paperwidth orpaperheight). In Table 1, functions R(x) and M(x) are defined as follows:
R(x) = L− xM(x) = R(x) / (1 + σ) (12)
Here σ denotes the ratio of left margin (inner) to right margin (outer) or the ratio of top to bottom. Toset σ as a geometry option, you can use {h,v}marginratio options with a:b-type value, for example,hmarginratio=2:3.
hmarginratio = left : right (13)vmarginratio = top : bottom (14)
By default, σ is 1/1 (=1) for oneside and 2/3 for twoside in the horizontal direction, and 2/3 in thevertical. If none of three dimensions is specified in each direction, the default setting is used: widthand height is set to 70% of the paper width and height respectively. If all the three dimensions wouldbe specified, margins remain and width or height is ignored.
5 User interface
5.1 General features
The geometry options using the keyval interface ‘〈key〉=〈value〉’ can be set either in the optional ar-gument to the \usepackage command, or in the argument of the \geometry macro. This macro, if
7
necessary, should be used only in the preamble, i.e., before \begin{document}. In either case, theargument consists of a list of comma-separated keyval options. The main features of setting options arelisted 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 8.1 for details.)
For example,
\usepackage[ a5paper , hmargin = { 3cm,.8in } , height
= 10in ]{geometry}
is equivalent to
\usepackage[height=10in,a5paper,hmargin={3cm,0.8in}]{geometry}
Some options are allowed to have sub-list, e.g. {3cm,0.8in}. Note that the order of values in thesub-list is significant. The above setting is also 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.Geometry supports package calc2. For example,
\usepackage{calc}\usepackage[textheight=20\baselineskip+10pt]{geometry}
5.2 Option types
Geometry options are categorized into four types:
1. Boolean type
takes a boolean value (true or false). If no value, true is set by default.
〈key〉=true false.〈key〉 with no value is equivalent to 〈key〉=true.
Examples: verbose=true, includehead, twoside=false.Paper name is the exception. The preferred paper name should be set with no values. Whatevervalue 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=7in, left=1.25in, footskip=1cm, height=.86\paperheight.
3. Double-valued type
takes a pair of comma-separated values in braces. The two values can be shortened to one valueif they are identical.
〈key〉={〈value1 〉,〈value2 〉}.〈key〉=〈value〉 is equivalent to 〈key〉={〈value〉,〈value〉}.
2CTAN: macros/latex/required/tools
8
Examples: hmargin={1.5in,1in}, scale=0.8, body={7in,10in}.
4. Triple-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 andleaves the appropriate value to the auto-completion mechanism. You need to specify at least onedimension, 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}.
6 Option specification
This section describes all the options provided by geometry.
6.1 Paper size
The options below set paper/media size and orientation.
paper papernamespecifies a paper name. The paper names available in geometry. paper=〈paper-name〉.For example paper=a4paper, which is equivalent to just a4paper.
a0paper, a1paper, a2paper, a3paper, a4paper, a5paper, a6paperb0paper, b1paper, b2paper, b3paper, b4paper, b5paper, b6paperansiapaper, ansibpaper, ansicpaper, ansidpaper, ansiepaperletterpaper, executivepaper, legalpaper
specifies paper name. They can typically be used with no values. Note that whatevervalue (even false) is given to this option, the value will be ignored. For example, thefollowings have the same effect: a5paper, a5paper=true, a5paper=false anda5paper=XXXX.
screen a special paper size with (W,H) = (225mm,180mm). For presentation with PC andvideo projector, “screen,centering” with ‘slide’ documentclass would be useful.
paperwidth width of the paper. paperwidth=〈length〉.paperheight height of the paper. paperheight=〈length〉.papersize width and height of the paper.
papersize={〈width〉,〈height〉} or papersize=〈length〉.landscape switches the paper orientation to landscape mode.portrait switches the paper orientation to portrait mode. This is equivalent to
landscape=false.
Options for paper names (e.g., a4paper) and orientation (portrait and landscape) can be set asdocument class options. For example, you can set \documentclass[a4paper,landscape]{article},then a4paper and landscape are processed in geometry as well. This is also the case for twoside andtwocolumn (see also Section 6.4).
6.2 Body size
The options specifying the size of total body are described in this section.
hscale ratio of width of total body to \paperwidth. hscale=〈h-scale〉, e.g., hscale=0.8 isequivalent to width=0.8\paperwidth. (0.7 by default)
vscale ratio of height of total body to \paperheight, e.g., vscale=〈v-scale〉. (0.7 bydefault) vscale=0.9 is equivalent to height=0.9\paperheight.
scale ratio of total body to the paper. scale={〈h-scale〉,〈v-scale〉} or scale=〈scale〉. (0.7by default)
9
width totalwidthwidth of total body. width=〈length〉 or totalwidth=〈length〉. This dimension shouldnot be confused with textwidth. Generally, width ≥ textwidth because widthincludes the width of the marginal notes if includemp is set to true. If textwidthand width are specified at the same time, width is ignored.
height totalheightheight of total body, excluding header and footer by default. If includehead orincludefoot is set, height includes the head or foot of the page as well astextheight. height=〈length〉 or totalheight=〈length〉. If both textheight andheight are specified, height will be ignored.
total width and height of total body.total={〈width〉,〈height〉} or total=〈length〉.
textwidth modifies \textwidth, the width of body (the text are). textwidth=〈length〉.textheight modifies \textheight, the height of body. textheight=〈length〉.text body sets both \textwidth and \textheight of the body of page. body={〈width〉,〈height〉}
or text=〈length〉.lines enables users to specify \textheight by the number of lines. lines=〈integer〉.includehead includes the head of the page, \headheight and \headsep, into total body. It is set
to false by default. It is opposite to ignorehead. See Figure 2.includefoot includes the foot of the page, \footskip, into total body. It is opposite to
ignorefoot. It is false by default. See Figure 2.includeheadfoot
sets both includehead and includefoot to true, which is opposite toignoreheadfoot. See Figure 2.
includemp includes the margin notes, \marginparwidth and \marginparsep, into body whencalculating horizontal calculation. In version 3, includemp is independent of optionsmarginparwidth and marginparsep, and set to false by default.
includeall sets both includeheadfoot and includemp to true. See Figure 2 and Figure 3.ignorehead disregards the head of the page, headheight and headsep, in determining vertical
layout, but does not change those lengths. It is equivalent to includehead=false. Itis set to true by default. See also includehead.
ignorefoot disregards the foot of page, footskip, in determining vertical layout, but does notchange that length. This option is set to true by default. See also includefoot.
ignoreheadfootsets both ignorehead and ignorefoot to true. See also includeheadfoot.
ignoremp disregards the marginal notes in determining the horizontal margins (true is set bydefault). If marginal notes fall off the page, the warning message will be displayedwhen verbose=true. See also Figure 3 and includemp.
ignoreall sets both ignoreheadfoot and ignoremp to true. See also includeall.heightrounded
This option rounds \textheight to n-times (n: an integer) of \baselineskip plus\topskip to avoid “underfull vbox” in some cases. For example, if \textheight is486pt with \baselineskip 12pt and \topskip 10pt, then
(39× 12pt + 10pt =) 478pt < 486pt < 490pt (= 40× 12pt + 10pt),
as a result \textheight is rounded to 490pt. heightrounded=false by default.
The following options can specify body and margins simultaneously with three comma-separatedvalues in braces.
hdivide horizontal partitions (left,width,right). hdivide={〈left margin〉,〈width〉,〈rightmargin〉}. Note that you should not specify all of the three parameters. The best wayof 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 theright-side edge of page will be determined calculating paperwidth-2cm-15cm.
vdivide vertical partitions (top,height,bottom). vdivide={〈top margin〉,〈height〉,〈bottommargin〉}.
divide divide={A,B,C} is interpreted as hdivide={A,B,C} and vdivide={A,B,C}.
10
6.3 Margin size
The options specifying the size of visible margins are listed below.
left lmargin innerleft margin (for oneside) or inner margin (for twoside) of total body. In other words,the distance between the left (inner) edge of the paper and that of total body.left=〈length〉. inner has no special meaning, just an alias of left and lmargin.
right rmargin outerright or outer margin of total body. right=〈length〉.
top tmargin top margin of the page. top=〈length〉. Note this option has nothing to do with thenative dimension \topmargin.
bottom bmarginbottom margin of the page. bottom=〈length〉.
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.hmarginratio horizontal margin ratio of left (inner) to right (outer). The value of 〈ratio〉 should
be specified with colon-separated two values. Each value should be a positive integerless than 100 to prevent arithmetic overflow, e.g., 2:3 instead of 1:1.5. The defaultratio is 1:1 for oneside, 2:3 for twoside.
vmarginratio vertical margin ratio of top to bottom. The default ratio is 2:3.marginratio ratio
horizontal and vertical margin ratios. marginratio={〈horizontal ratio〉,〈verticalratio〉} or marginratio=〈ratio〉.
hcentering sets auto-centering horizontally and is equivalent to hmarginratio=1:1. It is set totrue by default for oneside. See also hmarginratio.
vcentering sets auto-centering vertically and is equivalent to vmarginratio=1:1. The default isfalse. See also vmarginratio.
centering sets auto-centering and is equivalent to marginratio=1:1. See also marginratio.The default is false. See also marginratio.
twoside switches on twoside mode with left and right margins swapped on verso pages. Theoption sets \@twoside and \@mparswitch switches. See also asymmetric.
asymmetric implements a twosided layout in which margins are not swapped on alternate pages(by setting \oddsidemargin to \evensidemargin + bindingoffset) and in which themarginal notes stay always on the same side. This option can be used as analternative to the twoside option. See also twoside.
bindingoffsetremoves a specified space from the lefthand-side of the page for oneside or theinner-side for twoside. bindingoffset=〈length〉. This is useful if pages are bound by apress binding (glued, stitched, stapled . . . ). See Figure 4.
hdivide See description in Section 6.2.vdivide See description in Section 6.2.divide See description in Section 6.2.
6.4 Native dimensions
The options below specify LATEX native dimensions and switches for page layout. See Figure 1. Notethat unlike version 2.3, nohead, nofoot and noheadfoot become overwritable, in other words, justshorthand for setting the corresponding LaTeX dimensions (\headheight, \headsep and \footskip)to 0pt.
headheight headmodifies \headheight, height of header. headheight=〈length〉 or head=〈length〉.
11
a) every page for oneside orodd pages for twoside
paper
total body
-� left(inner)
-� right(outer)
- bindingoffset
b) even (back) pages for twoside
paper
total body
-� outer(right)
-�inner(left)
�bindingoffset
Figure 4: bindingoffset option. Note that twoside option swaps the horizontal margins and themarginal notes together with bindingoffset on even pages (see b)), but asymmetric
option suppresses the swap of the margins and marginal notes (but bindingoffset isstill swapped).
headsep modifies \headsep, separation between header and text (body). headsep=〈length〉.footskip foot
modifies \footskip, distance separation between baseline of last line of text andbaseline of footer. footskip=〈length〉 or foot=〈length〉.
nohead eliminates spaces for the head of the page, which is equivalent to both\headheight=0pt and \headsep=0pt.
nofoot eliminates spaces for the foot of the page, which is equivalent to \footskip=0pt.noheadfoot equivalent to nohead and nofoot, which means that \headheight, \headsep and
\footskip are all set to 0pt.footnotesep changes the dimension \skip\footins, separation between the bottom of text body
and the top of footnote text.marginparwidth marginpar
modifies \marginparwidth, width of the marginal notes. marginparwidth=〈length〉.Unlike version 2.3, it does not set includemp=true.
marginparsep modifies \marginparsep, separation between body and marginal notes.marginparsep=〈length〉. Unlike version 2.3, it does not set includemp=true.
nomarginpar shrinks spaces for marginal notes to 0pt, which is equivalent to \marginparwidth=0ptand \marginparsep=0pt.
columnsep modifies \columnsep, the separation between two columns in twocolumn mode.hoffset modifies \hoffset. hoffset=〈length〉.voffset modifies \voffset. voffset=〈length〉.offset horizontal and vertical offset.
offset={〈hoffset〉,〈voffset〉} or offset=〈length〉.twocolumn sets twocolumn mode with \@twocolumntrue. twocolumn=false denotes onecolumn
mode with\@twocolumnfalse.twoside sets both \@twosidetrue and \@mparswitchtrue. See Section 6.3.textwidth sets \textwidth directly. See Section 6.2.textheight sets \textheight directly. See Section 6.2.reversemp reversemarginpar
makes the marginal notes appear in the left (inner) margin with\@reversemargintrue. Unlike version 2.3 or earlier, it does not change includempmode. This is false by default.
12
6.5 drivers
Package geometry supports dvips, dvipdfm including its derivatives dvipdfmx and xdvipdfmx, pdftexfor pdflatex, and vtex for VTEX environment. These driver options are exclusive. The driver can beset by either driver=〈driver name〉 or any of the drivers directly like pdftex. A driver auto-detectionmechanism is introduced in version 4. Therefore, you don’t have to set a driver in most cases, exceptfor dvipdfm. Setting driver=auto makes the auto-detection work whatever the previous setting is.Setting driver=none does nothing for driver.
driver sets driver. driver=〈driver name〉. dvips, dvipdfm, pdftex, vtex, auto and none areavailable as a driver name.
The options below can be set directly instead of driver=〈value〉.
dvips writes the paper size in dvi output with the \special macro. If you use dvips as aDVI-to-PS driver, for example, to print a document with\geometry{a3paper,landscape} on A3 paper in landscape orientation, you don’tneed options “-t a3 -t landscape” to dvips.
dvipdfm works like dvips except landscape correction.pdftex sets \pdfpagewidth and \pdfpageheight internally.vtex sets dimensions \mediawidth and \mediaheight for VTEX. When this driver is
selected (explicitly or automatically), geometry will auto-detect which output mode(DVI, PDF or PS) is selected in VTEX, and do proper settings for it.
If explicit driver setting is mismatched with the typesetting program in use, the default driver dvipswould be selected.
6.6 Other options
The other useful options are described here.
verbose displays parameter results on the terminal. verbose=false (default) still puts theminto the log file.
reset sets back the layout dimensions and switches to the settings before geometry is loaded.Options given in geometry.cfg are also cleared. Note that this cannot reset pass andmag with truedimen. reset=false has no effect and cannot cancel the previousreset(=true) if any. For example, when you go
\documentclass[landscape]{article}\usepackage[twoside,reset,left=2cm]{geometry}
with \ExecuteOptions{scale=0.9} in geometry.cfg, then as a result, landscapeand left=2cm remain effective, and scale=0.9 and twoside are ineffective.
mag sets magnification value (\mag) and automatically modifies \hoffset and \voffsetaccording to the magnification. mag=〈value〉. Note that 〈value〉 should be an integervalue with 1000 as a normal size. For example, mag=1414 with a4paper provides anenlarged print fitting in a3paper, which is 1.414 (=
√2) times larger than a4paper.
Font enlargement needs extra disk space. Note that setting mag should precedeany other settings with ‘true’ dimensions, such as 1.5truein, 2truecm andso on. See also truedimen option.
truedimen changes all internal explicit dimension values into true dimensions, e.g., 1in ischanged to 1truein. Typically this option will be used together with mag option.Note that this is ineffective against externally specified dimensions. For example,when you set “mag=1440, margin=10pt, truedimen”, margins are not ‘true’ butmagnified. If you want to set exact margins, you should set like “mag=1440,margin=10truept, truedimen” instead.
pass disables all of the geometry options and calculations except verbose and showframe.It can be used for checking out the page layout of the documentclass, other packagesand manual settings without geometry.
showframe shows visible frames for the text area and page, and the lines for the head and foot onthe first page.
13
compat2 sets all kind of options so that \usepackage[compat2]{geometry} would behave as ifone is using the old version (v2.3) with the old default layout: [scale={0.8,0.9},centering, includeheadfoot], which is here expressed by options available inversion 3. Note this option should be set as a first option.
7 Default settings
7.1 Default layout
Let us recapitulate the default layout here. The geometry package has the following default page layoutfor onesided documents:
scale=0.7, marginratio={1:1, 2:3}, ignoreall
For twoside, the horizontal margin ratio is also set 2:3,
scale=0.7, marginratio=2:3, ignoreall.
Of course, you don’t need to set them explicitly. \usepackage{geometry} will internally set the aboveoptions. Additional options will overwrite the layout dimensions. For example,
\usepackage[hmargin=2cm]{geometry}
will overwrite horizontal dimensions, but use the default for vertical layout. Page dimensions specifiedby the documentclass being used and other direct settings before geometry is loaded are passed downto geometry.
Note version 2.3 or earlier had default layout different from the version 3. The old default optionscan be expressed with options available in the current version:
scale={0.8,0.9}, centering, includeheadfoot.
Adding compat2 as a first option sets those options so that, for example,
\usepackage[compat2, width=10cm]{geometry}
would behave as if one is using the old version (v2.3).
7.2 Configuration file
One can set up a configuration file to make default options. To do this, produce a file geometry.cfgcontaining an \ExecuteOptions macro, for example,
\ExecuteOptions{a4paper,dvips}
and install it somewhere TEX can find it.The options specified in the geometry.cfg can be cleared by option reset.
8 Relations between options
This section shows how complexity is solved when options are over-specified.
8.1 Order dependence
The geometry options are basically order-independent, but there are some exceptions. For multiplespecification of the same option, 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(or inner) margin is overwritten by left=1cm. As a result, it is equivalent to hmargin={1cm,2cm}.The reset option removes all the geometry options (except pass) before it. If you set
14
\documentclass[landscape]{article}\usepackage[margin=1cm,twoside]{geometry}\geometry{a5paper, reset, left=2cm}
then margin=1cm, twoside and a5paper are removed. As a result, this case is equivalent to
\documentclass[landscape]{article}\usepackage[left=2cm]{geometry}
The mag option should be set in advance of any other settings with ‘true’ length, such asleft=1.5truecm, width=5truein and so on. The \mag primitive can be set before this package iscalled.
8.2 Priority
There are several ways to set dimensions of the printable area: scale, total, text and lines. Basicallyspecification with the more concrete dimension has the higher priority:
low −→ high (priority) hscalevscalescale
<
widthheighttotal
<
textwidthtextheighttext
< lines.
For example,
\usepackage[hscale=0.8, textwidth=7in, width=18cm]{geometry}
is the same as \usepackage[textwidth=7in]{geometry}. Another example:
\usepackage[lines=30, scale=0.8, text=7in]{geometry}
results in [lines=30, textwidth=7in].Options determining margin size also have priority rule: margin ratios versus margin length. For
example, if both marginratio=1:2 and margin=1cm are set at the same time, margin=1cm wins becausemargin=1cm is more concrete dimension than ratios. That is why normal margin options work well withdefault margin ratios (marginratio={1:1, 2:3} for oneside).
low −→ high (priority) hmarginratiovmarginratiomarginratio
<
hmargin or left & rightvmargin or top & bottommargin
.
9 Examples
• A onesided page layout with the text area centered in the paper. The examples below have thesame result because the horizontal margin ratio is set 1:1 for oneside by default.
– centering
– marginratio=1:1
– vcentering
• A twosided page layout with the inside offset for binding 1cm.
– twoside, bindingoffset=1cm
In this case, textwidth is shorter than the case without bindingoffset=1cm by 0.7 × 1cm(=0.7cm).
• A layout with the left, right, and top margin 3cm, 2cm and 2.5in respectively, with textheight of40 lines, and with the head and foot of the page included in total body. The two examples belowhave the same result.
15
– left=3cm, right=2cm, lines=40, top=2.5in, includeheadfoot
– hmargin={3cm,2cm}, tmargin=2.5in, lines=40, includeheadfoot
• A layout with the height of total body 10in, the bottom margin 2cm, and the default width. Thetop margin will be calculated automatically. Each solution below results in the same page layout.
– vdivide={*, 10in, 2cm}
– bmargin=2cm, height=10in
– bottom=2cm, textheight=10in
Note that dimensions for head and foot are excluded from height of total body. An additionalincludefoot makes \footskip included in totalheight. Therefore, in the two cases below,textheight in the former layout is shorter than the latter (with 10in exactly) by \footskip. Inother words, height = textheight + footskip when includefoot=true in this case.
– bmargin=2cm, height=10in, includefoot
– bottom=2cm, textheight=10in, includefoot
• A layout with textwidth and textheight 90% of the paper and with body centered. Each solutionbelow results in the same page layout.
– scale=0.9, centering
– text={.9\paperwidth,.9\paperheight}, ratio=1:1
– width=.9\paperwidth, vmargin=.05\paperheight, marginratio=1:1
– hdivide={*,0.9\paperwidth,*}, vdivide={*,0.9\paperheight,*} (as for onesided doc-uments)
– margin={0.05\paperwidth,0.05\paperheight}
You can add heightrounded to avoid an “underfull vbox warning” like
Underfull \vbox (badness 10000) has occurred while \output is active.
See Section 6.2 for the detail description about heightrounded.
• A layout with the width of marginal notes 3cm and included in the width of total body. Thefollowing examples are the same.
– marginparwidth=3cm, includemp
– marginpar=3cm, ignoremp=false
• A layout the full scale body of the paper with A5 paper in landscape. The following examplesare the same.
– a5paper, landscape, scale=1.0
– landscape=TRUE, paper=a5paper, margin=0pt
• A screen size layout appropriate to presentation with PC and video projector.
\documentclass{slide}
\usepackage[screen,margin=0.8in]{geometry}
...
\begin{slide}
...
\end{slide}
• A layout with fonts and spaces both enlarged from A4 to A3. In the case below, the resultedpaper size is A3.
– a4paper, mag=1414.
If you want to have a layout with two times bigger fonts, but without changing paper size, youcan go
16
– letterpaper, mag=2000, truedimen.
You can add dvips option, that is useful to preview it with proper paper size by dviout or xdvi.
• An old style setting with v2.3 or earlier
\usepackage[a4paper,mag=1200,truedimen,margin=2cm,
twosideshift=10pt,
headsep=7pt,headheight=14.5pt,
marginparwidth=30pt]{geometry}
can be rewritten with options in version 3 without compat2:
\usepackage{calc}
\usepackage[a4paper,mag=1200,truedimen,margin=2cm,
twoside, left=2cm+10pt, right=2cm-10pt,
includeheadfoot, headsep=7pt,headheight=14.5pt,
includemp, marginparwidth=30pt]{geometry}
In this case, includeall can be used instead of includeheadfoot and includemp.
• A complex page layout.
\usepackage[a5paper, landscape, twocolumn, twoside,
left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt,
bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
columnsep=1cm, dvips, verbose]{geometry}
Try typesetting it and checking out the result yourself. :-)
10 Known problems
• With pdftex=true, mag 6= 1000 and truedimen, paperwidth and paperheight shown in verbosemode are different from the real size of the resulted PDF. The PDF itself is correct anyway.
• With pdftex=true, mag 6= 1000, no truedimen, and hyperref, hyperref should be loaded by\usepackage before geometry. Otherwise the resulted PDF size will become wrong.
• With crop package and mag 6= 1000, center option of crop doesn’t work well.
11 Acknowledgments
The author appreciates helpful suggestions and comments from Jean-Bernard Addor, Frank Ben-nett, Alexis Dimitriadis, Friedrich Flender, Stephan Hennig, Morten Høgholm, Jonathan Kew, JamesKilfiger, Jean-Marc Lasgouttes, Wlodzimierz Macewicz, Rolf Niepraschk, Hans Fr. Nordhaug, KeithReckdahl, Peter Riocreux, Will Robertson, Nico Schloemer, Perry C. Stearns, Frank Stengel, PlamenTanovski, Petr Uher, Piet van Oostrum, Vladimir Volovich, and Michael Vulis.
The author is deeply grateful to Frank Mittelbach for checking the codes patiently and providingextremely helpful insight and suggestions for version 3.
12 Implementation
1 〈∗package〉
This package requires three other packages: keyval in LATEX graphics bundle, ifpdf and ifvtex in ‘oberdiek’bundle.2 \RequirePackage{keyval}%
3 \RequirePackage{ifpdf}%
4 \RequirePackage{ifvtex}%
Internal switches are declared here.5 \newif\ifGm@verbose
17
6 \newif\ifGm@landscape
7 \newif\ifGm@includehead
8 \newif\ifGm@includefoot
9 \newif\ifGm@includemp
10 \newif\ifGm@hbody
11 \newif\ifGm@vbody
12 \newif\ifGm@heightrounded
13 \newif\ifGm@showframe
14 \newif\ifGm@compatii
15 \newif\ifGm@sworient\Gm@sworientfalse
16 \newif\ifGm@pass\Gm@passfalse
17 \newif\ifGm@resetpaper
\Gm@cnth
\Gm@cntv
Counters for horizontal and vertical partitioning patterns.18 \newcount\Gm@cnth
19 \newcount\Gm@cntv
\c@Gm@tempcnt The counter is used to set number with calc.20 \newcount\c@Gm@tempcnt
\Gm@bindingoffset An additional inner offset for binding.21 \newdimen\Gm@bindingoffset
\Gm@wd@mp
\Gm@odd@mp
\Gm@even@mp
Correction lengths for \textwidth, \oddsidemargin and \evensidemargin in includemp mode.22 \newdimen\Gm@wd@mp
23 \newdimen\Gm@odd@mp
24 \newdimen\Gm@even@mp
\Gm@dimlist Native dimension setting list.25 \newtoks\Gm@dimlist
\Gm@warning Macro for printing warning messages.26 \def\Gm@warning#1{\PackageWarningNoLine{geometry}{#1}}%
27 \@onlypreamble\Gm@warning
\Gm@Dhratio
\Gm@Dhratiotwo
\Gm@Dvratio
The default values for the horizontal and vertical marginalratio are defined. \Gm@Dhratiotwo denotesthe default value of horizonal marginratio for twoside page layout with left and right margins swappedon verso pages, which is set by twoside.28 \def\Gm@Dhratio{1:1}% = left:right default for oneside
29 \def\Gm@Dhratiotwo{2:3}% = inner:outer default for twoside.
30 \def\Gm@Dvratio{2:3}% = top:bottom default
31 \@onlypreamble\Gm@Dhratio
32 \@onlypreamble\Gm@Dhratiotwo
33 \@onlypreamble\Gm@Dvratio
\Gm@Dhscale
\Gm@Dvscale
The default values for the horizontal and vertical scale are defined. In version 3 the default scale hasbeen changed from {0.8, 0.9} to {0.7, 0.7} in each direction.34 \def\Gm@Dhscale{0.7}%
35 \def\Gm@Dvscale{0.7}%
36 \@onlypreamble\Gm@Dhscale
37 \@onlypreamble\Gm@Dvscale
\Gm@dvips
\Gm@dvipdfm
\Gm@pdftex
\Gm@vtex
The driver names.38 \def\Gm@dvips{dvips}%
39 \def\Gm@dvipdfm{dvipdfm}%
40 \def\Gm@pdftex{pdftex}%
41 \def\Gm@vtex{vtex}%
42 \@onlypreamble\Gm@dvips
43 \@onlypreamble\Gm@dvipdfm
44 \@onlypreamble\Gm@pdftex
45 \@onlypreamble\Gm@vtex
18
\Gm@true
\Gm@false 46 \def\Gm@true{true}%
47 \def\Gm@false{false}%
\Gm@orgpw
\Gm@orgph
These macros keep original paper (media) size intact.48 \edef\Gm@orgpw{\the\paperwidth}%
49 \edef\Gm@orgph{\the\paperheight}%
\Gm@dorg The macro saves LATEX native dimensions and switches before processing geometry options, and is calledwhen reset or pass is set.50 \edef\Gm@dorg{%
51 \noexpand\setlength{\paperwidth}{\the\paperwidth}%
52 \noexpand\setlength{\paperheight}{\the\paperheight}%
53 \noexpand\setlength{\textheight}{\the\textheight}%
54 \noexpand\setlength{\textwidth}{\the\textwidth}%
55 \noexpand\setlength{\oddsidemargin}{\the\oddsidemargin}%
56 \noexpand\setlength{\evensidemargin}{\the\evensidemargin}%
57 \noexpand\setlength{\topmargin}{\the\topmargin}%
58 \noexpand\setlength{\headsep}{\the\headsep}%
59 \noexpand\setlength{\headheight}{\the\headheight}%
60 \noexpand\setlength{\footskip}{\the\footskip}%
61 \noexpand\setlength{\marginparwidth}{\the\marginparwidth}%
62 \noexpand\setlength{\marginparsep}{\the\marginparsep}%
63 \noexpand\setlength{\columnsep}{\the\columnsep}%
64 \noexpand\setlength{\skip\footins}{\the\skip\footins}%
65 \noexpand\setlength{\hoffset}{\the\hoffset}%
66 \noexpand\setlength{\voffset}{\the\voffset}%
67 \expandafter\noexpand\csname @twocolumn\if@twocolumn
68 \Gm@true\else\Gm@false\fi\endcsname
69 \expandafter\noexpand\csname @twoside\if@twoside
70 \Gm@true\else\Gm@false\fi\endcsname
71 \expandafter\noexpand\csname @mparswitch\if@mparswitch
72 \Gm@true\else\Gm@false\fi\endcsname
73 \expandafter\noexpand\csname @reversemargin\if@reversemargin
74 \Gm@true\else\Gm@false\fi\endcsname
75 \noexpand\mag=\the\mag}%
76 \@onlypreamble\Gm@dorg
\Gm@init The macro for initializing modes and flags is defined here. This macro is called at the beginning of thepackage and when reset is specified.77 \def\Gm@init{%
78 \Gm@hbodyfalse\Gm@vbodyfalse
79 \Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse
80 \Gm@landscapefalse\Gm@compatiifalse\Gm@heightroundedfalse
81 \Gm@verbosefalse\Gm@showframefalse\Gm@resetpaperfalse
82 \let\Gm@paper\@undefined
83 \let\Gm@width\@undefined\let\Gm@height\@undefined
84 \let\Gm@textwidth\@undefined\let\Gm@textheight\@undefined
85 \let\Gm@hscale\@undefined\let\Gm@vscale\@undefined
86 \let\Gm@hmarginratio\@undefined\let\Gm@vmarginratio\@undefined
87 \let\Gm@lmargin\@undefined\let\Gm@rmargin\@undefined
88 \let\Gm@tmargin\@undefined\let\Gm@bmargin\@undefined
89 \let\Gm@driver\@empty\let\Gm@truedimen\@empty
90 \Gm@bindingoffset\z@\Gm@dimlist={}}%
91 \@onlypreamble\Gm@init
\Gm@setdriver The macro sets the specified driver.92 \def\Gm@setdriver#1{%
93 \expandafter\let\expandafter\Gm@driver\csname Gm@#1\endcsname}%
\Gm@unsetdriver The macro unsets the specified driver if it has been set.94 \def\Gm@unsetdriver#1{%
95 \expandafter\ifx\csname Gm@#1\endcsname\Gm@driver
19
96 \let\Gm@driver\@empty
97 \fi}%
\Gm@setbool
\Gm@setboolrev
The macros set a boolean option.98 \def\Gm@setbool{\@dblarg\Gm@@setbool}%
99 \def\Gm@setboolrev{\@dblarg\Gm@@setboolrev}%
100 \def\Gm@@setbool[#1]#2#3{\Gm@doif{#1}{#3}{\csname Gm@#2\Gm@bool\endcsname}}%
101 \def\Gm@@setboolrev[#1]#2#3{\Gm@doifelse{#1}{#3}%
102 {\csname Gm@#2\Gm@false\endcsname}{\csname Gm@#2\Gm@true\endcsname}}%
103 \@onlypreamble\Gm@setbool
104 \@onlypreamble\Gm@setboolrev
105 \@onlypreamble\Gm@@setbool
106 \@onlypreamble\Gm@@setboolrev
\Gm@doif
\Gm@doifelse
\Gm@doif excutes the third argument #3 using a boolean value #2 of a option #1. \Gm@doifelseexecutes the third argument #3 if a boolean option #1 with its value #2 is true, and executes thefourth argument #4 if false.
107 \def\Gm@doif#1#2#3{%
108 \lowercase{\def\Gm@bool{#2}}%
109 \ifx\Gm@bool\@empty
110 \let\Gm@bool\Gm@true
111 \fi
112 \ifx\Gm@bool\Gm@true
113 \else
114 \ifx\Gm@bool\Gm@false
115 \else
116 \let\Gm@bool\relax
117 \fi
118 \fi
119 \ifx\Gm@bool\relax
120 \Gm@warning{‘#1’ should be set to ‘true’ or ‘false’}%
121 \else
122 #3
123 \fi}%
124 \def\Gm@doifelse#1#2#3#4{%
125 \Gm@doif{#1}{#2}{\ifx\Gm@bool\Gm@true #3\else #4\fi}}%
126 \@onlypreamble\Gm@doif
127 \@onlypreamble\Gm@doifelse
\Gm@reverse The macro reverses a bool value.128 \def\Gm@reverse#1{%
129 \csname ifGm@#1\endcsname
130 \csname Gm@#1false\endcsname\else\csname Gm@#1true\endcsname\fi}%
131 \@onlypreamble\Gm@reverse
\Gm@checkbool The macro is used in \Gm@showparams to print true or nothing.132 \def\Gm@checkbool#1{#1: \csname ifGm@#1\endcsname true\else --\fi^^J}%
133 \@onlypreamble\Gm@checkbool
\Gm@defbylen
\Gm@defbycnt
Macros \Gm@defbylen and \Gm@defbycnt can be used to define \Gm@xxxx variables by length andcounter respectively with calc package.
134 \def\Gm@defbylen#1#2{%
135 \setlength\@tempdima{#2}%
136 \expandafter\edef\csname Gm@#1\endcsname{\the\@tempdima}}%
137 \def\Gm@defbycnt#1#2{%
138 \setcounter{Gm@tempcnt}{#2}%
139 \expandafter\edef\csname Gm@#1\endcsname{\the\value{Gm@tempcnt}}}%
140 \@onlypreamble\Gm@defbylen
141 \@onlypreamble\Gm@defbycnt
\Gm@set@ratio The macro parses the value of options specifying marginal ratios, which is used in \Gm@setbyratiomacro.
142 \def\Gm@sep@ratio#1:#2{\@tempcnta=#1\@tempcntb=#2}%
143 \@onlypreamble\Gm@set@ratio
20
\Gm@setbyratio The macro determines the dimension specified by #4 calculating #3×a/b, where a and b are given by\Gm@mratio with a : b value. If #1 in brackets is b, a and b are swapped. The second argument with hor v denoting horizontal or vertical is not used in this macro.
144 \def\Gm@setbyratio[#1]#2#3#4{% determine #4 by ratio
145 \expandafter\Gm@sep@ratio\Gm@mratio\relax
146 \if#1b
147 \edef\@@tempa{\the\@tempcnta}%
148 \@tempcnta=\@tempcntb
149 \@tempcntb=\@@tempa\relax
150 \fi
151 \expandafter\setlength\expandafter\@tempdimb\expandafter
152 {\csname Gm@#3\endcsname}%
153 \ifnum\@tempcntb>\z@
154 \multiply\@tempdimb\@tempcnta
155 \divide\@tempdimb\@tempcntb
156 \fi
157 \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdimb}}%
158 \@onlypreamble\Gm@setbyratio
\Gm@detiv This macro determines the fourth length(#4) from #1(paperwidth or paperheight), #2 and #3. It is usedin \Gm@detall macro.
159 \def\Gm@detiv#1#2#3#4{% determine #4.
160 \expandafter\setlength\expandafter\@tempdima\expandafter
161 {\csname paper#1\endcsname}%
162 \expandafter\setlength\expandafter\@tempdimb\expandafter
163 {\csname Gm@#2\endcsname}%
164 \addtolength\@tempdima{-\@tempdimb}%
165 \expandafter\setlength\expandafter\@tempdimb\expandafter
166 {\csname Gm@#3\endcsname}%
167 \addtolength\@tempdima{-\@tempdimb}%
168 \ifdim\@tempdima<\z@
169 \Gm@warning{‘#4’ results in NEGATIVE (\the\@tempdima).%
170 ^^J\@spaces ‘#2’ or ‘#3’ should be shortened in length}%
171 \fi
172 \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdima}}%
173 \@onlypreamble\Gm@detiv
\Gm@detiiandiii This macro determines #2 and #3 from #1 with the first argument (#1) can be width or height, whichis expanded into dimensions of paper and total body. It is used in \Gm@detall macro.
174 \def\Gm@detiiandiii#1#2#3{% determine #2 and #3.
175 \expandafter\setlength\expandafter\@tempdima\expandafter
176 {\csname paper#1\endcsname}%
177 \expandafter\setlength\expandafter\@tempdimb\expandafter
178 {\csname Gm@#1\endcsname}%
179 \addtolength\@tempdima{-\@tempdimb}%
180 \ifdim\@tempdima<\z@
181 \Gm@warning{‘#2’ and ‘#3’ result in NEGATIVE (\the\@tempdima).%
182 ^^J\@spaces ‘#1’ should be shortened in length}%
183 \fi
184 \ifx\Gm@mratio\@undefined
185 \divide\@tempdima\tw@
186 \@tempdimb=\@tempdima
187 \else
188 \@tempdimb=\@tempdima
189 \expandafter\Gm@sep@ratio\Gm@mratio\relax
190 \advance\@tempcntb\@tempcnta
191 \ifnum\@tempcntb>\z@
192 \divide\@tempdima\@tempcntb
193 \multiply\@tempdima\@tempcnta
194 \advance\@tempdimb-\@tempdima
195 \else
196 \divide\@tempdima\tw@
197 \@tempdimb=\@tempdima
21
198 \fi
199 \fi
200 \expandafter\edef\csname Gm@#2\endcsname{\the\@tempdima}%
201 \expandafter\edef\csname Gm@#3\endcsname{\the\@tempdimb}}%
202 \@onlypreamble\Gm@detiiandiii
\Gm@detall This macro determines partition of each direction. The first argument (#1) should be h or v, the second(#2) width or height, the third (#3) lmargin or top, and the last (#4) rmargin or bottom.
203 \def\Gm@detall#1#2#3#4{%
204 \@tempcnta\z@
205 \edef\Gm@mratio{\@nameuse{Gm@#1marginratio}}%
\@tempcnta is treated as a three-digit binary value with top, middle and bottom denoted left(top),width(height) and right(bottom) margins user specified respectively.
206 \if#1h
207 \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta4\relax\fi
208 \ifGm@hbody\advance\@tempcnta2\relax\fi
209 \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta1\relax\fi
210 \Gm@cnth\@tempcnta
211 \else
212 \ifx\Gm@tmargin\@undefined\else\advance\@tempcnta4\relax\fi
213 \ifGm@vbody\advance\@tempcnta2\relax\fi
214 \ifx\Gm@bmargin\@undefined\else\advance\@tempcnta1\relax\fi
215 \Gm@cntv\@tempcnta
216 \fi
Case the value is 000 (=0) with nothing fixed (default):217 \ifcase\@tempcnta
218 \if#1h
219 \edef\Gm@width{\Gm@Dhscale\paperwidth}%
220 \else
221 \edef\Gm@height{\Gm@Dvscale\paperheight}%
222 \fi
223 \Gm@detiiandiii{#2}{#3}{#4}%
Case 001 (=1) with right(bottom) fixed:224 \or\Gm@setbyratio[f]{#1}{#4}{#3}\Gm@detiv{#2}{#3}{#4}{#2}%
Case 010 (=2) with width(height) fixed:225 \or\Gm@detiiandiii{#2}{#3}{#4}%
Case 011 (=3) with both width(height) and right(bottom) fixed:226 \or\Gm@detiv{#2}{#2}{#4}{#3}%
Case 100 (=4) with left(top) fixed:227 \or\Gm@setbyratio[b]{#1}{#3}{#4}\Gm@detiv{#2}{#3}{#4}{#2}%
Case 101 (=5) with both left(top) and right(bottom) fixed:228 \or\Gm@detiv{#2}{#3}{#4}{#2}%
Case 110 (=6) with both left(top) and width(height) fixed:229 \or\Gm@detiv{#2}{#2}{#3}{#4}%
Case 111 (=7) with all fixed though it is over-specified:230 \or\Gm@warning{Over-specification in ‘#1’-direction.%
231 ^^J\@spaces ‘#2’ (\@nameuse{Gm@#2}) is ignored}%
232 \Gm@detiv{#2}{#3}{#4}{#2}%
233 \else\fi}%
234 \@onlypreamble\Gm@detall
\Gm@clean The macro for setting unspecified dimensions to be \@undefined. This is used by \geometry macro.235 \def\Gm@clean{%
236 \ifnum\Gm@cnth<4\let\Gm@lmargin\@undefined\fi
237 \ifodd\Gm@cnth\else\let\Gm@rmargin\@undefined\fi
238 \ifnum\Gm@cntv<4\let\Gm@tmargin\@undefined\fi
239 \ifodd\Gm@cntv\else\let\Gm@bmargin\@undefined\fi
240 \ifGm@hbody\else
22
241 \let\Gm@hscale\@undefined
242 \let\Gm@width\@undefined
243 \let\Gm@textwidth\@undefined
244 \fi
245 \ifGm@vbody\else
246 \let\Gm@vscale\@undefined
247 \let\Gm@height\@undefined
248 \let\Gm@textheight\@undefined
249 \fi
250 \if@twoside
251 \ifx\Gm@hmarginratio\Gm@Dhratiotwo
252 \let\Gm@hmarginratio\@undefined
253 \fi
254 \else
255 \ifx\Gm@hmarginratio\Gm@Dhratio
256 \let\Gm@hmarginratio\@undefined
257 \fi
258 \fi}%
259 \@onlypreamble\Gm@clean
\Gm@parse@divide The macro parses (h,v)divide options.260 \def\Gm@parse@divide#1#2#3#4{%
261 \def\Gm@star{*}%
262 \@tempcnta\z@
263 \@for\Gm@tmp:=#1\do{%
264 \expandafter\KV@@sp@def\expandafter\Gm@frag\expandafter{\Gm@tmp}%
265 \edef\Gm@value{\Gm@frag}%
266 \ifcase\@tempcnta\relax\edef\Gm@key{#2}%
267 \or\edef\Gm@key{#3}%
268 \else\edef\Gm@key{#4}%
269 \fi
270 \@nameuse{Gm@set\Gm@key false}%
271 \ifx\empty\Gm@value\else
272 \ifx\Gm@star\Gm@value\else
273 \setkeys{Gm}{\Gm@key=\Gm@value}%
274 \fi\fi
275 \advance\@tempcnta\@ne}%
276 \let\Gm@star\relax}%
277 \@onlypreamble\Gm@parse@divide
\Gm@branch The macro splits a value into the same two values.278 \def\Gm@branch#1#2#3{%
279 \@tempcnta\z@
280 \@for\Gm@tmp:=#1\do{%
281 \KV@@sp@def\Gm@frag{\Gm@tmp}%
282 \edef\Gm@value{\Gm@frag}%
283 \ifcase\@tempcnta\relax% cnta == 0
284 \setkeys{Gm}{#2=\Gm@value}%
285 \or% cnta == 1
286 \setkeys{Gm}{#3=\Gm@value}%
287 \else\fi
288 \advance\@tempcnta\@ne}%
289 \ifnum\@tempcnta=\@ne
290 \setkeys{Gm}{#3=\Gm@value}%
291 \fi}%
292 \@onlypreamble\Gm@branch
\Gm@magtooffset This macro is used to adjust offsets by \mag.293 \def\Gm@magtooffset{%
294 \@tempdima=\mag\Gm@truedimen sp%
295 \@tempdimb=1\Gm@truedimen in%
296 \divide\@tempdimb\@tempdima
297 \multiply\@tempdimb\@m
298 \addtolength{\hoffset}{1\Gm@truedimen in}%
23
299 \addtolength{\voffset}{1\Gm@truedimen in}%
300 \addtolength{\hoffset}{-\the\@tempdimb}%
301 \addtolength{\voffset}{-\the\@tempdimb}}%
302 \@onlypreamble\Gm@magtooffset
\Gm@setafter This macro stores LATEX native dimensions, which are stored and set afterwards.303 \def\Gm@setafter#1#2{%
304 \let\Gm@len=\relax\let\Gm@td=\relax
305 \edef\addtolist{\noexpand\Gm@dimlist=%
306 {\the\Gm@dimlist \Gm@len{#1}{#2}}}\addtolist}%
307 \@onlypreamble\Gm@setafter
\Gm@processdimlist This macro processes \[email protected] \def\Gm@processdimlist{%
309 \def\Gm@td{\Gm@truedimen}%
310 \def\Gm@len##1##2{\setlength{##1}{##2}}%
311 \the\Gm@dimlist}%
312 \@onlypreamble\Gm@processdimlist
\Gm@setpaper The macro sets paperwidth and paperheight dimensions using \Gm@setafter macro.313 \def\Gm@setpaper(#1,#2)#3{%
314 \let\Gm@td\relax
315 \Gm@setafter\paperwidth{#1\Gm@td #3}%
316 \Gm@setafter\paperheight{#2\Gm@td #3}%
317 \ifGm@landscape\Gm@sworienttrue\else\Gm@sworientfalse\fi}%
318 \@onlypreamble\Gm@setpaper
\Gm@chpaper The macro changes the paper size.319 \def\Gm@chpaper{\@nameuse{Gm@\Gm@paper}}%
320 \@onlypreamble\Gm@chpaper
Various paper size are defined here.321 \@namedef{Gm@a0paper}{\Gm@setpaper(841,1189){mm}}%
322 \@namedef{Gm@a1paper}{\Gm@setpaper(594,841){mm}}%
323 \@namedef{Gm@a2paper}{\Gm@setpaper(420,594){mm}}%
324 \@namedef{Gm@a3paper}{\Gm@setpaper(297,420){mm}}%
325 \@namedef{Gm@a4paper}{\Gm@setpaper(210,297){mm}}%
326 \@namedef{Gm@a5paper}{\Gm@setpaper(148,210){mm}}%
327 \@namedef{Gm@a6paper}{\Gm@setpaper(105,148){mm}}%
328 \@namedef{Gm@b0paper}{\Gm@setpaper(1000,1414){mm}}%
329 \@namedef{Gm@b1paper}{\Gm@setpaper(707,1000){mm}}%
330 \@namedef{Gm@b2paper}{\Gm@setpaper(500,707){mm}}%
331 \@namedef{Gm@b3paper}{\Gm@setpaper(353,500){mm}}%
332 \@namedef{Gm@b4paper}{\Gm@setpaper(250,353){mm}}%
333 \@namedef{Gm@b5paper}{\Gm@setpaper(176,250){mm}}%
334 \@namedef{Gm@b6paper}{\Gm@setpaper(125,176){mm}}%
335 \@namedef{Gm@ansiapaper}{\Gm@setpaper(8.5,11){in}}%
336 \@namedef{Gm@ansibpaper}{\Gm@setpaper(11,17){in}}%
337 \@namedef{Gm@ansicpaper}{\Gm@setpaper(17,22){in}}%
338 \@namedef{Gm@ansidpaper}{\Gm@setpaper(22,34){in}}%
339 \@namedef{Gm@ansiepaper}{\Gm@setpaper(34,44){in}}%
340 \@namedef{Gm@letterpaper}{\Gm@setpaper(8.5,11){in}}%
341 \@namedef{Gm@legalpaper}{\Gm@setpaper(8.5,14){in}}%
342 \@namedef{Gm@executivepaper}{\Gm@setpaper(7.25,10.5){in}}%
343 \@namedef{Gm@screen}{\Gm@setpaper(225,180){mm}}%
All the available options are defined below.
‘paper’ paper takes paper name as its value. Available paper names are listed below.344 \define@key{Gm}{paper}{\setkeys{Gm}{#1}}%
345 \let\KV@Gm@papername\KV@Gm@paper
‘a[0-6]paper’
‘b[0-6]paper’
‘ansi[a-e]paper’
‘letterpaper’
‘legalpaper’
‘executivepaper’
‘screen’
The following paper names are available. screen and ANSI paper sizes have been introduced in ver.3,but of course they can’t be used as a documentclass option.
24
346 \define@key{Gm}{a0paper}[true]{\def\Gm@paper{a0paper}\Gm@chpaper}%
347 \define@key{Gm}{a1paper}[true]{\def\Gm@paper{a1paper}\Gm@chpaper}%
348 \define@key{Gm}{a2paper}[true]{\def\Gm@paper{a2paper}\Gm@chpaper}%
349 \define@key{Gm}{a3paper}[true]{\def\Gm@paper{a3paper}\Gm@chpaper}%
350 \define@key{Gm}{a4paper}[true]{\def\Gm@paper{a4paper}\Gm@chpaper}%
351 \define@key{Gm}{a5paper}[true]{\def\Gm@paper{a5paper}\Gm@chpaper}%
352 \define@key{Gm}{a6paper}[true]{\def\Gm@paper{a6paper}\Gm@chpaper}%
353 \define@key{Gm}{b0paper}[true]{\def\Gm@paper{b0paper}\Gm@chpaper}%
354 \define@key{Gm}{b1paper}[true]{\def\Gm@paper{b1paper}\Gm@chpaper}%
355 \define@key{Gm}{b2paper}[true]{\def\Gm@paper{b2paper}\Gm@chpaper}%
356 \define@key{Gm}{b3paper}[true]{\def\Gm@paper{b3paper}\Gm@chpaper}%
357 \define@key{Gm}{b4paper}[true]{\def\Gm@paper{b4paper}\Gm@chpaper}%
358 \define@key{Gm}{b5paper}[true]{\def\Gm@paper{b5paper}\Gm@chpaper}%
359 \define@key{Gm}{b6paper}[true]{\def\Gm@paper{b6paper}\Gm@chpaper}%
360 \define@key{Gm}{ansiapaper}[true]{\def\Gm@paper{ansiapaper}\Gm@chpaper}%
361 \define@key{Gm}{ansibpaper}[true]{\def\Gm@paper{ansibpaper}\Gm@chpaper}%
362 \define@key{Gm}{ansicpaper}[true]{\def\Gm@paper{ansicpaper}\Gm@chpaper}%
363 \define@key{Gm}{ansidpaper}[true]{\def\Gm@paper{ansidpaper}\Gm@chpaper}%
364 \define@key{Gm}{ansiepaper}[true]{\def\Gm@paper{ansiepaper}\Gm@chpaper}%
365 \define@key{Gm}{letterpaper}[true]{\def\Gm@paper{letterpaper}\Gm@chpaper}%
366 \define@key{Gm}{legalpaper}[true]{\def\Gm@paper{legalpaper}\Gm@chpaper}%
367 \define@key{Gm}{executivepaper}[true]{\def\Gm@paper{executivepaper}%
368 \Gm@chpaper}%
369 \define@key{Gm}{screen}[true]{\def\Gm@paper{screen}\Gm@chpaper}%
‘paperwidth’
‘paperheight’
‘papersize’
Direct specification for paper size is also possible.370 \define@key{Gm}{paperwidth}{%
371 \Gm@setafter\paperwidth{#1}\def\Gm@paper{user defined}}%
372 \define@key{Gm}{paperheight}{%
373 \Gm@setafter\paperheight{#1}\def\Gm@paper{user defined}}%
374 \define@key{Gm}{papersize}{\Gm@branch{#1}{paperwidth}{paperheight}}%
‘landscape’
‘portrait’
Paper orientation setting is also available.375 \define@key{Gm}{landscape}[true]{\Gm@doifelse{landscape}{#1}%
376 {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{sworient}\fi}%
377 {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{sworient}\fi}}%
378 \define@key{Gm}{portrait}[true]{\Gm@doifelse{portrait}{#1}%
379 {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{sworient}\fi}%
380 {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{sworient}\fi}}%
‘hscale’
‘vscale’
‘scale’
These options can determine the length(s) of total body giving scale(s) against the paper size.381 \define@key{Gm}{hscale}{\Gm@hbodytrue\edef\Gm@hscale{#1}}%
382 \define@key{Gm}{vscale}{\Gm@vbodytrue\edef\Gm@vscale{#1}}%
383 \define@key{Gm}{scale}{\Gm@branch{#1}{hscale}{vscale}}%
‘width’
‘height’
‘total’
‘totalwidth’
‘totalheight’
These options give concrete dimension(s) of total body. totalwidth and totalheight are aliases ofwidth and height respectively.
384 \define@key{Gm}{width}{\Gm@hbodytrue\Gm@defbylen{width}{#1}}%
385 \define@key{Gm}{height}{\Gm@vbodytrue\Gm@defbylen{height}{#1}}%
386 \define@key{Gm}{total}{\Gm@branch{#1}{width}{height}}%
387 \let\KV@Gm@totalwidth\KV@Gm@width
388 \let\KV@Gm@totalheight\KV@Gm@height
‘textwidth’
‘textheight’
‘text’
‘body’
These options directly sets the dimensions \textwidth and \textheight. body is an alias of text.389 \define@key{Gm}{textwidth}{\Gm@hbodytrue\Gm@defbylen{textwidth}{#1}}%
390 \define@key{Gm}{textheight}{\Gm@vbodytrue\Gm@defbylen{textheight}{#1}}%
391 \define@key{Gm}{text}{\Gm@branch{#1}{textwidth}{textheight}}%
392 \let\KV@Gm@body\KV@Gm@text
‘lines’ The option sets \textheight with the number of lines.393 \define@key{Gm}{lines}{\Gm@vbodytrue\Gm@defbycnt{lines}{#1}}%
25
‘includehead’
‘includefoot’
‘includeheadfoot’
‘includemp’
‘includeall’
include* options include the corresponding part(s) in total body.394 \define@key{Gm}{includehead}[true]{\Gm@setbool{includehead}{#1}}%
395 \define@key{Gm}{includefoot}[true]{\Gm@setbool{includefoot}{#1}}%
396 \define@key{Gm}{includeheadfoot}[true]{\Gm@doifelse{includeheadfoot}{#1}%
397 {\Gm@includeheadtrue\Gm@includefoottrue}%
398 {\Gm@includeheadfalse\Gm@includefootfalse}}%
399 \define@key{Gm}{includemp}[true]{\Gm@setbool{includemp}{#1}}%
400 \define@key{Gm}{includeall}[true]{\Gm@doifelse{includeall}{#1}%
401 {\Gm@includeheadtrue\Gm@includefoottrue\Gm@includemptrue}%
402 {\Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse}}%
‘ignorehead’
‘ignorefoot’
‘ignoreheadfoot’
‘ignoremp’
‘ignoreall’
ignore* options disregard head, foot and marginpars in determining the location of total body.403 \define@key{Gm}{ignorehead}[true]{%
404 \Gm@setboolrev[ignorehead]{includehead}{#1}}%
405 \define@key{Gm}{ignorefoot}[true]{%
406 \Gm@setboolrev[ignorefoot]{includefoot}{#1}}%
407 \define@key{Gm}{ignoreheadfoot}[true]{\Gm@doifelse{ignoreheadfoot}{#1}%
408 {\Gm@includeheadfalse\Gm@includefootfalse}%
409 {\Gm@includeheadtrue\Gm@includefoottrue}}%
410 \define@key{Gm}{ignoremp}[true]{%
411 \Gm@setboolrev[ignoremp]{includemp}{#1}}%
412 \define@key{Gm}{ignoreall}[true]{\Gm@doifelse{ignoreall}{#1}%
413 {\Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse}%
414 {\Gm@includeheadtrue\Gm@includefoottrue\Gm@includemptrue}}%
‘heightrounded’ The option rounds \textheight to n-times of \baselineskip plus \topskip.415 \define@key{Gm}{heightrounded}[true]{\Gm@setbool{heightrounded}{#1}}%
‘hdivide’
‘vdivide’
‘divide’
The options are useful to specify partitioning in each direction of the paper.416 \define@key{Gm}{hdivide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}}%
417 \define@key{Gm}{vdivide}{\Gm@parse@divide{#1}{tmargin}{height}{bmargin}}%
418 \define@key{Gm}{divide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}%
419 \Gm@parse@divide{#1}{tmargin}{height}{bmargin}}%
‘lmargin’
‘rmargin’
‘tmargin’
‘bmargin’
‘left’
‘inner’
‘innermargin’
‘right’
‘outer’
‘outermargin’
‘top’
‘bottom’
These options set margins. left, inner, innermargin are aliases of lmargin. right, outer,outermargin are aliases of rmargin. top and bottom are aliases of tmargin and bmargin respec-tively.
420 \define@key{Gm}{lmargin}{\Gm@defbylen{lmargin}{#1}}%
421 \define@key{Gm}{rmargin}{\Gm@defbylen{rmargin}{#1}}%
422 \let\KV@Gm@left\KV@Gm@lmargin
423 \let\KV@Gm@inner\KV@Gm@lmargin
424 \let\KV@Gm@innermargin\KV@Gm@lmargin
425 \let\KV@Gm@right\KV@Gm@rmargin
426 \let\KV@Gm@outer\KV@Gm@rmargin
427 \let\KV@Gm@outermargin\KV@Gm@rmargin
428 \define@key{Gm}{tmargin}{\Gm@defbylen{tmargin}{#1}}%
429 \define@key{Gm}{bmargin}{\Gm@defbylen{bmargin}{#1}}%
430 \let\KV@Gm@top\KV@Gm@tmargin
431 \let\KV@Gm@bottom\KV@Gm@bmargin
‘hmargin’
‘vmargin’
‘margin’
These options are shorthands for setting margins.432 \define@key{Gm}{hmargin}{\Gm@branch{#1}{lmargin}{rmargin}}%
433 \define@key{Gm}{vmargin}{\Gm@branch{#1}{tmargin}{bmargin}}%
434 \define@key{Gm}{margin}{\Gm@branch{#1}{lmargin}{tmargin}%
435 \Gm@branch{#1}{rmargin}{bmargin}}%
‘hmarginratio’
‘vmarginratio’
‘marginratio’
‘hratio’
‘vratio’
‘ratio’
Options specifying the margin ratios.436 \define@key{Gm}{hmarginratio}{\edef\Gm@hmarginratio{#1}}%
437 \define@key{Gm}{vmarginratio}{\edef\Gm@vmarginratio{#1}}%
438 \define@key{Gm}{marginratio}{\Gm@branch{#1}{hmarginratio}{vmarginratio}}%
439 \let\KV@Gm@hratio\KV@Gm@hmarginratio
440 \let\KV@Gm@vratio\KV@Gm@vmarginratio
441 \let\KV@Gm@ratio\KV@Gm@marginratio
26
‘hcentering’
‘vcentering’
‘centering’
Useful shorthands to make body centered.442 \define@key{Gm}{hcentering}[true]{\Gm@doifelse{hcentering}{#1}%
443 {\def\Gm@hmarginratio{1:1}}{}}%
444 \define@key{Gm}{vcentering}[true]{\Gm@doifelse{vcentering}{#1}%
445 {\def\Gm@vmarginratio{1:1}}{}}%
446 \define@key{Gm}{centering}[true]{\Gm@doifelse{centering}{#1}%
447 {\def\Gm@hmarginratio{1:1}\def\Gm@vmarginratio{1:1}}{}}%
‘twoside’ If twoside=true, \@twoside and \@mparswitch is set to true.448 \define@key{Gm}{twoside}[true]{\Gm@doifelse{twoside}{#1}%
449 {\@twosidetrue\@mparswitchtrue}{\@twosidefalse\@mparswitchfalse}}%
‘asymmetric’ asymmetric sets \@mparswitchfalse and \@twosidetrue A asymmetric=false has no effect.450 \define@key{Gm}{asymmetric}[true]{\Gm@doifelse{asymmetric}{#1}%
451 {\@twosidetrue\@mparswitchfalse}{}}%
‘bindingoffset’ The macro specifies a white space added to the left or inner margin.452 \define@key{Gm}{bindingoffset}{\Gm@setafter\Gm@bindingoffset{#1}}%
‘headheight’
‘headsep’
‘footskip’
‘head’
‘foot’
The direct settings of head and/or foot dimensions.453 \define@key{Gm}{headheight}{\Gm@setafter\headheight{#1}}%
454 \define@key{Gm}{headsep}{\Gm@setafter\headsep{#1}}%
455 \define@key{Gm}{footskip}{\Gm@setafter\footskip{#1}}%
456 \let\KV@Gm@head\KV@Gm@headheight
457 \let\KV@Gm@foot\KV@Gm@footskip
‘nohead’
‘nofoot’
‘noheadfoot’
They are only shorthands to set head and/or foot to be 0pt.458 \define@key{Gm}{nohead}[true]{\Gm@doifelse{nohead}{#1}%
459 {\Gm@setafter\headheight\z@\Gm@setafter\headsep\z@}{}}%
460 \define@key{Gm}{nofoot}[true]{\Gm@doifelse{nofoot}{#1}%
461 {\Gm@setafter\footskip\z@}{}}%
462 \define@key{Gm}{noheadfoot}[true]{\Gm@doifelse{noheadfoot}{#1}%
463 {\Gm@setafter\headheight\z@\Gm@setafter\headsep
464 \z@\Gm@setafter\footskip\z@}{}}%
‘footnotesep’ The option directly sets a native dimension \footnotesep.465 \define@key{Gm}{footnotesep}{\Gm@setafter{\skip\footins}{#1}}%
‘marginparwidth’
‘marginpar’
‘marginparsep’
They directly set native dimensions \marginparwidth and \marginparsep. For compatibility,includemp is set to true if compat2 is set.
466 \define@key{Gm}{marginparwidth}{\ifGm@compatii\Gm@includemptrue\fi
467 \Gm@setafter\marginparwidth{#1}}%
468 \let\KV@Gm@marginpar\KV@Gm@marginparwidth
469 \define@key{Gm}{marginparsep}{\ifGm@compatii\Gm@includemptrue\fi
470 \Gm@setafter\marginparsep{#1}}%
‘nomarginpar’ The macro is a shorthand for \marginparwidth=0pt and \marginparsep=0pt.471 \define@key{Gm}{nomarginpar}[true]{\Gm@doifelse{nomarginpar}{#1}%
472 {\Gm@setafter\marginparwidth\z@\Gm@setafter\marginparsep\z@}{}}%
‘columnsep’ The option sets a native dimension \columnsep.473 \define@key{Gm}{columnsep}{\Gm@setafter\columnsep{#1}}%
‘hoffset’
‘voffset’
‘offset’
The former two options set native dimensions \hoffset and \voffset. offset can set both of themwith the same value.
474 \define@key{Gm}{hoffset}{\Gm@setafter\hoffset{#1}}%
475 \define@key{Gm}{voffset}{\Gm@setafter\voffset{#1}}%
476 \define@key{Gm}{offset}{\Gm@branch{#1}{hoffset}{voffset}}%
‘twocolumn’ The option sets \twocolumn switch.477 \define@key{Gm}{twocolumn}[true]{%
478 \Gm@doif{twocolumn}{#1}{\csname @twocolumn\Gm@bool\endcsname}}%
27
‘reversemp’
‘reversemarginpar’
The both options set \reversemargin.479 \define@key{Gm}{reversemp}[true]{%
480 \Gm@doif{reversemp}{#1}{\csname @reversemargin\Gm@bool\endcsname}}%
481 \define@key{Gm}{reversemarginpar}[true]{%
482 \Gm@doif{reversemarginpar}{#1}{\csname @reversemargin\Gm@bool\endcsname}}%
‘dviver’
483 \define@key{Gm}{driver}{\edef\@@tempa{#1}\edef\@@auto{auto}\edef\@@none{none}%
484 \ifx\@@tempa\@empty\let\Gm@driver\relax\else
485 \ifx\@@tempa\@@none\let\Gm@driver\relax\else
486 \ifx\@@tempa\@@auto\let\Gm@driver\@empty\else
487 \setkeys{Gm}{#1}\fi\fi\fi\let\@@auto\relax\let\@@none\relax}%
‘dvips’
‘dvipdfm’
‘pdftex’
‘vtex’
The geometry package supports dvips, dvipdfm, pdflatex and vtex. dvipdfm works like dvips.488 \define@key{Gm}{dvips}[true]{%
489 \Gm@doifelse{dvips}{#1}{\Gm@setdriver{dvips}}{\Gm@unsetdriver{dvips}}}%
490 \define@key{Gm}{dvipdfm}[true]{%
491 \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}%
492 \define@key{Gm}{pdftex}[true]{%
493 \Gm@doifelse{pdftex}{#1}{\Gm@setdriver{pdftex}}{\Gm@unsetdriver{pdftex}}}%
494 \define@key{Gm}{vtex}[true]{%
495 \Gm@doifelse{vtex}{#1}{\Gm@setdriver{vtex}}{\Gm@unsetdriver{vtex}}}%
‘verbose’ The verbose mode.496 \define@key{Gm}{verbose}[true]{\Gm@setbool{verbose}{#1}}%
‘reset’ The option cancels all the options specified before reset, except pass. mag (6= 1000) with truedimencannot be also reset.
497 \define@key{Gm}{reset}[true]{\Gm@doifelse{reset}{#1}%
498 {\Gm@init\Gm@dorg\ProcessOptionsKV[c]{Gm}\Gm@setdefaultpaper}{}}%
‘resetpaper’ If resetpaper is set to true, the paper size redefined in the package is discarded and the original oneis restored. This option may be useful to print nonstandard sized documents with normal printers andpapers.
499 \define@key{Gm}{resetpaper}[true]{\Gm@setbool{resetpaper}{#1}}%
‘mag’ mag is expanded immediately when it is specified. So reset can’t reset mag when it is set withtruedimen.
500 \define@key{Gm}{mag}{\mag=#1}%
‘truedimen’ If truedimen is set to true, all of the internal explicit dimensions is changed to true dimensions, e.g.,1in is changed to 1truein.
501 \define@key{Gm}{truedimen}[true]{\Gm@doifelse{truedimen}{#1}%
502 {\let\Gm@truedimen\Gm@true}{\let\Gm@truedimen\@empty}}%
‘pass’ The option makes all the options specified ineffective except verbose switch.503 \define@key{Gm}{pass}[true]{\Gm@setbool{pass}{#1}}%
‘showframe’ The showframe option.504 \define@key{Gm}{showframe}[true]{\Gm@setbool{showframe}{#1}}%
‘compat2’ The option sets the old default options for compatibility with version 2. compat2=false does nothing.505 \define@key{Gm}{compat2}[true]{%
506 \Gm@doifelse{compat2}{#1}{\Gm@compatiitrue
507 \setkeys{Gm}{scale={0.8,0.9},centering,includeheadfoot}}{}}%
Option twosideshift has been obsoleted. But for compatibility with version 2, one can usetwosideshift when compat2 is set to true.
508 \define@key{Gm}{twosideshift}{%
509 \ifGm@compatii\@twosidetrue\@mparswitchtrue\Gm@defbylen{twosideshift}{#1}%
510 \else\Gm@warning{‘twosideshift’ is obsolete}%
511 \fi}%
28
\Gm@setdefaultpaper The macro stores paper dimensions. This macro should be called after \ProcessOptionsKV[c]{Gm}.512 \def\Gm@setdefaultpaper{%
513 \ifx\Gm@paper\@undefined
514 \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
515 \Gm@sworientfalse
516 \fi}%
517 \@onlypreamble\Gm@setdefaultpaper
\Gm@checkpaper The macro checks if paperwidth/height is larger than 0pt, which is used in \[email protected] \def\Gm@checkpaper{%
519 \ifdim\paperwidth>\p@\else
520 \PackageError{geometry}{%
521 You must set \string\paperwidth\space properly}{%
522 Set your paper type (e.g., ‘a4paper’ for A4) as a class option^^J%
523 or as a geometry package option.}%
524 \fi
525 \ifdim\paperheight>\p@\else
526 \PackageError{geometry}{%
527 You must set \string\paperheight\space properly}{%
528 Set your paper type (e.g., ‘a4paper’ for A4) as a class option^^J%
529 or as a geometry package option.}%
530 \fi}%
\Gm@checkmp The macro checks if marginpars fall off the page.531 \def\Gm@checkmp{%
532 \ifGm@includemp\else
533 \@tempcnta\z@\@tempcntb\@ne
534 \if@twocolumn
535 \@tempcnta\@ne
536 \else
537 \if@reversemargin
538 \@tempcnta\@ne\@tempcntb\z@
539 \fi
540 \fi
541 \@tempdima\marginparwidth
542 \advance\@tempdima\marginparsep
543 \ifnum\@tempcnta=\@ne
544 \@tempdimc\@tempdima
545 \setlength\@tempdimb{\Gm@lmargin}%
546 \advance\@tempdimc-\@tempdimb
547 \ifdim\@tempdimc>\z@
548 \Gm@warning{The marginal notes would fall off the page.^^J
549 \@spaces Add \the\@tempdimc\space and more to the left margin}%
550 \fi
551 \fi
552 \ifnum\@tempcntb=\@ne
553 \@tempdimc\@tempdima
554 \setlength\@tempdimb{\Gm@rmargin}%
555 \advance\@tempdimc-\@tempdimb
556 \ifdim\@tempdimc>\z@
557 \Gm@warning{The marginal notes would fall off the page.^^J
558 \@spaces Add \the\@tempdimc\space and more to the right margin}%
559 \fi
560 \fi
561 \fi}%
562 \@onlypreamble\Gm@checkmp
\Gm@checkdrivers The macro checks the typeset environment and changes the driver option if necessary. To make theengine detection more robust, the macro is rewritten in version 4 with packages ifpdf and ifvtex.
563 \def\Gm@checkdrivers{%
If the driver option is not specified explicitly, then driver auto-detection works.564 \ifx\Gm@driver\@empty
565 \typeout{*geometry auto-detecting driver*}%
29
\ifpdf is defined in ifpdf package in ‘oberdiek’ bundle.566 \ifpdf
567 \Gm@setdriver{pdftex}%
568 \else
569 \Gm@setdriver{dvips}%
570 \fi
XeTEX supports the same page size parameter as pdfTEX.571 \@ifundefined{XeTeXrevision}{}{\Gm@setdriver{pdftex}}%
\ifvtex is defined in ifvtex package in ‘oberdiek’ bundle.572 \ifvtex
573 \Gm@setdriver{vtex}%
574 \fi
When the driver option is set by the user, check if it is valid or not.575 \else
576 \ifx\Gm@driver\Gm@pdftex
577 \ifpdf\else
578 \@ifundefined{XeTeXrevision}{\Gm@warning{%
579 Wrong driver setting: ‘pdftex’; using default driver}%
580 \Gm@setdriver{dvips}}{}%
581 \fi
582 \fi
583 \ifx\Gm@driver\Gm@vtex
584 \ifvtex\else
585 \Gm@warning{Wrong driver setting: ‘vtex’; using default driver}%
586 \Gm@setdriver{dvips}%
587 \fi
588 \fi
589 \fi}%
590 \@onlypreamble\Gm@checkdrivers
\Gm@mpfix The macro sets marginpar correction when includemp is set, which is used in \Gm@process. Localvariables \Gm@wd@mp, \Gm@odd@mp and \Gm@even@mp are set here. Note that \Gm@even@mp should beused only for twoside layout.
591 \def\Gm@mpfix{%
592 \@tempdimb\marginparwidth
593 \advance\@tempdimb\marginparsep
594 \Gm@wd@mp\@tempdimb
595 \Gm@odd@mp\z@
596 \Gm@even@mp\z@
597 \if@twocolumn
598 \Gm@wd@mp2\@tempdimb
599 \Gm@odd@mp\@tempdimb
600 \Gm@even@mp\@tempdimb
601 \else
602 \if@reversemargin
603 \Gm@odd@mp\@tempdimb
604 \if@mparswitch\else
605 \Gm@even@mp\@tempdimb
606 \fi
607 \else
608 \if@mparswitch
609 \Gm@even@mp\@tempdimb
610 \fi
611 \fi
612 \fi}%
613 \@onlypreamble\Gm@mpfix
\Gm@process The main macro processing specified layout dimensions is defined.614 \def\Gm@process{%
If pass is set, the original dimensions and switches are restored and process is ended here.615 \ifGm@pass
30
616 \Gm@dorg
617 \else
The stored native dimension settings are processed here.618 \Gm@processdimlist
The margin ratios are set to the default if not specified.619 \ifx\Gm@hmarginratio\@undefined
620 \if@twoside
621 \edef\Gm@hmarginratio{\Gm@Dhratiotwo}%
622 \else
623 \edef\Gm@hmarginratio{\Gm@Dhratio}%
624 \fi
625 \fi
626 \ifx\Gm@vmarginratio\@undefined
627 \edef\Gm@vmarginratio{\Gm@Dvratio}%
628 \fi
The paper size is checked here.629 \Gm@checkpaper
The paper dimensions can be swapped when paper orientation is changed over by landscape andportrait options.
630 \ifGm@sworient
631 \setlength\@tempdima{\paperwidth}%
632 \setlength\paperwidth{\paperheight}%
633 \setlength\paperheight{\@tempdima}%
634 \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
635 \Gm@sworientfalse
636 \fi
The bindingoffset value is removed from the paper width, which will be set back after auto-completioncalculation.
637 \addtolength\paperwidth{-\Gm@bindingoffset}%
The local variables are set here for marginpar correction \Gm@wd@mp, \Gm@odd@mp and \Gm@even@mpwhen includemp is set.
638 \ifGm@includemp
639 \Gm@mpfix
640 \fi
If the horizontal dimension of body is specified by user, \Gm@width is set properly here.641 \ifGm@hbody
642 \ifx\Gm@width\@undefined
643 \ifx\Gm@hscale\@undefined
644 \edef\Gm@width{\Gm@Dhscale\paperwidth}%
645 \else
646 \edef\Gm@width{\Gm@hscale\paperwidth}%
647 \fi
648 \fi
649 \ifx\Gm@textwidth\@undefined\else
650 \setlength\@tempdima{\Gm@textwidth}%
651 \ifGm@includemp
652 \advance\@tempdima\Gm@wd@mp
653 \fi
654 \edef\Gm@width{\the\@tempdima}%
655 \fi
656 \fi
If the vertical dimension of body is specified by user, \Gm@height is set properly here.657 \ifGm@vbody
658 \ifx\Gm@height\@undefined
659 \ifx\Gm@vscale\@undefined
660 \edef\Gm@height{\Gm@Dvscale\paperheight}%
661 \else
662 \edef\Gm@height{\Gm@vscale\paperheight}%
663 \fi
31
664 \fi
665 \ifx\Gm@lines\@undefined\else
\topskip has to be adjusted so that the formula “\textheight = (lines − 1) × \baselineskip +\topskip” to be correct even if large font sizes are specified by users. If \topskip is smaller than\ht\strutbox, then \topskip is set to \ht\strutbox.
666 \ifdim\topskip<\ht\strutbox
667 \setlength\@tempdima{\topskip}%
668 \setlength\topskip{\ht\strutbox}%
669 \Gm@warning{\noexpand\topskip was changed from \the\@tempdima\space
670 to \the\topskip}%
671 \fi
672 \setlength\@tempdima{\baselineskip}%
673 \multiply\@tempdima\Gm@lines
674 \addtolength\@tempdima{\topskip}%
675 \addtolength\@tempdima{-\baselineskip}%
676 \edef\Gm@textheight{\the\@tempdima}%
677 \fi
678 \ifx\Gm@textheight\@undefined\else
679 \setlength\@tempdima{\Gm@textheight}%
680 \ifGm@includehead
681 \addtolength\@tempdima{\headheight}%
682 \addtolength\@tempdima{\headsep}%
683 \fi
684 \ifGm@includefoot
685 \addtolength\@tempdima{\footskip}%
686 \fi
687 \edef\Gm@height{\the\@tempdima}%
688 \fi
689 \fi
The auto-completion calculation is executed for each direction.690 \Gm@detall{h}{width}{lmargin}{rmargin}%
691 \Gm@detall{v}{height}{tmargin}{bmargin}%
The real dimensions are set properly according to the result of the auto-completion calculation.692 \setlength\textwidth{\Gm@width}%
693 \setlength\textheight{\Gm@height}%
694 \setlength\topmargin{\Gm@tmargin}%
695 \setlength\oddsidemargin{\Gm@lmargin}%
696 \addtolength\oddsidemargin{-1\Gm@truedimen in}%
If includemp is set to true, \textwidth and \oddsidemargin are adjusted.697 \ifGm@includemp
698 \advance\textwidth-\Gm@wd@mp
699 \advance\oddsidemargin\Gm@odd@mp
700 \fi
Determining \evensidemargin. In the twoside page layout, the right margin value \Gm@rmargin isused. If the marginal note width is included, \evensidemargin should be corrected by \Gm@even@mp.
701 \if@mparswitch
702 \setlength\evensidemargin{\Gm@rmargin}%
703 \addtolength\evensidemargin{-1\Gm@truedimen in}%
704 \ifGm@includemp
705 \advance\evensidemargin\Gm@even@mp
706 \fi
707 \ifGm@compatii
708 \ifx\Gm@twosideshift\@undefined
709 \def\Gm@twosideshift{20\Gm@truedimen pt}%
710 \fi
711 \addtolength\oddsidemargin{\Gm@twosideshift}%
712 \addtolength\evensidemargin{-\Gm@twosideshift}%
713 \fi
714 \else
715 \evensidemargin\oddsidemargin
716 \fi
32
The bindingoffset correction for \oddsidemargin.717 \advance\oddsidemargin\Gm@bindingoffset
\topmargin is adjusted here.718 \addtolength\topmargin{-1\Gm@truedimen in}%
If the head of the page is included in total body, \headheight and \headsep are removed from\textheight, otherwise from \topmargin.
719 \ifGm@includehead
720 \addtolength\textheight{-\headheight}%
721 \addtolength\textheight{-\headsep}%
722 \else
723 \addtolength\topmargin{-\headheight}%
724 \addtolength\topmargin{-\headsep}%
725 \fi
If the foot of the page is included in total body, \footskip is removed from \textheight.726 \ifGm@includefoot
727 \addtolength\textheight{-\footskip}%
728 \fi
If heightrounded is set, \textheight is rounded.729 \ifGm@heightrounded
730 \setlength\@tempdima{\textheight}%
731 \addtolength\@tempdima{-\topskip}%
732 \@tempcnta\@tempdima
733 \@tempcntb\baselineskip
734 \divide\@tempcnta\@tempcntb
735 \setlength\@tempdimb{\baselineskip}%
736 \multiply\@tempdimb\@tempcnta
737 \advance\@tempdima-\@tempdimb
738 \multiply\@tempdima\tw@
739 \ifdim\@tempdima>\baselineskip
740 \addtolength\@tempdimb{\baselineskip}%
741 \fi
742 \addtolength\@tempdimb{\topskip}%
743 \textheight\@tempdimb
744 \fi
The paper width is set back by adding \[email protected] \addtolength\paperwidth{\Gm@bindingoffset}%
746 \fi}%
747 \@onlypreamble\Gm@process
\Gm@showparam The macro for typeout of geometry status and native dimensions for page layout.748 \def\Gm@showparams{%
749 -------------------- Geometry parameters^^J%
750 \ifGm@pass
751 ’pass’ is specified!! (disables the geometry layouter)^^J%
752 \else
753 paper: \ifx\Gm@paper\@undefined class default\else\Gm@paper\fi^^J%
754 \Gm@checkbool{landscape}%
755 twocolumn: \if@twocolumn\Gm@true\else--\fi^^J%
756 twoside: \if@twoside\Gm@true\else--\fi^^J%
757 asymmetric: \if@mparswitch --\else\if@twoside\Gm@true\else --\fi\fi^^J%
758 h-parts: \Gm@lmargin, \Gm@width, \Gm@rmargin%
759 \ifnum\Gm@cnth=\z@\space(default)\fi^^J%
760 v-parts: \Gm@tmargin, \Gm@height, \Gm@bmargin%
761 \ifnum\Gm@cntv=\z@\space(default)\fi^^J%
762 hmarginratio: \ifnum\Gm@cnth<5 \ifnum\Gm@cnth=3--\else%
763 \Gm@hmarginratio\fi\else--\fi^^J%
764 vmarginratio: \ifnum\Gm@cntv<5 \ifnum\Gm@cntv=3--\else%
765 \Gm@vmarginratio\fi\else--\fi^^J%
766 lines: \@ifundefined{Gm@lines}{--}{\Gm@lines}^^J%
767 \Gm@checkbool{heightrounded}%
33
768 bindingoffset: \the\Gm@bindingoffset^^J%
769 truedimen: \ifx\Gm@truedimen\@empty --\else\Gm@true\fi^^J%
770 \Gm@checkbool{includehead}%
771 \Gm@checkbool{includefoot}%
772 \Gm@checkbool{includemp}%
773 driver: \if\Gm@driver\relax --\else\Gm@driver\fi^^J%
774 \fi
775 -------------------- Page layout dimensions and switches^^J%
776 \string\paperwidth\space\space\the\paperwidth^^J%
777 \string\paperheight\space\the\paperheight^^J%
778 \string\textwidth\space\space\the\textwidth^^J%
779 \string\textheight\space\the\textheight^^J%
780 \string\oddsidemargin\space\space\the\oddsidemargin^^J%
781 \string\evensidemargin\space\the\evensidemargin^^J%
782 \string\topmargin\space\space\the\topmargin^^J%
783 \string\headheight\space\the\headheight^^J%
784 \string\headsep\@spaces\the\headsep^^J%
785 \string\footskip\space\space\space\the\footskip^^J%
786 \string\marginparwidth\space\the\marginparwidth^^J%
787 \string\marginparsep\space\space\space\the\marginparsep^^J%
788 \string\columnsep\space\space\the\columnsep^^J%
789 \string\skip\string\footins\space\space\the\skip\footins^^J%
790 \string\hoffset\space\the\hoffset^^J%
791 \string\voffset\space\the\voffset^^J%
792 \string\mag\space\the\mag^^J%
793 \if@twocolumn\string\@twocolumntrue\space\fi%
794 \if@twoside\string\@twosidetrue\space\fi%
795 \if@mparswitch\string\@mparswitchtrue\space\fi%
796 \if@reversemargin\string\@reversemargintrue\space\fi^^J%
797 (1in=72.27pt, 1cm=28.45pt)^^J%
798 -----------------------}%
799 \@onlypreamble\Gm@showparams
\ProcessOptionsKV This macro can process class and package options using ‘key=value’ scheme. Only class options areprocessed with an optional argument ‘c’, package options with ‘p’ , and both of them by default.
800 \def\ProcessOptionsKV{\@ifnextchar[%]
801 {\@ProcessOptionsKV}{\@ProcessOptionsKV[]}}%
802 \def\@ProcessOptionsKV[#1]#2{%
803 \let\@tempa\@empty
804 \@tempcnta\z@
805 \if#1p\@tempcnta\@ne\else\if#1c\@tempcnta\tw@\fi\fi
806 \ifodd\@tempcnta
807 \edef\@tempa{\@ptionlist{\@currname.\@currext}}%
808 \else
809 \@for\CurrentOption:=\@classoptionslist\do{%
810 \@ifundefined{KV@#2@\CurrentOption}%
811 {}{\edef\@tempa{\@tempa,\CurrentOption,}}}%
812 \ifnum\@tempcnta=\z@
813 \edef\@tempa{\@tempa,\@ptionlist{\@currname.\@currext}}%
814 \fi
815 \fi
816 \edef\@tempa{\noexpand\setkeys{#2}{\@tempa}}%
817 \@tempa
818 \AtEndOfPackage{\let\@unprocessedoptions\relax}}%
819 \@onlypreamble\ProcessOptionsKV
820 \@onlypreamble\@ProcessOptionsKV
Geometry parameters are initialized here. \Gm@init can be called by reset or pass options.821 \Gm@init
The optional arguments to \documentclass are processed here.822 \ProcessOptionsKV[c]{Gm}%
Paper dimensions given by class default are stored.823 \Gm@setdefaultpaper
34
\Gm@setkey \ExecuteOptions is replaced with \Gm@setkey to make it possible to deal with ’〈key〉=〈value〉’ as itsargument.
824 \def\Gm@setkeys{\setkeys{Gm}}%
825 \@onlypreamble\Gm@setkeys
826 \let\Gm@origExecuteOptions\ExecuteOptions
827 \let\ExecuteOptions\Gm@setkeys
A local configuration file may define more options. To set A4 paper as default, geometry.cfg gg tocontain \ExecuteOptions{a4paper}.
828 \InputIfFileExists{geometry.cfg}{}{}%
The original definition for \ExecuteOptions macro is restored.829 \let\ExecuteOptions\Gm@origExecuteOptions
The optional arguments to \usepackage are processed here.830 \ProcessOptionsKV[p]{Gm}%
Actual settings and calculation for layout dimensions are processed.831 \Gm@process
verbose, showframe and driver options are processed at \begin{document}.832 \AtBeginDocument{%
Paper size is temporally adjusted according to \mag for printing devices.833 \ifGm@resetpaper
834 \edef\Gm@pw{\Gm@orgpw}%
835 \edef\Gm@ph{\Gm@orgph}%
836 \else
837 \edef\Gm@pw{\the\paperwidth}%
838 \edef\Gm@ph{\the\paperheight}%
839 \fi
If pass is set to true, no adjustment for page dimensions is done.840 \ifGm@pass\else
841 \ifnum\mag=\@m\else
842 \Gm@magtooffset
843 \divide\paperwidth\@m
844 \multiply\paperwidth\the\mag
845 \divide\paperheight\@m
846 \multiply\paperheight\the\mag
847 \fi
848 \fi
Checking the driver options.849 \Gm@checkdrivers
850 \ifx\Gm@driver\relax
851 \typeout{*geometry detected driver: <none>*}%
852 \else
853 \typeout{*geometry detected driver: \Gm@driver*}%
854 \fi
If pdftex is set to true, pdf-commands are set properly. To avoid pdftex magnification problem,\pdfhorigin and \pdfvorigin are adjusted for \mag.
855 \ifx\Gm@driver\Gm@pdftex
856 \setlength\pdfpagewidth{\Gm@pw}%
857 \setlength\pdfpageheight{\Gm@ph}%
858 \ifnum\mag=\@m\else
859 \@tempdima=\mag sp%
860 \divide\pdfhorigin\@tempdima
861 \multiply\pdfhorigin\@m
862 \divide\pdfvorigin\@tempdima
863 \multiply\pdfvorigin\@m
864 \ifx\Gm@truedimen\Gm@true
865 \setlength\paperwidth{\Gm@pw}%
866 \setlength\paperheight{\Gm@ph}%
867 \fi
868 \fi
869 \fi
35
With VTEX environment, VTEX variables are set here.870 \ifx\Gm@driver\Gm@vtex
871 \mediawidth=\paperwidth
872 \mediaheight=\paperheight
873 \ifvtexdvi
874 \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
875 \fi
876 \fi
If dvips or dvipdfm is set to true, paper size is embedded in dvi file with \special. For dvips, alandscape correction is added because a landscape document converted by dvips is upside-down inPostScript viewers.
877 \ifx\Gm@driver\Gm@dvips
878 \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
879 \ifx\Gm@driver\Gm@dvips\ifGm@landscape
880 \AtBeginDvi{\special{! /landplus90 true store}}%
881 \fi\fi
When dvipdfm option is set and atbegshi package in ‘oberdiek’ bundle is loaded, \AtBeginShipoutFirstis used instead of \AtBeginDvi for compatibility with hyperref and dvipdfm program.
882 \else\ifx\Gm@driver\Gm@dvipdfm
883 \ifcase\ifx\AtBeginShipoutFirst\relax\@ne\else
884 \ifx\AtBeginShipoutFirst\@undefined\@ne\else\z@\fi\fi
885 \AtBeginShipoutFirst{\special{papersize=\the\paperwidth,\the\paperheight}}%
886 \or
887 \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
888 \fi
889 \fi\fi
If showframe=true, page frames and lines are showed on the first page.890 \ifGm@showframe
891 \AtBeginDvi{%
892 \moveright\@themargin%
893 \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
894 \vskip\topmargin\vbox to\z@{\vss\hrule width\textwidth}%
895 \vskip\headheight\vbox to\z@{\vss\hrule width\textwidth}%
896 \vskip\headsep\vbox to\z@{\vss\hrule width\textwidth}%
897 \hbox to\textwidth{\llap{\vrule height\textheight}\hfil%
898 \vrule height\textheight}%
899 \vbox to\z@{\vss\hrule width\textwidth}%
900 \vskip\footskip\vbox to\z@{\vss\hrule width\textwidth}%
901 \vss}}%
902 \AtBeginDvi{%
903 \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
904 \vskip-1\Gm@truedimen in\rlap{\hskip-1\Gm@truedimen in%
905 \vbox to\z@{\vbox to\z@{\vss\hrule width\paperwidth}%
906 \hbox to \paperwidth{\llap{\vrule height\paperheight}\hfil%
907 \vrule height\paperheight}%
908 \vbox to\z@{\vss\hrule width\paperwidth}%
909 \vss}}\vss}}%
910 \fi
If verbose=true and pass=false, the system checks if marginpars fall off the page.911 \ifGm@verbose\ifGm@pass\else\Gm@checkmp\fi\fi
If verbose=true the parameter results are displayed on the terminal. verbose=false (default) stillputs them into the log file.
912 \ifGm@verbose\expandafter\typeout\else\expandafter\wlog\fi
913 {\Gm@showparams}%
save memory.914 \let\Gm@cnth\relax
915 \let\Gm@cntv\relax
916 \let\c@Gm@tempcnt\relax
917 \let\Gm@bindingoffset\relax
918 \let\Gm@wd@mp\relax
36
919 \let\Gm@odd@mp\relax
920 \let\Gm@even@mp\relax
921 \let\Gm@orgpw\relax
922 \let\Gm@orgph\relax
923 \let\Gm@pw\relax
924 \let\Gm@ph\relax
925 \let\Gm@dimlist\relax}%
\geometry The user-interface macro \geometry is defined here. This command should be used in the preamble.926 \def\geometry#1{%
927 \Gm@clean
928 \setkeys{Gm}{#1}%
929 \Gm@process}%
930 \@onlypreamble\geometry
931 〈/package〉
13 Config file
In the configuration file geometry.cfg, one can use \ExecuteOptions to set the site or user defaultsettings.
932 〈∗config〉933 %<<SAVE_INTACT
934
935 % Uncomment and edit the line below to set default options.
936 %\ExecuteOptions{a4paper}
937
938 %SAVE_INTACT
939 〈/config〉
14 Sample file
Here is an executable sample tex file.940 〈∗samples〉941 %<<SAVE_INTACT
942 \documentclass{article}% uses letterpaper by default
943 % \documentclass[a4paper]{article}% for A4 paper
944 %---------------------------------------------------------------
945 % Edit and uncomment one of the settings below
946 %---------------------------------------------------------------
947 % \usepackage{geometry}
948 % \usepackage[centering]{geometry}
949 % \usepackage[width=10cm,vscale=.7]{geometry}
950 % \usepackage[margin=1cm, papersize={12cm,19cm}, resetpaper]{geometry}
951 % \usepackage[margin=1cm,includeheadfoot]{geometry}
952 \usepackage[margin=1cm,includeheadfoot,includemp]{geometry}
953 % \usepackage[margin=1cm,bindingoffset=1cm,twoside]{geometry}
954 % \usepackage[hmarginratio=2:1, vmargin=2cm]{geometry}
955 % \usepackage[hscale=0.5,twoside]{geometry}
956 % \usepackage[hscale=0.5,asymmetric]{geometry}
957 % \usepackage[hscale=0.5,heightrounded]{geometry}
958 % \usepackage[left=1cm,right=4cm,top=2cm,includefoot]{geometry}
959 % \usepackage[lines=20,left=2cm,right=6cm,top=2cm,twoside]{geometry}
960 % \usepackage[width=15cm, marginparwidth=3cm, includemp]{geometry}
961 % \usepackage[hdivide={1cm,,2cm}, vdivide={3cm,8in,}, nohead]{geometry}
962 % \usepackage[headsep=20pt, head=40pt,foot=20pt,includeheadfoot]{geometry}
963 % \usepackage[text={6in,8in}, top=2cm, left=2cm]{geometry}
964 % \usepackage[centering,includemp,twoside,landscape]{geometry}
965 % \usepackage[mag=1414,margin=2cm]{geometry}
966 % \usepackage[mag=1414,margin=2truecm,truedimen]{geometry}
967 % \usepackage[compat2,marginpar=50pt,twosideshift=50pt]{geometry}
968 % \usepackage[a5paper, landscape, twocolumn, twoside,
37
969 % left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt,
970 % bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
971 % columnsep=1cm,verbose]{geometry}
972 %---------------------------------------------------------------
973 % No need to change below
974 %---------------------------------------------------------------
975 \geometry{verbose,showframe}% options appended.
976 \newcommand\mynote{\marginpar%
977 [\raggedright\rule{\marginparwidth}{.7pt}\\A left side note.]%
978 {\raggedright\rule{\marginparwidth}{.7pt}\\A side note.}}%
979 \def\fox{A quick brown fox jumps over the lazy dog. }
980 \def\fivefoxes{\fox\fox\fox\fox\fox}
981 \def\manyfoxes{\fivefoxes\mynote\fivefoxes\par\fivefoxes\fivefoxes\par}
982 % \let\mynote\relax % removes marginal notes.
983 \begin{document}
984 \manyfoxes\manyfoxes\manyfoxes\manyfoxes
985 \manyfoxes\manyfoxes\manyfoxes\manyfoxes
986 \manyfoxes\manyfoxes\manyfoxes\manyfoxes
987 \end{document}
988 %SAVE_INTACT
989 〈/samples〉
38