Debian Codegraph @

texmf-dist/source/latex/geometry/geometry.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright 1996-2010 by Hideo Umeki <[email protected]>
4 % Copyright 2018-2026 Hideo Umeki and David Carlisle
5 %
6 % LaTeX Package: Geometry
7 % -----------------------
8 %
9 % This work may be distributed and/or modified under the conditions of
10 % the LaTeX Project Public License, either version 1.3c of this license
11 % or (at your option) any later version. The latest version of this
12 % license is in
13 % http://www.latex-project.org/lppl.txt
14 % and version 1.3c or later is part of all distributions of LaTeX
15 % version 2005/12/01 or later.
16 %
17 % This work is "maintained" (as per the LPPL maintenance status)
18 % by David Carlisle
19 %
20 % This work consists of the files geometry.dtx and
21 % the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
22 %
23 % * Distribution
24 % CTAN: macros/latex/contrib/geometry/README.md
25 % CTAN: macros/latex/contrib/geometry/changes.txt
26 % CTAN: macros/latex/contrib/geometry/geometry.ins
27 % CTAN: macros/latex/contrib/geometry/geometry.dtx
28 % CTAN: macros/latex/contrib/geometry/geometry.pdf
29 % CTAN: macros/latex/contrib/geometry/geometry-de.dtx
30 % CTAN: macros/latex/contrib/geometry/geometry-de.pdf
31 %
32 % * See README for installation.
33 %
34 %<*ignore>
35 \begingroup
36 \def\x{LaTeX2e}
37 \expandafter\endgroup
38 \ifcase 0\ifx\install y1\fi\expandafter
39 \ifx\csname processbatchFile\endcsname\relax\else1\fi
40 \ifx\fmtname\x\else 1\fi\relax
41 \else\csname fi\endcsname
42 %</ignore>
43 %<package|driver>\NeedsTeXFormat{LaTeX2e}
44 %<package>\ProvidesPackage{geometry}
45 %<package> [2026/03/07 v6.0 Page Geometry]
46 %<*install>
47 \input docstrip.tex
48 \Msg{************************************************************************}
49 \Msg{* Installation}
50 \Msg{* Package: geometry 2026/03/07 v6.0 Page Geometry}
51 \Msg{************************************************************************}
52
53 \keepsilent
54 \askforoverwritefalse
55 \preamble
56
57 Copyright (C) 1996-2010
58 by Hideo Umeki <[email protected]>
59 Copyright (C) 2018-2026
60 by Hideo Umeki and David Carlisle https://github.com/LaTeX-Package-Repositories/geometry
61
62 This work may be distributed and/or modified under the conditions of
63 the LaTeX Project Public License, either version 1.3c of this license
64 or (at your option) any later version. The latest version of this
65 license is in
66 http://www.latex-project.org/lppl.txt
67 and version 1.3c or later is part of all distributions of LaTeX
68 version 2005/12/01 or later.
69
70 This work is "maintained" (as per the LPPL maintenance status)
71 by David Carlisle.
72
73 This work consists of the files geometry.dtx and
74 the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
75
76 \endpreamble
77
78 \generate{%
79 \file{geometry.ins}{\from{geometry.dtx}{install}}%
80 \file{geometry.drv}{\from{geometry.dtx}{driver}}%
81 \usedir{tex/latex/geometry}%
82 \file{geometry.sty}{\from{geometry.dtx}{package}}%
83 \file{geometry.cfg}{\from{geometry.dtx}{config}}%
84 \file{geometry-samples.tex}{\from{geometry.dtx}{samples}}%
85 }
86
87 \obeyspaces
88 \Msg{************************************************************************}
89 \Msg{*}
90 \Msg{* To finish the installation you have to move the following}
91 \Msg{* file into a directory searched by LaTeX:}
92 \Msg{*}
93 \Msg{* \space\space geometry.sty}
94 \Msg{*}
95 \Msg{* To produce the documentation run the file `geometry.drv'}
96 \Msg{* through LaTeX.}
97 \Msg{*}
98 \Msg{* Happy TeXing!}
99 \Msg{*}
100 \Msg{************************************************************************}
101 \endbatchfile
102 %</install>
103 %<*ignore>
104 \fi
105 %</ignore>
106 %<*driver>
107 \ProvidesFile{geometry.drv}
108 \documentclass{ltxdoc}
109 \usepackage[colorlinks, linkcolor=blue]{hyperref}
110 \usepackage{graphicx}
111 \usepackage[a4paper, hmargin=2.5cm, vmargin=1cm,
112 includeheadfoot]{geometry}
113 \DeclareRobustCommand\XeTeX{%
114 X\lower.5ex\hbox{\kern-.07em\reflectbox{E}}%
115 \kern-.15em\TeX}
116 \DeclareRobustCommand\XeLaTeX{%
117 X\lower.5ex\hbox{\kern-.07em\reflectbox{E}}%
118 \kern-.15em\LaTeX}
119 \begin{document}
120 \DocInput{geometry.dtx}
121 \end{document}
122 %</driver>
123 % \fi
124 %
125 %
126 % \GetFileInfo{geometry.sty}
127 %
128 % \title{The \textsf{geometry} package}
129 % \date{\filedate\ \fileversion}
130 % \author{Hideo Umeki\\\url{https://github.com/LaTeX-Package-Repositories/geometry}}
131 %
132 % \MakeShortVerb{|}
133 %
134 % \def\OpenB{{\ttfamily\char`\{}}
135 % \def\Comma{{\ttfamily\char`,}}
136 % \def\CloseB{{\ttfamily\char`\}}}
137 % \def\Gm{\textsf{geometry}}
138 % \newcommand\argii[2]{\OpenB\meta{#1}\Comma\meta{#2}\CloseB}
139 % \newcommand\argiii[3]{\OpenB\meta{#1}\Comma\meta{#2}\Comma\meta{#3}\CloseB}
140 % \newcommand\vargii[2]{\OpenB#1\Comma#2\CloseB}
141 % \newcommand\vargiii[3]{\OpenB#1\Comma#2\Comma#3\CloseB}
142 % \newcommand\OR{\ \strut\vrule width .4pt\ }
143 % \newcommand\gpart[1]{\textsf{\textsl{\color[rgb]{.0,.45,.7}#1}}}%
144 % \newcommand\glen[1]{\textsf{#1}}
145 % \newenvironment{key}[2]{\expandafter\macro\expandafter{`#2'}}{\endmacro}
146 % \newenvironment{Options}%
147 % {\begin{list}{}{%
148 % \renewcommand{\makelabel}[1]{\texttt{##1}\hfil}%
149 % \setlength{\itemsep}{-.5\parsep}
150 % \settowidth{\labelwidth}{\texttt{xxxxxxxxxxx\space}}%
151 % \setlength{\leftmargin}{\labelwidth}%
152 % \addtolength{\leftmargin}{\labelsep}}%
153 % \raggedright}
154 % {\end{list}}
155 % \newenvironment{Spec}%
156 % {\begin{list}{}{%
157 % \renewcommand{\makelabel}[1]{\fbox{##1}\hfil}%
158 % \setlength{\itemsep}{-.5\parsep}
159 % \settowidth{\labelwidth}{\texttt{S(x,x)}}%
160 % \setlength{\leftmargin}{\labelwidth}%
161 % \addtolength{\leftmargin}{\labelsep}%
162 % \addtolength{\leftmargin}{2em}%
163 % \setlength{\rightmargin}{2em}}%
164 % \raggedright}
165 % {\end{list}}
166 % \def\Ss(#1,#2){\textsf{S(#1,#2)}}%
167 % \def\Sp(#1,#2,#3){\mbox{|(#1,#2,#3)|}}%
168 % \def\onlypre{\llap{$^{\dagger\:}$}}%
169 %
170 % \maketitle
171 %
172 % \begin{abstract}
173 % This package provides a flexible and easy interface to page dimensions.
174 % You can change the page layout with intuitive parameters. For instance,
175 % if you want to set a margin to 2cm from each edge of the paper,
176 % you can type just |\usepackage[margin=2cm]{geometry}|.
177 % The page layout can be changed in the middle of the document
178 % with |\newgeometry| command.
179 % \end{abstract}
180 %
181 % \section{Preface to version 5}
182 %
183 % \begin{itemize}
184 % \item \textbf{Changing page layout mid-document.}\par
185 % The new commands \cs{newgeometry\{$\cdots$\}} and
186 % \cs{restoregeometry} allow users to change page dimensions in the
187 % middle of the document. \cs{newgeometry} is almost similar to
188 % \cs{geometry} except that \cs{newgeometry} disables all the options
189 % specified in the preamble and skips the papersize-related options:
190 % |landscape|, |portrait| and paper size options (such as
191 % |papersize|, |paper=a4paper| and so forth).
192 % \item \textbf{A new set of options to specify the layout area.}\par
193 % The options specified for the area, in which the page dimensions
194 % are calculated, are added: \textsf{layout}, \textsf{layoutsize},
195 % \textsf{layoutwidth}, \textsf{layoutheight} and so forth.
196 % These options would help to print the specified
197 % layout to a different sized paper. For example, with |a4paper|
198 % and |layout=a5paper|, the \Gm\ package uses `A5' layout to
199 % calculate margins with the paper size still `A4'.
200 % \item \textbf{A new driver option |xetex|.}\par
201 % The new driver option |xetex| is added. The driver auto-detection
202 % routine has been revised so as to avoid an error with undefined
203 % control sequences. Note that `geometry.cfg' in \TeX{} Live, which
204 % disables the auto-detection routine and sets |pdftex|, is no
205 % longer necessary and has no problem even though it still exists.
206 % To set |xetex| is strongly recommended with \XeLaTeX{}.
207 % \item \textbf{New paper size presets for JIS B-series and ISO C-series.}\par
208 % The papersize presets |b0j| to |b6j| for JIS (Japanese Industrial
209 % Standards) B-series and |c0paper| to |c6paper| for ISO C-series
210 % (v5.4$\sim$) are added.
211 % \item \textbf{Changing default for underspecified margin.}\par
212 % In the previous version, if only one margin was specified,
213 % |bottom=1cm| for example, then \Gm\ set the other margin with
214 % the margin ratio (1:1 by default for the vertical dimensions)
215 % and got |top=1cm| in this case.
216 % The version 5 sets the text-body size with the default |scale|
217 % ($=0.7$) and determine the unspecified margin. (See Section~\ref{sec:rules})
218 % \item \textbf{The option |showframe| and |showcrop| works on every page.}\par
219 % With |showframe| option, the page frames are shown on every page.
220 % In addition, a new option |showcrop| prints crop marks at each
221 % corner of layout area on every page. Note that the marks would be
222 % invisible without specifying the layout size smaller than paper size.
223 % Version 5.4 introduced a new |\shipout| overloading process using
224 % \textsf{atbegshi} package, so the \textsf{atbegshi} package
225 % is required when showframe or showcrop option is specified.
226 % \item \textbf{Loading geometry.cfg precedes processing class options.}\par
227 % The previous version loaded \textsf{geometry.cfg} after
228 % processing the document class options. Now that the config file is
229 % loaded before processing the class options, you can change the
230 % behavior specified in \textsf{geometry.cfg} by adding options
231 % into |\documentclass| as well as |\usepackage| and |\geometry|.
232 % \item \textbf{Deleted options: |compat2| and |twosideshift|.}
233 % The version 5 has no longer compatibility with the previous ones.
234 % |compat2| and |twosideshift| are gone for simplicity.
235 % \end{itemize}
236 %
237 % \section{Introduction}
238 %
239 % To set dimensions for page layout in \LaTeX\ is not straightforward.
240 % You need to adjust several \LaTeX{} native dimensions to place a text area
241 % where you want.
242 % If you want to center the text area in the paper you use, for example,
243 % you have to specify native dimensions as follows:
244 % \begin{quote}
245 % |\usepackage{calc}|\\
246 % |\setlength\textwidth{7in}|\\
247 % |\setlength\textheight{10in}|\\
248 % |\setlength\oddsidemargin{(\paperwidth-\textwidth)/2 - 1in}|\\
249 % |\setlength\topmargin{(\paperheight-\textheight|\\
250 % | -\headheight-\headsep-\footskip)/2 - 1in}|.
251 % \end{quote}
252 % Without package \textsl{calc}, the above example would need
253 % more tedious settings. Package \Gm\ provides an easy
254 % way to set page layout parameters. In this case, what you have to do
255 % is just
256 % \begin{quote}
257 % |\usepackage[text={7in,10in},centering]{geometry}|.
258 % \end{quote}
259 % Besides centering problem, setting margins from each edge of the paper is
260 % also troublesome. But \Gm\ also make it easy.
261 % If you want to set each margin to 1.5in, you can type
262 % \begin{quote}
263 % |\usepackage[margin=1.5in]{geometry}|
264 % \end{quote}
265 % Thus, the geometry package has an auto-completion mechanism, in which
266 % unspecified dimensions are automatically determined.
267 % The \Gm\ package will be also useful when you have to set page layout
268 % obeying the following strict instructions: for example,
269 % \begin{quote}\slshape
270 % The total allowable width of the text area is $6.5$ inches wide by $8.75$
271 % inches high. The top margin on each page should be $1.2$ inches from
272 % the top edge of the page. The left margin should be $0.9$ inch from
273 % the left edge. The footer with page number should be at the bottom
274 % of the text area.
275 % \end{quote}
276 % In this case, using \Gm\ you can type
277 % \begin{quote}
278 % |\usepackage[total={6.5in,8.75in},|\\
279 % | top=1.2in, left=0.9in, includefoot]{geometry}|.
280 % \end{quote}
281 %
282 % Setting a text area on the paper in document preparation system has some
283 % analogy to placing a window on the background in the window system.
284 % The name `geometry' comes from the |-geometry| option used for specifying
285 % a size and location of a window in X Window System.
286 %
287 % \section{Page geometry}
288 %
289 % Figure~\ref{fig:layout} shows the page layout dimensions defined
290 % in the \Gm\ package.
291 % The page layout contains a \gpart{total body} (printable area) and \gpart{margins}.
292 % The \gpart{total body} consists of a \gpart{body} (text area) with an
293 % optional \gpart{header}, \gpart{footer} and marginal notes (marginpar).
294 % There are four margins: \gpart{left}, \gpart{right}, \gpart{top} and
295 % \gpart{bottom}. For twosided documents, horizontal
296 % margins should be called \gpart{inner} and \gpart{outer}.
297 % \begin{quote}
298 % \begin{tabular}{rcl}
299 % \gpart{paper}&:&\gpart{total body} and
300 % \gpart{margins}\\
301 % \gpart{total body}&:&\gpart{body} (text area)\quad
302 % (optional \gpart{head}, \gpart{foot} and \gpart{marginpar})\\
303 % \gpart{margins}&:&\gpart{left} (\gpart{inner}),
304 % \gpart{right} (\gpart{outer}), \gpart{top} and \gpart{bottom}
305 % \end{tabular}
306 % \end{quote}
307 % Each margin is measured from the corresponding edge of a paper.
308 % For example, left margin (inner margin) means a horizontal distance
309 % between the left (inner) edge of the paper and that of the total body.
310 % Therefore the left and top margins defined in \Gm\ are different
311 % from the native dimensions \cs{leftmargin} and \cs{topmargin}.
312 % The size of a body (text area) can be modified by \cs{textwidth} and
313 % \cs{textheight}.
314 % The dimensions for paper, total body and margins have the following
315 % relations.
316 % \begin{eqnarray}
317 % \label{eq:paperwidth}
318 % |paperwidth| &=& |left|+|width|+|right| \\
319 % |paperheight| &=& |top|+|height|+|bottom|
320 % \label{eq:paperheight}
321 % \end{eqnarray}
322 %
323 % \begin{figure}
324 % \centering\small
325 % {\unitlength=.65pt
326 % \begin{picture}(450,250)(0,-10)
327 % \put(20,0){\framebox(170,230){}}
328 % \put(20,235){\makebox(170,230)[br]{\gpart{paper}}}
329 % \begingroup\thicklines
330 % \put(40,30){\framebox(120,170){}}\endgroup
331 % \put(40,30){\makebox(120,165)[tr]{\gpart{total body}~}}
332 % \put(45,30){\makebox(0,170)[l]{|height|}}
333 % \put(40,35){\makebox(120,0)[bc]{|width|}}
334 % \put(50,-20){\makebox(120,0)[bc]{|paperwidth|}}
335 % \put(10,45){\makebox(0,170)[r]{|paperheight|}}
336 % \put(90,200){\makebox(0,30)[lc]{|top|}}
337 % \put(90,0){\makebox(0,30)[lc]{|bottom|}}
338 % \put(10,70){\makebox(0,0)[r]{|left|}}
339 % \put(10,55){\makebox(0,0)[r]{(|inner|)}}
340 % \put(200,70){\makebox(0,0)[l]{|right|}}
341 % \put(200,55){\makebox(0,0)[l]{(|outer|)}}
342 % \put(80,230){\vector(0,-1){30}}\put(80,30){\vector(0,-1){30}}
343 % \put(80,200){\vector(0,1){30}}\put(80,0){\vector(0,1){30}}
344 % \put(20,70){\vector(1,0){20}}\put(40,70){\vector(-1,0){20}}
345 % \put(160,70){\vector(1,0){30}}\put(190,70){\vector(-1,0){30}}
346 % \multiput(160,30)(5,0){24}{\line(1,0){2}}
347 % \multiput(160,200)(5,0){24}{\line(1,0){2}}
348 % \begingroup\thicklines
349 % \put(280,30){\framebox(120,170){}}\endgroup
350 % \put(283,133){\makebox(0,12)[l]{|textheight|}}
351 % \put(295,130){\vector(0,-1){100}}\put(295,150){\vector(0,1){50}}
352 % \multiput(280,220)(5,0){24}{\line(1,0){3}}
353 % \put(280,208){\makebox(120,20)[bc]{\gpart{head}}}
354 % \multiput(280,207)(5,0){24}{\line(1,0){3}}
355 % \put(420,225){\makebox(0,0)[l]{|headheight|}}
356 % \put(418,225){\line(-2,-1){20}}
357 % \put(420,213){\makebox(0,0)[l]{|headsep|}}
358 % \put(418,213){\line(-2,-1){20}}
359 % \put(420,12){\makebox(0,0)[l]{|footskip|}}
360 % \put(418,12){\line(-2,1){20}}
361 % \put(280,40){\makebox(120,140)[c]{\gpart{body}}}
362 % \put(305,45){\vector(-1,0){25}}\put(375,45){\vector(1,0){25}}
363 % \put(80,230){\vector(0,-1){30}}\put(80,30){\vector(0,-1){30}}
364 % \put(280,48){\makebox(120,0)[c]{|textwidth|}}
365 % \put(280,15){\makebox(120,10)[c]{\gpart{foot}}}
366 % \multiput(280,14)(5,0){24}{\line(1,0){2}}
367 % \put(410,30){\dashbox{3}(30,170){}}
368 % \put(415,30){\makebox(30,170)[l]{\gpart{marginal note}}}
369 % \put(425,45){\vector(-1,0){15}}\put(425,45){\vector(1,0){15}}
370 % \put(450,70){\makebox(0,0)[l]{|marginparsep|}}
371 % \put(448,70){\line(-3,-1){43}}
372 % \put(450,45){\makebox(0,0)[l]{|marginparwidth|}}
373 % \end{picture}}
374 % \caption[Dimension names for \Gm]{%
375 % \begin{minipage}[t]{.8\textwidth}\raggedright\small
376 % Dimension names used in the \Gm\ package.
377 % |width| $=$ |textwidth| and |height| $=$ |textheight| by default.
378 % |left|, |right|, |top| and |bottom| are margins.
379 % If margins on verso pages are swapped by |twoside| option,
380 % margins specified by |left| and |right| options
381 % are used for the inside and outside margins respectively.
382 % |inner| and |outer| are aliases of |left| and |right|
383 % respectively.
384 % \end{minipage}}
385 % \label{fig:layout}
386 % \end{figure}
387 %
388 % The total body |width| and |height| would be defined:
389 % \begin{eqnarray}
390 % \label{eq:width}
391 % |width| &:=& |textwidth| \quad( +\> |marginparsep| + |marginparwidth| )\\
392 % |height| &:=& |textheight| \quad(+\> |headheight| + |headsep| + |footskip| )
393 % \label{eq:height}
394 % \end{eqnarray}
395 % In Equation (\ref{eq:width}) |width:=textwidth| by default,
396 % while |marginparsep| and |marginparwidth| are included in |width|
397 % if |includemp| option is set |true|.
398 % In Equation (\ref{eq:height}), |height:=textheight| by default.
399 % If |includehead| is set to |true|, |headheight| and |headsep| are
400 % considered as a part of |height|.
401 % In the same way, |includefoot| takes |footskip| into |height|.
402 % Figure~\ref{fig:includes} shows how these options
403 % work in the vertical direction.
404 % \begin{figure}
405 % \centering\small
406 % {\unitlength=.65pt
407 % \begin{picture}(490,280)(0,-10)
408 % \put(60,250){\makebox(120,0)[bl]{\textbf{(a)}~\textit{default}}}%
409 % \put(20,0){\framebox(170,230){}}
410 % \put(20,230){\makebox(170,15)[r]{\gpart{paper}}}
411 % \begingroup\thicklines
412 % \put(40,30){\framebox(120,165){}}\endgroup
413 % \put(70,165){\vector(0,1){30}}
414 % \put(55,145){\makebox(0,20)[lc]{|textheight|}}
415 % \put(70,145){\vector(0,-1){115}}
416 % \multiput(40,203)(5,0){24}{\line(1,0){3}}
417 % \multiput(40,213)(5,0){24}{\line(1,0){3}}
418 % \multiput(40,10)(5,0){24}{\line(1,0){3}}
419 % \put(40,203){\makebox(120,20)[bc]{\gpart{head}}}
420 % \put(40,40){\makebox(120,140)[c]{\gpart{body}}}
421 % \put(40,11){\makebox(120,10)[c]{\gpart{foot}}}
422 % \put(150,230){\vector(0,-1){35}}\put(150,30){\vector(0,-1){30}}
423 % \put(150,195){\vector(0,1){35}}\put(150,0){\vector(0,1){30}}
424 % \put(160,197){\makebox(0,30)[lc]{|top|}}
425 % \put(160,0){\makebox(0,30)[lc]{|bottom|}}
426 % \multiput(160,30)(5,0){24}{\line(1,0){2}}
427 % \multiput(160,195)(5,0){24}{\line(1,0){2}}
428 % \put(255,250){\makebox(120,0)[bl]
429 % {\textbf{(b)}~|includehead| and |includefoot|}}%
430 % \put(260,0){\framebox(170,230){}}
431 % \put(260,230){\makebox(170,15)[r]{\gpart{paper}}}
432 % \begingroup\thicklines
433 % \put(280,30){\framebox(120,165){}}\endgroup
434 % \put(310,152){\vector(0,1){25}}
435 % \put(295,130){\makebox(0,20)[lc]{|textheight|}}
436 % \put(310,130){\vector(0,-1){80}}
437 % \multiput(280,184)(5,0){24}{\line(1,0){3}}
438 % \multiput(280,177)(5,0){24}{\line(1,0){3}}
439 % \multiput(280,50)(5,0){24}{\line(1,0){3}}
440 % \put(280,184){\makebox(120,10)[c]{\gpart{head}}}
441 % \put(280,40){\makebox(120,140)[c]{\gpart{body}}}
442 % \put(400,140){\line(1,1){45}}
443 % \put(437,187){\makebox(50,10)[l]{\gpart{total body}}}
444 % \put(280,31){\makebox(120,10)[c]{\gpart{foot}}}
445 % \put(370,230){\vector(0,-1){35}}\put(370,30){\vector(0,-1){30}}
446 % \put(370,195){\vector(0,1){35}}\put(370,0){\vector(0,1){30}}
447 % \put(380,197){\makebox(0,30)[lc]{|top|}}
448 % \put(380,0){\makebox(0,30)[lc]{|bottom|}}
449 % \end{picture}}
450 % \caption[An effect of \texttt{includehead} and \texttt{includefoot}.]{%
451 % \begin{minipage}[t]{.8\textwidth}\raggedright\small
452 % |includehead| and |includefoot| include the head and foot respectively
453 % into \gpart{total body}. \textbf{(a)} |height| $=$ |textheight| (default).
454 % \textbf{(b)} |height| $=$ |textheight| $+$ |headheight| $+$ |headsep| $+$
455 % |footskip| if |includehead| and |includefoot|. If the top and bottom
456 % margins are specified, |includehead| and |includefoot| result in
457 % shorter |textheight|.
458 % \end{minipage}}
459 % \label{fig:includes}
460 % \end{figure}
461 %
462 % Thus, the page layout consists of three parts (lengths) in each
463 % direction: one body and two margins. If the two of them are explicitly
464 % specified, the other length is obvious and no need to be specified.
465 % Figure~\ref{fig:Labc} shows a simple model of page dimensions.
466 % When a length |L| is given and is partitioned into the body |b|, the
467 % margins |a| and |c|, it's obvious that
468 % \begin{equation}
469 % |L|=|a|+|b|+|c| \label{eq:Labc}
470 % \end{equation}
471 % The specification with two of the three (|a|, |b| and |c|) fixed
472 % explicitly is solvable. If two or more are left unspecified
473 % or `underspecified', Equation~(\ref{eq:Labc}) cannot be solved
474 % without any other relation between them. If all of them are
475 % specified, then it needs to check whether or not they
476 % satisfy Equation~(\ref{eq:Labc}), that is too much specification or
477 % `overspecified'.
478 % \begin{figure}
479 % \centering
480 % {\unitlength=0.8pt
481 % \begin{picture}(300,60)(0,-5)
482 % \begingroup\linethickness{5pt}
483 % \put(0,5){\textcolor{green}{\line(1,0){60}}}
484 % \put(60,5){\textcolor{black}{\line(1,0){160}}}
485 % \put(220,5){\textcolor{green}{\line(1,0){80}}}
486 % \endgroup
487 % \put(0,15){\makebox(60,10)[b]{|a|}}
488 % \put(60,0){\line(0,1){20}}
489 % \put(60,15){\makebox(160,10)[b]{|b|}}
490 % \put(220,0){\line(0,1){20}}
491 % \put(220,15){\makebox(80,10)[b]{|c|}}
492 % \put(0,0){\line(0,1){50}}
493 % \put(150,35){\vector(-1,0){150}}
494 % \put(0,40){\makebox(300,10){|L|}}
495 % \put(150,35){\vector(1,0){150}}
496 % \put(300,0){\line(0,1){50}}
497 % \end{picture}}
498 % \caption{A simple model of page dimensions.}
499 % \label{fig:Labc}
500 % \end{figure}
501 %
502 % The \Gm\ package has auto-completion mechanism that saves the
503 % trouble of specifying the page layout dimensions. For example,
504 % you can set
505 % \begin{quote}
506 % |\usepackage[width=14cm, left=3cm]{geometry}|
507 % \end{quote}
508 % on A4 paper. In this case you don't have to set the right margin.
509 % The details of auto-completion will be described in
510 % Section~\ref{sec:rules}.
511 %
512 % \section{User interface}
513 %
514 % \subsection{Commands}
515 %
516 % The \Gm\ package provides the following commands:
517 % \begin{itemize}\setlength{\itemsep}{-.5\parsep}
518 % \item |\geometry{|\meta{options}|}|
519 % \item |\newgeometry{|\meta{options}|}| and |\restoregeometry|
520 % \item |\savegeometry{|\meta{name}|}| and |\loadgeometry{|\meta{name}|}|
521 % \end{itemize}
522 %
523 % |\geometry{|\meta{options}|}|
524 % changes the page layout according to the options specified in the
525 % argument. This command, if any, should be placed only in the
526 % preamble (before |\begin{document}|).
527 %
528 % The \Gm\ package may be used as part of a class or another package
529 % you use in your document. The command \cs{geometry} can overwrite
530 % some of the settings in the preamble. Multiple use of \cs{geometry}
531 % is allowed and then processed with the options concatenated.
532 % If \Gm\ is not yet loaded, you can use only
533 % |\usepackage[|\meta{options}|]{geometry}| instead of \cs{geometry}.
534 %
535 % \medskip
536 % |\newgeometry{|\meta{options}|}|
537 % changes the page layout mid-document. \cs{newgeometry} is almost
538 % similar to \cs{geometry} except that \cs{newgeometry} disables all
539 % the options specified by \cs{usepackage} and \cs{geometry} in
540 % the preamble and skips papersize-related options.
541 % \cs{restoregeometry}
542 % restores the page layout specified in the preamble. This command
543 % has no arguments. See Section~\ref{sec:midchange} for details.
544 %
545 % \medskip
546 % |\savegeometry{|\meta{name}|}|
547 % saves the page dimensions as \meta{name} where you put
548 % this command.
549 % |\loadgeometry{|\meta{name}|}|
550 % loads the page dimensions saved as \meta{name}. See
551 % Section~\ref{sec:midchange} for details.
552 %
553 % \subsection{Optional argument}
554 %
555 % The \Gm\ package adopts \textsf{keyval} interface
556 % `\meta{key}=\meta{value}' for the optional argument to
557 % \cs{usepackage}, \cs{geometry} and \cs{newgeometry}.
558 %
559 % The argument includes a list of comma-separated \textsf{keyval}
560 % options and has basic rules as follows:
561 % \begin{itemize}\setlength{\itemsep}{-.5\parsep}
562 % \item Multiple lines are allowed, while blank lines are not.
563 % \item Any spaces between words are ignored.
564 % \item Options are basically order-independent.
565 % (There are some exceptions. See Section~\ref{sec:optionorder} for details.)
566 % \end{itemize}
567 % For example,
568 % \begin{quote}
569 % |\usepackage[ a5paper , hmargin = { 3cm,|\\
570 % | .8in } , height|\\
571 % | = 10in ]{geometry}|
572 % \end{quote}
573 % is equivalent to
574 % \begin{quote}
575 % |\usepackage[height=10in,a5paper,hmargin={3cm,0.8in}]{geometry}|
576 % \end{quote}
577 % Some options are allowed to have sub-list, e.g. |{3cm,0.8in}|.
578 % Note that the order of values in the sub-list is significant.
579 % The above setting is also equivalent to the following:
580 % \begin{quote}
581 % |\usepackage{geometry}|\\
582 % |\geometry{height=10in,a5paper,hmargin={3cm,0.8in}}|
583 % \end{quote}
584 % or
585 % \begin{quote}
586 % |\usepackage[a5paper]{geometry}|\\
587 % |\geometry{hmargin={3cm,0.8in},height=8in}|\\
588 % |\geometry{height=10in}|.
589 % \end{quote}
590 % Thus, multiple use of \cs{geometry} just appends options.
591 %
592 % \Gm\ supports package
593 % \textsl{calc}\footnote{CTAN:~\texttt{macros/latex/required/tools}}.
594 % For example,
595 % \begin{quote}
596 % |\usepackage{calc}|\\
597 % |\usepackage[textheight=20\baselineskip+10pt]{geometry}|
598 % \end{quote}
599 %
600 % \subsection{Option types}
601 % \Gm\ options are categorized into four types:
602 %
603 % \begin{enumerate}\itemsep=0pt
604 % \item \textbf{Boolean type}
605 %
606 % takes a boolean value (|true| or |false|). If no value,
607 % |true| is set by default.
608 % \begin{quote}
609 % \meta{key}|=true|\OR|false|.\\
610 % \meta{key} with no value is equivalent to
611 % \meta{key}|=true|.
612 % \end{quote}
613 % \textit{Examples:}~ |verbose=true|, |includehead|,
614 % |twoside=false|.\\
615 % Paper name is the exception. The preferred paper name should be set
616 % with no values. Whatever value is given, it is ignored. For
617 % instance, |a4paper=XXX| is equivalent to |a4paper|.
618 %
619 % \item \textbf{Single-valued type}
620 %
621 % takes a mandatory value.
622 % \begin{quote}
623 % \meta{key}|=|\meta{value}.
624 % \end{quote}
625 % \textit{Examples:}~ |width=7in|, |left=1.25in|,
626 % |footskip=1cm|, |height=.86\paperheight|.
627 %
628 % \item \textbf{Double-valued type}
629 %
630 % takes a pair of comma-separated values in braces. The two values can
631 % be shortened to one value if they are identical.
632 % \begin{quote}
633 % \meta{key}|=|\argii{value1}{value2}.\\
634 % \meta{key}|=|\meta{value} is equivalent to
635 % \meta{key}|=|\argii{value}{value}.
636 % \end{quote}
637 % \textit{Examples:}~ |hmargin={1.5in,1in}|, |scale=0.8|,
638 % |body={7in,10in}|.
639 %
640 % \item \textbf{Triple-valued type}
641 %
642 % takes three mandatory, comma-separated values in braces.
643 % \begin{quote}
644 % \meta{key}|=|\argiii{value1}{value2}{value3}
645 % \end{quote}
646 % Each value must be a dimension or null. When you give an empty value
647 % or `|*|', it means null and leaves the appropriate value
648 % to the auto-completion mechanism. You need to specify at least one
649 % dimension, typically two dimensions. You can set nulls for all the
650 % values, but it makes no sense.
651 % \textit{Examples:}\\
652 % \hspace*{2em} |hdivide={2cm,*,1cm}|, |vdivide={3cm,19cm, }|,
653 % |divide={1in,*,1in}|.
654 % \end{enumerate}
655 %
656 % \section{Option details}
657 %
658 % This section describes all options available in \Gm.
659 % Options with a dagger $^\dagger$ are not available
660 % as arguments of \cs{newgeometry} (See Section~\ref{sec:midchange}).
661 %
662 % \subsection{Paper size}\label{sec:paper}
663 %
664 % The options below set paper/media size and orientation.
665 % \begin{Options}
666 % \item[\onlypre paper\OR papername] ~\\
667 % specifies the paper size by name. |paper=|\meta{paper-name}.
668 % For convenience, you can specify the paper name without |paper=|.
669 % For example, |a4paper| is equivalent to |paper=a4paper|.
670 % \item[\onlypre \vtop{
671 % \hbox{a0paper, a1paper, a2paper, a3paper, a4paper, a5paper, a6paper,}
672 % \hbox{b0paper, b1paper, b2paper, b3paper, b4paper, b5paper, b6paper,}
673 % \hbox{c0paper, c1paper, c2paper, c3paper, c4paper, c5paper, c6paper,}
674 % \hbox{b0j, b1j, b2j, b3j, b4j, b5j, b6j,}
675 % \hbox{ansiapaper, ansibpaper, ansicpaper, ansidpaper, ansiepaper,}
676 % \hbox{letterpaper, executivepaper, legalpaper}}]~\\[1ex]
677 % specifies paper name. The value part is ignored even if any.
678 % For example, the following have the same effect:
679 % |a5paper|, |a5paper=true|, |a5paper=false| and so forth.
680 % |a[0-6]paper|, |b[0-6]paper| and |c[0-6]paper| are ISO A, B and C
681 % series of paper sizes respectively.
682 % The JIS (Japanese Industrial Standards) A-series is identical to the
683 % ISO A-series, but the JIS B-series is different from the ISO B-series.
684 % |b[0-6]j| should be used for the JIS B-series.
685 % \item[\onlypre screen] a special paper size with (W,H) = (225mm,180mm).
686 % For presentation with PC and video projector, ``|screen,centering|''
687 % with `slide' documentclass would be useful.
688 % \item[\onlypre paperwidth] width of the paper. |paperwidth=|\meta{length}.
689 % \item[\onlypre paperheight] height of the paper. |paperheight=|\meta{length}.
690 % \item[\onlypre papersize] width and height of the paper.
691 % |papersize=|\argii{width}{height} or |papersize=|\meta{length}.
692 % \item[\onlypre landscape] switches the paper orientation to landscape mode.
693 % \item[\onlypre portrait] switches the paper orientation to portrait mode.
694 % This is equivalent to |landscape=false|.
695 % \end{Options}
696 %
697 % The options for paper names (e.g., |a4paper|) and orientation
698 % (|portrait| and |landscape|) can be set as document class options.
699 % For example, you can set |\documentclass[a4paper,landscape]{article}|,
700 % then |a4paper| and |landscape| are processed in \Gm\ as well.
701 % This is also the case for |twoside| and |twocolumn|
702 % (see also Section~\ref{sec:dimension}).
703 %
704 % \subsection{Layout size}
705 %
706 % You can specify the layout area with options described in this
707 % section regardless of the paper size.
708 % The options would help to print the specified layout to a different
709 % sized paper. For example, with |a4paper| and |layout=a5paper|, the
710 % package uses `A5' layout to calculate margins on `A4' paper.
711 % The layout size defaults to the same as the paper.
712 % The options for the layout size are available in \cs{newgeometry},
713 % so that you can change the layout size in the middle of the document.
714 % The paper size itself can't be changed though.
715 % Figure~\ref{fig:layoutandpaper} shows what the difference between
716 % |layout| and |paper| is.
717 % \begin{Options}
718 % \item[layout] specifies the layout size by paper
719 % name. |layout=|\meta{paper-name}. All the paper names defined in \Gm\
720 % are available. See Section~\ref{sec:paper} for details.
721 % \item[layoutwidth] width of the layout. |layoutwidth=|\meta{length}.
722 % \item[layoutheight] height of the layout. |layoutheight=|\meta{length}.
723 % \item[layoutsize] width and height of the layout.
724 % |layoutsize=|\argii{width}{height} or |layoutsize=|\meta{length}.
725 % \item[layouthoffset] specifies the horizontal offset from the left edge of
726 % the paper. |layouthoffset=|\meta{length}.
727 % \item[layoutvoffset] specifies the vertical offset from the top edge of
728 % the paper. |layoutvoffset=|\meta{length}.
729 % \item[layoutoffset] specifies both horizontal and vertical offsets.
730 % |layoutoffset=|\argii{hoffset}{voffset} or |layoutsize=|\meta{length}.
731 % \end{Options}
732 % \begin{figure}
733 % \centering\small
734 % {\unitlength=.6pt
735 % \begin{picture}(450,250)(0,-10)
736 % \put(20,0){\makebox(168,12)[r]{\gpart{paper}}}
737 % \put(20,0){\framebox(170,230){}}
738 % \put(21,40){\dashbox{3}(140,189){}}
739 % \put(21,28){\makebox(140,12)[r]{\gpart{layout}}}
740 % \put(40,50){\makebox(100,10){\gpart{foot}}}
741 % \put(40,50){\line(1,0){100}}
742 % \put(40,65){\framebox(100,125){\gpart{body}}}
743 % \put(40,200){\framebox(100,10){\gpart{head}}}
744 % \put(20,230){\makebox(140,20){|layoutwidth|}}
745 % \put(40,240){\vector(-1,0){20}}
746 % \put(140,240){\vector(1,0){20}}
747 % \put(10,145){\vector(0,1){85}}
748 % \put(15,125){\makebox(0,20)[r]{|layoutheight|}}
749 % \put(10,125){\vector(0,-1){85}}
750 % \put(280,0){\makebox(168,12)[r]{\gpart{paper}}}
751 % \put(280,0){\framebox(170,230){}}
752 % \put(293,35){\dashbox{3}(140,189){}}
753 % \put(293,23){\makebox(140,12)[r]{\gpart{layout}}}
754 % \put(312,45){\makebox(100,10){\gpart{foot}}}
755 % \put(312,45){\line(1,0){100}}
756 % \put(312,60){\framebox(100,125){\gpart{body}}}
757 % \put(312,195){\framebox(100,10){\gpart{head}}}
758 % \put(235,230){\makebox(80,20)[l]{|layouthoffset|}}
759 % \put(260,210){\vector(1,0){20}}
760 % \put(308,210){\vector(-1,0){15}}
761 % \put(260,210){\line(-1,2){10}}
762 % \put(355,230){\makebox(100,20){|layoutvoffset|}}
763 % \put(350,250){\vector(0,-1){20}}
764 % \put(350,209){\vector(0,1){15}}
765 % \end{picture}}
766 % \caption[layout and paper]{%
767 % \begin{minipage}[t]{.7\textwidth}\raggedright\small
768 % The dimensions related to the layout size. Note that the layout size
769 % defaults to the same size as the paper, so you don't have to specify
770 % layout-related options explicitly in most cases.
771 % \end{minipage}}
772 % \label{fig:layoutandpaper}
773 % \end{figure}
774 %
775 % \subsection{Body size}\label{sec:body}
776 %
777 % The options specifying the size of \gpart{total body} are described in this
778 % section.
779 %
780 % \begin{Options}
781 % \item[hscale]
782 % ratio of width of \gpart{total body} to \cs{paperwidth}.
783 % |hscale=|\meta{h-scale}, e.g., |hscale=0.8| is equivalent to
784 % |width=0.8|\cs{paperwidth}. (|0.7| by default)
785 % \item[vscale]
786 % ratio of height of \gpart{total body} to \cs{paperheight}, e.g.,
787 % |vscale=|\meta{v-scale}. (|0.7| by default) |vscale=0.9| is equivalent
788 % to |height=0.9|\cs{paperheight}.
789 % \item[scale] ratio of \gpart{total body} to the paper.
790 % |scale=|\argii{h-scale}{v-scale} or |scale=|\meta{scale}.
791 % (|0.7| by default)
792 % \item[width\OR totalwidth] ~\\
793 % width of \gpart{total body}. |width=|\meta{length} or
794 % |totalwidth=|\meta{length}. This dimension defaults to |textwidth|,
795 % but if |includemp| is set to |true|, |width| $\ge$ |textwidth|
796 % because |width| includes the width of the marginal notes.
797 % If |textwidth| and |width| are specified at the same time,
798 % |textwidth| takes priority over |width|.
799 % \item[height\OR totalheight] ~\\
800 % height of \gpart{total body}, excluding header and footer by default.
801 % If |includehead| or |includefoot| is set, |height| includes
802 % the head or foot of the page as well as |textheight|.
803 % |height=|\meta{length} or |totalheight=|\meta{length}. If both
804 % |textheight| and |height| are specified, |height| will be ignored.
805 % \item[total] width and height of \gpart{total body}.\\
806 % |total=|\argii{width}{height} or |total=|\meta{length}.
807 % \item[textwidth] specifies \cs{textwidth}, the width of \gpart{body}
808 % (the text area). |textwidth=|\meta{length}.
809 % \item[textheight] specifies \cs{textheight}, the height of
810 % \gpart{body} (the text area). |textheight=|\meta{length}.
811 % \item[text\OR body] specifies both \cs{textwidth} and \cs{textheight}
812 % of the body of page. |body=|\argii{width}{height} or
813 % |text=|\meta{length}.
814 % \item[lines] enables users to specify \cs{textheight} by the number
815 % of lines. |lines|=\meta{integer}.
816 % \item[includehead] includes the head of the page, \cs{headheight}
817 % and \cs{headsep}, into \gpart{total body}. It is set to |false| by
818 % default. It is opposite to |ignorehead|. See
819 % Figure~\ref{fig:includes} and Figure~\ref{fig:modes}.
820 % \item[includefoot] includes the foot of the page, \cs{footskip},
821 % into \gpart{total body}. It is opposite to |ignorefoot|.
822 % It is |false| by default. See Figure~\ref{fig:includes} and
823 % Figure~\ref{fig:modes}.
824 % \item[includeheadfoot]~\\
825 % sets both |includehead| and |includefoot| to |true|, which is opposite
826 % to |ignoreheadfoot|. See Figure~\ref{fig:includes} and
827 % Figure~\ref{fig:modes}.
828 % \item[includemp] includes the margin notes, \cs{marginparwidth}
829 % and \cs{marginparsep}, into \gpart{body} when calculating horizontal
830 % calculation.
831 % \item[includeall] sets both |includeheadfoot| and |includemp| to
832 % |true|. See Figure~\ref{fig:modes}.
833 % \item[ignorehead] disregards the head of the page,
834 % |headheight| and |headsep|, in determining vertical layout, but does not
835 % change those lengths. It is equivalent to |includehead=false|. It is set
836 % to |true| by default. See also |includehead|.
837 % \item[ignorefoot] disregards the foot of page, |footskip|,
838 % in determining vertical layout, but does not change that length.
839 % This option defaults to |true|. See also |includefoot|.
840 % \item[ignoreheadfoot]~\\ sets both |ignorehead| and |ignorefoot|
841 % to |true|. See also |includeheadfoot|.
842 % \item[ignoremp] disregards the marginal notes in determining the
843 % horizontal margins (defaults to |true|). If marginal notes overrun
844 % the page, the warning message will be displayed when |verbose=true|.
845 % See also |includemp| and Figure~\ref{fig:modes}.
846 % \item[ignoreall] sets both |ignoreheadfoot| and |ignoremp| to |true|.
847 % See also |includeall|.
848 % \item[heightrounded]~\\
849 % This option rounds \cs{textheight} to \textit{n}-times (\textit{n}:
850 % an integer) of \cs{baselineskip} plus \cs{topskip} to avoid
851 % ``underfull vbox'' in some cases. For example, if \cs{textheight} is
852 % 486pt with \cs{baselineskip} 12pt and \cs{topskip} 10pt, then
853 % \begin{quote}
854 % $(39\times12\textrm{pt}+10\textrm{pt}=)\: 478\textrm{pt}
855 % < 486\textrm{pt} <
856 % 490\textrm{pt} \:(=40\times12\textrm{pt}+10\textrm{pt})$,
857 % \end{quote}
858 % as a result \cs{textheight} is rounded to 490pt. |heightrounded=false|
859 % by default.
860 % \end{Options}
861 %
862 % Figure~\ref{fig:modes} illustrates various layouts with different layout
863 % modes. The dimensions for a header and a footer can be controlled by
864 % |nohead| or |nofoot| mode, which sets each length to 0pt directly.
865 % On the other hand, options with the prefix |ignore| do \textit{not}
866 % change the corresponding native dimensions.
867 % \begin{figure}
868 % \centering\small
869 % {\unitlength=.65pt
870 % \begin{picture}(460,525)(0,0)
871 % \put( 20,310){\framebox(120,170){}}
872 % \put( 20,507){\makebox(120,0)[bl]%
873 % {\textbf{(a)}~|includeheadfoot|}}
874 % \put( 20,460){\line(1,0){120}}\put( 20,450){\line(1,0){120}}
875 % \put( 20,330){\line(1,0){120}}
876 % \put( 20,485){\makebox(120,0)[br]{\gpart{total body}}}
877 % \put( 20,335){\makebox(120,0)[bc]{|textwidth|}}
878 % \put(150,470){\makebox(0,0)[l]{|headheight|}}
879 % \put(150,450){\makebox(0,0)[l]{|headsep|}}
880 % \put(150,390){\makebox(0,0)[l]{|textheight|}}
881 % \put(150,320){\makebox(0,0)[l]{|footskip|}}
882 % \put( 10,460){\makebox(120,20)[bc]{\gpart{head}}}
883 % \put( 10,320){\makebox(120,140)[c]{\gpart{body}}}
884 % \put( 10,310){\makebox(120,10)[c]{\gpart{foot}}}
885 % \put(250,310){\framebox(120,170){}}
886 % \put(250,507){\makebox(120,0)[bl]%
887 % {\textbf{(b)}~|includeall|}}
888 % \put(250,460){\line(1,0){95}}\put(250,450){\line(1,0){95}}
889 % \put(250,330){\line(1,0){95}}\put(345,330){\line(0,1){120}}
890 % \put(350,330){\line(0,1){120}}\put(350,450){\line(1,0){20}}
891 % \put(350,330){\line(1,0){20}}
892 % \put(250,485){\makebox(120,0)[br]{\gpart{total body}}}
893 % \put(250,460){\makebox(95,20)[bc]{\gpart{head}}}
894 % \put(250,320){\makebox(95,140)[c]{\gpart{body}}}
895 % \put(385,390){\makebox(95,0)[cl]%
896 % {\gpart{\shortstack[l]{marginal\\note}}}}
897 % \put(250,310){\makebox(95,10)[c]{\gpart{foot}}}
898 % \put(250,335){\makebox(95,0)[bc]{|textwidth|}}
899 % \multiput(360, 390)(4,0){6}{\line(1,0){2}}
900 % \multiput(348,333)(0,-4){12}{\line(0,1){2}}
901 % \multiput(360,333)(0,-4){8}{\line(0,1){2}}
902 % \put(355,292){\makebox(0,0)[bl]{|marginparwidth|}}
903 % \put(345,275){\makebox(0,0)[bl]{|marginparsep|}}
904 % \put( 20, 40){\framebox(120,170){}}
905 % \put( 20,237){\makebox(120,0)[bl]%
906 % {\textbf{(c)}~|includefoot|}}
907 % \put( 20, 60){\line(1,0){120}}
908 % \put( 20,215){\makebox(120,0)[br]{\gpart{total body}}}
909 % \put(150,130){\makebox(0,0)[l]{|textheight|}}
910 % \put(150, 50){\makebox(0,0)[l]{|footskip|}}
911 % \put( 20, 50){\makebox(120,160)[c]{\gpart{body}}}
912 % \put( 20, 40){\makebox(120,10)[c]{\gpart{foot}}}
913 % \put( 20, 65){\makebox(120,10)[c]{|textwidth|}}
914 % \put(250, 40){\framebox(120,170){}}
915 % \put(250,237){\makebox(120,0)[bl]%
916 % {\textbf{(d)}~|includefoot,includemp|}}
917 % \put(250, 60){\line(1,0){95}}\put(350, 60){\line(1,0){20}}
918 % \put(250,215){\makebox(120,0)[br]{\gpart{total body}}}
919 % \put(250, 50){\makebox(95,160)[c]{\gpart{body}}}
920 % \put(385,130){\makebox(95,0)[cl]%
921 % {\gpart{\shortstack[l]{marginal\\note}}}}
922 % \put(250, 40){\makebox(95,10)[c]{\gpart{foot}}}
923 % \put(250, 65){\makebox(95,0)[bc]{|textwidth|}}
924 % \put(345, 60){\line(0,1){150}}\put(350, 60){\line(0,1){150}}
925 % \multiput(360, 130)(4,0){6}{\line(1,0){2}}
926 % \multiput(348, 63)(0,-4){12}{\line(0,1){2}}
927 % \multiput(360, 63)(0,-4){8}{\line(0,1){2}}
928 % \put(355,22){\makebox(0,0)[bl]{|marginparwidth|}}
929 % \put(345, 5){\makebox(0,0)[bl]{|marginparsep|}}
930 % \end{picture}}
931 % \caption[Sample layouts for \gpart{total body} with different
932 % layout modes]{%
933 % \begin{minipage}[t]{.8\textwidth}\small
934 % Sample layouts for \gpart{total body} with different switches.
935 % (a) |includeheadfoot|, (b) |includeall|, (c) |includefoot|
936 % and (d) |includefoot,includemp|.
937 % If |reversemp| is set to |true|, the location of the
938 % marginal notes are swapped on every page.
939 % Option |twoside| swaps both margins and marginal notes on verso pages.
940 % Note that the marginal note, if any, is printed despite
941 % |ignoremp| or |includemp=false| and overrun the page in some cases.
942 % \end{minipage}}
943 % \label{fig:modes}
944 % \end{figure}
945 %
946 % The following options can specify body and margins simultaneously with
947 % three comma-separated values in braces.
948 %
949 % \begin{Options}
950 % \item[hdivide] horizontal partitions (left,width,right).
951 % |hdivide=|\argiii{left margin}{width}{right margin}.
952 % Note that you should not specify all of the three parameters.
953 % The best way of using this option is to specify two of three and
954 % leave the rest with null(nothing) or `|*|'. For example, when you set
955 % |hdivide={2cm,15cm, }|, the margin from the right-side edge of page
956 % will be determined calculating |paperwidth-2cm-15cm|.
957 % \item[vdivide] vertical partitions (top,height,bottom).
958 % |vdivide=|\argiii{top margin}{height}{bottom margin}.
959 % \item[divide] |divide=|\vargiii{$A$}{$B$}{$C$} is interpreted as
960 % |hdivide=|\vargiii{$A$}{$B$}{$C$} and |vdivide=|\vargiii{$A$}{$B$}{$C$}.
961 % \end{Options}
962 %
963 % \subsection{Margin size}\label{sec:margin}
964 %
965 % The options specifying the size of the margins are listed below.
966 %
967 % \begin{Options}
968 % \item[left\OR lmargin\OR inner]~\\
969 % left margin (for oneside) or inner margin (for twoside) of
970 % \gpart{total body}. In other words, the distance between the left (inner)
971 % edge of the paper and that of \gpart{total body}. |left=|\meta{length}.
972 % |inner| has no special meaning, just an alias of |left| and |lmargin|.
973 % \item[right\OR rmargin\OR outer]~\\
974 % right or outer margin of \gpart{total body}. |right=|\meta{length}.
975 % \item[top\OR tmargin] top margin of the page. |top=|\meta{length}.
976 % Note this option has nothing to do with the native dimension
977 % \cs{topmargin}.
978 % \item[bottom\OR bmargin]~\\
979 % bottom margin of the page. |bottom=|\meta{length}.
980 % \item[hmargin] left and right margin.
981 % |hmargin=|\argii{left margin}{right margin} or |hmargin=|\meta{length}.
982 % \item[vmargin] top and bottom margin.
983 % |vmargin=|\argii{top margin}{bottom margin} or |vmargin=|\meta{length}.
984 % \item[margin] |margin=|\vargii{$A$}{$B$} is equivalent to
985 % |hmargin=|$A$ and |vmargin=|$B$.
986 % |margin=|$A$ is automatically expanded to |hmargin=|$A$ and |vmargin=|$A$.
987 % \item[hmarginratio]
988 % horizontal margin ratio of |left| (inner) to |right| (outer).
989 % The value of \meta{ratio} should be specified with colon-separated
990 % two values. Each value should be a positive integer less than 100
991 % to prevent arithmetic overflow, e.g., |2:3| instead of |1:1.5|.
992 % The default ratio is |1:1| for oneside, |2:3| for twoside.
993 % \item[vmarginratio]
994 % vertical margin ratio of |top| to |bottom|. The default ratio is |2:3|.
995 % \item[marginratio\OR ratio]~\\
996 % horizontal and vertical margin ratios.
997 % |marginratio=|\argii{horizontal ratio}{vertical ratio} or
998 % |marginratio=|\meta{ratio}.
999 % \item[hcentering] sets auto-centering horizontally and is
1000 % equivalent to |hmarginratio=1:1|. It is set to |true| by default for
1001 % oneside. See also |hmarginratio|.
1002 % \item[vcentering] sets auto-centering vertically and is
1003 % equivalent to |vmarginratio=1:1|. The default is |false|.
1004 % See also |vmarginratio|.
1005 % \item[centering] sets auto-centering and is equivalent to
1006 % |marginratio=1:1|. See also |marginratio|. The default is |false|.
1007 % See also |marginratio|.
1008 % \item[twoside] switches on twoside mode with left and right margins swapped
1009 % on verso pages. The option sets \cs{@twoside} and \cs{@mparswitch}
1010 % switches. See also |asymmetric|.
1011 % \item[asymmetric] implements a twosided layout in which margins are
1012 % not swapped on alternate pages (by setting \cs{oddsidemargin} to
1013 % \cs{evensidemargin} |+| |bindingoffset|) and in which the marginal notes
1014 % stay always on the same side. This option can be used as an alternative
1015 % to the twoside option. See also |twoside|.
1016 % \item[bindingoffset]~\\ removes a specified space
1017 % from the lefthand-side of the page for oneside or the inner-side for
1018 % twoside. |bindingoffset=|\meta{length}. This is useful if pages
1019 % are bound by a press binding (glued, stitched, stapled \ldots).
1020 % See Figure~\ref{fig:bindingoffset}.
1021 % \item[hdivide] See description in Section~\ref{sec:body}.
1022 % \item[vdivide] See description in Section~\ref{sec:body}.
1023 % \item[divide] See description in Section~\ref{sec:body}.
1024 % \end{Options}
1025 % \begin{figure}
1026 % \centering\small
1027 % {\unitlength=.65pt
1028 % \begin{picture}(500,270)(0,0)
1029 % \put(20,0){\framebox(170,230){}}
1030 % \put(20,255){\makebox(80,20)[l]{\textbf{a)}~every page for oneside or}}
1031 % \put(20,240){\makebox(80,20)[l]{\hspace{3ex}odd pages for twoside}}
1032 % \put(110,225){\makebox(80,20)[r]{\gpart{paper}}}
1033 % \put(55,37){\framebox(110,170)[tc]{\gpart{total body}}}
1034 % \multiput(38,0)(0,7){33}{\line(0,1){4}}
1035 % \put(38,100){\vector(1,0){17}}\put(55,100){\vector(-1,0){17}}
1036 % \put(60,95){\makebox(80,10)[l]{|left|}}
1037 % \put(60,80){\makebox(80,10)[l]{(|inner|)}}
1038 % \put(165,100){\vector(1,0){25}}\put(190,100){\vector(-1,0){25}}
1039 % \put(195,95){\makebox(80,10)[l]{|right|}}
1040 % \put(195,80){\makebox(80,10)[l]{(|outer|)}}
1041 % \put(20,16){\vector(1,0){18}}
1042 % \put(45,10){\makebox(80,10)[bl]{|bindingoffset|}}
1043 % \put(280,255){\makebox(80,20)[l]{\textbf{b)}~even (back) pages for twoside}}
1044 % \put(280,0){\framebox(170,230){}}
1045 % \put(370,225){\makebox(80,20)[r]{\gpart{paper}}}
1046 % \put(305,37){\framebox(110,170)[tc]{\gpart{total body}}}
1047 % \multiput(432,0)(0,7){33}{\line(0,1){4}}
1048 % \put(280,100){\vector(1,0){25}}\put(305,100){\vector(-1,0){25}}
1049 % \put(310,95){\makebox(80,10)[l]{|outer|}}
1050 % \put(310,80){\makebox(80,10)[l]{(|right|)}}
1051 % \put(415,100){\vector(1,0){17}}\put(432,100){\vector(-1,0){17}}
1052 % \put(373,95){\makebox(80,10)[l]{|inner|}}
1053 % \put(373,80){\makebox(80,10)[l]{(|left|)}}
1054 % \put(450,16){\vector(-1,0){18}}
1055 % \put(330,10){\makebox(80,10)[bl]{|bindingoffset|}}
1056 % \end{picture}}
1057 % \caption[\texttt{bindingoffset} option]{%
1058 % \begin{minipage}[t]{.8\textwidth}\raggedright\small
1059 % The option |bindingoffset| adds the specified length to the inner margin.
1060 % Note that |twoside| option swaps the horizontal margins and the
1061 % marginal notes together with |bindingoffset| on even pages (see
1062 % \textbf{b)}), but |asymmetric| option suppresses the swap of the
1063 % margins and marginal notes (but |bindingoffset| is still swapped).
1064 % \end{minipage}}
1065 % \label{fig:bindingoffset}
1066 % \end{figure}
1067 %
1068 % \subsection{Native dimensions}\label{sec:dimension}
1069 %
1070 % The options below overwrite \LaTeX\ native dimensions and switches for page
1071 % layout (See the right-hand side in Figure~\ref{fig:layout}).
1072 %
1073 % \begin{Options}
1074 % \item[headheight\OR head]~\\
1075 % modifies \cs{headheight}, height of header.
1076 % |headheight=|\meta{length} or |head=|\meta{length}.
1077 % \item[headsep] modifies \cs{headsep}, separation between header and text
1078 % (body). |headsep=|\meta{length}.
1079 % \item[footskip\OR foot]~\\ modifies \cs{footskip}, distance separation
1080 % between baseline of last line of text and baseline of footer.
1081 % |footskip=|\meta{length} or |foot=|\meta{length}.
1082 % \item[nohead] eliminates spaces for the head of the page, which is
1083 % equivalent to both \cs{headheight}|=0pt| and \cs{headsep}|=0pt|.
1084 % \item[nofoot] eliminates spaces for the foot of the page, which is
1085 % equivalent to \cs{footskip}|=0pt|.
1086 % \item[noheadfoot] equivalent to |nohead| and |nofoot|, which means that
1087 % \cs{headheight}, \cs{headsep} and \cs{footskip} are all set to |0pt|.
1088 % \item[footnotesep] changes the dimension \cs{skip}\cs{footins}, separation
1089 % between the bottom of text body and the top of footnote text.
1090 % \item[marginparwidth\OR marginpar]~\\
1091 % modifies \cs{marginparwidth}, width of the marginal notes.
1092 % |marginparwidth=|\meta{length}.
1093 % \item[marginparsep] modifies \cs{marginparsep}, separation between
1094 % body and marginal notes. |marginparsep=|\meta{length}.
1095 % \item[nomarginpar] shrinks spaces for marginal notes to 0pt, which
1096 % is equivalent to \cs{marginparwidth}|=0pt| and \cs{marginparsep}|=0pt|.
1097 % \item[columnsep] modifies \cs{columnsep}, the separation between two
1098 % columns in |twocolumn| mode.
1099 % \item[hoffset] modifies \cs{hoffset}. |hoffset=|\meta{length}.
1100 % \item[voffset] modifies \cs{voffset}. |voffset=|\meta{length}.
1101 % \item[offset] horizontal and vertical offset.\\
1102 % |offset=|\argii{hoffset}{voffset} or |offset=|\meta{length}.
1103 % \item[twocolumn] sets |twocolumn| mode with \cs{@twocolumntrue}.
1104 % |twocolumn=false| denotes onecolumn mode with\cs{@twocolumnfalse}.
1105 % Instead of |twocolumn=false|, you can specify |onecolumn| (which
1106 % defaults to |true|)
1107 % \item[onecolumn] works as |twocolumn=false|. On the other hand,
1108 % |onecolumn=false| is equivalent to |twocolumn|.
1109 % \item[twoside] sets both \cs{@twosidetrue} and \cs{@mparswitchtrue}.
1110 % See Section~\ref{sec:margin}.
1111 % \item[textwidth] sets \cs{textwidth} directly. See Section~\ref{sec:body}.
1112 % \item[textheight] sets \cs{textheight} directly. See Section~\ref{sec:body}.
1113 % \item[reversemp\OR reversemarginpar]~\\
1114 % makes the marginal notes appear in the left (inner) margin with
1115 % \cs{@reversemargintrue}. The option doesn't change |includemp| mode.
1116 % It's set |false| by default.
1117 % \end{Options}
1118 %
1119 % \subsection{Drivers}\label{sec:drivers}
1120 %
1121 % The package supports drivers |dvips|, |dvipdfm|, |pdftex|, |luatex|,
1122 % |xetex| and |vtex|. You can also set |dvipdfm| for \textsf{dvipdfmx} and
1123 % \textsf{xdvipdfmx} The options |dvipdfmx| and |xdvipdfmx| are also supported
1124 % as aliases for the |dvipdfm| option.
1125 % |pdftex| for \textsf{pdflatex}, and |vtex| for
1126 % V\TeX{} environment.
1127 % The driver options are exclusive. The driver can be set by either
1128 % |driver=|\meta{driver name} or any of the drivers directly like |pdftex|.
1129 % By default, \Gm\ guesses the driver appropriate to the system
1130 % in use. Therefore, you don't have to set a driver in most cases.
1131 % However, if you want to use |dvipdfm|, you should specify it explicitly.
1132 %
1133 % \begin{Options}
1134 % \item[\onlypre driver] specifies the driver with |driver=|\meta{driver name}.
1135 % |dvips|, |dvipdfm|, |pdftex|, |luatex|, |vtex|, |xetex|, |auto| and |none| are
1136 % available as a driver name. The names except for |auto| and |none| can
1137 % be specified directly with the name without |driver=|.
1138 % |driver=auto| makes the auto-detection work whatever the previous setting is.
1139 % |driver=none| disables the auto-detection and sets no driver, which
1140 % may be useful when you want to let other package work out the driver
1141 % setting. For example, if you want to use \textsf{crop} package with \Gm,
1142 % you should call |\usepackage[driver=none]{geometry}| before
1143 % the \textsf{crop} package.
1144 % \item[\onlypre dvips] writes the paper size in dvi output with the \cs{special}
1145 % macro. If you use \textsl{dvips} as a DVI-to-PS driver,
1146 % for example, to print a document with |\geometry{a3paper,landscape}|
1147 % on A3 paper in landscape orientation, you don't need options
1148 % ``|-t a3 -t landscape|'' to \textsl{dvips}.
1149 % \item[\onlypre dvipdfm] works like |dvips| except for landscape correction.
1150 % You can set this option when using \textsf{dvipdfmx} and
1151 % \textsf{xdvipdfmx} to process the dvi output.
1152 % \item[\onlypre pdftex] sets \cs{pdfpagewidth} and \cs{pdfpageheight}
1153 % internally.
1154 % \item[\onlypre luatex] sets \cs{pagewidth} and \cs{pageheight} internally.
1155 % \item[\onlypre xetex] is the same as |pdftex| except for ignoring
1156 % |\pdf{h,v}origin| undefined in \XeLaTeX{}. This option is introduced in
1157 % the version 5. Note that `geometry.cfg' in \TeX{} Live, which disables the
1158 % auto-detection routine and sets |pdftex|, is no longer necessary,
1159 % but has no problem even though it's left undeleted.
1160 % Instead of |xetex|, you can specify |dvipdfm| with \XeLaTeX{}
1161 % if you want to use specials of dvipdfm \XeTeX{} supports.
1162 % \item[\onlypre vtex] sets dimensions \cs{mediawidth} and \cs{mediaheight}
1163 % for V\TeX. When this driver is selected (explicitly or
1164 % automatically), \Gm\ will auto-detect which output mode
1165 % (DVI, PDF or PS) is selected in V\TeX, and do proper
1166 % settings for it.
1167 % \end{Options}
1168 % If explicit driver setting is mismatched with the typesetting program
1169 % in use, the default driver |dvips| would be selected.
1170 %
1171 % \subsection{Other options}
1172 %
1173 % The other useful options are described here.
1174 %
1175 % \begin{Options}
1176 % \item[\onlypre verbose] displays the parameter results on the terminal.
1177 % |verbose=false| (default) still puts them into the log file.
1178 % \item[\onlypre reset] sets back the layout dimensions and switches to the
1179 % settings before \Gm\ is loaded. Options given in
1180 % |geometry.cfg| are also cleared.
1181 % Note that this cannot reset |pass| and |mag| with |truedimen|.
1182 % |reset=false| has no effect and cannot cancel the previous
1183 % |reset|(|=true|) if any. For example, when you go
1184 % \begin{quote}
1185 % |\documentclass[landscape]{article}|\\
1186 % |\usepackage[twoside,reset,left=2cm]{geometry}|
1187 % \end{quote}
1188 % with |\ExecuteOptions{scale=0.9}| in |geometry.cfg|,
1189 % then as a result, |landscape| and |left=2cm| remain effective,
1190 % and |scale=0.9| and |twoside| are ineffective.
1191 % \item[\onlypre mag] sets magnification value (\cs{mag}) and automatically modifies
1192 % \cs{hoffset} and \cs{voffset} according to the magnification.
1193 % |mag=|\meta{value}. Note that \meta{value} should be an integer value
1194 % with 1000 as a normal size. For example, |mag=1414| with |a4paper|
1195 % provides an enlarged print fitting in |a3paper|, which is $1.414$
1196 % (=$\sqrt{2}$) times larger than |a4paper|. Font enlargement needs extra
1197 % disk space. \textbf{Note that setting |mag| should precede any other
1198 % settings with `true' dimensions, such as |1.5truein|, |2truecm|
1199 % and so on.} See also |truedimen| option.
1200 % \item[\onlypre truedimen] changes all internal explicit dimension values into
1201 % \textit{true} dimensions, e.g., |1in| is changed to |1truein|.
1202 % Typically this option will be used together with |mag| option. Note that
1203 % this is ineffective against externally specified dimensions. For example,
1204 % when you set ``\texttt{mag=1440, margin=10pt, truedimen}'', margins are
1205 % not `true' but magnified. If you want to set exact margins, you should
1206 % set like ``\texttt{mag=1440, margin=10truept, truedimen}'' instead.
1207 % \item[\onlypre pass] disables all of the geometry options and calculations
1208 % except |verbose| and |showframe|. It is order-independent and can be
1209 % used for checking out the page layout of the documentclass, other
1210 % packages and manual settings without \Gm.
1211 % \item[\onlypre showframe] shows visible frames for the text area and page,
1212 % and the lines for the head and foot on the first page.
1213 % \item[\onlypre showcrop] prints crop marks at each corner of user-specified
1214 % layout area.
1215 % \end{Options}
1216 %
1217 % \section{Processing options}\label{sec:process}
1218 %
1219 % \subsection{Order of loading}\label{sec:loadorder}
1220 %
1221 % If there's |geometry.cfg| somewhere \TeX{} can find it, \Gm\ loads
1222 % it first. For example, in |geometry.cfg| you may write
1223 % |\ExecuteOptions{a4paper}|, which specifies A4 paper as the default
1224 % paper. Basically you can use all the options defined in \Gm\ with
1225 % |\ExecuteOptions{}|.
1226 %
1227 % The order of loading in the preamble of your document is as follows:
1228 % \begin{enumerate}
1229 % \item |geometry.cfg| if it exists.
1230 % \item Options specified with |\documentclass[|\meta{options}|]{...}|.
1231 % \item Options specified with |\usepackage[|\meta{options}|]{geometry}|
1232 % \item Options specified with |\geometry{|\meta{options}|}|, which
1233 % can be called multiple times. (|reset| option will cancel the
1234 % specified options ever given in |\usepackage{geometry}| or
1235 % |\geometry|.)
1236 % \end{enumerate}
1237 %
1238 % \subsection{Order of options}\label{sec:optionorder}
1239 %
1240 % The specification of \Gm\ options is order-independent,
1241 % and overwrites the previous one for the same setting.
1242 % For example,
1243 % \begin{center}
1244 % |[left=2cm, right=3cm]| is equivalent to
1245 % |[right=3cm, left=2cm]|.
1246 % \end{center}
1247 % The options called multiple times overwrite the previous
1248 % settings. For example,
1249 % \begin{center}
1250 % |[verbose=true, verbose=false]| results in |verbose=false|.
1251 % \end{center}
1252 % |[hmargin={3cm,2cm}, left=1cm]| is the same as |hmargin={1cm,2cm}|,
1253 % where the left (or inner) margin is overwritten by |left=1cm|.
1254 %
1255 % |reset| and |mag| are exceptions.
1256 % The |reset| option removes all the geometry options (except |pass|)
1257 % before it. If you set
1258 % \begin{quote}
1259 % |\documentclass[landscape]{article}|\\
1260 % |\usepackage[margin=1cm,twoside]{geometry}|\\
1261 % |\geometry{a5paper, reset, left=2cm}|
1262 % \end{quote}
1263 % then |margin=1cm|, |twoside| and |a5paper| are removed, and
1264 % is eventually equivalent to
1265 % \begin{quote}
1266 % |\documentclass[landscape]{article}|\\
1267 % |\usepackage[left=2cm]{geometry}|
1268 % \end{quote}
1269 %
1270 % The |mag| option should be set in advance of any other settings with
1271 % `true' length, such as |left=1.5truecm|, |width=5truein| and so on.
1272 % The |\mag| primitive can be set before this package is called.
1273 %
1274 % \subsection{Priority}\label{sec:priority}
1275 %
1276 % There are several ways to set dimensions of the \gpart{body}:
1277 % |scale|, |total|, |text| and |lines|. The \Gm\ package gives higher
1278 % priority to the more concrete specification. Here is the priority
1279 % rule for \gpart{body}.
1280 % \[\begin{array}{c}
1281 % \textrm{priority:}\qquad\textrm{low}\quad
1282 % \longrightarrow\quad\textrm{high}\\[1em]
1283 % \left\{\begin{array}{l}|hscale|\\|vscale|\\|scale|
1284 % \end{array}\right\} <
1285 % \left\{\begin{array}{l}|width|\\|height|\\|total|
1286 % \end{array}\right\} <
1287 % \left\{\begin{array}{l}|textwidth|\\|textheight|
1288 % \\|text|\end{array}\right\} < |lines|.
1289 % \end{array}\]
1290 % For example,
1291 % \begin{quote}
1292 % |\usepackage[hscale=0.8, textwidth=7in, width=18cm]{geometry}|
1293 % \end{quote}
1294 % is the same as |\usepackage[textwidth=7in]{geometry}|. Another example:
1295 % \begin{quote}
1296 % |\usepackage[lines=30, scale=0.8, text=7in]{geometry}|
1297 % \end{quote}
1298 % results in \texttt{[lines=30, textwidth=7in]}.
1299 %
1300 % \subsection{Defaults}\label{sec:defaults}
1301 %
1302 % This section sums up the default settings for the auto-completion
1303 % described later.
1304 %
1305 % The default vertical margin ratio is $2/3$, namely,
1306 % \begin{equation}
1307 % |top| : |bottom| = 2 : 3 \qquad\textit{default}.
1308 % \end{equation}
1309 % As for the horizontal margin ratio, the default value depends on
1310 % whether the document is onesided or twosided,
1311 % \begin{equation}
1312 % |left|\;(|inner|) : |right|\;(|outer|)
1313 % = \left\{ \begin{array}{ll}
1314 % 1 : 1 \qquad\textit{default for oneside},\\
1315 % 2 : 3 \qquad\textit{default for twoside}.
1316 % \end{array}\right.
1317 % \end{equation}
1318 % Obviously the default horizontal margin ratio for oneside is `centering'.
1319 %
1320 % The \Gm\ package has the following default setting for
1321 % \textit{onesided} documents:
1322 % \begin{itemize}\setlength{\itemsep}{-.5\parsep}
1323 % \item |scale=0.7| (\gpart{body} is $0.7 \times \gpart{paper}$)
1324 % \item |marginratio={1:1, 2:3}| (1:1 for horizontal and 2:3 for vertical margins)
1325 % \item |ignoreall| (the header, footer, marginal notes are excluded
1326 % when calculating the size of \gpart{body}.)
1327 % \end{itemize}
1328 % For \textit{twosided} document with |twoside| option, the default
1329 % setting is the same as \textit{onesided} except that the horizontal
1330 % margin ratio is set to |2:3| as well.
1331 %
1332 % Additional options overwrite the previous specified dimensions.
1333 %
1334 % \subsection{Auto-completion} \label{sec:rules}
1335 %
1336 % Figure~\ref{fig:specrule} shows schematically how many specification
1337 % patterns exist and how to solve the ambiguity of the
1338 % specifications. Each axis shows the numbers of lengths
1339 % explicitly specified for body and margins. \Ss($m$,$b$) presents the
1340 % specification with a set of numbers $(\gpart{margin},\gpart{body})=(m,b)$.
1341 %
1342 % For example, the specification |width=14cm, left=3cm| is categorized
1343 % into \Ss(1,1), which is an adequate specification. If you add
1344 % |right=4cm|, it would be in \Ss(2,1) and overspecified.
1345 % If only |width=14cm| is given, it's in \Ss(0,1), underspecified.
1346 %
1347 % The \Gm\ package has the auto-completion mechanism, in which
1348 % if the layout parameters are underspecified or overspecified,
1349 % \Gm\ works out the ambiguity using the defaults and other
1350 % relations. Here are the specifications and the completion rules.
1351 %
1352 % \begin{figure}
1353 % \centering
1354 % {\unitlength=1pt
1355 % \begin{picture}(400,150)(40,0)
1356 % \put(1,49){\makebox(90,49)[r]{\large 0}}
1357 % \put(1,1){\makebox(70,99)[r]{\large \gpart{body}}}
1358 % \put(1,1){\makebox(90,49)[r]{\large 1}}
1359 % \put(100,100){\makebox(99,20){\large 0}}
1360 % \put(100,50){\framebox(99,49){}}
1361 % \put(100,80){\makebox(99,15){\Ss(0,0)}}
1362 % \put(100,50){\makebox(99,49){use |scale|}}
1363 % {\linethickness{1pt}%
1364 % \put(150,35){\line(0,1){30}}
1365 % \put(150,35){\line(-1,3){4}}
1366 % \put(150,35){\line(1,3){4}}}
1367 % \put(100,0){\framebox(99,49){}}
1368 % \put(100,2){\makebox(99,15){\Ss(0,1)}}
1369 % \put(100,0){\makebox(99,49){use |marginratio|}}
1370 % \put(200,120){\makebox(99,12){\large \gpart{margin}}}
1371 % \put(200,100){\makebox(99,20){\large 1}}
1372 % \put(200,50){\framebox(99,49){use |scale|}}
1373 % \put(200,55){\makebox(89,10)[r]{\scriptsize\shortstack[l]{if |ratio|\\specified}}}
1374 % \put(200,2){\makebox(99,15){\Ss(1,1)}}
1375 % {\linethickness{1pt}%
1376 % \put(250,35){\line(0,1){30}}
1377 % \put(250,35){\line(-1,3){4}}
1378 % \put(250,35){\line(1,3){4}}}
1379 % {\linethickness{1pt}%
1380 % \put(225,25){\line(-1,0){35}}
1381 % \put(225,25){\line(-3,-1){12}}
1382 % \put(225,25){\line(-3,1){12}}}
1383 % \put(200,80){\makebox(99,15){\Ss(1,0)}}
1384 % \put(200,0){\framebox(99,49){\textcolor{red}{\textit{solvable}}}}
1385 % \put(300,100){\makebox(99,20){\large 2}}
1386 % \put(300,80){\makebox(99,15){\Ss(2,0)}}
1387 % \put(300,50){\framebox(99,49){\textcolor{red}{\textit{solvable}}}}
1388 % \put(300,0){\framebox(99,49){forget |body|}}
1389 % \put(300,2){\makebox(99,15){\Ss(2,1)}}
1390 % {\linethickness{1pt}%
1391 % \multiput(290,65)(5,0){6}{\line(1,0){3}}
1392 % \put(320,65){\line(-3,-1){12}}
1393 % \put(320,65){\line(-3,1){12}}}
1394 % {\linethickness{1pt}%
1395 % \put(350,65){\line(0,-1){30}}
1396 % \put(350,65){\line(-1,-3){4}}
1397 % \put(350,65){\line(1,-3){4}}}
1398 % \end{picture}}
1399 % \caption[Specifications and completion rules]{%
1400 % \begin{minipage}[t]{.7\textwidth}\raggedright\small
1401 % Specifications \Ss(0,0) to \Ss(2,1) and the completion rules
1402 % (arrows). Column and row numbers denote the number of explicitly
1403 % specified lengths for margin and body respectively. \Ss($m$,$b$) denote a
1404 % specification with a set of the numbers $(\gpart{margin},\gpart{body})=(m,b)$.
1405 % \end{minipage}}
1406 % \label{fig:specrule}
1407 % \end{figure}
1408 %
1409 % \begin{Spec}
1410 % \item[\Ss(0,0)]
1411 % Nothing is specified. The \Gm\ package sets \gpart{body} with the
1412 % default |scale| ($=0.7$). \\ For example, |width| is set to be
1413 % $|0.7|\times|layoutwidth|$. Note that by default |layoutwidth|
1414 % and |layoutheight| will be equal to |\paperwidth| and |\paperheight|
1415 % respectively.
1416 % Thus \Ss(0,0) goes to \Ss(0,1). See \Ss(0,1).
1417 % \bigskip
1418 %
1419 % \item[\Ss(0,1)]
1420 % Only \gpart{body} is specified, such as |width=7in|, |lines=20|,
1421 % |body={20cm,24cm}|, |scale=0.9| and so forth.
1422 % Then \Gm\ sets margins with the margin ratio.
1423 % If the margin ratio is not specified, the default is used.
1424 % The default vertical margin ratio is defined as
1425 % \begin{equation}
1426 % |top| : |bottom| = 2 : 3 \qquad\textit{default}.
1427 % \end{equation}
1428 % As for the horizontal margin ratio, the default value depends on
1429 % whether the document is onesided or twosided,
1430 % \begin{equation}
1431 % |left|\;(|inner|) : |right|\;(|outer|)
1432 % = \left\{ \begin{array}{ll}
1433 % 1 : 1 \qquad\textit{default for oneside},\\
1434 % 2 : 3 \qquad\textit{default for twoside}.
1435 % \end{array}\right.
1436 % \end{equation}
1437 % For example, if |height=22cm| is specified on A4 paper,
1438 % \Gm\ calculates |top| margin as follows:
1439 % \begin{equation}
1440 % \begin{array}{ll}
1441 % |top| &= ( |layoutheight| - |height| ) \times 2/5 \\
1442 % &= (29.7-22)\times2/5 = 3.08\textrm{(cm)}
1443 % \end{array}
1444 % \end{equation}
1445 % Thus |top| margin and body |height| have been determined, the
1446 % specification for the vertical goes to \Ss(1,1) and
1447 % all the parameters can be solved.
1448 % \bigskip
1449 %
1450 % \item[\Ss(1,0)]
1451 % Only one margin is specified, such as |bottom=2cm|, |left=1in|,
1452 % |top=3cm|, and so forth.
1453 %
1454 % \begin{itemize}
1455 % \item \textbf{If the margin ratio is \textit{not} specified}, \Gm\ sets
1456 % \gpart{body} with the default |scale| ($=0.7$).
1457 % For example, if |top=2.4cm| is specified, \Gm\ sets
1458 % \begin{center}
1459 % $|height|= |0.7|\times|layoutheight|$
1460 % ~~($=|0.7\paperheight|$ by default),
1461 % \end{center}
1462 % then \Ss(1,0) goes to \Ss(1,1), in which |bottom| is calculated
1463 % with $|layoutheight|-(|height|+|top|)$ and results in 6.51cm on A4
1464 % paper if the layout size is equal to the paper size.
1465 % \medskip
1466 % \item \textbf{If the margin ratio is specified}, such as
1467 % |hmarginratio={1:2}|, |vratio={3:4}| and so forth,
1468 % \Gm\ sets the other% margin with the specified margin ratio.
1469 % For example, if a set of options ``|top=2.4cm,vratio={3:4}|'' is
1470 % specified, \Gm\ sets |bottom| to be |3.2cm| calculating
1471 % \begin{center}
1472 % $|bottom|= |top|/3\times4 = 3.2\textrm{cm}$
1473 % \end{center}
1474 % Thus \Ss(1,0) goes to \Ss(2,0).
1475 % \end{itemize}
1476 %
1477 % Note that the version 4 or earlier used to set the other margin
1478 % with the margin ratio. In the version 5, therefore, with the
1479 % same specification, the result will be different from the one in the
1480 % version 4. For example, if only |top=2.4cm| is specified,
1481 % you got |bottom=2.4cm| in the version 4 or earlier, but you will get
1482 % |bottom=6.51cm| in the version 5.
1483 % \bigskip
1484 %
1485 % \item[\Ss(2,1)]
1486 % The \gpart{body} and two \gpart{margins} are all specified, such as
1487 % |vdivide={1in,8in,1.5in}|, ``|left=3cm,width=13cm,right=4cm|'' and
1488 % so forth. Since \Gm\ basically gives priority to \gpart{margins}
1489 % if dimensions are overspecified, \Gm\ forgets and resets
1490 % \gpart{body}. For example, if you specify
1491 % \begin{center}
1492 % |\usepackage[a4paper,left=3cm,width=13cm,right=4cm]{geometry}|,
1493 % \end{center}
1494 % |width| is reset to be 14cm because the width of a A4 paper is 21cm
1495 % long.
1496 % \end{Spec}
1497 %
1498 % \section{Changing layout mid-document}\label{sec:midchange}
1499 %
1500 % The version 5 provides the new commands \cs{newgeometry\{$\cdots$\}}
1501 % and \cs{restoregeometry}, which allow you to change page dimensions
1502 % in the middle of the document. Unlike \cs{geometry} in the preamble,
1503 % \cs{newgeometry} is available only after |\begin{document}|,
1504 % resets all the options ever specified except for the
1505 % papersize-related options: |landscape|, |portrait|, and paper size
1506 % options (such as |papersize|, |paper=a4paper| and so forth), which
1507 % can't be changed with \cs{newgeometry}.
1508 %
1509 % The command \cs{restoregeometry} restores the page layout specified
1510 % in the preamble (before |\begin{document}|) with the options to
1511 % |\usepackage{geometry}| and \cs{geometry}.
1512 %
1513 % Note that both \cs{newgeometry} and \cs{restoregeometry} insert
1514 % |\clearpage| where they are called.
1515 %
1516 % Below is an example of changing layout mid-document. The layout L1
1517 % specified with |hmargin=3cm| (|left| and |right| margins are |3cm|
1518 % long) is changed to L2 with |left=3cm|, |right=1cm| and
1519 % |bottom=0.1cm|. The layout L1 is restored with
1520 % \cs{restoregeometry}.
1521 % \begin{center}
1522 % \begin{minipage}{.8\textwidth}
1523 % |\usepackage[hmargin=3cm]{geometry}|\\
1524 % |\begin{document}|\\
1525 % \medskip
1526 % \hspace{1cm}\fbox{Layout L1}\\
1527 % \medskip
1528 % |\newgeometry{left=3cm,right=1cm,bottom=0.1cm}|\\
1529 % \medskip
1530 % \hspace{1cm}\fbox{Layout L2 (new)}\\
1531 % \medskip
1532 % |\restoregeometry|\\
1533 % \medskip
1534 % \hspace{1cm}\fbox{Layout L1 (restored)}\\
1535 % \medskip
1536 % |\newgeometry{margin=1cm,includefoot}|\\
1537 % \medskip
1538 % \hspace{1cm}\fbox{Layout L3 (new)}\\
1539 % \medskip
1540 % |\end{document}|
1541 % \end{minipage}%
1542 % \end{center}
1543 % \begin{center}
1544 % \centering\small
1545 % {\unitlength=.8pt
1546 % \begin{picture}(450,180)(0,0)
1547 % \put(0,165){\makebox(95,12){(saved)}}
1548 % \put(15,135){\framebox(65,10){\gpart{head}}}
1549 % \put(15,60){\framebox(65,70){\gpart{body}}}
1550 % \put(15,45){\makebox(65,12){\gpart{foot}}}
1551 % \put(15,45){\line(1,0){65}}
1552 % \put(0,20){\framebox(95,140){}}
1553 % \put(0,0){\makebox(95,20){L1}}
1554 % \put(104,90){\circle*{4}}
1555 % \put(110,90){\circle*{4}}
1556 % \put(116,90){\circle*{4}}
1557 % \put(125,165){\makebox(95,12){\cs{newgeometry}}}
1558 % \put(140,135){\framebox(71,10){\gpart{head}}}
1559 % \put(140,33){\framebox(71,97){\gpart{body}}}
1560 % \put(140,21){\makebox(71,12){\gpart{foot}}}
1561 % \put(125,20){\framebox(95,140){}}
1562 % \put(125,0){\makebox(95,20){L2 (new)}}
1563 % \put(229,90){\circle*{4}}
1564 % \put(235,90){\circle*{4}}
1565 % \put(241,90){\circle*{4}}
1566 % \put(250,165){\makebox(95,12){\cs{restoregeometry}}}
1567 % \put(265,135){\framebox(65,10){\gpart{head}}}
1568 % \put(265,60){\framebox(65,70){\gpart{body}}}
1569 % \put(265,45){\makebox(65,12){\gpart{foot}}}
1570 % \put(265,45){\line(1,0){65}}
1571 % \put(250,20){\framebox(95,140){}}
1572 % \put(250,0){\makebox(95,20){L1 (restored)}}
1573 % \put(354,90){\circle*{4}}
1574 % \put(360,90){\circle*{4}}
1575 % \put(366,90){\circle*{4}}
1576 % \put(375,165){\makebox(95,12){\cs{newgeometry}}}
1577 % \put(383,41){\framebox(80,111){\gpart{body}}}
1578 % \put(383,29){\makebox(80,12){\gpart{foot}}}
1579 % \put(383,29){\line(1,0){80}}
1580 % \put(375,20){\framebox(95,140){}}
1581 % \put(375,0){\makebox(95,20){L3 (new)}}
1582 % \end{picture}}
1583 % \end{center}
1584 %
1585 % A set of commands |\savegeometry{|\meta{name}|}| and
1586 % |\loadgeometry{|\meta{name}|}| is handy if you want to
1587 % reuse more different layouts in your document.
1588 % For example,
1589 % \begin{center}
1590 % \begin{verbatim}
1591 % \usepackage[hmargin=3cm]{geometry}
1592 % \begin{document}
1593 % L1
1594 % \newgeometry{left=3cm,right=1cm,bottom=0.1cm}
1595 % \savegeometry{L2}
1596 % L2 (new, saved)
1597 % \restoregeometry
1598 % L1 (restored)
1599 % \newgeometry{margin=1cm,includefoot}
1600 % L3 (new)
1601 % \loadgeometry{L2}
1602 % L2 (loaded)
1603 % \end{document}
1604 % \end{verbatim}
1605 % \end{center}
1606 %
1607 % \section{Examples}
1608 %
1609 % \begin{enumerate}
1610 % \item A onesided page layout with the text area centered in the paper.
1611 % The examples below have the same result because the horizontal margin ratio
1612 % is set |1:1| for oneside by default.
1613 % \begin{itemize}
1614 % \item |centering|
1615 % \item |marginratio=1:1|
1616 % \item |vcentering|
1617 % \end{itemize}
1618 %
1619 % \item A twosided page layout with the inside offset for binding set to |1cm|.
1620 % \begin{itemize}
1621 % \item |twoside, bindingoffset=1cm|
1622 % \end{itemize}
1623 % In this case, |textwidth| is shorter than that of the default twosided
1624 % document by $0.7\times|1cm|$ ($=|0.7cm|$) because the default width of
1625 % \gpart{body} is set with |scale=0.7|, which means
1626 % $|width|=|0.7|\times|layoutwidth|$ ($=|0.7\paperwidth|$ by default).
1627 %
1628 % \item A layout with the left, right, and top margin |3cm|, |2cm| and
1629 % |2.5in| respectively, with textheight of 40 lines, and with the head and
1630 % foot of the page included in \gpart{total body}.
1631 % The two examples below have the same result.
1632 % \begin{itemize}
1633 % \item |left=3cm, right=2cm, lines=40, top=2.5in, includeheadfoot|
1634 % \item |hmargin={3cm,2cm}, tmargin=2.5in, lines=40, includeheadfoot|
1635 % \end{itemize}
1636 %
1637 % \item A layout with the height of \gpart{total body} |10in|, the bottom
1638 % margin |2cm|, and the default width. The top margin will be calculated
1639 % automatically. Each solution below results in the same page layout.
1640 % \begin{itemize}
1641 % \item |vdivide={*, 10in, 2cm}|
1642 % \item |bmargin=2cm, height=10in|
1643 % \item |bottom=2cm, textheight=10in|
1644 % \end{itemize}
1645 % Note that dimensions for \gpart{head} and \gpart{foot} are excluded from
1646 % |height| of \gpart{total body}. An additional |includefoot| makes
1647 % \cs{footskip} included in |totalheight|. Therefore, in the two cases below,
1648 % |textheight| in the former layout is shorter than the latter
1649 % (with 10in exactly) by \cs{footskip}. In other words,
1650 % |height| = |textheight| + |footskip| when |includefoot=true| in this case.
1651 % \begin{itemize}
1652 % \item |bmargin=2cm, height=10in, includefoot|
1653 % \item |bottom=2cm, textheight=10in, includefoot|
1654 % \end{itemize}
1655 %
1656 % \item A layout with \glen{textwidth} and \glen{textheight} 90\% of the
1657 % paper and with \gpart{body} centered.
1658 % Each solution below results in the same page layout as long as
1659 % |layoutwidth| and |layoutheight| are not modified from the default.
1660 % \begin{itemize}
1661 % \item |scale=0.9, centering|
1662 % \item |text={.9\paperwidth,.9\paperheight}, ratio=1:1|
1663 % \item |width=.9\paperwidth, vmargin=.05\paperheight, marginratio=1:1|
1664 % \item |hdivide={*,0.9\paperwidth,*}, vdivide={*,0.9\paperheight,*}|
1665 % (as for onesided documents)
1666 % \item |margin={0.05\paperwidth,0.05\paperheight}|
1667 % \end{itemize}
1668 % You can add |heightrounded| to avoid an ``underfull vbox warning'' like
1669 % \begin{quote}\small
1670 % |Underfull \vbox (badness 10000) has occurred while \output is active|.
1671 % \end{quote}
1672 % See Section~\ref{sec:body} for the detailed description about |heightrounded|.
1673 %
1674 % \item A layout with the width of marginal notes set to |3cm| and included
1675 % in the width of \gpart{total body}. The following examples are the same.
1676 % \begin{itemize}
1677 % \item |marginparwidth=3cm, includemp|
1678 % \item |marginpar=3cm, ignoremp=false|
1679 % \end{itemize}
1680 %
1681 % \item A layout where \gpart{body} occupies the whole paper with A5 paper in
1682 % landscape. The following examples are the same.
1683 % \begin{itemize}
1684 % \item |a5paper, landscape, scale=1.0|
1685 % \item |landscape=TRUE, paper=a5paper, margin=0pt|
1686 % \end{itemize}
1687 %
1688 % \item A screen size layout appropriate for presentation with PC and video
1689 % projector.
1690 % \begin{verbatim}
1691 % \documentclass{slide}
1692 % \usepackage[screen,margin=0.8in]{geometry}
1693 % ...
1694 % \begin{slide}
1695 % ...
1696 % \end{slide}\end{verbatim}
1697 % \item A layout with fonts and spaces both enlarged from A4 to A3.
1698 % In the case below, the resulting paper size is A3.
1699 % \begin{itemize}
1700 % \item |a4paper, mag=1414|.
1701 % \end{itemize}
1702 % If you want to have a layout with two times bigger fonts, but without
1703 % changing paper size, you can type
1704 % \begin{itemize}
1705 % \item |letterpaper, mag=2000, truedimen|.
1706 % \end{itemize}
1707 % You can add |dvips| option, that is useful to preview it with proper
1708 % paper size by |dviout| or |xdvi|.
1709 %
1710 % \item Changing the layout of the first page and leaving the others
1711 % as default before loading \Gm. Use |pass| option, |\newgeometry|
1712 % and |\restoregeometry|.
1713 % \begin{verbatim}
1714 % \documentclass{book}
1715 % \usepackage[pass]{geometry}
1716 % % 'pass' disregards the package layout,
1717 % % so the original 'book' layout is memorized here.
1718 % \begin{document}
1719 % \newgeometry{margin=1cm}% changes the first page dimensions.
1720 % Page 1
1721 % \restoregeometry % restores the original 'book' layout.
1722 % Page 2 and more
1723 % \end{document}\end{verbatim}
1724 %
1725 % \item A complex page layout.
1726 % \begin{verbatim}
1727 % \usepackage[a5paper, landscape, twocolumn, twoside,
1728 % left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt,
1729 % bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
1730 % columnsep=1cm, dvips, verbose]{geometry}\end{verbatim}
1731 % Try typesetting it and checking out the result yourself. |:-)|
1732 % \end{enumerate}
1733 %
1734 % \section{Known problems}
1735 % \begin{itemize}
1736 % \item With |mag| $\neq 1000$ and |truedimen|,
1737 % |paperwidth| and |paperheight| shown in verbose mode are different
1738 % from the real size of the resulted PDF. The PDF itself is correct anyway.
1739 %
1740 % \item With |mag| $\neq 1000$, \textit{no} |truedimen|
1741 % and \textsf{hyperref}, \textsf{hyperref} should be loaded before \Gm.
1742 % Otherwise the resulted PDF size will become wrong.
1743 %
1744 % \item With \textsf{crop} package and |mag| $\neq 1000$,
1745 % |center| option of \textsf{crop} doesn't work well.
1746 %
1747 % \end{itemize}
1748 %
1749 % \section{Acknowledgments}
1750 % The author appreciates helpful suggestions and comments from many
1751 % people including (in alphabetical order of family name):
1752 % Jean-Bernard Addor,
1753 % Frank Bennett,
1754 % Alexis Dimitriadis,
1755 % Friedrich Flender,
1756 % Adrian Heathcote,
1757 % Stephan Hennig,
1758 % Morten H\o{}gholm,
1759 % Jonathan Kew,
1760 % James Kilfiger,
1761 % Yusuke Kuroki,
1762 % Jean-Marc Lasgouttes,
1763 % Wlodzimierz Macewicz,
1764 % Frank Mittelbach,
1765 % Eckhard Neber,
1766 % Rolf Niepraschk,
1767 % Hans Fr.~Nordhaug,
1768 % Heiko Oberdiek,
1769 % Keith Reckdahl,
1770 % Peter Riocreux,
1771 % Will Robertson,
1772 % Pablo Rodriguez,
1773 % Nico Schl\"{o}emer,
1774 % Perry C.~Stearns,
1775 % Frank Stengel,
1776 % Plamen Tanovski,
1777 % Petr Uher,
1778 % Piet van Oostrum,
1779 % Vladimir Volovich,
1780 % Michael Vulis.
1781 %
1782 % \StopEventually{%
1783 % }
1784 %
1785 % \newgeometry{hmargin={4.2cm,1.5cm},vmargin={1cm,1cm},
1786 % includeheadfoot, marginpar=3.8cm}
1787 % \section{Implementation}
1788 % \begin{macrocode}
1789 %<*package>
1790 % \end{macrocode}
1791 % This package requires the following packages:
1792 % \textsf{keyval}, \textsf{ifvtex}.
1793 % \begin{macrocode}
1794 \RequirePackage{keyval}%
1795 \RequirePackage{ifvtex}%
1796 % \end{macrocode}
1797 %
1798 % Internal switches are declared here.
1799 % \begin{macrocode}
1800 \newif\ifGm@verbose
1801 \newif\ifGm@landscape
1802 \newif\ifGm@swap@papersize
1803 \newif\ifGm@includehead
1804 \newif\ifGm@includefoot
1805 \newif\ifGm@includemp
1806 \newif\ifGm@hbody
1807 \newif\ifGm@vbody
1808 \newif\ifGm@heightrounded
1809 \newif\ifGm@showframe
1810 \newif\ifGm@showcrop
1811 \newif\ifGm@pass
1812 \newif\ifGm@resetpaper
1813 \newif\ifGm@layout
1814 \newif\ifGm@newgm
1815 % \end{macrocode}
1816 % \begin{macro}{\Gm@cnth}
1817 % \begin{macro}{\Gm@cntv}
1818 % The counters for horizontal and vertical partitioning patterns.
1819 % \begin{macrocode}
1820 \newcount\Gm@cnth
1821 \newcount\Gm@cntv
1822 % \end{macrocode}
1823 % \end{macro}\end{macro}
1824 % \begin{macro}{\c@Gm@tempcnt}
1825 % The counter is used to set number with \textsf{calc}.
1826 % \begin{macrocode}
1827 \newcount\c@Gm@tempcnt
1828 % \end{macrocode}
1829 % \end{macro}
1830 % \begin{macro}{\Gm@bindingoffset}
1831 % The binding offset for the inner margin.
1832 % \begin{macrocode}
1833 \newdimen\Gm@bindingoffset
1834 % \end{macrocode}
1835 % \end{macro}
1836 % \begin{macro}{\Gm@wd@mp}
1837 % \begin{macro}{\Gm@odd@mp}
1838 % \begin{macro}{\Gm@even@mp}
1839 % Correction lengths for \cs{textwidth}, \cs{oddsidemargin} and
1840 % \cs{evensidemargin} in |includemp| mode.
1841 % \begin{macrocode}
1842 \newdimen\Gm@wd@mp
1843 \newdimen\Gm@odd@mp
1844 \newdimen\Gm@even@mp
1845 % \end{macrocode}
1846 % \end{macro}\end{macro}\end{macro}
1847 % \begin{macro}{\Gm@layoutwidth}
1848 % \begin{macro}{\Gm@layoutheight}
1849 % \begin{macro}{\Gm@layouthoffset}
1850 % \begin{macro}{\Gm@layoutvoffset}
1851 % The dimensions for the layout area.
1852 % \begin{macrocode}
1853 \newdimen\Gm@layoutwidth
1854 \newdimen\Gm@layoutheight
1855 \newdimen\Gm@layouthoffset
1856 \newdimen\Gm@layoutvoffset
1857 % \end{macrocode}
1858 % \end{macro}\end{macro}\end{macro}\end{macro}
1859 % \begin{macro}{\Gm@dimlist}
1860 % The token in which \LaTeX{} native dimensions can be stored.
1861 % \begin{macrocode}
1862 \newtoks\Gm@dimlist
1863 % \end{macrocode}
1864 % \end{macro}
1865 % \begin{macro}{\Gm@warning}
1866 % The macro to print warning messages.
1867 % \begin{macrocode}
1868 \def\Gm@warning#1{\PackageWarningNoLine{geometry}{#1}}%
1869 % \end{macrocode}
1870 % \end{macro}
1871 % \begin{macro}{\ifGm@preamble}
1872 % The macro executes the option given as an argument
1873 % only if it's specified in the preamble, as the options of
1874 % |\usepackage| and/or the argument of |\geometry|. Otherwise,
1875 % the macro would print the warning message and ignores
1876 % the option setting.
1877 % \begin{macrocode}
1878 \def\ifGm@preamble#1{%
1879 \ifGm@newgm
1880 \Gm@warning{`#1': not available in `\string\newgeometry'; skipped}%
1881 \else
1882 \expandafter\@firstofone
1883 \fi}%
1884 % \end{macrocode}
1885 % \end{macro}
1886 % \begin{macro}{\Gm@Dhratio}
1887 % \begin{macro}{\Gm@Dhratiotwo}
1888 % \begin{macro}{\Gm@Dvratio}
1889 % The default values for the horizontal and vertical
1890 % \textsl{marginalratio} are defined. \cs{Gm@Dhratiotwo} denotes the
1891 % default value of horizontal \textsl{marginratio} for twoside
1892 % page layout with left and right margins swapped on verso pages,
1893 % which is set by |twoside|.
1894 % \begin{macrocode}
1895 \def\Gm@Dhratio{1:1}% = left:right default for oneside
1896 \def\Gm@Dhratiotwo{2:3}% = inner:outer default for twoside.
1897 \def\Gm@Dvratio{2:3}% = top:bottom default
1898 % \end{macrocode}
1899 % \end{macro}\end{macro}\end{macro}
1900 % \begin{macro}{\Gm@Dhscale}
1901 % \begin{macro}{\Gm@Dvscale}
1902 % The default values for the horizontal and vertical \textsl{scale}
1903 % are defined with $0.7$.
1904 % \begin{macrocode}
1905 \def\Gm@Dhscale{0.7}%
1906 \def\Gm@Dvscale{0.7}%
1907 % \end{macrocode}
1908 % \end{macro}\end{macro}
1909 % \begin{macro}{\Gm@dvips}%
1910 % \begin{macro}{\Gm@dvipdfm}%
1911 % \begin{macro}{\Gm@pdftex}%
1912 % \begin{macro}{\Gm@luatex}%
1913 % \begin{macro}{\Gm@xetex}%
1914 % \begin{macro}{\Gm@vtex}%
1915 % The driver names.
1916 % \begin{macrocode}
1917 \def\Gm@dvips{dvips}%
1918 \def\Gm@dvipdfm{dvipdfm}%
1919 \def\Gm@pdftex{pdftex}%
1920 \def\Gm@luatex{luatex}%
1921 \def\Gm@xetex{xetex}%
1922 \def\Gm@vtex{vtex}%
1923 % \end{macrocode}
1924 % \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
1925 % \begin{macro}{\Gm@true}%
1926 % \begin{macro}{\Gm@false}%
1927 % The macros for |true| and |false|.
1928 % \begin{macrocode}
1929 \def\Gm@true{true}%
1930 \def\Gm@false{false}%
1931 % \end{macrocode}
1932 % \end{macro}\end{macro}
1933 % \begin{macro}{\Gm@orgpw}
1934 % \begin{macro}{\Gm@orgph}
1935 % These macros keep original paper (media) size intact.
1936 % \begin{macrocode}
1937 \edef\Gm@orgpw{\the\paperwidth}%
1938 \edef\Gm@orgph{\the\paperheight}%
1939 % \end{macrocode}
1940 % \end{macro}\end{macro}
1941 % \begin{macro}{\Gm@savelength}
1942 % The macro saves the specified length to |\Gm@restore|.
1943 % \begin{macrocode}
1944 \def\Gm@savelength#1{%
1945 \g@addto@macro\Gm@restore{\expandafter\noexpand\expandafter\csname
1946 #1\endcsname\expandafter=\expandafter\the\csname #1\endcsname\relax}}%
1947 % \end{macrocode}
1948 % \end{macro}
1949 % \begin{macro}{\Gm@saveboolean}
1950 % The macro saves the specified boolean to |\Gm@restore|.
1951 % \begin{macrocode}
1952 \def\Gm@saveboolean#1{%
1953 \csname if#1\endcsname
1954 \g@addto@macro\Gm@restore{\expandafter\noexpand\csname #1true\endcsname}%
1955 \else
1956 \g@addto@macro\Gm@restore{\expandafter\noexpand\csname #1false\endcsname}%
1957 \fi}%
1958 % \end{macrocode}
1959 % \end{macro}
1960 % \begin{macro}{\Gm@restore}
1961 % The initialization for |\Gm@restore|.
1962 % \begin{macrocode}
1963 \def\Gm@restore{}%
1964 % \end{macrocode}
1965 % \end{macro}
1966 % \begin{macro}{\Gm@save}
1967 % The definition of the macro saving the real lengths
1968 % \LaTeX\ options.
1969 % \begin{macrocode}
1970 \def\Gm@save{%
1971 \Gm@savelength{paperwidth}%
1972 \Gm@savelength{paperheight}%
1973 \Gm@savelength{textwidth}%
1974 \Gm@savelength{textheight}%
1975 \Gm@savelength{evensidemargin}%
1976 \Gm@savelength{oddsidemargin}%
1977 \Gm@savelength{topmargin}%
1978 \Gm@savelength{headheight}%
1979 \Gm@savelength{headsep}%
1980 \Gm@savelength{topskip}%
1981 \Gm@savelength{footskip}%
1982 \Gm@savelength{baselineskip}%
1983 \Gm@savelength{marginparwidth}%
1984 \Gm@savelength{marginparsep}%
1985 \Gm@savelength{columnsep}%
1986 \Gm@savelength{hoffset}%
1987 \Gm@savelength{voffset}
1988 \Gm@savelength{Gm@layoutwidth}%
1989 \Gm@savelength{Gm@layoutheight}%
1990 \Gm@savelength{Gm@layouthoffset}%
1991 \Gm@savelength{Gm@layoutvoffset}%
1992 \Gm@saveboolean{@twocolumn}%
1993 \Gm@saveboolean{@twoside}%
1994 \Gm@saveboolean{@mparswitch}%
1995 \Gm@saveboolean{@reversemargin}}%
1996 % \end{macrocode}
1997 % \end{macro}
1998 % \begin{macro}{\Gm@initnewgm}
1999 % The macro initializes the parameters for layout
2000 % in |\newgeometry|.
2001 % \begin{macrocode}
2002 \def\Gm@initnewgm{%
2003 \Gm@passfalse
2004 \Gm@swap@papersizefalse
2005 \Gm@dimlist={}
2006 \Gm@hbodyfalse
2007 \Gm@vbodyfalse
2008 \Gm@heightroundedfalse
2009 \Gm@includeheadfalse
2010 \Gm@includefootfalse
2011 \Gm@includempfalse
2012 \let\Gm@width\@undefined
2013 \let\Gm@height\@undefined
2014 \let\Gm@textwidth\@undefined
2015 \let\Gm@textheight\@undefined
2016 \let\Gm@lines\@undefined
2017 \let\Gm@hscale\@undefined
2018 \let\Gm@vscale\@undefined
2019 \let\Gm@hmarginratio\@undefined
2020 \let\Gm@vmarginratio\@undefined
2021 \let\Gm@lmargin\@undefined
2022 \let\Gm@rmargin\@undefined
2023 \let\Gm@tmargin\@undefined
2024 \let\Gm@bmargin\@undefined
2025 \Gm@layoutfalse
2026 \Gm@layouthoffset\z@
2027 \Gm@layoutvoffset\z@
2028 \Gm@bindingoffset\z@}%
2029 % \end{macrocode}
2030 % \end{macro}
2031 % \begin{macro}{\Gm@initall}
2032 % This initialization is called as soon as the package is load
2033 % It's also called as soon as |reset| option is specified.
2034 % \begin{macrocode}
2035 \def\Gm@initall{%
2036 \let\Gm@driver\@empty
2037 \let\Gm@truedimen\@empty
2038 \let\Gm@paper\@undefined
2039 \Gm@resetpaperfalse
2040 \Gm@landscapefalse
2041 \Gm@verbosefalse
2042 \Gm@showframefalse
2043 \Gm@showcropfalse
2044 \Gm@newgmfalse
2045 \Gm@initnewgm}%
2046 % \end{macrocode}
2047 % \end{macro}
2048 % \begin{macro}{\Gm@setdriver}
2049 % The macro sets the specified driver.
2050 % \begin{macrocode}
2051 \def\Gm@setdriver#1{%
2052 \expandafter\let\expandafter\Gm@driver\csname Gm@#1\endcsname}%
2053 % \end{macrocode}
2054 % \end{macro}
2055 % \begin{macro}{\Gm@unsetdriver}
2056 % The macro unsets the specified driver if it has been set.
2057 % \begin{macrocode}
2058 \def\Gm@unsetdriver#1{%
2059 \expandafter\ifx\csname Gm@#1\endcsname\Gm@driver\let\Gm@driver\@empty\fi}%
2060 % \end{macrocode}
2061 % \end{macro}
2062 % \begin{macro}{\Gm@setbool}
2063 % \begin{macro}{\Gm@setboolrev}
2064 % The macros for boolean option processing.
2065 % \begin{macrocode}
2066 \def\Gm@setbool{\@dblarg\Gm@@setbool}%
2067 \def\Gm@setboolrev{\@dblarg\Gm@@setboolrev}%
2068 \def\Gm@@setbool[#1]#2#3{\Gm@doif{#1}{#3}{\csname Gm@#2\Gm@bool\endcsname}}%
2069 \def\Gm@@setboolrev[#1]#2#3{\Gm@doifelse{#1}{#3}%
2070 {\csname Gm@#2\Gm@false\endcsname}{\csname Gm@#2\Gm@true\endcsname}}%
2071 % \end{macrocode}
2072 % \end{macro}\end{macro}
2073 % \begin{macro}{\Gm@doif}
2074 % \begin{macro}{\Gm@doifelse}
2075 % \cs{Gm@doif} executes the third argument |#3| using a boolean value
2076 % |#2| of a option |#1|. \cs{Gm@doifelse} executes the third
2077 % argument |#3| if a boolean option |#1| with its value |#2| |true|,
2078 % and executes the fourth argument |#4| if |false|.
2079 % \begin{macrocode}
2080 \def\Gm@doif#1#2#3{%
2081 \lowercase{\def\Gm@bool{#2}}%
2082 \ifx\Gm@bool\@empty
2083 \let\Gm@bool\Gm@true
2084 \fi
2085 \ifx\Gm@bool\Gm@true
2086 \else
2087 \ifx\Gm@bool\Gm@false
2088 \else
2089 \let\Gm@bool\relax
2090 \fi
2091 \fi
2092 \ifx\Gm@bool\relax
2093 \Gm@warning{`#1' should be set to `true' or `false'}%
2094 \else
2095 #3
2096 \fi}%
2097 \def\Gm@doifelse#1#2#3#4{%
2098 \Gm@doif{#1}{#2}{\ifx\Gm@bool\Gm@true #3\else #4\fi}}%
2099 % \end{macrocode}
2100 % \end{macro}\end{macro}
2101 % \begin{macro}{\Gm@reverse}
2102 % The macro reverses a bool value.
2103 % \begin{macrocode}
2104 \def\Gm@reverse#1{%
2105 \csname ifGm@#1\endcsname
2106 \csname Gm@#1false\endcsname\else\csname Gm@#1true\endcsname\fi}%
2107 % \end{macrocode}
2108 % \end{macro}
2109 % \begin{macro}{\Gm@defbylen}
2110 % \begin{macro}{\Gm@defbycnt}
2111 % Macros \cs{Gm@defbylen} and \cs{Gm@defbycnt} can be used to define
2112 % \cs{Gm@xxxx} variables by length and counter respectively
2113 % with \textsf{calc} package.
2114 % \begin{macrocode}
2115 \def\Gm@defbylen#1#2{%
2116 \begingroup\setlength\@tempdima{#2}%
2117 \expandafter\xdef\csname Gm@#1\endcsname{\the\@tempdima}\endgroup}%
2118 \def\Gm@defbycnt#1#2{%
2119 \begingroup\setcounter{Gm@tempcnt}{#2}%
2120 \expandafter\xdef\csname Gm@#1\endcsname{\the\value{Gm@tempcnt}}\endgroup}%
2121 % \end{macrocode}
2122 % \end{macro}\end{macro}
2123 % \begin{macro}{\Gm@set@ratio}
2124 % The macro parses the value of options specifying marginal ratios,
2125 % which is used in \cs{Gm@setbyratio} macro.
2126 % \begin{macrocode}
2127 \def\Gm@sep@ratio#1:#2{\@tempcnta=#1\@tempcntb=#2}%
2128 % \end{macrocode}
2129 % \end{macro}
2130 % \begin{macro}{\Gm@setbyratio}
2131 % The macro determines the dimension specified by |#4| calculating
2132 % |#3|$\times a / b$, where $a$ and $b$ are given by \cs{Gm@mratio}
2133 % with $a:b$ value. If |#1| in brackets is |b|, $a$ and $b$ are swapped.
2134 % The second argument with |h| or |v| denoting horizontal or vertical
2135 % is not used in this macro.
2136 % \begin{macrocode}
2137 \def\Gm@setbyratio[#1]#2#3#4{% determine #4 by ratio
2138 \expandafter\Gm@sep@ratio\Gm@mratio\relax
2139 \if#1b
2140 \edef\@@tempa{\the\@tempcnta}%
2141 \@tempcnta=\@tempcntb
2142 \@tempcntb=\@@tempa\relax
2143 \fi
2144 \expandafter\setlength\expandafter\@tempdimb\expandafter
2145 {\csname Gm@#3\endcsname}%
2146 \ifnum\@tempcntb>\z@
2147 \multiply\@tempdimb\@tempcnta
2148 \divide\@tempdimb\@tempcntb
2149 \fi
2150 \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdimb}}%
2151 % \end{macrocode}
2152 % \end{macro}
2153 % \begin{macro}{\Gm@detiv}
2154 % This macro determines the fourth length(|#4|) from |#1|(\glen{layoutwidth}
2155 % or \glen{layoutheight}), |#2| and |#3|. It is used in
2156 % \cs{Gm@detall} macro.
2157 % \begin{macrocode}
2158 \def\Gm@detiv#1#2#3#4{% determine #4.
2159 \expandafter\setlength\expandafter\@tempdima\expandafter
2160 {\csname Gm@layout#1\endcsname}%
2161 \expandafter\setlength\expandafter\@tempdimb\expandafter
2162 {\csname Gm@#2\endcsname}%
2163 \addtolength\@tempdima{-\@tempdimb}%
2164 \expandafter\setlength\expandafter\@tempdimb\expandafter
2165 {\csname Gm@#3\endcsname}%
2166 \addtolength\@tempdima{-\@tempdimb}%
2167 \ifdim\@tempdima<\z@
2168 \Gm@warning{`#4' results in NEGATIVE (\the\@tempdima).%
2169 ^^J\@spaces `#2' or `#3' should be shortened in length}%
2170 \fi
2171 \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdima}}%
2172 % \end{macrocode}
2173 % \end{macro}
2174 % \begin{macro}{\Gm@detiiandiii}
2175 % This macro determines |#2| and |#3| from |#1| with the first argument
2176 % (|#1|) can be |width| or |height|, which is expanded into dimensions
2177 % of paper and total body. It is used in \cs{Gm@detall} macro.
2178 % \begin{macrocode}
2179 \def\Gm@detiiandiii#1#2#3{% determine #2 and #3.
2180 \expandafter\setlength\expandafter\@tempdima\expandafter
2181 {\csname Gm@layout#1\endcsname}%
2182 \expandafter\setlength\expandafter\@tempdimb\expandafter
2183 {\csname Gm@#1\endcsname}%
2184 \addtolength\@tempdima{-\@tempdimb}%
2185 \ifdim\@tempdima<\z@
2186 \Gm@warning{`#2' and `#3' result in NEGATIVE (\the\@tempdima).%
2187 ^^J\@spaces `#1' should be shortened in length}%
2188 \fi
2189 \ifx\Gm@mratio\@undefined
2190 \expandafter\Gm@sep@ratio\Gm@Dmratio\relax
2191 \else
2192 \expandafter\Gm@sep@ratio\Gm@mratio\relax
2193 \ifnum\@tempcntb>\z@\else
2194 \Gm@warning{margin ratio a:b should be non-zero; default used}%
2195 \expandafter\Gm@sep@ratio\Gm@Dmratio\relax
2196 \fi
2197 \fi
2198 \@tempdimb=\@tempdima
2199 \advance\@tempcntb\@tempcnta
2200 \divide\@tempdima\@tempcntb
2201 \multiply\@tempdima\@tempcnta
2202 \advance\@tempdimb-\@tempdima
2203 \expandafter\edef\csname Gm@#2\endcsname{\the\@tempdima}%
2204 \expandafter\edef\csname Gm@#3\endcsname{\the\@tempdimb}}%
2205 % \end{macrocode}
2206 % \end{macro}
2207 %
2208 % \begin{macro}{\Gm@detall}
2209 % This macro determines partition of each direction.
2210 % The first argument (|#1|) should be |h| or |v|, the second (|#2|)
2211 % |width| or |height|, the third (|#3|) |lmargin| or |top|, and
2212 % the last (|#4|) |rmargin| or |bottom|.
2213 % \begin{macrocode}
2214 \def\Gm@detall#1#2#3#4{%
2215 \@tempcnta\z@
2216 \if#1h
2217 \let\Gm@mratio\Gm@hmarginratio
2218 \edef\Gm@Dmratio{\if@twoside\Gm@Dhratiotwo\else\Gm@Dhratio\fi}%
2219 \else
2220 \let\Gm@mratio\Gm@vmarginratio
2221 \edef\Gm@Dmratio{\Gm@Dvratio}%
2222 \fi
2223 % \end{macrocode}
2224 % \cs{@tempcnta} is treated as a three-digit binary value with
2225 % top, middle and bottom denoted |left|(|top|), |width|(|height|)
2226 % and |right|(|bottom|) margins user specified respectively.
2227 % \begin{macrocode}
2228 \if#1h
2229 \ifx\Gm@lmargin\@undefined\else\advance\@tempcnta4\relax\fi
2230 \ifGm@hbody\advance\@tempcnta2\relax\fi
2231 \ifx\Gm@rmargin\@undefined\else\advance\@tempcnta1\relax\fi
2232 \Gm@cnth\@tempcnta
2233 \else
2234 \ifx\Gm@tmargin\@undefined\else\advance\@tempcnta4\relax\fi
2235 \ifGm@vbody\advance\@tempcnta2\relax\fi
2236 \ifx\Gm@bmargin\@undefined\else\advance\@tempcnta1\relax\fi
2237 \Gm@cntv\@tempcnta
2238 \fi
2239 % \end{macrocode}
2240 % Case the value is |000| (=0) with nothing fixed (default):
2241 % \begin{macrocode}
2242 \ifcase\@tempcnta
2243 \if#1h
2244 \Gm@defbylen{width}{\Gm@Dhscale\Gm@layoutwidth}%
2245 \else
2246 \Gm@defbylen{height}{\Gm@Dvscale\Gm@layoutheight}%
2247 \fi
2248 \Gm@detiiandiii{#2}{#3}{#4}%
2249 % \end{macrocode}
2250 % Case |001| (=1) with |right|(|bottom|) fixed:
2251 % \begin{macrocode}
2252 \or
2253 \ifx\Gm@mratio\@undefined
2254 \if#1h
2255 \Gm@defbylen{width}{\Gm@Dhscale\Gm@layoutwidth}%
2256 \else
2257 \Gm@defbylen{height}{\Gm@Dvscale\Gm@layoutheight}%
2258 \fi
2259 \setlength\@tempdimc{\@nameuse{Gm@#4}}%
2260 \Gm@detiiandiii{#2}{#3}{#4}%
2261 \expandafter\let\csname Gm@#2\endcsname\@undefined
2262 \Gm@defbylen{#4}{\@tempdimc}%
2263 \else
2264 \Gm@setbyratio[f]{#1}{#4}{#3}%
2265 \fi
2266 \Gm@detiv{#2}{#3}{#4}{#2}%
2267 % \end{macrocode}
2268 % Case |010| (=2) with |width|(|height|) fixed:
2269 % \begin{macrocode}
2270 \or\Gm@detiiandiii{#2}{#3}{#4}%
2271 % \end{macrocode}
2272 % Case |011| (=3) with both |width|(|height|) and |right|(|bottom|) fixed:
2273 % \begin{macrocode}
2274 \or\Gm@detiv{#2}{#2}{#4}{#3}%
2275 % \end{macrocode}
2276 % Case |100| (=4) with |left|(|top|) fixed:
2277 % \begin{macrocode}
2278 \or
2279 \ifx\Gm@mratio\@undefined
2280 \if#1h
2281 \Gm@defbylen{width}{\Gm@Dhscale\Gm@layoutwidth}%
2282 \else
2283 \Gm@defbylen{height}{\Gm@Dvscale\Gm@layoutheight}%
2284 \fi
2285 \setlength\@tempdimc{\@nameuse{Gm@#3}}%
2286 \Gm@detiiandiii{#2}{#4}{#3}%
2287 \expandafter\let\csname Gm@#2\endcsname\@undefined
2288 \Gm@defbylen{#3}{\@tempdimc}%
2289 \else
2290 \Gm@setbyratio[b]{#1}{#3}{#4}%
2291 \fi
2292 \Gm@detiv{#2}{#3}{#4}{#2}%
2293 % \end{macrocode}
2294 % Case |101| (=5) with both |left|(|top|) and |right|(|bottom|) fixed:
2295 % \begin{macrocode}
2296 \or\Gm@detiv{#2}{#3}{#4}{#2}%
2297 % \end{macrocode}
2298 % Case |110| (=6) with both |left|(|top|) and |width|(|height|) fixed:
2299 % \begin{macrocode}
2300 \or\Gm@detiv{#2}{#2}{#3}{#4}%
2301 % \end{macrocode}
2302 % Case |111| (=7) with all fixed though it is over-specified:
2303 % \begin{macrocode}
2304 \or\Gm@warning{Over-specification in `#1'-direction.%
2305 ^^J\@spaces `#2' (\@nameuse{Gm@#2}) is ignored}%
2306 \Gm@detiv{#2}{#3}{#4}{#2}%
2307 \else\fi}%
2308 % \end{macrocode}
2309 % \end{macro}
2310 %
2311 % \begin{macro}{\Gm@clean}
2312 % The macro for setting unspecified dimensions to be \cs{@undefined}.
2313 % This is used by \cs{geometry} macro.
2314 % \begin{macrocode}
2315 \def\Gm@clean{%
2316 \ifnum\Gm@cnth<4\let\Gm@lmargin\@undefined\fi
2317 \ifodd\Gm@cnth\else\let\Gm@rmargin\@undefined\fi
2318 \ifnum\Gm@cntv<4\let\Gm@tmargin\@undefined\fi
2319 \ifodd\Gm@cntv\else\let\Gm@bmargin\@undefined\fi
2320 \ifGm@hbody\else
2321 \let\Gm@hscale\@undefined
2322 \let\Gm@width\@undefined
2323 \let\Gm@textwidth\@undefined
2324 \fi
2325 \ifGm@vbody\else
2326 \let\Gm@vscale\@undefined
2327 \let\Gm@height\@undefined
2328 \let\Gm@textheight\@undefined
2329 \fi
2330 }%
2331 % \end{macrocode}
2332 % \end{macro}
2333 %
2334 % \begin{macro}{\Gm@parse@divide}
2335 % The macro parses (|h|,|v|)|divide| options.
2336 % \begin{macrocode}
2337 \def\Gm@parse@divide#1#2#3#4{%
2338 \def\Gm@star{*}%
2339 \@tempcnta\z@
2340 \@for\Gm@tmp:=#1\do{%
2341 \expandafter\KV@@sp@def\expandafter\Gm@frag\expandafter{\Gm@tmp}%
2342 \edef\Gm@value{\Gm@frag}%
2343 \ifcase\@tempcnta\relax\edef\Gm@key{#2}%
2344 \or\edef\Gm@key{#3}%
2345 \else\edef\Gm@key{#4}%
2346 \fi
2347 \@nameuse{Gm@set\Gm@key false}%
2348 \ifx\empty\Gm@value\else
2349 \ifx\Gm@star\Gm@value\else
2350 \setkeys{Gm}{\Gm@key=\Gm@value}%
2351 \fi\fi
2352 \advance\@tempcnta\@ne}%
2353 \let\Gm@star\relax}%
2354 % \end{macrocode}
2355 % \end{macro}
2356 %
2357 % \begin{macro}{\Gm@branch}
2358 % The macro splits a value into the same two values.
2359 % \begin{macrocode}
2360 \def\Gm@branch#1#2#3{%
2361 \@tempcnta\z@
2362 \@for\Gm@tmp:=#1\do{%
2363 \KV@@sp@def\Gm@frag{\Gm@tmp}%
2364 \edef\Gm@value{\Gm@frag}%
2365 \ifcase\@tempcnta\relax% cnta == 0
2366 \setkeys{Gm}{#2=\Gm@value}%
2367 \or% cnta == 1
2368 \setkeys{Gm}{#3=\Gm@value}%
2369 \else\fi
2370 \advance\@tempcnta\@ne}%
2371 \ifnum\@tempcnta=\@ne
2372 \setkeys{Gm}{#3=\Gm@value}%
2373 \fi}%
2374 % \end{macrocode}
2375 % \end{macro}
2376 %
2377 % \begin{macro}{\Gm@magtooffset}
2378 % This macro is used to adjust offsets by \cs{mag}.
2379 % \begin{macrocode}
2380 \def\Gm@magtooffset{%
2381 \@tempdima=\mag\Gm@truedimen sp%
2382 \@tempdimb=1\Gm@truedimen in%
2383 \divide\@tempdimb\@tempdima
2384 \multiply\@tempdimb\@m
2385 \addtolength{\hoffset}{1\Gm@truedimen in}%
2386 \addtolength{\voffset}{1\Gm@truedimen in}%
2387 \addtolength{\hoffset}{-\the\@tempdimb}%
2388 \addtolength{\voffset}{-\the\@tempdimb}}%
2389 % \end{macrocode}
2390 % \end{macro}
2391 %
2392 % \begin{macro}{\Gm@setlength}
2393 % This macro stores \LaTeX{} native dimensions, which are stored and
2394 % set afterwards.
2395 % \begin{macrocode}
2396 \def\Gm@setlength#1#2{%
2397 \let\Gm@len=\relax\let\Gm@td=\relax
2398 \edef\addtolist{\noexpand\Gm@dimlist=%
2399 {\the\Gm@dimlist \Gm@len{#1}{#2}}}\addtolist}%
2400 % \end{macrocode}
2401 % \end{macro}
2402 % \begin{macro}{\Gm@expandlengths}
2403 % This macro processes \cs{Gm@dimlist}.
2404 % \begin{macrocode}
2405 \def\Gm@expandlengths{%
2406 \def\Gm@td{\Gm@truedimen}%
2407 \def\Gm@len##1##2{\setlength{##1}{##2}}%
2408 \the\Gm@dimlist}%
2409 % \end{macrocode}
2410 % \end{macro}
2411 %
2412 % \begin{macro}{\Gm@setsize}
2413 % The macro sets |paperwidth| and |paperheight| dimensions
2414 % using \cs{Gm@setlength} macro.
2415 % \begin{macrocode}
2416 \def\Gm@setsize#1(#2,#3)#4{%
2417 \let\Gm@td\relax
2418 \expandafter\Gm@setlength\csname #1width\endcsname{#2\Gm@td #4}%
2419 \expandafter\Gm@setlength\csname #1height\endcsname{#3\Gm@td #4}%
2420 \ifGm@landscape\Gm@swap@papersizetrue\else\Gm@swap@papersizefalse\fi}%
2421 % \end{macrocode}
2422 % \end{macro}
2423 % \begin{macro}{\Gm@setpaper@ifpre}
2424 % The macro changes the paper size.
2425 % \begin{macrocode}
2426 \def\Gm@setpaper@ifpre#1{%
2427 \ifGm@preamble{#1}{\def\Gm@paper{#1}\@nameuse{Gm@#1}{paper}}}%
2428 % \end{macrocode}
2429 % \end{macro}
2430 % Various paper size are defined here.
2431 % \begin{macrocode}
2432 \@namedef{Gm@a0paper}#1{\Gm@setsize{#1}(841,1189){mm}}% ISO A0
2433 \@namedef{Gm@a1paper}#1{\Gm@setsize{#1}(594,841){mm}}% ISO A1
2434 \@namedef{Gm@a2paper}#1{\Gm@setsize{#1}(420,594){mm}}% ISO A2
2435 \@namedef{Gm@a3paper}#1{\Gm@setsize{#1}(297,420){mm}}% ISO A3
2436 \@namedef{Gm@a4paper}#1{\Gm@setsize{#1}(210,297){mm}}% ISO A4
2437 \@namedef{Gm@a5paper}#1{\Gm@setsize{#1}(148,210){mm}}% ISO A5
2438 \@namedef{Gm@a6paper}#1{\Gm@setsize{#1}(105,148){mm}}% ISO A6
2439 \@namedef{Gm@b0paper}#1{\Gm@setsize{#1}(1000,1414){mm}}% ISO B0
2440 \@namedef{Gm@b1paper}#1{\Gm@setsize{#1}(707,1000){mm}}% ISO B1
2441 \@namedef{Gm@b2paper}#1{\Gm@setsize{#1}(500,707){mm}}% ISO B2
2442 \@namedef{Gm@b3paper}#1{\Gm@setsize{#1}(353,500){mm}}% ISO B3
2443 \@namedef{Gm@b4paper}#1{\Gm@setsize{#1}(250,353){mm}}% ISO B4
2444 \@namedef{Gm@b5paper}#1{\Gm@setsize{#1}(176,250){mm}}% ISO B5
2445 \@namedef{Gm@b6paper}#1{\Gm@setsize{#1}(125,176){mm}}% ISO B6
2446 \@namedef{Gm@c0paper}#1{\Gm@setsize{#1}(917,1297){mm}}% ISO C0
2447 \@namedef{Gm@c1paper}#1{\Gm@setsize{#1}(648,917){mm}}% ISO C1
2448 \@namedef{Gm@c2paper}#1{\Gm@setsize{#1}(458,648){mm}}% ISO C2
2449 \@namedef{Gm@c3paper}#1{\Gm@setsize{#1}(324,458){mm}}% ISO C3
2450 \@namedef{Gm@c4paper}#1{\Gm@setsize{#1}(229,324){mm}}% ISO C4
2451 \@namedef{Gm@c5paper}#1{\Gm@setsize{#1}(162,229){mm}}% ISO C5
2452 \@namedef{Gm@c6paper}#1{\Gm@setsize{#1}(114,162){mm}}% ISO C6
2453 \@namedef{Gm@b0j}#1{\Gm@setsize{#1}(1030,1456){mm}}% JIS B0
2454 \@namedef{Gm@b1j}#1{\Gm@setsize{#1}(728,1030){mm}}% JIS B1
2455 \@namedef{Gm@b2j}#1{\Gm@setsize{#1}(515,728){mm}}% JIS B2
2456 \@namedef{Gm@b3j}#1{\Gm@setsize{#1}(364,515){mm}}% JIS B3
2457 \@namedef{Gm@b4j}#1{\Gm@setsize{#1}(257,364){mm}}% JIS B4
2458 \@namedef{Gm@b5j}#1{\Gm@setsize{#1}(182,257){mm}}% JIS B5
2459 \@namedef{Gm@b6j}#1{\Gm@setsize{#1}(128,182){mm}}% JIS B6
2460 \@namedef{Gm@ansiapaper}#1{\Gm@setsize{#1}(8.5,11){in}}%
2461 \@namedef{Gm@ansibpaper}#1{\Gm@setsize{#1}(11,17){in}}%
2462 \@namedef{Gm@ansicpaper}#1{\Gm@setsize{#1}(17,22){in}}%
2463 \@namedef{Gm@ansidpaper}#1{\Gm@setsize{#1}(22,34){in}}%
2464 \@namedef{Gm@ansiepaper}#1{\Gm@setsize{#1}(34,44){in}}%
2465 \@namedef{Gm@letterpaper}#1{\Gm@setsize{#1}(8.5,11){in}}%
2466 \@namedef{Gm@legalpaper}#1{\Gm@setsize{#1}(8.5,14){in}}%
2467 \@namedef{Gm@executivepaper}#1{\Gm@setsize{#1}(7.25,10.5){in}}%
2468 \@namedef{Gm@screen}#1{\Gm@setsize{#1}(225,180){mm}}%
2469 % \end{macrocode}
2470 %
2471 % \begin{key}{Gm}{paper}
2472 % |paper| takes a paper name as its value.
2473 % \begin{macrocode}
2474 \define@key{Gm}{paper}{\setkeys{Gm}{#1}}%
2475 \let\KV@Gm@papername\KV@Gm@paper
2476 % \end{macrocode}
2477 % \end{key}
2478 % \begin{key}{Gm}{a[0-6]paper}
2479 % \begin{key}{Gm}{b[0-6]paper}
2480 % \begin{key}{Gm}{b[0-6]j}
2481 % \begin{key}{Gm}{ansi[a-e]paper}
2482 % \begin{key}{Gm}{letterpaper}
2483 % \begin{key}{Gm}{legalpaper}
2484 % \begin{key}{Gm}{executivepaper}
2485 % \begin{key}{Gm}{screen}
2486 % The following paper names are available.
2487 % \begin{macrocode}
2488 \define@key{Gm}{a0paper}[true]{\Gm@setpaper@ifpre{a0paper}}%
2489 \define@key{Gm}{a1paper}[true]{\Gm@setpaper@ifpre{a1paper}}%
2490 \define@key{Gm}{a2paper}[true]{\Gm@setpaper@ifpre{a2paper}}%
2491 \define@key{Gm}{a3paper}[true]{\Gm@setpaper@ifpre{a3paper}}%
2492 \define@key{Gm}{a4paper}[true]{\Gm@setpaper@ifpre{a4paper}}%
2493 \define@key{Gm}{a5paper}[true]{\Gm@setpaper@ifpre{a5paper}}%
2494 \define@key{Gm}{a6paper}[true]{\Gm@setpaper@ifpre{a6paper}}%
2495 \define@key{Gm}{b0paper}[true]{\Gm@setpaper@ifpre{b0paper}}%
2496 \define@key{Gm}{b1paper}[true]{\Gm@setpaper@ifpre{b1paper}}%
2497 \define@key{Gm}{b2paper}[true]{\Gm@setpaper@ifpre{b2paper}}%
2498 \define@key{Gm}{b3paper}[true]{\Gm@setpaper@ifpre{b3paper}}%
2499 \define@key{Gm}{b4paper}[true]{\Gm@setpaper@ifpre{b4paper}}%
2500 \define@key{Gm}{b5paper}[true]{\Gm@setpaper@ifpre{b5paper}}%
2501 \define@key{Gm}{b6paper}[true]{\Gm@setpaper@ifpre{b6paper}}%
2502 \define@key{Gm}{c0paper}[true]{\Gm@setpaper@ifpre{c0paper}}%
2503 \define@key{Gm}{c1paper}[true]{\Gm@setpaper@ifpre{c1paper}}%
2504 \define@key{Gm}{c2paper}[true]{\Gm@setpaper@ifpre{c2paper}}%
2505 \define@key{Gm}{c3paper}[true]{\Gm@setpaper@ifpre{c3paper}}%
2506 \define@key{Gm}{c4paper}[true]{\Gm@setpaper@ifpre{c4paper}}%
2507 \define@key{Gm}{c5paper}[true]{\Gm@setpaper@ifpre{c5paper}}%
2508 \define@key{Gm}{c6paper}[true]{\Gm@setpaper@ifpre{c6paper}}%
2509 \define@key{Gm}{b0j}[true]{\Gm@setpaper@ifpre{b0j}}%
2510 \define@key{Gm}{b1j}[true]{\Gm@setpaper@ifpre{b1j}}%
2511 \define@key{Gm}{b2j}[true]{\Gm@setpaper@ifpre{b2j}}%
2512 \define@key{Gm}{b3j}[true]{\Gm@setpaper@ifpre{b3j}}%
2513 \define@key{Gm}{b4j}[true]{\Gm@setpaper@ifpre{b4j}}%
2514 \define@key{Gm}{b5j}[true]{\Gm@setpaper@ifpre{b5j}}%
2515 \define@key{Gm}{b6j}[true]{\Gm@setpaper@ifpre{b6j}}%
2516 \define@key{Gm}{ansiapaper}[true]{\Gm@setpaper@ifpre{ansiapaper}}%
2517 \define@key{Gm}{ansibpaper}[true]{\Gm@setpaper@ifpre{ansibpaper}}%
2518 \define@key{Gm}{ansicpaper}[true]{\Gm@setpaper@ifpre{ansicpaper}}%
2519 \define@key{Gm}{ansidpaper}[true]{\Gm@setpaper@ifpre{ansidpaper}}%
2520 \define@key{Gm}{ansiepaper}[true]{\Gm@setpaper@ifpre{ansiepaper}}%
2521 \define@key{Gm}{letterpaper}[true]{\Gm@setpaper@ifpre{letterpaper}}%
2522 \define@key{Gm}{legalpaper}[true]{\Gm@setpaper@ifpre{legalpaper}}%
2523 \define@key{Gm}{executivepaper}[true]{\Gm@setpaper@ifpre{executivepaper}}%
2524 \define@key{Gm}{screen}[true]{\Gm@setpaper@ifpre{screen}}%
2525 % \end{macrocode}
2526 % \end{key}\end{key}\end{key}\end{key}\end{key}
2527 % \end{key}\end{key}\end{key}
2528 % \begin{key}{Gm}{paperwidth}
2529 % \begin{key}{Gm}{paperheight}
2530 % \begin{key}{Gm}{papersize}
2531 % Direct specification for paper size is also possible.
2532 % \begin{macrocode}
2533 \define@key{Gm}{paperwidth}{\ifGm@preamble{paperwidth}{%
2534 \def\Gm@paper{custom}\Gm@setlength\paperwidth{#1}}}%
2535 \define@key{Gm}{paperheight}{\ifGm@preamble{paperheight}{%
2536 \def\Gm@paper{custom}\Gm@setlength\paperheight{#1}}}%
2537 \define@key{Gm}{papersize}{\ifGm@preamble{papersize}{%
2538 \def\Gm@paper{custom}\Gm@branch{#1}{paperwidth}{paperheight}}}%
2539 % \end{macrocode}
2540 % \end{key}\end{key}\end{key}
2541 % \begin{key}{Gm}{layout}
2542 % \begin{key}{Gm}{layoutwidth}
2543 % \begin{key}{Gm}{layoutheight}
2544 % \begin{key}{Gm}{layoutsize}
2545 % Direct specification for layout size is also possible.
2546 % \begin{macrocode}
2547 \define@key{Gm}{layout}{\Gm@layouttrue\@nameuse{Gm@#1}{Gm@layout}}%
2548 \let\KV@Gm@layoutname\KV@Gm@layout
2549 \define@key{Gm}{layoutwidth}{\Gm@layouttrue\Gm@setlength\Gm@layoutwidth{#1}}%
2550 \define@key{Gm}{layoutheight}{\Gm@layouttrue\Gm@setlength\Gm@layoutheight{#1}}%
2551 \define@key{Gm}{layoutsize}{\Gm@branch{#1}{layoutwidth}{layoutheight}}%
2552 % \end{macrocode}
2553 % \end{key}\end{key}\end{key}\end{key}
2554 % \begin{key}{Gm}{landscape}
2555 % \begin{key}{Gm}{portrait}
2556 % Paper orientation setting.
2557 % \begin{macrocode}
2558 \define@key{Gm}{landscape}[true]{\ifGm@preamble{landscape}{%
2559 \Gm@doifelse{landscape}{#1}%
2560 {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{swap@papersize}\fi}%
2561 {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{swap@papersize}\fi}}}%
2562 \define@key{Gm}{portrait}[true]{\ifGm@preamble{portrait}{%
2563 \Gm@doifelse{portrait}{#1}%
2564 {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{swap@papersize}\fi}%
2565 {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{swap@papersize}\fi}}}%
2566 % \end{macrocode}
2567 % \end{key}\end{key}
2568 % \begin{key}{Gm}{hscale}
2569 % \begin{key}{Gm}{vscale}
2570 % \begin{key}{Gm}{scale}
2571 % These options can determine the length(s) of \gpart{total body}
2572 % giving \textit{scale(s)} against the paper size.
2573 % \begin{macrocode}
2574 \define@key{Gm}{hscale}{\Gm@hbodytrue\edef\Gm@hscale{#1}}%
2575 \define@key{Gm}{vscale}{\Gm@vbodytrue\edef\Gm@vscale{#1}}%
2576 \define@key{Gm}{scale}{\Gm@branch{#1}{hscale}{vscale}}%
2577 % \end{macrocode}
2578 % \end{key}\end{key}\end{key}
2579 % \begin{key}{Gm}{width}
2580 % \begin{key}{Gm}{height}
2581 % \begin{key}{Gm}{total}
2582 % \begin{key}{Gm}{totalwidth}
2583 % \begin{key}{Gm}{totalheight}
2584 % These options give concrete dimension(s) of \gpart{total body}.
2585 % |totalwidth| and |totalheight| are aliases of |width| and |height|
2586 % respectively.
2587 % \begin{macrocode}
2588 \define@key{Gm}{width}{\Gm@hbodytrue\Gm@defbylen{width}{#1}}%
2589 \define@key{Gm}{height}{\Gm@vbodytrue\Gm@defbylen{height}{#1}}%
2590 \define@key{Gm}{total}{\Gm@branch{#1}{width}{height}}%
2591 \let\KV@Gm@totalwidth\KV@Gm@width
2592 \let\KV@Gm@totalheight\KV@Gm@height
2593 % \end{macrocode}
2594 % \end{key}\end{key}\end{key}\end{key}\end{key}
2595 % \begin{key}{Gm}{textwidth}
2596 % \begin{key}{Gm}{textheight}
2597 % \begin{key}{Gm}{text}
2598 % \begin{key}{Gm}{body}
2599 % These options directly sets the dimensions \cs{textwidth} and
2600 % \cs{textheight}. |body| is an alias of |text|.
2601 % \begin{macrocode}
2602 \define@key{Gm}{textwidth}{\Gm@hbodytrue\Gm@defbylen{textwidth}{#1}}%
2603 \define@key{Gm}{textheight}{\Gm@vbodytrue\Gm@defbylen{textheight}{#1}}%
2604 \define@key{Gm}{text}{\Gm@branch{#1}{textwidth}{textheight}}%
2605 \let\KV@Gm@body\KV@Gm@text
2606 % \end{macrocode}
2607 % \end{key}\end{key}\end{key}\end{key}
2608 % \begin{key}{Gm}{lines}
2609 % The option sets \cs{textheight} with the number of lines.
2610 % \begin{macrocode}
2611 \define@key{Gm}{lines}{\Gm@vbodytrue\Gm@defbycnt{lines}{#1}}%
2612 % \end{macrocode}
2613 % \end{key}
2614 % \begin{key}{Gm}{includehead}
2615 % \begin{key}{Gm}{includefoot}
2616 % \begin{key}{Gm}{includeheadfoot}
2617 % \begin{key}{Gm}{includemp}
2618 % \begin{key}{Gm}{includeall}
2619 % The options take the corresponding dimensions as part of
2620 % \gpart{body}.
2621 % \begin{macrocode}
2622 \define@key{Gm}{includehead}[true]{\Gm@setbool{includehead}{#1}}%
2623 \define@key{Gm}{includefoot}[true]{\Gm@setbool{includefoot}{#1}}%
2624 \define@key{Gm}{includeheadfoot}[true]{\Gm@doifelse{includeheadfoot}{#1}%
2625 {\Gm@includeheadtrue\Gm@includefoottrue}%
2626 {\Gm@includeheadfalse\Gm@includefootfalse}}%
2627 \define@key{Gm}{includemp}[true]{\Gm@setbool{includemp}{#1}}%
2628 \define@key{Gm}{includeall}[true]{\Gm@doifelse{includeall}{#1}%
2629 {\Gm@includeheadtrue\Gm@includefoottrue\Gm@includemptrue}%
2630 {\Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse}}%
2631 % \end{macrocode}
2632 % \end{key}\end{key}\end{key}\end{key}\end{key}
2633 % \begin{key}{Gm}{ignorehead}
2634 % \begin{key}{Gm}{ignorefoot}
2635 % \begin{key}{Gm}{ignoreheadfoot}
2636 % \begin{key}{Gm}{ignoremp}
2637 % \begin{key}{Gm}{ignoreall}
2638 % These options exclude \gpart{head}, \gpart{foot}
2639 % and \gpart{marginpars} when determining \gpart{body}.
2640 % \begin{macrocode}
2641 \define@key{Gm}{ignorehead}[true]{%
2642 \Gm@setboolrev[ignorehead]{includehead}{#1}}%
2643 \define@key{Gm}{ignorefoot}[true]{%
2644 \Gm@setboolrev[ignorefoot]{includefoot}{#1}}%
2645 \define@key{Gm}{ignoreheadfoot}[true]{\Gm@doifelse{ignoreheadfoot}{#1}%
2646 {\Gm@includeheadfalse\Gm@includefootfalse}%
2647 {\Gm@includeheadtrue\Gm@includefoottrue}}%
2648 \define@key{Gm}{ignoremp}[true]{%
2649 \Gm@setboolrev[ignoremp]{includemp}{#1}}%
2650 \define@key{Gm}{ignoreall}[true]{\Gm@doifelse{ignoreall}{#1}%
2651 {\Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse}%
2652 {\Gm@includeheadtrue\Gm@includefoottrue\Gm@includemptrue}}%
2653 % \end{macrocode}
2654 % \end{key}\end{key}\end{key}\end{key}\end{key}
2655 % \begin{key}{Gm}{heightrounded}
2656 % The option rounds \cs{textheight} to n-times of \cs{baselineskip}
2657 % plus \cs{topskip}.
2658 % \begin{macrocode}
2659 \define@key{Gm}{heightrounded}[true]{\Gm@setbool{heightrounded}{#1}}%
2660 % \end{macrocode}
2661 % \end{key}
2662 % \begin{key}{Gm}{hdivide}
2663 % \begin{key}{Gm}{vdivide}
2664 % \begin{key}{Gm}{divide}
2665 % The options are useful to specify partitioning
2666 % in each direction of the paper.
2667 % \begin{macrocode}
2668 \define@key{Gm}{hdivide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}}%
2669 \define@key{Gm}{vdivide}{\Gm@parse@divide{#1}{tmargin}{height}{bmargin}}%
2670 \define@key{Gm}{divide}{\Gm@parse@divide{#1}{lmargin}{width}{rmargin}%
2671 \Gm@parse@divide{#1}{tmargin}{height}{bmargin}}%
2672 % \end{macrocode}
2673 % \end{key}\end{key}\end{key}
2674 %
2675 % \begin{key}{Gm}{lmargin}
2676 % \begin{key}{Gm}{rmargin}
2677 % \begin{key}{Gm}{tmargin}
2678 % \begin{key}{Gm}{bmargin}
2679 % \begin{key}{Gm}{left}
2680 % \begin{key}{Gm}{inner}
2681 % \begin{key}{Gm}{innermargin}
2682 % \begin{key}{Gm}{right}
2683 % \begin{key}{Gm}{outer}
2684 % \begin{key}{Gm}{outermargin}
2685 % \begin{key}{Gm}{top}
2686 % \begin{key}{Gm}{bottom}
2687 % These options set \gpart{margins}.
2688 % |left|, |inner|, |innermargin| are aliases of |lmargin|.
2689 % |right|, |outer|, |outermargin| are aliases of |rmargin|.
2690 % |top| and |bottom| are aliases of |tmargin| and |bmargin| respectively.
2691 % \begin{macrocode}
2692 \define@key{Gm}{lmargin}{\Gm@defbylen{lmargin}{#1}}%
2693 \define@key{Gm}{rmargin}{\Gm@defbylen{rmargin}{#1}}%
2694 \let\KV@Gm@left\KV@Gm@lmargin
2695 \let\KV@Gm@inner\KV@Gm@lmargin
2696 \let\KV@Gm@innermargin\KV@Gm@lmargin
2697 \let\KV@Gm@right\KV@Gm@rmargin
2698 \let\KV@Gm@outer\KV@Gm@rmargin
2699 \let\KV@Gm@outermargin\KV@Gm@rmargin
2700 \define@key{Gm}{tmargin}{\Gm@defbylen{tmargin}{#1}}%
2701 \define@key{Gm}{bmargin}{\Gm@defbylen{bmargin}{#1}}%
2702 \let\KV@Gm@top\KV@Gm@tmargin
2703 \let\KV@Gm@bottom\KV@Gm@bmargin
2704 % \end{macrocode}
2705 % \end{key}\end{key}\end{key}\end{key}\end{key}
2706 % \end{key}\end{key}\end{key}\end{key}\end{key}
2707 % \end{key}\end{key}
2708 % \begin{key}{Gm}{hmargin}
2709 % \begin{key}{Gm}{vmargin}
2710 % \begin{key}{Gm}{margin}
2711 % These options are shorthands for setting \gpart{margins}.
2712 % \begin{macrocode}
2713 \define@key{Gm}{hmargin}{\Gm@branch{#1}{lmargin}{rmargin}}%
2714 \define@key{Gm}{vmargin}{\Gm@branch{#1}{tmargin}{bmargin}}%
2715 \define@key{Gm}{margin}{\Gm@branch{#1}{lmargin}{tmargin}%
2716 \Gm@branch{#1}{rmargin}{bmargin}}%
2717 % \end{macrocode}
2718 % \end{key}\end{key}\end{key}
2719 % \begin{key}{Gm}{hmarginratio}
2720 % \begin{key}{Gm}{vmarginratio}
2721 % \begin{key}{Gm}{marginratio}
2722 % \begin{key}{Gm}{hratio}
2723 % \begin{key}{Gm}{vratio}
2724 % \begin{key}{Gm}{ratio}
2725 % Options specifying the margin ratios.
2726 % \begin{macrocode}
2727 \define@key{Gm}{hmarginratio}{\edef\Gm@hmarginratio{#1}}%
2728 \define@key{Gm}{vmarginratio}{\edef\Gm@vmarginratio{#1}}%
2729 \define@key{Gm}{marginratio}{\Gm@branch{#1}{hmarginratio}{vmarginratio}}%
2730 \let\KV@Gm@hratio\KV@Gm@hmarginratio
2731 \let\KV@Gm@vratio\KV@Gm@vmarginratio
2732 \let\KV@Gm@ratio\KV@Gm@marginratio
2733 % \end{macrocode}
2734 % \end{key}\end{key}\end{key}
2735 % \end{key}\end{key}\end{key}
2736 % \begin{key}{Gm}{hcentering}
2737 % \begin{key}{Gm}{vcentering}
2738 % \begin{key}{Gm}{centering}
2739 % Useful shorthands to place \gpart{body} centered.
2740 % \begin{macrocode}
2741 \define@key{Gm}{hcentering}[true]{\Gm@doifelse{hcentering}{#1}%
2742 {\def\Gm@hmarginratio{1:1}}{}}%
2743 \define@key{Gm}{vcentering}[true]{\Gm@doifelse{vcentering}{#1}%
2744 {\def\Gm@vmarginratio{1:1}}{}}%
2745 \define@key{Gm}{centering}[true]{\Gm@doifelse{centering}{#1}%
2746 {\def\Gm@hmarginratio{1:1}\def\Gm@vmarginratio{1:1}}{}}%
2747 % \end{macrocode}
2748 % \end{key}\end{key}\end{key}
2749 % \begin{key}{Gm}{twoside}
2750 % If |twoside=true|, \cs{@twoside} and \cs{@mparswitch} is set to |true|.
2751 % \begin{macrocode}
2752 \define@key{Gm}{twoside}[true]{\Gm@doifelse{twoside}{#1}%
2753 {\@twosidetrue\@mparswitchtrue}{\@twosidefalse\@mparswitchfalse}}%
2754 % \end{macrocode}
2755 % \end{key}
2756 % \begin{key}{Gm}{asymmetric}
2757 % |asymmetric| sets \cs{@mparswitchfalse} and \cs{@twosidetrue}
2758 % A |asymmetric=false| has no effect.
2759 % \begin{macrocode}
2760 \define@key{Gm}{asymmetric}[true]{\Gm@doifelse{asymmetric}{#1}%
2761 {\@twosidetrue\@mparswitchfalse}{}}%
2762 % \end{macrocode}
2763 % \end{key}
2764 % \begin{key}{Gm}{bindingoffset}
2765 % The macro adds the specified space to the inner margin.
2766 % \begin{macrocode}
2767 \define@key{Gm}{bindingoffset}{\Gm@setlength\Gm@bindingoffset{#1}}%
2768 % \end{macrocode}
2769 % \end{key}
2770 % \begin{key}{Gm}{headheight}
2771 % \begin{key}{Gm}{headsep}
2772 % \begin{key}{Gm}{footskip}
2773 % \begin{key}{Gm}{head}
2774 % \begin{key}{Gm}{foot}
2775 % The direct settings of \gpart{head} and/or \gpart{foot} dimensions.
2776 % \begin{macrocode}
2777 \define@key{Gm}{headheight}{\Gm@setlength\headheight{#1}}%
2778 \define@key{Gm}{headsep}{\Gm@setlength\headsep{#1}}%
2779 \define@key{Gm}{footskip}{\Gm@setlength\footskip{#1}}%
2780 \let\KV@Gm@head\KV@Gm@headheight
2781 \let\KV@Gm@foot\KV@Gm@footskip
2782 % \end{macrocode}
2783 % \end{key}\end{key}\end{key}\end{key}\end{key}
2784 % \begin{key}{Gm}{nohead}
2785 % \begin{key}{Gm}{nofoot}
2786 % \begin{key}{Gm}{noheadfoot}
2787 % They are only shorthands to set \gpart{head} and/or \gpart{foot}
2788 % to be |0pt|.
2789 % \begin{macrocode}
2790 \define@key{Gm}{nohead}[true]{\Gm@doifelse{nohead}{#1}%
2791 {\Gm@setlength\headheight\z@\Gm@setlength\headsep\z@}{}}%
2792 \define@key{Gm}{nofoot}[true]{\Gm@doifelse{nofoot}{#1}%
2793 {\Gm@setlength\footskip\z@}{}}%
2794 \define@key{Gm}{noheadfoot}[true]{\Gm@doifelse{noheadfoot}{#1}%
2795 {\Gm@setlength\headheight\z@\Gm@setlength\headsep
2796 \z@\Gm@setlength\footskip\z@}{}}%
2797 % \end{macrocode}
2798 % \end{key}\end{key}\end{key}
2799 % \begin{key}{Gm}{footnotesep}
2800 % The option directly sets a native dimension \cs{footnotesep}.
2801 % \begin{macrocode}
2802 \define@key{Gm}{footnotesep}{\Gm@setlength{\skip\footins}{#1}}%
2803 % \end{macrocode}
2804 % \end{key}
2805 % \begin{key}{Gm}{marginparwidth}
2806 % \begin{key}{Gm}{marginpar}
2807 % \begin{key}{Gm}{marginparsep}
2808 % They directly set native dimensions \cs{marginparwidth} and
2809 % \cs{marginparsep}.
2810 % \begin{macrocode}
2811 \define@key{Gm}{marginparwidth}{\Gm@setlength\marginparwidth{#1}}%
2812 \let\KV@Gm@marginpar\KV@Gm@marginparwidth
2813 \define@key{Gm}{marginparsep}{\Gm@setlength\marginparsep{#1}}%
2814 % \end{macrocode}
2815 % \end{key}\end{key}\end{key}
2816 % \begin{key}{Gm}{nomarginpar}
2817 % The macro is a shorthand for \cs{marginparwidth}|=0pt| and
2818 % \cs{marginparsep}|=0pt|.
2819 % \begin{macrocode}
2820 \define@key{Gm}{nomarginpar}[true]{\Gm@doifelse{nomarginpar}{#1}%
2821 {\Gm@setlength\marginparwidth\z@\Gm@setlength\marginparsep\z@}{}}%
2822 % \end{macrocode}
2823 % \end{key}
2824 % \begin{key}{Gm}{columnsep}
2825 % The option sets a native dimension \cs{columnsep}.
2826 % \begin{macrocode}
2827 \define@key{Gm}{columnsep}{\Gm@setlength\columnsep{#1}}%
2828 % \end{macrocode}
2829 % \end{key}
2830 % \begin{key}{Gm}{hoffset}
2831 % \begin{key}{Gm}{voffset}
2832 % \begin{key}{Gm}{offset}
2833 % The former two options set native dimensions \cs{hoffset} and
2834 % \cs{voffset}. |offset| can set both of them with the same value.
2835 % \begin{macrocode}
2836 \define@key{Gm}{hoffset}{\Gm@setlength\hoffset{#1}}%
2837 \define@key{Gm}{voffset}{\Gm@setlength\voffset{#1}}%
2838 \define@key{Gm}{offset}{\Gm@branch{#1}{hoffset}{voffset}}%
2839 % \end{macrocode}
2840 % \end{key}\end{key}\end{key}
2841 % \begin{key}{Gm}{layouthoffset}
2842 % \begin{key}{Gm}{layoutvoffset}
2843 % \begin{key}{Gm}{layoutoffset}
2844 % \begin{macrocode}
2845 \define@key{Gm}{layouthoffset}{\Gm@setlength\Gm@layouthoffset{#1}}%
2846 \define@key{Gm}{layoutvoffset}{\Gm@setlength\Gm@layoutvoffset{#1}}%
2847 \define@key{Gm}{layoutoffset}{\Gm@branch{#1}{layouthoffset}{layoutvoffset}}%
2848 % \end{macrocode}
2849 % \end{key}\end{key}\end{key}
2850 % \begin{key}{Gm}{twocolumn}
2851 % The option sets \cs{twocolumn} switch.
2852 % \begin{macrocode}
2853 \define@key{Gm}{twocolumn}[true]{%
2854 \Gm@doif{twocolumn}{#1}{\csname @twocolumn\Gm@bool\endcsname}}%
2855 % \end{macrocode}
2856 % \end{key}
2857 % \begin{key}{Gm}{onecolumn}
2858 % This option has the reverse effect of |twocolumn| option.
2859 % \begin{macrocode}
2860 \define@key{Gm}{onecolumn}[true]{%
2861 \Gm@doifelse{onecolumn}{#1}{\@twocolumnfalse}{\@twocolumntrue}}%
2862 % \end{macrocode}
2863 % \end{key}
2864 % \begin{key}{Gm}{reversemp}
2865 % \begin{key}{Gm}{reversemarginpar}
2866 % The both options set \cs{reversemargin}.
2867 % \begin{macrocode}
2868 \define@key{Gm}{reversemp}[true]{%
2869 \Gm@doif{reversemp}{#1}{\csname @reversemargin\Gm@bool\endcsname}}%
2870 \define@key{Gm}{reversemarginpar}[true]{%
2871 \Gm@doif{reversemarginpar}{#1}{\csname @reversemargin\Gm@bool\endcsname}}%
2872 % \end{macrocode}
2873 % \end{key}\end{key}
2874 % \begin{key}{Gm}{dviver}
2875 % \begin{macrocode}
2876 \define@key{Gm}{driver}{\ifGm@preamble{driver}{%
2877 \edef\@@tempa{#1}\edef\@@auto{auto}\edef\@@none{none}%
2878 \ifx\@@tempa\@empty\let\Gm@driver\relax\else
2879 \ifx\@@tempa\@@none\let\Gm@driver\relax\else
2880 \ifx\@@tempa\@@auto\let\Gm@driver\@empty\else
2881 \setkeys{Gm}{#1}\fi\fi\fi\let\@@auto\relax\let\@@none\relax}}%
2882 % \end{macrocode}
2883 % \end{key}
2884 % \begin{key}{Gm}{dvips}
2885 % \begin{key}{Gm}{dvipdfm}\begin{key}{Gm}{dvipdfmx}\begin{key}{Gm}{xdvipdfmx}
2886 % \begin{key}{Gm}{pdftex}
2887 % \begin{key}{Gm}{luatex}
2888 % \begin{key}{Gm}{xetex}
2889 % \begin{key}{Gm}{vtex}
2890 % The \Gm\ package supports |dvips|, |dvipdfm|,
2891 % |pdflatex|, |luatex| and |vtex|. |dvipdfm| works like |dvips|.
2892 % \begin{macrocode}
2893 \define@key{Gm}{dvips}[true]{\ifGm@preamble{dvips}{%
2894 \Gm@doifelse{dvips}{#1}{\Gm@setdriver{dvips}}{\Gm@unsetdriver{dvips}}}}%
2895 \define@key{Gm}{dvipdfm}[true]{\ifGm@preamble{dvipdfm}{%
2896 \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}}%
2897 \define@key{Gm}{dvipdfmx}[true]{\ifGm@preamble{dvipdfm}{%
2898 \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}}%
2899 \define@key{Gm}{xdvipdfmx}[true]{\ifGm@preamble{dvipdfm}{%
2900 \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}}%
2901 \define@key{Gm}{pdftex}[true]{\ifGm@preamble{pdftex}{%
2902 \Gm@doifelse{pdftex}{#1}{\Gm@setdriver{pdftex}}{\Gm@unsetdriver{pdftex}}}}%
2903 \define@key{Gm}{luatex}[true]{\ifGm@preamble{luatex}{%
2904 \Gm@doifelse{luatex}{#1}{\Gm@setdriver{luatex}}{\Gm@unsetdriver{luatex}}}}%
2905 \define@key{Gm}{xetex}[true]{\ifGm@preamble{xetex}{%
2906 \Gm@doifelse{xetex}{#1}{\Gm@setdriver{xetex}}{\Gm@unsetdriver{xetex}}}}%
2907 \define@key{Gm}{vtex}[true]{\ifGm@preamble{vtex}{%
2908 \Gm@doifelse{vtex}{#1}{\Gm@setdriver{vtex}}{\Gm@unsetdriver{vtex}}}}%
2909 % \end{macrocode}
2910 % \end{key}\end{key}\end{key}\end{key}\end{key}\end{key}\end{key}\end{key}
2911 % \begin{key}{Gm}{verbose}
2912 % The verbose mode.
2913 % \begin{macrocode}
2914 \define@key{Gm}{verbose}[true]{\ifGm@preamble{verbose}{\Gm@setbool{verbose}{#1}}}%
2915 % \end{macrocode}
2916 % \end{key}
2917 % \begin{key}{Gm}{reset}
2918 % The option cancels all the options specified before |reset|,
2919 % except |pass|. |mag| ($\neq1000$) with |truedimen| cannot be also
2920 % reset.
2921 % \begin{macrocode}
2922 \define@key{Gm}{reset}[true]{\ifGm@preamble{reset}{%
2923 \Gm@doifelse{reset}{#1}{\Gm@restore@org\Gm@initall
2924 \ProcessOptionsKV[c]{Gm}\Gm@setdefaultpaper}{}}}%
2925 % \end{macrocode}
2926 % \end{key}
2927 % \begin{key}{Gm}{resetpaper}
2928 % If |resetpaper| is set to |true|, the paper size redefined in the package
2929 % is discarded and the original one is restored. This option may be useful
2930 % to print nonstandard sized documents with normal printers and papers.
2931 % \begin{macrocode}
2932 \define@key{Gm}{resetpaper}[true]{\ifGm@preamble{resetpaper}{%
2933 \Gm@setbool{resetpaper}{#1}}}%
2934 % \end{macrocode}
2935 % \end{key}
2936 % \begin{key}{Gm}{mag}
2937 % |mag| is expanded immediately when it is specified. So |reset| can't
2938 % reset |mag| when it is set with |truedimen|.
2939 % \begin{macrocode}
2940 \define@key{Gm}{mag}{\ifGm@preamble{mag}{\mag=#1}}%
2941 % \end{macrocode}
2942 % \end{key}
2943 % \begin{key}{Gm}{truedimen}
2944 % If |truedimen| is set to |true|, all of the internal
2945 % explicit dimensions is changed to \textit{true} dimensions,
2946 % e.g., |1in| is changed to |1truein|.
2947 % \begin{macrocode}
2948 \define@key{Gm}{truedimen}[true]{\ifGm@preamble{truedimen}{%
2949 \Gm@doifelse{truedimen}{#1}{\let\Gm@truedimen\Gm@true}%
2950 {\let\Gm@truedimen\@empty}}}%
2951 % \end{macrocode}
2952 % \end{key}
2953 % \begin{key}{Gm}{pass}
2954 % The option makes all the options specified ineffective except
2955 % verbose switch.
2956 % \begin{macrocode}
2957 \define@key{Gm}{pass}[true]{\ifGm@preamble{pass}{\Gm@setbool{pass}{#1}}}%
2958 % \end{macrocode}
2959 % \end{key}
2960 % \begin{key}{Gm}{showframe}
2961 % The showframe option prints page frames to help you understand
2962 % what the resulting layout is like.
2963 % \begin{macrocode}
2964 \define@key{Gm}{showframe}[true]{\Gm@setbool{showframe}{#1}}%
2965 % \end{macrocode}
2966 % \end{key}
2967 % \begin{key}{Gm}{showcrop}
2968 % The showcrop option prints crop marks at each corner of the layout area.
2969 % \begin{macrocode}
2970 \define@key{Gm}{showcrop}[true]{\Gm@setbool{showcrop}{#1}}%
2971 % \end{macrocode}
2972 % \end{key}
2973 % \begin{macro}{\Gm@setdefaultpaper}
2974 % The macro stores paper dimensions.
2975 % This macro should be called after |\ProcessOptionsKV[c]{Gm}|.
2976 % If the |landscape| option in |\documentclass| is
2977 % specified, the class immediately swaps the paper dimensions.
2978 % \begin{macrocode}
2979 \def\Gm@setdefaultpaper{%
2980 \ifx\Gm@paper\@undefined
2981 \Gm@setsize{paper}(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
2982 \Gm@setsize{Gm@layout}(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
2983 \Gm@swap@papersizefalse
2984 \fi}%
2985 % \end{macrocode}
2986 % \end{macro}
2987 % \begin{macro}{\Gm@adjustpaper}
2988 % The macro checks if paperwidth/height is larger than 0pt,
2989 % which is used in \cs{Gm@process}.
2990 % The paper dimensions can be swapped when paper orientation
2991 % is changed over by |landscape| and |portrait| options.
2992 % \begin{macrocode}
2993 \def\Gm@adjustpaper{%
2994 \ifdim\paperwidth>\p@\else
2995 \PackageError{geometry}{%
2996 \string\paperwidth\space(\the\paperwidth) too short}{%
2997 Set a paper type (e.g., `a4paper').}%
2998 \fi
2999 \ifdim\paperheight>\p@\else
3000 \PackageError{geometry}{%
3001 \string\paperheight\space(\the\paperheight) too short}{%
3002 Set a paper type (e.g., `a4paper').}%
3003 \fi
3004 \ifGm@swap@papersize
3005 \setlength\@tempdima{\paperwidth}%
3006 \setlength\paperwidth{\paperheight}%
3007 \setlength\paperheight{\@tempdima}%
3008 \fi
3009 \ifGm@layout\else
3010 \setlength\Gm@layoutwidth{\paperwidth}%
3011 \setlength\Gm@layoutheight{\paperheight}%
3012 \fi}%
3013 % \end{macrocode}
3014 % \end{macro}
3015 % \begin{macro}{\Gm@checkmp}
3016 % The macro checks whether or not the marginpars overrun the page.
3017 % \begin{macrocode}
3018 \def\Gm@checkmp{%
3019 \ifGm@includemp\else
3020 \@tempcnta\z@\@tempcntb\@ne
3021 \if@twocolumn
3022 \@tempcnta\@ne
3023 \else
3024 \if@reversemargin
3025 \@tempcnta\@ne\@tempcntb\z@
3026 \fi
3027 \fi
3028 \@tempdima\marginparwidth
3029 \advance\@tempdima\marginparsep
3030 \ifnum\@tempcnta=\@ne
3031 \@tempdimc\@tempdima
3032 \setlength\@tempdimb{\Gm@lmargin}%
3033 \advance\@tempdimc-\@tempdimb
3034 \ifdim\@tempdimc>\z@
3035 \Gm@warning{The marginal notes overrun the paper edge.^^J
3036 \@spaces Add \the\@tempdimc\space and more to the left margin}%
3037 \fi
3038 \fi
3039 \ifnum\@tempcntb=\@ne
3040 \@tempdimc\@tempdima
3041 \setlength\@tempdimb{\Gm@rmargin}%
3042 \advance\@tempdimc-\@tempdimb
3043 \ifdim\@tempdimc>\z@
3044 \Gm@warning{The marginal notes overrun the paper.^^J
3045 \@spaces Add \the\@tempdimc\space and more to the right margin}%
3046 \fi
3047 \fi
3048 \fi}%
3049 % \end{macrocode}
3050 % \end{macro}
3051 % \begin{macro}{\Gm@adjustmp}
3052 % The macro sets marginpar correction when |includemp| is set,
3053 % which is used in \cs{Gm@process}. The variables \cs{Gm@wd@mp},
3054 % \cs{Gm@odd@mp} and \cs{Gm@even@mp} are set here.
3055 % Note that \cs{Gm@even@mp} should be used only for twoside layout.
3056 % \begin{macrocode}
3057 \def\Gm@adjustmp{%
3058 \ifGm@includemp
3059 \@tempdimb\marginparwidth
3060 \advance\@tempdimb\marginparsep
3061 \Gm@wd@mp\@tempdimb
3062 \Gm@odd@mp\z@
3063 \Gm@even@mp\z@
3064 \if@twocolumn
3065 \Gm@wd@mp2\@tempdimb
3066 \Gm@odd@mp\@tempdimb
3067 \Gm@even@mp\@tempdimb
3068 \else
3069 \if@reversemargin
3070 \Gm@odd@mp\@tempdimb
3071 \if@mparswitch\else
3072 \Gm@even@mp\@tempdimb
3073 \fi
3074 \else
3075 \if@mparswitch
3076 \Gm@even@mp\@tempdimb
3077 \fi
3078 \fi
3079 \fi
3080 \fi}%
3081 % \end{macrocode}
3082 % \end{macro}
3083 % \begin{macro}{\Gm@adjustbody}
3084 % If the horizontal dimension of \gpart{body} is specified by user,
3085 % \cs{Gm@width} is set properly here.
3086 % \begin{macrocode}
3087 \def\Gm@adjustbody{
3088 \ifGm@hbody
3089 \ifx\Gm@width\@undefined
3090 \ifx\Gm@hscale\@undefined
3091 \Gm@defbylen{width}{\Gm@Dhscale\Gm@layoutwidth}%
3092 \else
3093 \Gm@defbylen{width}{\Gm@hscale\Gm@layoutwidth}%
3094 \fi
3095 \fi
3096 \ifx\Gm@textwidth\@undefined\else
3097 \setlength\@tempdima{\Gm@textwidth}%
3098 \ifGm@includemp
3099 \advance\@tempdima\Gm@wd@mp
3100 \fi
3101 \edef\Gm@width{\the\@tempdima}%
3102 \fi
3103 \fi
3104 % \end{macrocode}
3105 % If the vertical dimension of \gpart{body} is specified by user,
3106 % \cs{Gm@height} is set properly here.
3107 % \begin{macrocode}
3108 \ifGm@vbody
3109 \ifx\Gm@height\@undefined
3110 \ifx\Gm@vscale\@undefined
3111 \Gm@defbylen{height}{\Gm@Dvscale\Gm@layoutheight}%
3112 \else
3113 \Gm@defbylen{height}{\Gm@vscale\Gm@layoutheight}%
3114 \fi
3115 \fi
3116 \ifx\Gm@lines\@undefined\else
3117 % \end{macrocode}
3118 % \cs{topskip} has to be adjusted so that the formula
3119 % ``$\cs{textheight} = (lines - 1) \times \cs{baselineskip} + \cs{topskip}$''
3120 % to be correct even if large font sizes are specified by users.
3121 % If \cs{topskip} is smaller than \cs{ht}\cs{strutbox}, then \cs{topskip}
3122 % is set to \cs{ht}\cs{strutbox}.
3123 % \begin{macrocode}
3124 \ifdim\topskip<\ht\strutbox
3125 \setlength\@tempdima{\topskip}%
3126 \setlength\topskip{\ht\strutbox}%
3127 \Gm@warning{\noexpand\topskip was changed from \the\@tempdima\space
3128 to \the\topskip}%
3129 \fi
3130 \setlength\@tempdima{\baselineskip}%
3131 \multiply\@tempdima\Gm@lines
3132 \addtolength\@tempdima{\topskip}%
3133 \addtolength\@tempdima{-\baselineskip}%
3134 \edef\Gm@textheight{\the\@tempdima}%
3135 \fi
3136 \ifx\Gm@textheight\@undefined\else
3137 \setlength\@tempdima{\Gm@textheight}%
3138 \ifGm@includehead
3139 \addtolength\@tempdima{\headheight}%
3140 \addtolength\@tempdima{\headsep}%
3141 \fi
3142 \ifGm@includefoot
3143 \addtolength\@tempdima{\footskip}%
3144 \fi
3145 \edef\Gm@height{\the\@tempdima}%
3146 \fi
3147 \fi}%
3148 % \end{macrocode}
3149 % \end{macro}
3150 % \begin{macro}{\Gm@process}
3151 % The main macro processing the specified dimensions is defined.
3152 % \begin{macrocode}
3153 \def\Gm@process{%
3154 % \end{macrocode}
3155 % If |pass| is set, the original dimensions and switches are restored
3156 % and process is ended here.
3157 % \begin{macrocode}
3158 \ifGm@pass
3159 \Gm@restore@org
3160 \else
3161 \Gm@@process
3162 \fi}%
3163 % \end{macrocode}
3164 % The main processing macro.
3165 % \begin{macrocode}
3166 \def\Gm@@process{%
3167 \Gm@expandlengths
3168 \Gm@adjustpaper
3169 \addtolength\Gm@layoutwidth{-\Gm@bindingoffset}%
3170 \Gm@adjustmp
3171 \Gm@adjustbody
3172 \Gm@detall{h}{width}{lmargin}{rmargin}%
3173 \Gm@detall{v}{height}{tmargin}{bmargin}%
3174 % \end{macrocode}
3175 % The real dimensions are set properly according to the result
3176 % of the auto-completion calculation.
3177 % \begin{macrocode}
3178 \setlength\textwidth{\Gm@width}%
3179 \setlength\textheight{\Gm@height}%
3180 \setlength\topmargin{\Gm@tmargin}%
3181 \setlength\oddsidemargin{\Gm@lmargin}%
3182 \addtolength\oddsidemargin{-1\Gm@truedimen in}%
3183 % \end{macrocode}
3184 % If |includemp| is set to |true|, \cs{textwidth} and \cs{oddsidemargin}
3185 % are adjusted.
3186 % \begin{macrocode}
3187 \ifGm@includemp
3188 \advance\textwidth-\Gm@wd@mp
3189 \advance\oddsidemargin\Gm@odd@mp
3190 \fi
3191 % \end{macrocode}
3192 % Determining \cs{evensidemargin}.
3193 % In the twoside page layout, the right margin value \cs{Gm@rmargin} is used.
3194 % If the marginal note width is included,
3195 % \cs{evensidemargin} should be corrected by \cs{Gm@even@mp}.
3196 % \begin{macrocode}
3197 \if@mparswitch
3198 \setlength\evensidemargin{\Gm@rmargin}%
3199 \addtolength\evensidemargin{-1\Gm@truedimen in}%
3200 \ifGm@includemp
3201 \advance\evensidemargin\Gm@even@mp
3202 \fi
3203 \else
3204 \evensidemargin\oddsidemargin
3205 \fi
3206 % \end{macrocode}
3207 % The bindingoffset correction for \cs{oddsidemargin}.
3208 % \begin{macrocode}
3209 \advance\oddsidemargin\Gm@bindingoffset
3210 \addtolength\topmargin{-1\Gm@truedimen in}%
3211 % \end{macrocode}
3212 % If the head of the page is included in \gpart{total body},
3213 % \cs{headheight} and \cs{headsep} are removed from \cs{textheight},
3214 % otherwise from \cs{topmargin}.
3215 % \begin{macrocode}
3216 \ifGm@includehead
3217 \addtolength\textheight{-\headheight}%
3218 \addtolength\textheight{-\headsep}%
3219 \else
3220 \addtolength\topmargin{-\headheight}%
3221 \addtolength\topmargin{-\headsep}%
3222 \fi
3223 % \end{macrocode}
3224 % If the foot of the page is included in \gpart{total body},
3225 % \cs{footskip} is removed from \cs{textheight}.
3226 % \begin{macrocode}
3227 \ifGm@includefoot
3228 \addtolength\textheight{-\footskip}%
3229 \fi
3230 % \end{macrocode}
3231 % If |heightrounded| is set, \cs{textheight} is rounded.
3232 % \begin{macrocode}
3233 \ifGm@heightrounded
3234 \setlength\@tempdima{\textheight}%
3235 \addtolength\@tempdima{-\topskip}%
3236 \@tempcnta\@tempdima
3237 \@tempcntb\baselineskip
3238 \divide\@tempcnta\@tempcntb
3239 \setlength\@tempdimb{\baselineskip}%
3240 \multiply\@tempdimb\@tempcnta
3241 \advance\@tempdima-\@tempdimb
3242 \multiply\@tempdima\tw@
3243 \ifdim\@tempdima>\baselineskip
3244 \addtolength\@tempdimb{\baselineskip}%
3245 \fi
3246 \addtolength\@tempdimb{\topskip}%
3247 \textheight\@tempdimb
3248 \fi
3249 % \end{macrocode}
3250 % The paper width is set back by adding \cs{Gm@bindingoffset}.
3251 % \begin{macrocode}
3252 \advance\oddsidemargin\Gm@layouthoffset%
3253 \advance\evensidemargin\Gm@layouthoffset%
3254 \advance\topmargin\Gm@layoutvoffset%
3255 \addtolength\Gm@layoutwidth{\Gm@bindingoffset}%
3256 }% end of \Gm@@process
3257 % \end{macrocode}
3258 % \end{macro}
3259 %
3260 % \begin{macro}{\Gm@detectdriver}
3261 % The macro checks the typeset environment and changes the driver option
3262 % if necessary. To make the engine detection more robust, the macro is
3263 % rewritten with packages \textsf{ifpdf}, \textsf{ifvtex} and
3264 % \textsf{ifxetex}.
3265 % \begin{macrocode}
3266 \def\Gm@detectdriver{%
3267 % \end{macrocode}
3268 % If the driver option is not specified explicitly, then driver
3269 % auto-detection works.
3270 % \begin{macrocode}
3271 \ifx\Gm@driver\@empty
3272 \typeout{*geometry* driver: auto-detecting}%
3273 % \end{macrocode}
3274 % \cs{ifpdf} is defined in \textsf{ifpdf} package in `oberdiek' bundle.
3275 % \begin{macrocode}
3276 \ifpdf
3277 \ifx\pdfextension\@undefined
3278 \Gm@setdriver{pdftex}%
3279 \else
3280 \Gm@setdriver{luatex}%
3281 \fi
3282 \else
3283 \Gm@setdriver{dvips}%
3284 \fi
3285 % \end{macrocode}
3286 % \cs{ifvtex} is defined in \textsf{ifvtex} package in `oberdiek'
3287 % bundle.
3288 % \begin{macrocode}
3289 \ifvtex
3290 \Gm@setdriver{vtex}%
3291 \fi
3292 % \end{macrocode}
3293 % \cs{ifxetex} is defined in \textsf{ifxetex} package written by
3294 % Will Robertson.
3295 % \begin{macrocode}
3296 \ifxetex
3297 \Gm@setdriver{xetex}
3298 \fi
3299 % \end{macrocode}
3300 % When the driver option is set by the user, check if it is valid or not.
3301 % \begin{macrocode}
3302 \else
3303 \ifx\Gm@driver\Gm@xetex %%
3304 \ifxetex\else
3305 \Gm@warning{Wrong driver setting: `xetex'; trying `pdftex' driver}%
3306 \Gm@setdriver{pdftex}
3307 \fi
3308 \fi
3309 \ifx\Gm@driver\Gm@vtex
3310 \ifvtex\else
3311 \Gm@warning{Wrong driver setting: `vtex'; trying `dvips' driver}%
3312 \Gm@setdriver{dvips}%
3313 \fi
3314 \fi
3315 \fi
3316 \ifx\Gm@driver\relax
3317 \typeout{*geometry* detected driver: <none>}%
3318 \else
3319 \typeout{*geometry* detected driver: \Gm@driver}%
3320 \fi}%
3321 % \end{macrocode}
3322 % \end{macro}
3323 % \begin{macro}{\Gm@showparams}
3324 % Prints the resulted parammeters and dimensions to STDOUT
3325 % if |verbose| is true.
3326 % |\Gm@width| and |\Gm@height| are expanded to get the real size.
3327 % \begin{macrocode}
3328 \def\Gm@showparams#1{%
3329 \ifGm@verbose\expandafter\typeout\else\expandafter\wlog\fi
3330 {\Gm@logcontent{#1}}}%
3331 \def\Gm@showdim#1{* \string#1=\the#1^^J}%
3332 \def\Gm@showbool#1{\@nameuse{ifGm@#1}#1\space\fi}%
3333 % \end{macrocode}
3334 % \end{macro}
3335 % \begin{macro}{\Gm@logcontent}
3336 % The content of geometry parameters and native dimensions for the
3337 % page layout.
3338 % \begin{macrocode}
3339 \def\Gm@logcontent#1{%
3340 *geometry* verbose mode - [ #1 ] result:^^J%
3341 \ifGm@pass * pass: disregarded the geometry package!^^J%
3342 \else
3343 * driver: \if\Gm@driver<none>\else\Gm@driver\fi^^J%
3344 * paper: \ifx\Gm@paper\@undefined<default>\else\Gm@paper\fi^^J%
3345 * layout: \ifGm@layout<custom>\else<same size as paper>\fi^^J%
3346 \ifGm@layout
3347 * layout(width,height): (\the\Gm@layoutwidth,\the\Gm@layoutheight)^^J%
3348 \fi
3349 * layoutoffset:(h,v)=(\the\Gm@layouthoffset,\the\Gm@layoutvoffset)^^J%
3350 \@ifundefined{Gm@lines}{}{* lines: \Gm@lines^^J}%
3351 \@ifundefined{Gm@hmarginratio}{}{* hratio: \Gm@hmarginratio^^J}%
3352 \@ifundefined{Gm@vmarginratio}{}{* vratio: \Gm@vmarginratio^^J}%
3353 \ifdim\Gm@bindingoffset=\z@\else
3354 * bindingoffset: \the\Gm@bindingoffset^^J\fi
3355 * modes: %
3356 \Gm@showbool{landscape}%
3357 \Gm@showbool{includehead}%
3358 \Gm@showbool{includefoot}%
3359 \Gm@showbool{includemp}%
3360 \if@twoside twoside\space\fi%
3361 \if@mparswitch\else\if@twoside asymmetric\space\fi\fi%
3362 \Gm@showbool{heightrounded}%
3363 \ifx\Gm@truedimen\@empty\else truedimen\space\fi%
3364 \Gm@showbool{showframe}%
3365 \Gm@showbool{showcrop}%
3366 ^^J%
3367 * h-part:(L,W,R)=(\Gm@lmargin, \Gm@width, \Gm@rmargin)^^J%
3368 * v-part:(T,H,B)=(\Gm@tmargin, \Gm@height, \Gm@bmargin)^^J%
3369 \fi
3370 \Gm@showdim{\paperwidth}%
3371 \Gm@showdim{\paperheight}%
3372 \Gm@showdim{\textwidth}%
3373 \Gm@showdim{\textheight}%
3374 \Gm@showdim{\oddsidemargin}%
3375 \Gm@showdim{\evensidemargin}%
3376 \Gm@showdim{\topmargin}%
3377 \Gm@showdim{\headheight}%
3378 \Gm@showdim{\headsep}%
3379 \Gm@showdim{\topskip}%
3380 \Gm@showdim{\footskip}%
3381 \Gm@showdim{\marginparwidth}%
3382 \Gm@showdim{\marginparsep}%
3383 \Gm@showdim{\columnsep}%
3384 * \string\skip\string\footins=\the\skip\footins^^J%
3385 \Gm@showdim{\hoffset}%
3386 \Gm@showdim{\voffset}%
3387 \Gm@showdim{\mag}%
3388 * \string\@twocolumn\if@twocolumn true\else false\fi^^J%
3389 * \string\@twoside\if@twoside true\else false\fi^^J%
3390 * \string\@mparswitch\if@mparswitch true\else false\fi^^J%
3391 * \string\@reversemargin\if@reversemargin true\else false\fi^^J%
3392 * (1in=72.27pt=25.4mm, 1cm=28.453pt)^^J}%
3393 % \end{macrocode}
3394 % \end{macro}
3395 %
3396 % Macros for the page frames and cropmarks.
3397 % \begin{macrocode}
3398 \IfDocumentMetadataTF
3399 {
3400 \def\Gm@cropmark(#1,#2,#3,#4){%
3401 \begin{picture}[artifact](0,0)
3402 \setlength\unitlength{1truemm}%
3403 \linethickness{0.25pt}%
3404 \put(#3,0){\line(#1,0){17}}%
3405 \put(0,#4){\line(0,#2){17}}%
3406 \end{picture}}%
3407 }
3408 {
3409 \def\Gm@cropmark(#1,#2,#3,#4){%
3410 \begin{picture}(0,0)
3411 \setlength\unitlength{1truemm}%
3412 \linethickness{0.25pt}%
3413 \put(#3,0){\line(#1,0){17}}%
3414 \put(0,#4){\line(0,#2){17}}%
3415 \end{picture}}%
3416 }
3417 \providecommand*\vb@xt@{\vbox to}%
3418 \def\Gm@vrule{\vrule width 0.2pt height\textheight depth\z@}%
3419 \def\Gm@hrule{\hrule height 0.2pt depth\z@ width\textwidth}%
3420 \def\Gm@hruled{\hrule height\z@ depth0.2pt width\textwidth}%
3421 \newcommand*{\Gm@vrules@mpi}{%
3422 \hb@xt@\@tempdima{\llap{\Gm@vrule}\ignorespaces
3423 \hskip \textwidth\Gm@vrule\hskip \marginparsep
3424 \llap{\Gm@vrule}\hfil\Gm@vrule}}%
3425 \newcommand*{\Gm@vrules@mpii}{%
3426 \hb@xt@\@tempdima{\hskip-\marginparwidth\hskip-\marginparsep
3427 \llap{\Gm@vrule}\ignorespaces
3428 \hskip \marginparwidth\rlap{\Gm@vrule}\hskip \marginparsep
3429 \llap{\Gm@vrule}\hskip\textwidth\rlap{\Gm@vrule}\hss}}%
3430 \newcommand*{\Gm@pageframes}{%
3431 \vb@xt@\z@{%
3432 \ifGm@showcrop
3433 \vb@xt@\z@{\vskip-1\Gm@truedimen in\vskip\Gm@layoutvoffset%
3434 \hb@xt@\z@{\hskip-1\Gm@truedimen in\hskip\Gm@layouthoffset%
3435 \vb@xt@\Gm@layoutheight{%
3436 \let\protect\relax
3437 \hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,1,-3,3)\hfil\Gm@cropmark(1,1,3,3)}%
3438 \vfil
3439 \hb@xt@\Gm@layoutwidth{\Gm@cropmark(-1,-1,-3,-3)\hfil\Gm@cropmark(1,-1,3,-3)}}%
3440 \hss}%
3441 \vss}%
3442 \fi%
3443 \ifGm@showframe
3444 \if@twoside
3445 \ifodd\count\z@
3446 \let\@themargin\oddsidemargin
3447 \else
3448 \let\@themargin\evensidemargin
3449 \fi
3450 \fi
3451 \moveright\@themargin%
3452 \vb@xt@\z@{%
3453 \vskip\topmargin\vb@xt@\z@{\vss\Gm@hrule}%
3454 \vskip\headheight\vb@xt@\z@{\vss\Gm@hruled}%
3455 \vskip\headsep\vb@xt@\z@{\vss\Gm@hrule}%
3456 \@tempdima\textwidth
3457 \advance\@tempdima by \marginparsep
3458 \advance\@tempdima by \marginparwidth
3459 \if@mparswitch
3460 \ifodd\count\z@
3461 \Gm@vrules@mpi
3462 \else
3463 \Gm@vrules@mpii
3464 \fi
3465 \else
3466 \Gm@vrules@mpi
3467 \fi
3468 \vb@xt@\z@{\vss\Gm@hrule}%
3469 \vskip\footskip\vb@xt@\z@{\vss\Gm@hruled}%
3470 \vss}%
3471 \fi%
3472 }}%
3473 % \end{macrocode}
3474 %
3475 % \begin{macro}{\ProcessOptionsKV}
3476 % This macro can process class and package options using `key=value'
3477 % scheme. Only class options are processed with an optional argument
3478 % `|c|', package options with `|p|' , and both of them by default.
3479 % \begin{macrocode}
3480 \def\ProcessOptionsKV{\@ifnextchar[%]
3481 {\@ProcessOptionsKV}{\@ProcessOptionsKV[]}}%
3482 \def\@ProcessOptionsKV[#1]#2{%
3483 \let\@tempa\@empty
3484 \@tempcnta\z@
3485 \if#1p\@tempcnta\@ne\else\if#1c\@tempcnta\tw@\fi\fi
3486 \ifodd\@tempcnta
3487 \edef\@tempa{\@ptionlist{\@currname.\@currext}}%
3488 \else
3489 \@for\CurrentOption:=\@classoptionslist\do{%
3490 \@ifundefined{KV@#2@\CurrentOption}%
3491 {}{\edef\@tempa{\@tempa,\CurrentOption,}}}%
3492 \ifnum\@tempcnta=\z@
3493 \edef\@tempa{\@tempa,\@ptionlist{\@currname.\@currext}}%
3494 \fi
3495 \fi
3496 \edef\@tempa{\noexpand\setkeys{#2}{\@tempa}}%
3497 \@tempa
3498 \AtEndOfPackage{\let\@unprocessedoptions\relax}}%
3499 % \end{macrocode}
3500 % \end{macro}
3501 % \begin{macrocode}
3502 \def\Gm@setkeys{\setkeys{Gm}}%
3503 % \end{macrocode}
3504 % \begin{macro}{\Gm@processconf}
3505 % \cs{ExecuteOptions} is replaced with \cs{Gm@setkey} to make it
3506 % possible to deal with '\meta{key}=\meta{value}' as its argument.
3507 % \begin{macrocode}
3508 \def\Gm@processconfig{%
3509 \let\Gm@origExecuteOptions\ExecuteOptions
3510 \let\ExecuteOptions\Gm@setkeys
3511 \InputIfFileExists{geometry.cfg}{}{}
3512 \let\ExecuteOptions\Gm@origExecuteOptions}%
3513 % \end{macrocode}
3514 % \end{macro}
3515 %
3516 % The original page layout before loading \Gm\ is saved here.
3517 % |\Gm@restore@org| is defined here for |reset| option.
3518 % \begin{macrocode}
3519 \Gm@save
3520 \edef\Gm@restore@org{\Gm@restore}%
3521 \Gm@initall
3522 % \end{macrocode}
3523 % Processing config file.
3524 % \begin{macrocode}
3525 \Gm@processconfig
3526 % \end{macrocode}
3527 % The optional arguments to \cs{documentclass} are processed here.
3528 % \begin{macrocode}
3529 \ProcessOptionsKV[c]{Gm}%
3530 % \end{macrocode}
3531 % Paper dimensions given by class default are stored.
3532 % \begin{macrocode}
3533 \Gm@setdefaultpaper
3534 % \end{macrocode}
3535 % The optional arguments to \cs{usepackage} are processed here.
3536 % \begin{macrocode}
3537 \ProcessOptionsKV[p]{Gm}%
3538 % \end{macrocode}
3539 % Actual settings and calculation for layout dimensions are processed.
3540 % \begin{macrocode}
3541 \Gm@process
3542 % \end{macrocode}
3543 %
3544 % \begin{macro}{\AtBeginDocument}
3545 % The processes for |verbose|, |showframe| and drivers are added to
3546 % |\AtBeginDocument|.
3547 % |\Gm@restore@org| is redefined here with the paper size specified
3548 % in the preamble for |\newgeometry| to use it. This should be done
3549 % before magnifying the paper size with |\mag| because the layout
3550 % calculation would be affected by changing the paper size.
3551 % \begin{macrocode}
3552 \AtBeginDocument{%
3553 \Gm@savelength{paperwidth}%
3554 \Gm@savelength{paperheight}%
3555 \edef\Gm@restore@org{\Gm@restore}%
3556 % \end{macrocode}
3557 % The original paper size is used if |resetpaper|.
3558 % \begin{macrocode}
3559 \ifGm@resetpaper
3560 \edef\Gm@pw{\Gm@orgpw}%
3561 \edef\Gm@ph{\Gm@orgph}%
3562 \else
3563 \edef\Gm@pw{\the\paperwidth}%
3564 \edef\Gm@ph{\the\paperheight}%
3565 \fi
3566 % \end{macrocode}
3567 % If |pass| is not set, the paper size is multiplied
3568 % according to the specified |mag|.
3569 % \begin{macrocode}
3570 \ifGm@pass\else
3571 \ifnum\mag=\@m\else
3572 \Gm@magtooffset
3573 \divide\paperwidth\@m
3574 \multiply\paperwidth\the\mag
3575 \divide\paperheight\@m
3576 \multiply\paperheight\the\mag
3577 \fi
3578 \fi
3579 % \end{macrocode}
3580 % Checking the driver options.
3581 % \begin{macrocode}
3582 \Gm@detectdriver
3583 % \end{macrocode}
3584 % If |xetex| and |\pdfpagewidth| is defined,
3585 % |\pdfpagewidth| and |\pdfpageheight| would be set.
3586 % \begin{macrocode}
3587 \ifx\Gm@driver\Gm@xetex
3588 \@ifundefined{pdfpagewidth}{}{%
3589 \setlength\pdfpagewidth{\Gm@pw}%
3590 \setlength\pdfpageheight{\Gm@ph}}%
3591 \ifnum\mag=\@m\else
3592 \ifx\Gm@truedimen\Gm@true
3593 \setlength\paperwidth{\Gm@pw}%
3594 \setlength\paperheight{\Gm@ph}%
3595 \fi
3596 \fi
3597 \fi
3598 % \end{macrocode}
3599 % If |pdftex| is set to |true|, pdf-commands are set properly.
3600 % To avoid |pdftex| magnification problem, \cs{pdfhorigin} and
3601 % \cs{pdfvorigin} are adjusted for \cs{mag}.
3602 % \begin{macrocode}
3603 \ifx\Gm@driver\Gm@pdftex
3604 \@ifundefined{pdfpagewidth}{}{%
3605 \setlength\pdfpagewidth{\Gm@pw}%
3606 \setlength\pdfpageheight{\Gm@ph}}%
3607 \ifnum\mag=\@m\else
3608 \@tempdima=\mag sp%
3609 \@ifundefined{pdfhorigin}{}{%
3610 \divide\pdfhorigin\@tempdima
3611 \multiply\pdfhorigin\@m
3612 \divide\pdfvorigin\@tempdima
3613 \multiply\pdfvorigin\@m}%
3614 \ifx\Gm@truedimen\Gm@true
3615 \setlength\paperwidth{\Gm@pw}%
3616 \setlength\paperheight{\Gm@ph}%
3617 \fi
3618 \fi
3619 \fi
3620 % \end{macrocode}
3621 % If |luatex| is set to |true|, pdf-commands are set properly.
3622 % To avoid |luatex| magnification problem, \cs{horigin} and
3623 % \cs{vorigin} are adjusted for \cs{mag}.
3624 % \begin{macrocode}
3625 \ifx\Gm@driver\Gm@luatex
3626 \setlength\pagewidth{\Gm@pw}%
3627 \setlength\pageheight{\Gm@ph}%
3628 \ifnum\mag=\@m\else
3629 \@tempdima=\mag sp
3630 \edef\Gm@horigin{\pdfvariable horigin}%
3631 \edef\Gm@vorigin{\pdfvariable vorigin}%
3632 \divide\Gm@horigin\@tempdima
3633 \multiply\Gm@horigin\@m
3634 \divide\Gm@vorigin\@tempdima
3635 \multiply\Gm@vorigin\@m
3636 \ifx\Gm@truedimen\Gm@true
3637 \setlength\paperwidth{\Gm@pw}%
3638 \setlength\paperheight{\Gm@ph}%
3639 \fi
3640 \fi
3641 \fi
3642 % \end{macrocode}
3643 % With V\TeX{} environment, V\TeX{} variables are set here.
3644 % \begin{macrocode}
3645 \ifx\Gm@driver\Gm@vtex
3646 \@ifundefined{mediawidth}{}{%
3647 \mediawidth=\paperwidth
3648 \mediaheight=\paperheight}%
3649 \ifvtexdvi
3650 \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
3651 \fi
3652 \fi
3653 % \end{macrocode}
3654 % If |dvips| or |dvipdfm| is specified, paper size is embedded in dvi
3655 % file with \cs{special}. For dvips, a landscape correction is added
3656 % because a landscape document converted by dvips is upside-down in
3657 % PostScript viewers.
3658 % \begin{macrocode}
3659 \ifx\Gm@driver\Gm@dvips
3660 \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
3661 \ifx\Gm@driver\Gm@dvips\ifGm@landscape
3662 \AtBeginDvi{\special{! /landplus90 true store}}%
3663 \fi\fi
3664 % \end{macrocode}
3665 % If |dvipdfm| is specified and \textsf{atbegshi} package in
3666 % `oberdiek' bundle is loaded, \cs{AtBeginShipoutFirst} is used
3667 % instead of \cs{AtBeginDvi} for compatibility with \textsf{hyperref}
3668 % and |dvipdfm| program.
3669 % \begin{macrocode}
3670 \else\ifx\Gm@driver\Gm@dvipdfm
3671 \ifcase\ifx\AtBeginShipoutFirst\relax\@ne\else
3672 \ifx\AtBeginShipoutFirst\@undefined\@ne\else\z@\fi\fi
3673 \AtBeginShipoutFirst{\special{papersize=\the\paperwidth,\the\paperheight}}%
3674 \or
3675 \AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
3676 \fi
3677 \fi\fi
3678 % \end{macrocode}
3679 % Page frames are shipped out when |showframe=true|, cropmarks for |showcrop=true|
3680 % on each page. The \textsf{atbegshi} package is used for overloading |\shipout|.
3681 % \begin{macrocode}
3682 \@tempswafalse
3683 \ifGm@showframe
3684 \@tempswatrue
3685 \else\ifGm@showcrop
3686 \@tempswatrue
3687 \fi\fi
3688 \if@tempswa
3689 \RequirePackage{atbegshi}%
3690 \AtBeginShipout{\setbox\AtBeginShipoutBox=\vbox{%
3691 \baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@
3692 \Gm@pageframes\box\AtBeginShipoutBox}}%
3693 \fi
3694 % \end{macrocode}
3695 % The layout dimensions for \cs{restoregeometry} are saved
3696 % at the end of the \cs{AtBeginDocument}.
3697 % \begin{macrocode}
3698 \Gm@save
3699 \edef\Gm@restore@pkg{\Gm@restore}%
3700 % \end{macrocode}
3701 % The package checks whether or not the marginpars overrun the page,
3702 % if |verbose| and unless |pass|.
3703 % \begin{macrocode}
3704 \ifGm@verbose\ifGm@pass\else\Gm@checkmp\fi\fi
3705 % \end{macrocode}
3706 % |\Gm@showparams| puts the resulting parameters and dimensions
3707 % into the log file. With |verbose|, they are shown on the terminal
3708 % as well.
3709 % \begin{macrocode}
3710 \Gm@showparams{preamble}%
3711 % \end{macrocode}
3712 % The following lines free the memories no longer needed.
3713 % \begin{macrocode}
3714 \let\Gm@pw\relax
3715 \let\Gm@ph\relax
3716 }% end of \AtBeginDocument
3717 % \end{macrocode}
3718 % \end{macro}
3719 %
3720 % \begin{macro}{\geometry}
3721 % The macro \cs{geometry} can be called multiple times
3722 % in the preamble (before |\begin{document}|).
3723 % \begin{macrocode}
3724 \newcommand{\geometry}[1]{%
3725 \Gm@clean
3726 \setkeys{Gm}{#1}%
3727 \Gm@process}%
3728 \@onlypreamble\geometry
3729 % \end{macrocode}
3730 % \end{macro}
3731 % \begin{macro}{\Gm@changelayout}
3732 % The macro, which can be called from |\newgeometry|,
3733 % |\restoregeometry| and |\loadgeometry|, changes the layout
3734 % in the middle of the document.
3735 % \begin{macrocode}
3736 \DeclareRobustCommand\Gm@changelayout{%
3737 \setlength{\@colht}{\textheight}
3738 \setlength{\@colroom}{\textheight}%
3739 \setlength{\vsize}{\textheight}
3740 \setlength{\columnwidth}{\textwidth}%
3741 \if@twocolumn%
3742 \advance\columnwidth-\columnsep
3743 \divide\columnwidth\tw@%
3744 \@firstcolumntrue%
3745 \fi%
3746 \setlength{\hsize}{\columnwidth}%
3747 \setlength{\linewidth}{\hsize}}%
3748 % \end{macrocode}
3749 % \end{macro}
3750 % \begin{macro}{\newgeometry}
3751 % The macro |\newgeometry|, which changes the layout,
3752 % can be used only in the document.
3753 % It would reset the options specified in the preamble except for
3754 % paper size options and |\mag|.
3755 % \begin{macrocode}
3756 \newcommand{\newgeometry}[1]{%
3757 \clearpage
3758 \Gm@restore@org
3759 \Gm@initnewgm
3760 \Gm@newgmtrue
3761 \setkeys{Gm}{#1}%
3762 \Gm@newgmfalse
3763 \Gm@process
3764 \ifnum\mag=\@m\else\Gm@magtooffset\fi
3765 \Gm@changelayout
3766 \Gm@showparams{newgeometry}}%
3767 % \end{macrocode}
3768 % \end{macro}
3769 % \begin{macro}{\restoregeometry}
3770 % The macro restores the resulting layout specified in the preamble,
3771 % namely the first-page layout right after |\begin{document}|.
3772 % \begin{macrocode}
3773 \newcommand{\restoregeometry}{%
3774 \clearpage
3775 \Gm@restore@pkg
3776 \Gm@changelayout}%
3777 % \end{macrocode}
3778 % \end{macro}
3779 % \begin{macro}{\savegeometry}
3780 % The macro saves the layout with the name specified
3781 % with the argument. The saved layout can be loaded
3782 % with |\loadgeometry{|\meta{name}|}|.
3783 % \begin{macrocode}
3784 \newcommand*{\savegeometry}[1]{%
3785 \Gm@save
3786 \expandafter\edef\csname Gm@restore@@#1\endcsname{\Gm@restore}}%
3787 % \end{macrocode}
3788 % \end{macro}
3789 % \begin{macro}{\loadgeometry}
3790 % The macro loads the layout saved with |\savegeometry{|\meta{name}|}|.
3791 % If the name is not found, the macro would warn it and
3792 % do nothing for the layout.
3793 % \begin{macrocode}
3794 \newcommand*{\loadgeometry}[1]{%
3795 \clearpage
3796 \@ifundefined{Gm@restore@@#1}{%
3797 \PackageError{geometry}{%
3798 \string\loadgeometry : name `#1' undefined}{%
3799 The name `#1' should be predefined with \string\savegeometry}%
3800 }{\@nameuse{Gm@restore@@#1}%
3801 \Gm@changelayout}}%
3802 %</package>
3803 % \end{macrocode}
3804 % \end{macro}
3805 %
3806 % \section{Config file}
3807 % In the configuration file |geometry.cfg|, one can use
3808 % \cs{ExecuteOptions} to set the site or user default settings.
3809 % \begin{macrocode}
3810 %<*config>
3811 %<<SAVE_INTACT
3812
3813 % Uncomment and edit the line below to set default options.
3814 %\ExecuteOptions{a4paper}
3815
3816 %SAVE_INTACT
3817 %</config>
3818 % \end{macrocode}
3819 %
3820 % \section{Sample file}
3821 % Here is a sample document for the \Gm\ package.
3822 % \begin{macrocode}
3823 %<*samples>
3824 %<<SAVE_INTACT
3825 \documentclass[12pt]{article}% uses letterpaper by default
3826 % \documentclass[12pt,a4paper]{article}% for A4 paper
3827 %---------------------------------------------------------------
3828 % Edit and uncomment one of the settings below
3829 %---------------------------------------------------------------
3830 % \usepackage{geometry}
3831 % \usepackage[centering]{geometry}
3832 % \usepackage[width=10cm,vscale=.7]{geometry}
3833 % \usepackage[margin=1cm, papersize={12cm,19cm}, resetpaper]{geometry}
3834 % \usepackage[margin=1cm,includeheadfoot]{geometry}
3835 \usepackage[margin=1cm,includeheadfoot,includemp]{geometry}
3836 % \usepackage[margin=1cm,bindingoffset=1cm,twoside]{geometry}
3837 % \usepackage[hmarginratio=2:1, vmargin=2cm]{geometry}
3838 % \usepackage[hscale=0.5,twoside]{geometry}
3839 % \usepackage[hscale=0.5,asymmetric]{geometry}
3840 % \usepackage[hscale=0.5,heightrounded]{geometry}
3841 % \usepackage[left=1cm,right=4cm,top=2cm,includefoot]{geometry}
3842 % \usepackage[lines=20,left=2cm,right=6cm,top=2cm,twoside]{geometry}
3843 % \usepackage[width=15cm, marginparwidth=3cm, includemp]{geometry}
3844 % \usepackage[hdivide={1cm,,2cm}, vdivide={3cm,8in,}, nohead]{geometry}
3845 % \usepackage[headsep=20pt, head=40pt,foot=20pt,includeheadfoot]{geometry}
3846 % \usepackage[text={6in,8in}, top=2cm, left=2cm]{geometry}
3847 % \usepackage[centering,includemp,twoside,landscape]{geometry}
3848 % \usepackage[mag=1414,margin=2cm]{geometry}
3849 % \usepackage[mag=1414,margin=2truecm,truedimen]{geometry}
3850 % \usepackage[a5paper, landscape, twocolumn, twoside,
3851 % left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt,
3852 % bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
3853 % columnsep=1cm,verbose]{geometry}
3854 %---------------------------------------------------------------
3855 % No need to change below
3856 %---------------------------------------------------------------
3857 \geometry{verbose,showframe}% the options appended.
3858 \usepackage{lipsum}% for dummy text of 150 paragraphs
3859 \newcommand\mynote{\marginpar[\raggedright
3860 A sample margin note in the left side.]%
3861 {\raggedright A sample margin note.}}%
3862 \newcommand\myfootnote{\footnote{This is a sample footnote text.}}
3863 \begin{document}
3864 \lipsum[1-2]\mynote\lipsum[3-4]\mynote
3865 \lipsum[5-11]\mynote\lipsum[12]\myfootnote
3866 \lipsum[13-22]\mynote\lipsum[23-32]
3867 \end{document}
3868 %SAVE_INTACT
3869 %</samples>
3870 % \end{macrocode}
3871 %
3872 % \Finale
3873 %
3874 \endinput