% \iffalse meta-comment
%% geometry.dtx Copyright (C) 1996,1997
%% Hideo Umeki (hideo.umeki@toshiba.co.jp)
%%
%  Distributed under the terms of the GNU General Public License.
%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{geometry}[1997/09/09 v1.08 Page Geometry]
%<*driver>
\documentclass{ltxdoc}
\usepackage{geometry}
\geometry{hdivide={1.7in,*,2cm}, vmargin=.5in, nohead}
\begin{document}
 \GetFileInfo{geometry.sty}
 \title{The \textsf{geometry} package}
 \author{Hideo Umeki\\
         \texttt{hideo.umeki@toshiba.co.jp}}
 \date{\filedate ~(\fileversion)}
 \maketitle
 %\OnlyDescription% Comment out to print Section "The Code" as well.
 \DocInput{geometry.dtx}
\end{document}
%</driver>
% \fi
% \CheckSum{1111}
%
% \changes{v1.00}{1996/05/31}{major changes by the `keyval' interface}
% \changes{v1.01}{1996/06/03}%
%                {bugs fixed for paper setting and option processing}
% \changes{v1.01}{1996/06/03}{geometry.cfg file inclusion}
% \changes{v1.01}{1996/06/03}{dvips option added}
% \changes{v1.02}{1996/06/07}{definition for reset option changed}
% \changes{v1.02}{1996/06/07}%
%                {instructions for reset and dvips options revised}
% \changes{v1.03}{1996/06/25}{document refined}
% \changes{v1.03}{1996/07/17}{compatible with calc package}
% \changes{v1.04}{1996/08/05}{bug fixed that papersize= had no effect%
%       when papertype was given in geometry.cfg or as a package option}
% \changes{v1.05}{1997/02/17}{definition for dvips option changed}
% \changes{v1.06}{1997/04/16}{reversemarginpar supported}
% \changes{v1.07}{1997/07/05}{dvips modified, pdftex supported,%
%    \texttt{a0paper} and \texttt{b0paper} added, and document refined}
% \changes{v1.07}{1997/07/08}{the code refined}
% \changes{v1.08}{1997/07/18}{geometry.cfg included in dtx}
% \changes{v1.08}{1997/09/08}{The catcode of exclamation mark changed}
%
% \begin{abstract}
%   This package provides an easy and flexible user interface to
%   customize page layout. It impliments auto-centering and auto-balancing
%   mechanisms so that the users have only to give the least description
%   for the page layout. 
%   This package requires the \textsf{keyval} package\footnote{%
%   CTAN:\texttt{macros/latex/packages/graphics}}.
% \end{abstract}
%
% \newif\ifmulticols
% \IfFileExists{multicol.sty}{\multicolstrue}{}
% \ifmulticols
% \addtocontents{toc}{\protect\begin{multicols}{2}}
% \fi
% {\parskip 0pt
% \tableofcontents
% }
%
% \newenvironment{key}[2]{\expandafter\macro\expandafter{`#2'}}%
%   {\endmacro}
% \providecommand\argii[2]{%
%   {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`,{}}\meta{#2}{\ttfamily%
%   \char`\}}}
% \providecommand\vargii[2]{%
%   {\ttfamily\char`\{}#1{\ttfamily\char`,{}}#2{\ttfamily\char`\}}}
% \providecommand\argiii[3]{%
%   {\ttfamily\char`\{}\meta{#1}{\ttfamily\char`,{}}\meta{#2}{\ttfamily%
%   \char`,{}}\meta{#3}{\ttfamily\char`\}}}
% \providecommand\vargiii[3]{%
%   {\ttfamily\char`\{}#1{\ttfamily\char`,{}}#2{\ttfamily%
%   \char`,{}}#3{\ttfamily\char`\}}}
% \providecommand\OR{\ \strut\vrule width .4pt\ }
% \providecommand\len[1]{\textsf{#1}}
% \newenvironment{Options}%
%  {\begin{list}{}{%
%     \renewcommand{\makelabel}[1]{\texttt{##1}\hfil}%
%     \setlength{\itemsep}{-.5\parsep}
%     \settowidth{\labelwidth}{\texttt{xxxxxxxxxx\space}}%
%     \setlength{\leftmargin}{\labelwidth}%
%     \addtolength{\leftmargin}{\labelsep}}%
%     \raggedright}
%  {\end{list}}
%
% \section{Introduction}
%
% To set dimensions for page layout in \LaTeX\ is not straightforward. 
% You will find a gap between comprehensible layout parameters and the
% \LaTeX\ dimensions to be specified, when you have to write a document
% according to the following layout instructions, for example:
% \begin{quote}
% The total allowable width of the text area is 6.5 inches wide by 8.75
% inches high. The first line on each page should begin 1.2 inches from
% the top edge of the page. The left margin should be 0.4 inch from 
% the left edge. 
% \end{quote}
% In this case, you need to specify 
% \begin{quote}
% \begin{verbatim}
%  \setlength\textwidth{6.5in}
%  \setlength\textheight{8.75in}
%  \setlength\topmargin{0.2in}
%  \setlength\oddsidemargin{-0.6in}
%  \setlength\headheight{0pt}
%  \setlength\headsep{0pt}
% \end{verbatim}
% \end{quote}
%
% This package allows \LaTeXe\ users to customize the page layout
% (page size) in an easier way. One can realize the above page layout
% by putting, for example,
% \begin{quote}
% \begin{verbatim}
%  \usepackge{geometry}
%  \geometry{body={6.5in,8.75in}, top=1.2in, left=0.4in, nohead}
% \end{verbatim}
% \end{quote}
% in the preamble.
%
% The name \textsl{geometry} comes from the \texttt{-geometry} option
% used for specifying a size and location of a window in X Window System.
% In the system one can set a window like 
% \begin{quote}
%  \texttt{-geometry 150x200+8-10}
% \end{quote}
% Setting a window on the root window corresponds to setting a total body
% (printable area) on the paper in this package, for example,
% \begin{quote}
%  |\geometry{ width=6in, height=8in, left=0.8in, bottom=1in }|
% \end{quote}
%
% The previous version of the \textsf{geometry} package was called
% \textsf{pagesize}, but was renamed because the package is totally 
% rewritten to use the \textsf{keyval} interface and to introduce a new
% algorithm for determining layout parameters. As a result, the package
% provides more flexible user interface and new specification for page
% layout while it does not work in the obsolete \LaTeX209 environment.
% 
% \section{Page Geometry}
%
% To realize a straightforward setting for page layout, the following page 
% structure is introduced: A paper contains a total body (printable area)
% and margins.
% The total body consists of a body, a header, a footer and a marginal
% note which is optional. There are four margins: left-, right-,
% top- and bottom-margin. 
% \begin{quote}
%   \begin{tabular}{rcl}
%      \len{paper}&:&\len{total-body} (printable area) and \len{margins}\\
% \len{total-body}&:&\len{head}, \len{body}, \len{foot} 
%                    \len{marginal notes} (optional)\\
%    \len{margins}&:&\len{left-}, \len{right-}, \len{top-}
%    and \len{bottom-margin}
%   \end{tabular}
% \end{quote}
% Each margin is measured from the corresponding edge of a paper. 
% For example, left-margin means a horizontal distance between 
% the left edge of a paper and that of a body.
% Therefore the left-margin and top-margin defined in the \textsf{geometry}
% package are different from the ordinary \LaTeX{} dimensions
% \cs{leftmargin} and \cs{topmargin}.
% A body is also called a text area, size of which can be modified by
% \cs{textwidth} and \cs{textheight}. 
%
% The layout parts and the corresponding dimension names in this package
% are listed below.
% \begin{quote}
%   \begin{tabular}{r@{\hspace{2.5em}}ll}
%                 & \multicolumn{2}{c}{Dimension names}\\
%    Parts\hfil\null & \hfil Horizontal & \hfil Vertical \\\hline
%   \noalign{\vskip.2em}
%     \len{paper}       &\texttt{paperwidth} &\texttt{paperheight}\\
%     \len{total-body}  &\texttt{width} or \texttt{totalwidth} 
%                       &\texttt{height} or \texttt{totalheight}\\
%     \len{body}        &\texttt{textwidth}  & \texttt{textheight}\\
%   [.2em]\hline\noalign{\vskip.2em}
%   \len{left margin}   &\texttt{left} or \texttt{lmargin}   & \hfil---\\
%   \len{right margin}  &\texttt{right} or  \texttt{rmargin} &\hfil---\\
%   \len{top margin}    &\hfil--- &\texttt{top} or \texttt{tmargin}\\
%   \len{bottom margin} &\hfil--- &\texttt{bottom} or \texttt{bmargin}\\
%   [.2em]\hline\noalign{\vskip.2em}
%   \len{marginal notes}&\vtop{\hbox{\texttt{marginparwidth} and}%
%                        \hbox{\texttt{marginparsep}}} & \hfil---\\[.3em] 
%            \len{head} &\hfil---&\vtop{\hbox{\texttt{headheight} and}
%                                 \hbox{\texttt{headsep}}}\\[.4em]
%            \len{foot} &\hfil---&\texttt{footskip}\\
%   \noalign{\vskip.2em}\hline
%   \end{tabular}
% \end{quote}
%
% The dimensions for paper, total body and margins have the following
% relations.
% \[ \begin{array}{rcl}
%  \texttt{paperwidth} &=&\texttt{left}+\texttt{width}+\texttt{right}\\
%  \texttt{paperheight}&=&\texttt{top}+\texttt{height}+\texttt{bottom}\\[1em]
% \end{array} \]
%
% Suppose that the paper size is pre-defined, if two dimensions out of
% three in the right-hand side of each equation are given, the remnant
% dimension will be determined automatically. The partitioning patterns
% in each direction with auto-centering and auto-balancing mechanism
% are shown below.
% \begin{center}
% \def\AST{\texttt{*}}
% \begin{tabular}{cccccccl}
% \multicolumn{3}{c}{Settings}& &\multicolumn{3}{c}{Results}\\
% \noalign{\vspace{.1em}}
% \cline{1-3}\cline{5-7}
% \parbox{3em}{\hfil\len{left}}&\parbox{3em}{\hfil\len{width}}&
% \parbox{3em}{\hfil\len{right}}&&%
% \parbox{3em}{\hfil\len{left}}&\parbox{3em}{\hfil\len{width}}&
% \parbox{3em}{\hfil\len{right}}&\\
% \cline{1-3}\cline{5-7}
% \len{top}&\len{height}&\len{bottom}&&%
% \len{top}&\len{height}&\len{bottom}&\\
% \noalign{\vspace{.1em}}
% \cline{1-3}\cline{5-7}
% \AST     & \AST & \AST     && $m$      & $\ell$   & $m$      &Default\\
% $\alpha$ & \AST & \AST     && $\alpha$ & $R_1$    & $\alpha$ &Balancing\\
% \AST     & \AST & $\alpha$ && $\alpha$ & $R_1$    & $\alpha$ &Balancing\\
% \AST     & $\alpha$ & \AST &$\Longrightarrow$%
%                            & $R_2$    & $\alpha$ & $R_2$    &Centering\\
% $\alpha$ & \AST     & $\beta$ && $\alpha$ & $R_3$    & $\beta$ &\\
% $\alpha$ & $\beta$  & \AST    && $\alpha$ & $\beta$  & $R_3$   &\\
% \AST     & $\alpha$ & $\beta$ && $R_3$    & $\alpha$ & $\beta$ &\\
% $\alpha$ & $\gamma$ & $\beta$ && $\alpha$ & $R_3$    & $\beta$ &
%                                                           Margins win.\\
% \cline{1-3}\cline{5-7}
% \end{tabular}
% \end{center}
% The mark `\texttt{*}' denotes the parameter not specified, which means
% the parameter will be automatically determined later.
% $R_{n}$ ($n$=$1,2,3$) are remnant lengths which can be determined by
% $\alpha$, $\beta$ and $L$ (\texttt{paperwidth} or \texttt{paperheight}) :
% \[ \begin{array}{rcl}
%    R_1&=&L-2\alpha\\
%    R_2&=&(L-\alpha)/2\\
%    R_3&=&L-\alpha-\beta
% \end{array}\]
% If none of three dimensions is specified in each direction, the default
% setting is used: $\ell$ and $m$ in horizontal direction are 80\% and
% 10\% of \texttt{paperwidth} respectively, 90\% and 5\% of
% \texttt{paperheight} vertically.
%
% The dimensions of the total body, \texttt{width} and \texttt{height},
% are defined as follows:
% \[ \begin{array}{rcl}
%   \texttt{width} &:=&\texttt{textwidth}\quad ( + \texttt{marginparsep} +
%                      \texttt{marginparwidth} )\\
%   \texttt{height}&:=&\texttt{textheight} + \texttt{headheight} +
%                      \texttt{headsep} + \texttt{footskip}
% \end{array} \]
% Each of the seven dimensions in the right-hand side of the above
% equations corresponds to the ordinary \LaTeX\ control sequence with the
% same name.
% You can include dimensions for marginal notes (\texttt{marginparsep}
% and \texttt{marginparwidth}) in the \texttt{width} by \texttt{includemp}
% option. The dimensions for a header and a footer can be also controlled
% by options (modes) as well as direct specification of lengths.
% These options are summarized below.
% \begin{center}
% \begin{tabular}{l@{\hspace{2em}}p{11cm}}
%  \hfil Modes  &   \hfil Effects \\\hline
%  \texttt{nohead}    & sets \texttt{headheight=0pt, headsep=0pt}
%                       at the end.\\
%  \texttt{nofoot}    & sets \texttt{footskip=0pt} at the end.\\
%  \texttt{noheadfoot}& equals \texttt{nohead} and \texttt{nofoot}\\
%  \texttt{includemp} & takes account of the dimensions for 
%                       marginal notes\newline
%                       when determining \texttt{width}:\newline
%                       \texttt{width} := \texttt{textwidth} + 
%                      \texttt{marginparsep} + \texttt{marginparwidth}\\
%  \texttt{reversemp} & makes the marginal notes appear in the left
%                       margin\newline and sets \texttt{includemp}
%                       unless \texttt{includemp=false} exists.\newline
%               \texttt{reversemarginpar} results in the same effect.\\
% \hline
% \end{tabular}
% \end{center}
% \texttt{includemp} is forced \texttt{true} if either 
% \texttt{marginparwidth} or \texttt{marginparsep} is explicitly set in
% \cs{geometry}. See also Section~\ref{sec:singvalued-opts}.
%
% Figure~\ref{fig:layout} illustrates the dimension names for page
% geometry.
% \begin{figure}[!hbt]
% \centering
% {\unitlength=.65pt
% \begin{picture}(450,250)(0,-10)
% \put(20,0){\framebox(170,230)[tr]{\textsl{paper}}}
% \put(50,30){\framebox(120,170)[tr]{\textsl{total body}}}
% \put(55,30){\makebox(0,170)[l]{\texttt{height}}}
% \put(50,35){\makebox(120,0)[bc]{\texttt{width}}}
% \put(50,-20){\makebox(120,0)[bc]{\texttt{paperwidth}}}
% \put(10,30){\makebox(0,170)[r]{\texttt{paperheight}}}
% \put(90,200){\makebox(0,30)[lc]{\texttt{top}}}
% \put(90,0){\makebox(0,30)[lc]{\texttt{bottom}}}
% \put(10,50){\makebox(0,0)[r]{\texttt{left}}}
% \put(200,50){\makebox(0,0)[l]{\texttt{right}}}
% \put(80,230){\vector(0,-1){30}}
% \put(80,30){\vector(0,-1){30}}
% \put(80,200){\vector(0,1){30}}
% \put(80,0){\vector(0,1){30}}
% \put(20,50){\vector(1,0){30}}
% \put(50,50){\vector(-1,0){30}}
% \put(170,50){\vector(1,0){20}}
% \put(190,50){\vector(-1,0){20}}
% \multiput(170,30)(5,0){22}{\line(1,0){2}}
% \multiput(170,200)(5,0){22}{\line(1,0){2}}
% \put(280,30){\framebox(120,170){}}
% \put(280,180){\line(1,0){120}}
% \put(280,170){\line(1,0){120}}
% \put(280,50){\line(1,0){120}}
% \put(280,210){\makebox(120,0)[br]{\textsl{total body}}}
% \put(280,55){\makebox(120,0)[bc]{\texttt{textwidth}}}
% \put(410,190){\makebox(0,0)[l]{\texttt{headheight}}}
% \put(410,170){\makebox(0,0)[l]{\texttt{headsep}}}
% \put(410,110){\makebox(0,0)[l]{\texttt{textheight}}}
% \put(410,40){\makebox(0,0)[l]{\texttt{footskip}}}
% \put(280,180){\makebox(120,20)[bc]{\textsl{head}}}
% \put(280,40){\makebox(120,140)[c]{\textsl{body}}}
% \put(280,30){\makebox(120,10)[c]{\textsl{foot}}}
% \multiput(380,30)(0,5){34}{\line(0,1){1.5}}
% \multiput(375,30)(0,5){34}{\line(0,1){1.5}}
% \put(375,5){\makebox(0,0)[bl]{(\texttt{marginparsep})}}
% \put(385,-10){\makebox(0,0)[bl]{(\texttt{marginparwidth})}}
% \end{picture}}
% \caption[Dimension names for page geometry]{%
% \begin{minipage}[t]{.7\textwidth}\raggedright
%   Dimension names for page geometry. 
%   If \texttt{includemp} is \texttt{false} (default),
%   \texttt{width}=\texttt{textwidth}.
% \end{minipage}}
% \label{fig:layout}
% \end{figure}
%
% \section{User Interface}
%
% \subsection{General Features}
%
% The \cs{geometry} macro takes one mandatory argument which specifies
% parameters for the page layout.
% The argument consists of a list of comma-separated options, which are
% specified by the \textsf{keyval} interface: \meta{key}=\meta{value}.
% The \cs{geometry} argument has the following features:
% \begin{itemize}\itemsep=0pt
% \item Multiple lines are allowed. (But blank lines are not allowed.)
% \item Any spaces between words are ignored.
% \item Options are basically order-independent.\\
% (There are some exceptions. See Section~\ref{sec:order-depend}
%  for details.)
% \end{itemize}
%  For example,
% \begin{quote}
% |\geometry{  a5paper ,  hmargin = { 3cm,|\\
% |                .1\w } , height|\\
% |         =  10in }|
% \end{quote}
% is equivalent to 
% \begin{quote}
%   |\geometry{height=10in,a5paper,hmargin={3cm,0.1\w}}|
% \end{quote}
% Note that when a value has a sub-list of values (e.g.,
% |hmargin={3cm,0.1\w}|), the order of values in the sub-list is 
% significant.
% Here \cs{w} and \cs{h} are defined as \texttt{paperwidth} and 
% \texttt{paperheight} respectively in the \cs{geometry} argument.
%
% The \textsf{geometry} package supports the \textsf{calc} 
% package\footnote{CTAN:\texttt{macros/latex/contrib/support/calc}}.
% For example,
% \begin{quote}
%   |\usepackage{calc,geometry}|\\
%   |\geometry{hmargin=\w/15+10pt}|
% \end{quote}
%
% \subsection{Option Types}
% There are five types of options:
% \begin{enumerate}\itemsep=0pt
%
% \item \textbf{Boolean type}
%
%    takes a boolean value (\texttt{true} or \texttt{false}). If no value,
%    \texttt{true} is set for default.
%    \begin{quote}
%       \meta{key}\texttt{=}\texttt{true}\OR\texttt{false}.\\
%       \meta{key} with no value is equivalent to 
%       \meta{key}\texttt{=}\texttt{true}.
%    \end{quote}
%    \textit{Examples:}~ \texttt{verbose=true}, \texttt{nohead}, 
%    \texttt{twoside=false}.\\
%    Paper name is the exception. The preferred paper name should be set
%    with no values. Whatever value is given, it is ignored. For
%    instance, \texttt{a4paper=XXX} is equivalent to \texttt{a4paper}.
%
% \item \textbf{Single-valued type}
%
%    takes a mandatory value, namely dimension:
%    \begin{quote}
%    \meta{key}\texttt{=}\meta{value}.
%    \end{quote}
%    \textit{Examples:}~ \texttt{width=8in}, \texttt{left=1.25in},
%    \texttt{footskip=1cm}, |height=.86\h|.
%
% \item \textbf{Two-valued type}
%
%    takes a pair of comma-separated values in braces. The two values can
%    be shortened to one value if they are identical.
%    \begin{quote}
%    \meta{key}\texttt{=}\argii{value1}{value2}.\\
%    \meta{key}\texttt{=}\meta{value} is equivalent to 
%              \meta{key}\texttt{=}\argii{value}{value}.
%    \end{quote}
%    \textit{Examples:}~ |hmargin={1.5in,1in}|, \texttt{scale=0.8},
%    |body={7in,10in}|.
%
% \item \textbf{Three-valued type}
%
%    takes three mandatory, comma-separated values in braces.
%    \begin{quote}
%    \meta{key}\texttt{=}\argiii{value1}{value2}{value3}
%    \end{quote}
%    Each value must be a dimension or null. When you give an empty value
%    or `\texttt{*}', it means null and leaves the appropriate value 
%    to the auto-calculation mechanism. One needs to specify at least one
%    dimension, typically two dimensions. You can set nulls for all the 
%    values, but it makes no sense.
%    \textit{Examples:}\\
%    \hspace*{2em} |hdivide={2cm,*,1cm}|, |vdivide={3cm,19cm, }|,
%                   |divide={1in,*,1in}|.
% \end{enumerate}
%
% \section{Option list}
%
% \subsection{Boolean Options}
% 
% Boolean options are also called `modes'. One can change various
% modes of page geometry. These options can appear not only in the
% argument of \cs{geometry} but also in the package option list of
% geometry with no values like,
% \begin{quote}
%   |\usepackage[verbose,landscape]{geometry}|
% \end{quote}
% which is equivalent to 
% \begin{quote}
%   |\usepackage{geometry}|\\
%   |\geometry{verbose,landscape,|$\cdots$|}|
% \end{quote}
% The option \texttt{reset} is the only exception. It should not appear 
% in the package option.
%
% The boolean options are listed below.
% \begin{Options}
% \item[verbose]   typeouts warnings and a list of resulted page
%                  parameters.
% \item[landscape] switches the paper orientation to landscape mode.
% \item[portrait]  switches the paper orientation to portrait mode.
%                  This is equivalent to \texttt{landscape=false}.
% \item[twoside]   switches on two-sided printing.
% \item[includemp] takes account of spaces for margin notes
%                  (\cs{marginparwidth} and \cs{marginparsep})
%                  when adjusting horizontal partition.
% \item[reversemp\OR reversemarginpar]~\\
%                 makes the marginal notes appear in the left margin and
%                 sets \texttt{includemp=true} unless
%                 \texttt{includemp=false} has been set explicitly.
% \item[nohead]   eliminates spaces for the head of page, which is
%                 equivalent to \cs{headheight}\texttt{=0pt} 
%                 and \cs{headsep}\texttt{=0pt}.
% \item[nofoot]   eliminates spaces for the foot of page, which is
%                 equivalent to \cs{footskip}\texttt{=0pt}.
% \item[noheadfoot] eliminates spaces for the head and foot of page, which
%                   is equivalent to \texttt{nohead} and \texttt{nofoot}, 
%                   i.e., \cs{headheight}\texttt{=0pt}, 
%                   \cs{headsep}\texttt{=0pt} and \cs{footskip}\texttt{=0pt}.
% \item[dvips]    writes the paper size in the PostScript output with
%                 the \cs{special} macro. If you use \textsl{dvips} as a 
%                 DVI-to-PS driver, this option is very useful. 
%                 For example, to print a document with 
%                 |\geometry{a3paper,landscape}| on A3 paper in landscape
%                 mode, you don't need options
%                 ``\texttt{-t a3 -t landscape}'' to \textsl{dvips}.
%                 This option is ineffective and forced \texttt{false} if
%                 \texttt{pdftex} is \texttt{true}.
% \item[pdftex] sets \cs{pdfoutput}\texttt{=1} and sets
%        \cs{pdfpagewidth} and \cs{pdfpageheight} properly in the 
%        |\begin{document}| if \textsl{pdflatex} is used. Therefore,
%        when you use \textsl{latex} with \texttt{pdftex=true},
%        this option is ineffective and forced to be \texttt{false}.
%        If |\pdfoutput=1| is already specified, this option is
%        initialized to be \texttt{true}.
%        You can set \texttt{pdftex=false} explicitly to output DVI,
%        not PDF, when \textsl{pdflatex} is used.
%        This option has priority over \texttt{dvips}.
% \item[reset] initializes all the abovementioned modes
%         except \texttt{portrait} to be \texttt{false}. 
%         This option, if necessary, must appear in the
%         \cs{geometry} argument and precede any other options. Note that 
%         \texttt{reset=false} has no effect and cannot cancel the
%         previous \texttt{reset}(\texttt{=true}) if any.
% \item[\vtop{\hbox{a0paper, a1paper, a2paper, a3paper, a4paper, a5paper,}
%             \hbox{b0paper, b1paper, b2paper, b3paper, b4paper, b5paper,}
%             \hbox{letterpaper, executivepaper, legalpaper}}]~\\[1ex] 
%       specifies paper name. They must be used with no values. Note that
%       whatever value (even \texttt{false}) is given to this option, the
%       value will be ignored and the paper name is used. For example, the
%       followings have the same effect: \texttt{a5paper},
%       \texttt{a5paper=true}, \texttt{a5paper=false} and
%       \texttt{a5paper=XXXX}.
% \end{Options}
%
% The boolean options except for \texttt{reset} can be used as package
% options like \\
% |\usepackage[nohead,includemp,landscape]{geometry}|.
%
% Some of the above options may be given as document class options. 
% For example, you can set |\documentclass[a4paper,landscape]{article}|, 
% then \texttt{a4paper} and \texttt{landscape} are interpreted in 
% the \textsf{geometry} package as well.
%
% \subsection{Single-Valued Options}\label{sec:singvalued-opts}
%
% The single-valued options (key names) with a mandatory value are listed
% below.
% \begin{Options}
% \item[paper\OR papername] ~\\ 
%      specifies a paper name. The available paper names are defined in
%      the \textsf{geometry} package.
%      \texttt{paper=}\meta{paper name}. For example
%      \texttt{paper=a4paper}, which is equivalent to just \texttt{a4paper}.
% \item[paperwidth] width of the paper.
%      \texttt{paperwidth=}\meta{paper width}.
% \item[paperheight]  height of the paper. 
%      \texttt{paperheight=}\meta{paper height}.
% \item[width\OR totalwidth] ~\\
%      width of the total body. \texttt{width=}\meta{width} or
%      \texttt{totalwidth=}\meta{width}. This dimension should not be 
%      confused with \texttt{textwidth}. Generally, \texttt{width} $\ge$ 
%      \texttt{textwidth} because \texttt{width} includes the width of
%      marginal notes when \texttt{includemp} or dimensions for marginal
%      notes is set. If \texttt{textwidth} and \texttt{width} are specified
%      at the same time, \texttt{width} is ignored.
% \item[height\OR totalheight] ~\\
%      height of the total body (including header and footer).
%      \texttt{height=}\meta{height} or \texttt{totalheight=}\meta{height}.
%      If both \texttt{textheight} and \texttt{height} are specified,
%      \texttt{height} will be ignored.
% \item[left\OR lmargin]~\\
%      left margin of the total body. In other words,
%      the distance between the left edge of the paper
%      and that of the total body. \texttt{left=}\meta{left margin}.
% \item[right\OR rmargin]~\\ 
%      right margin of the total body. \texttt{right=}\meta{right margin}.
% \item[top\OR tmargin]~\\ top margin of the total body.
%      \texttt{top=}\meta{top margin}.
% \item[bottom\OR bmargin]~\\ 
%      bottom margin of the total body. \texttt{bottom=}\meta{bottom margin}.
% \item[hscale] ratio of width of the total body to \cs{paperwidth}. 
%      \texttt{hscale=}\meta{h-ratio}. \texttt{hscale=0.8} is equivalent to
%      \texttt{width=0.8}\cs{w}, where \cs{w} is defined as an abbreviation of
%      \cs{paperwidth} and valid in the \cs{geometry} argument.
% \item[vscale] ratio of height of the total body to \cs{paperheight}.
%      \texttt{vscale=}\meta{v-ratio}.
%      \texttt{vscale=0.9} is equivalent to \texttt{height=0.9}\cs{h}, 
%      where \cs{h} is an abbreviation of \cs{paperheight} within the
%      \cs{geometry} argument.
% \item[textwidth] modifies \cs{textwidth}, width of text (body).
%      \texttt{textwidth=}\meta{width}.
% \item[textheight] modifies \cs{textheight}, height of text (body).
%      \texttt{textheight=}\meta{height}.
% \item[marginparwidth\OR marginpar]~\\ 
%      modifies \cs{marginparwidth}, width of the marginal notes.
%      When this option is set, \texttt{includemp} is also set \texttt{true}
%      automatically. \texttt{marginparwidth=}\meta{length}.
% \item[marginparsep]~\\ modifies \cs{marginparsep}, separation between body
%      and marginal notes. \texttt{includemp} is also set \texttt{true}
%      automatically.  \texttt{marginparsep=}\meta{length}.
% \item[headheight\OR head]~\\
%      modifies \cs{headheight}, height of header.
%      \texttt{headheight=}\meta{length} or \texttt{head=}\meta{length}.
% \item[headsep] modifies \cs{headsep}, separation between header
%      and text (body).  \texttt{headsep=}\meta{length}.
% \item[footskip\OR foot]~\\ modifies \cs{footskip}, distance separation
%      between baseline of last line of text and baseline of footer.
%      \texttt{footskip=}\meta{length} or \texttt{foot=}\meta{length}.
% \item[hoffset]  modifies \cs{hoffset}. \texttt{hoffset=}\meta{length}.
% \item[voffset]  modifies \cs{voffset}. \texttt{voffset=}\meta{length}.
% \item[twosideshift]~\\ specifies extra space which is added to
%   left-margin of odd-numbered pages and subtracted from that of
%   even-numbered pages. \texttt{twoside} mode is also
%   set. \texttt{twosideshift=}\meta{length}. The default is 20pt.
% \end{Options}
%
% \subsection{Two-Valued Options}
%
% The following list shows keys taking two values in braces or one value
% for short.
% \begin{Options}
% \item[papersize] width and height of the paper.\\
%      \texttt{papersize=}\argii{width}{height} or 
%      \texttt{papersize=}\meta{length}.
% \item[total] width and height of the total body.\\
%      \texttt{total=}\argii{width}{height} or \texttt{total=}\meta{length}.
% \item[body\OR text] textwidth and textheight of the body of page.\\
%      \texttt{body=}\argii{width}{height} or \texttt{body=}\meta{length}.
% \item[scale] ratio of the total body length to the paper's.\\
%      \texttt{scale=}\argii{h-ratio}{v-ratio} or \texttt{scale=}\meta{ratio}.
% \item[hmargin] left and right margin.\\
%      \texttt{hmargin=}\argii{left margin}{right margin} or
%      \texttt{hmargin=}\meta{length}.
% \item[vmargin] top and bottom margin.\\
%      \texttt{vmargin=}\argii{top margin}{bottom margin} or
%      \texttt{vmargin=}\meta{length}.
% \item[margin] \texttt{margin=}\vargii{$\alpha$}{$\beta$} is 
%      equivalent to \texttt{hmargin=}\vargii{$\alpha$}{$\beta$} and 
%      \texttt{vmargin=}\vargii{$\alpha$}{$\beta$}.
%      \texttt{margin=}$\alpha$ is automatically expanded to
%      \texttt{hmargin=}$\alpha$ and \texttt{vmargin=}$\alpha$.
% \item[offset] horizontal and vertical offset.\\
%      \texttt{offset=}\argii{hoffset}{voffset} or 
%      \texttt{offset=}\meta{length}.
% \end{Options}
%
% \subsection{Three-Valued Options}
%
% The keys taking three comma-separated values in braces are listed below.
% \begin{Options}
% \item[hdivide] horizontal partitions (left,width,right).\\
%      \texttt{hdivide=}\argiii{left margin}{width}{right margin}. \\
%      Note that you should not specify all of
%      the three parameters. The best way of using this option is to
%      specify two of three and leave the rest with null(nothing) or
%      `\texttt{*}'. For example, when you set
%      |hdivide={2cm,15cm, }|, the margin from the rightside edge of page
%      will be determined calculating \texttt{paperwidth-2cm-15cm}.
% \item[vdivide] vertical partitions (top,height,bottom).\\
%      \texttt{vdivide=}\argiii{top margin}{height}{bottom margin}.
% \item[divide]  \texttt{divide=}\vargiii{$\alpha$}{$\beta$}{$\gamma$}
%                is interpreted  as 
%              \texttt{hdivide=}\vargiii{$\alpha$}{$\beta$}{$\gamma$}
%              and \texttt{vdivide=}\vargiii{$\alpha$}{$\beta$}{$\gamma$}.
% \end{Options}
%
% \section{Relations Between Options}
%
% \subsection{Option Priority}
%
% \[\begin{array}{l}
% \multicolumn{1}{c}{\textrm{low}\quad\longrightarrow\quad\textrm{high}
% \quad(\textrm{priority}) }\\[1em]
% \bullet\quad
% \left\{\begin{array}{l}\texttt{hscale}\\\texttt{vscale}
%        \end{array}\right\} <
% \left\{\begin{array}{l}\texttt{width}\\\texttt{height}
%        \end{array}\right\} <
% \left\{\begin{array}{l}\texttt{textwidth}\\\texttt{textheight}
%        \end{array}\right\},\\[1.5em]
% \bullet\quad
% \left\{\begin{array}{l}\texttt{head(height)}\\\texttt{headsep}\\
%        \texttt{foot(skip)}\end{array}\right\} <
% \left\{\begin{array}{l}\texttt{nohead}\\\texttt{nofoot}\\
%        \texttt{noheadfoot}\end{array}\right\},\\[2em]
% \bullet\quad
% \texttt{dvips} < \texttt{pdftex}.\\
% \end{array}\]
% For example, 
% \begin{quote}
%  |\geometry{hscale=0.8, textwidth=7in, width=18cm }|
% \end{quote}
% is the same as |\geometry{textwidth=7in}|.
%
% \subsection{Order Dependence}\label{sec:order-depend}
%
% The options are basically order-independent, but there are some
% exceptions.
%
% When redundant, overlap specification is given, the last setting is 
% adopted. For example,
% \begin{quote}
% |\geometry{verbose=true, verbose=false}|
% \end{quote}
% obviously results in \texttt{verbose=false}.
% If you set
% \begin{quote}
% |\geometry{hmargin={3cm,2cm},left=1cm}|
% \end{quote}
% the left-margin is overwritten by |left=1cm|.
% As a result, it is equivalent to 
% \begin{quote}
% |\geometry{hmargin={1cm,2cm}}|
% \end{quote}
% 
% The \texttt{reset} option should precede all other options in the
% \cs{geometry} argument. If you set
% \begin{quote}
% |\geometry{nohead, reset}|
% \end{quote}
% then \texttt{nohead} takes no effect.
%
% \subsection{\textsf{dvips} and \textsf{pdftex}}
%  
% The options \texttt{dvips} and \texttt{pdftex} are provided for driver
% support. They may be used for other packages that support them. In the
% \textsf{geometry} package, the \texttt{pdftex} option has priority over
% \texttt{dvips}. The table below shows relations between the processing
% command, \cs{pdfoutput} and effective values for each driver option.
% \begin{center}
%  \begin{tabular}{llll}
%   command           &\cs{pdfoutput}&\texttt{dvips}&\texttt{pdftex}\\
%   \hline
%   \textsl{latex}    & ---          & T/F           & F\\
%   \textsl{pdflatex} & 1            & F             & T/F\\
%   \textsl{pdflatex} & 0            & (T)/F         & T/F\\
%   \hline
%  \end{tabular}
% \end{center}
% `T/F' means one can choose \texttt{true} or \texttt{false} and the
% choice is effective. `F' means it is always forced \texttt{false}.
% `(T)/F' denotes that if \texttt{pdftex} is \texttt{false} 
% the choice is effective, but otherwise it is forced \texttt{false}.
%
% \section{Default Settings}
%
% \subsection{Page Size}
%
% Once you write |\usepackage{geometry}| in the preamble, the package will 
% perform the default layout, namely |scale={0.8, 0.9}|, by internal execution
% of |\geometry{}|.
%
% \subsection{Default Options}
%
% You can set up a configuration file to make some boolean options
% effective in default.
% To do this, produce a file \texttt{geometry.cfg} ( like 
% \texttt{graphics.cfg} of graphics package) containing, for example, 
% \begin{quote}
% |\ExecuteOptions{a4paper,dvips}|
% \end{quote}
% and install it to the TEXINPUTS directory with \texttt{geometry.sty}.
%
% \section{Examples}
%
% \begin{itemize}
% \item Set the width of the total body to be 70\% that of the paper. 
% The total body is then centered horizontally. The following settings
% result in the same effect.
% \begin{quote}
%  |\geometry{hscale=0.7}|,\\ |\geometry{ width=0.7\w }|,\\ 
%  |\geometry{hdivide={*,0.7\w,*}}|,\\
%  |\geometry{ hmargin=0.15\w }|,\\ |\geometry{ left=0.15\w }|,\\
%  |\geometry{left = .15\w, right= 0.15\w}|,\\
%  |\geometry{ rmargin= .15\w }|.
% \end{quote}
% In this case, the default is used for vertical layout: |vscale=0.9|.
% \item Set the height of the total body to be |10in|, the bottom-margin
% |3cm|, and the width default. Then the top-margin is automatically
% calculated in the package.
% \begin{quote}
%  |\geometry{height=10in,bottom=2cm}|,\\
%  |\geometry{bmargin = 2cm ,totalheight= 10in }|,\\ 
%  |\geometry{vdivide  = { *, 10in ,2cm } }|,\\
%  and so on.
% \end{quote}
% \item Set the left-, right-, and top-margin |3cm|, |2cm| and |2.5in|
% respectively. The page header is not used. The body is 40 lines of text
% in height.
% \begin{quote}
%  |\geometry{left=3cm,right=2cm, nohead,|\\
%  |               top=2.5in, textheight=40\baselineskip}|,\\
%  |\geometry{ hmargin = {3cm, 2cm} , head=0pt, headsep=0pt|\\
%  |             tmargin = 2.5in, textheight=40\baselineskip}|,\\
%  and so on.
% \end{quote}
% \item Include marginal notes when adjusting horizontal partition.
% \begin{quote}
%  |\geometry{ includemp }|,\\
%  |\geometry{ includemp = true }|,\\
%  and so on.
% \end{quote}
% \item Modify the width of marginal notes to \texttt{3cm} and include
% marginal notes when adjusting horizontal partition
% \begin{quote}
%  |\geometry{ marginpar=3cm }|,\\
%  |\geometry{ marginparwidth=3cm }|,\\
%  |\geometry{ marginpar=3cm , includemp }|.\\
%  In the last case |includemp| is not necessary.\\
%  |\geometry{marginpar=3cm, reversemp}|\\
%   makes the marginal notes appear in the left margin.
% \end{quote}
% \item Use A5 paper in landscape mode and a full scale of the
% paper as the body.
% \begin{quote}
%  |\geometry{ a5paper, landscape, scale=1.0 , noheadfoot}|,\\
%  |\geometry{ landscape = TRUE , paper =a5paper, |\\
%  |             noheadfoot , total={\w,\h} }|,\\
% and so on.
% \end{quote}
% \item Get PDF output using \textsl{pdflatex}.
% \begin{quote}
%  |% pdflatex foo|\\
%  with\\
%  |\documentclass[pdftex]{article}|\\
%  |\usepackage{geometry}|\\
%  or\\
%  |\documentclass{article}|\\
%  |\usepackage[pdftex]{geometry}|\\
%  is equivalent to\\
%  |% pdflatex '\pdfoutput=1 \input{foo}'|\\
%  with\\
%  |\documentclass{article}|\\
%  |\usepackage{geometry}|
%
%  When \texttt{pdftex} option is appeared as a class option, it will be
%  used in the \textsf{graphics} package\footnote{for the \textsf{graphics}
%  package on 1997/06/07 v1.0d or later.} and other packages in which
%  \texttt{pdftex} option is declared.
% \end{quote}
% \end{itemize}
%
% \section{Acknowledgements}
%  I would like to thank Friedrich Flender, Piet van Oostrum and 
%  Keith Reckdahl for their pointing out bugs and suggesting improvements.
%  I would like to thank Frank Bennett for many helpful comments.
%
% \StopEventually{%
%  \ifmulticols
%  \addtocontents{toc}{\protect\end{multicols}}
%  \fi
% }
%
% \section{The Code}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% This package requires David Carlisle's \textsf{keyval} package.
%    \begin{macrocode}
\RequirePackage{keyval}[1995/09/21]
%    \end{macrocode}
% 
% \begin{macro}{\Geom@exclcode}
% The catcode of exclamation mark is stored and explicitly changed 
% `other'(12).
%    \begin{macrocode}
\edef\Geom@exclcode{\catcode`\noexpand\!\the\catcode`\!\relax}
\@makeother\!%
%    \end{macrocode}
% \end{macro}
% 
% Internal switches are declared here.
%    \begin{macrocode}
\newif\ifGeom@verbose
\newif\ifGeom@landscape
\newif\ifGeom@nohead
\newif\ifGeom@nofoot
\newif\ifGeom@includemp
\newif\ifGeom@passincmp
\newif\ifGeom@hbody
\newif\ifGeom@vbody
\newif\ifGeom@dvips
\newif\ifGeom@pdftex
%    \end{macrocode}
% \begin{macro}{\Geom@Dhscale}
% \begin{macro}{\Geom@Dvscale}
% The default values for the horizontal and vertical \textsl{scale}
% are defined.
%    \begin{macrocode}
\def\Geom@Dhscale{0.8}
\def\Geom@Dvscale{0.9}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\Geom@Dtwosideshift}
% The default for \textsl{twosideshift} is defined.
%    \begin{macrocode}
\def\Geom@Dtwosideshift{20pt}
%    \end{macrocode}
% \end{macro}
% The modes and the flag are initialized here. But \texttt{twoside}
% should not be reset here because it may be inherited from the class
% option. \cs{Geom@passincmp} is just used for checking if
% \texttt{includemp} has been explicitly specified. \cs{Geom@pdftex} is
% true if \cs{pdfoutput}\texttt{=1}.
%    \begin{macrocode}
\Geom@verbosefalse
\Geom@landscapefalse
\Geom@noheadfalse
\Geom@nofootfalse
\Geom@includempfalse
\Geom@passincmpfalse
\Geom@dvipsfalse
\ifx\undefined\pdfpagewidth
  \Geom@pdftexfalse
\else
   \ifnum\pdfoutput=1\Geom@pdftextrue\else\Geom@pdftexfalse\fi
\fi
%    \end{macrocode}
% \begin{macro}{\Geom@reset}
% The \texttt{reset} option can be used only as an argument of 
% |\geometry{}|.
%    \begin{macrocode}
\def\Geom@reset{%
   \@twosidefalse
   \@mparswitchfalse
   \Geom@verbosefalse
   \Geom@landscapefalse
   \Geom@noheadfalse
   \Geom@nofootfalse
   \Geom@includempfalse
   \Geom@passincmpfalse
   \Geom@dvipsfalse
   \Geom@pdftexfalse}
%    \end{macrocode}
% \end{macro}
% \cs{Geom@paper} is initialized as |{}|(empty).
%    \begin{macrocode}
\providecommand\Geom@paper{}
%    \end{macrocode}
%
% The option keys are defined below.
% \begin{key}{Geom}{paper}
% \texttt{paper} takes paper name as its value.
% Available paper names are listed below.
%    \begin{macrocode}
\define@key{Geom}{paper}{\setkeys{Geom}{#1}}
%    \end{macrocode}
% \end{key}
% \begin{key}{Geom}{a[0-5]paper}
% \begin{key}{Geom}{b[0-5]paper}
% \begin{key}{Geom}{letterpaper}
% \begin{key}{Geom}{legalpaper}
% \begin{key}{Geom}{executivepaper}
% Thirteen standard paper names are available.
%    \begin{macrocode}
\define@key{Geom}{a0paper}[true]{\def\Geom@paper{a0paper}}
\define@key{Geom}{a1paper}[true]{\def\Geom@paper{a1paper}}
\define@key{Geom}{a2paper}[true]{\def\Geom@paper{a2paper}}
\define@key{Geom}{a3paper}[true]{\def\Geom@paper{a3paper}}
\define@key{Geom}{a4paper}[true]{\def\Geom@paper{a4paper}}
\define@key{Geom}{a5paper}[true]{\def\Geom@paper{a5paper}}
\define@key{Geom}{b0paper}[true]{\def\Geom@paper{b0paper}}
\define@key{Geom}{b1paper}[true]{\def\Geom@paper{b1paper}}
\define@key{Geom}{b2paper}[true]{\def\Geom@paper{b2paper}}
\define@key{Geom}{b3paper}[true]{\def\Geom@paper{b3paper}}
\define@key{Geom}{b4paper}[true]{\def\Geom@paper{b4paper}}
\define@key{Geom}{b5paper}[true]{\def\Geom@paper{b5paper}}
\define@key{Geom}{letterpaper}[true]{\def\Geom@paper{letterpaper}}
\define@key{Geom}{legalpaper}[true]{\def\Geom@paper{legalpaper}}
\define@key{Geom}{executivepaper}[true]{\def\Geom@paper{executivepaper}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \end{key}\end{key}
% \begin{key}{Geom}{papersize}
% \begin{key}{Geom}{paperwidth}
% \begin{key}{Geom}{paperheight}
%    \begin{macrocode}
\define@key{Geom}{papersize}{\Geom@branch{#1}{paperwidth}{paperheight}}
\define@key{Geom}{paperwidth}{\setlength\paperwidth{#1}%
                              \let\Geom@paper\empty}
\define@key{Geom}{paperheight}{\setlength\paperheight{#1}%
                              \let\Geom@paper\empty}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{total}
% \begin{key}{Geom}{width}
% \begin{key}{Geom}{height}
%    \begin{macrocode}
\define@key{Geom}{total}{\Geom@branch{#1}{width}{height}}
\define@key{Geom}{width}{\Geom@hbodytrue\edef\Geom@width{#1}}
\define@key{Geom}{height}{\Geom@vbodytrue\edef\Geom@height{#1}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{body}
% \begin{key}{Geom}{textwidth}
% \begin{key}{Geom}{textheight}
%    \begin{macrocode}
\define@key{Geom}{body}{\Geom@branch{#1}{textwidth}{textheight}}
\define@key{Geom}{textwidth}{\Geom@hbodytrue\edef\Geom@textwidth{#1}}
\define@key{Geom}{textheight}{\Geom@vbodytrue\edef\Geom@textheight{#1}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{scale}
% \begin{key}{Geom}{hscale}
% \begin{key}{Geom}{vscale}
%    \begin{macrocode}
\define@key{Geom}{scale}{\Geom@branch{#1}{hscale}{vscale}}
\define@key{Geom}{hscale}{\Geom@hbodytrue\edef\Geom@hscale{#1}}
\define@key{Geom}{vscale}{\Geom@vbodytrue\edef\Geom@vscale{#1}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{margin}
% \begin{key}{Geom}{hmargin}
% \begin{key}{Geom}{vmargin}
% \begin{key}{Geom}{lmargin}
% \begin{key}{Geom}{rmargin}
% \begin{key}{Geom}{tmargin}
% \begin{key}{Geom}{bmargin}
%    \begin{macrocode}
\define@key{Geom}{margin}{\Geom@branch{#1}{lmargin}{tmargin}%
                          \Geom@branch{#1}{rmargin}{bmargin}}
\define@key{Geom}{hmargin}{\Geom@branch{#1}{lmargin}{rmargin}}
\define@key{Geom}{vmargin}{\Geom@branch{#1}{tmargin}{bmargin}}
\define@key{Geom}{lmargin}{\edef\Geom@lmargin{#1}}
\define@key{Geom}{rmargin}{\edef\Geom@rmargin{#1}}
\define@key{Geom}{tmargin}{\edef\Geom@tmargin{#1}}
\define@key{Geom}{bmargin}{\edef\Geom@bmargin{#1}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \end{key}\end{key}\end{key}
% \end{key}
% \begin{key}{Geom}{divide}
% \begin{key}{Geom}{hdivide}
% \begin{key}{Geom}{vdivide}
% Provide useful ways to partition each direction of paper.
%    \begin{macrocode}
\define@key{Geom}{divide}{\Geom@divideParser{#1}{lmargin}{width}{rmargin}%
                         \Geom@divideParser{#1}{tmargin}{height}{bmargin}}
\define@key{Geom}{hdivide}{\Geom@divideParser{#1}{lmargin}{width}{rmargin}}
\define@key{Geom}{vdivide}{\Geom@divideParser{#1}{tmargin}{height}{bmargin}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{offset}
% \begin{key}{Geom}{hoffset}
% \begin{key}{Geom}{voffset}
%    \begin{macrocode}
\define@key{Geom}{offset}{\Geom@branch{#1}{hoffset}{voffset}}
\define@key{Geom}{hoffset}{\setlength\hoffset{#1}}
\define@key{Geom}{voffset}{\setlength\voffset{#1}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{headheight}
% \begin{key}{Geom}{headsep}
% \begin{key}{Geom}{footskip}
%    \begin{macrocode}
\define@key{Geom}{headheight}{\Geom@noheadfalse\setlength\headheight{#1}}
\define@key{Geom}{headsep}{\Geom@noheadfalse\setlength\headsep{#1}}
\define@key{Geom}{footskip}{\Geom@nofootfalse\setlength\footskip{#1}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Geom}{marginparwidth}
% \begin{key}{Geom}{marginparsep}
%    \begin{macrocode}
\define@key{Geom}{marginparwidth}%
           {\ifGeom@passincmp\else\Geom@includemptrue\fi%
            \setlength\marginparwidth{#1}}
\define@key{Geom}{marginparsep}%
           {\ifGeom@passincmp\else\Geom@includemptrue\fi%
            \setlength\marginparsep{#1}}
%    \end{macrocode}
% \end{key}\end{key}
% \begin{key}{Geom}{verbose}
% \begin{key}{Geom}{reset}
% \begin{key}{Geom}{includemp}
% \begin{key}{Geom}{reversemp}
% \begin{key}{Geom}{reversemarginpar}
% \begin{key}{Geom}{twoside}
% \begin{key}{Geom}{twosideshift}
% \begin{key}{Geom}{nohead}
% \begin{key}{Geom}{nofoot}
% \begin{key}{Geom}{noheadfoot}
% \begin{key}{Geom}{landscape}
% \begin{key}{Geom}{portrait}
% \begin{key}{Geom}{dvips}
% \begin{key}{Geom}{pdftex}
%    \begin{macrocode}
\define@key{Geom}{verbose}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@verbose}}
\define@key{Geom}{reset}[true]{%
            \lowercase{\expandafter\csname if#1\endcsname\Geom@reset\fi}}
\define@key{Geom}{includemp}[true]{%
            \Geom@passincmptrue
            \lowercase{\Geom@setbool{#1}}{Geom@includemp}}
\define@key{Geom}{reversemp}[true]{%
            \ifGeom@passincmp\else\Geom@includemptrue\fi%
            \lowercase{\Geom@setbool{#1}}{@reversemargin}}
\define@key{Geom}{reversemarginpar}[true]{%
            \ifGeom@passincmp\else\Geom@includemptrue\fi%
            \lowercase{\Geom@setbool{#1}}{@reversemargin}}
\define@key{Geom}{twoside}[true]{%
            \lowercase{\Geom@setbool{#1}}{@twoside}%
            \lowercase{\Geom@setbool{#1}}{@mparswitch}}
\define@key{Geom}{twosideshift}{\@twosidetrue\def\Geom@twosideshift{#1}}
\define@key{Geom}{nohead}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@nohead}}
\define@key{Geom}{nofoot}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@nofoot}}
\define@key{Geom}{noheadfoot}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@nohead}%
            \lowercase{\Geom@setbool{#1}}{Geom@nofoot}}
\define@key{Geom}{landscape}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@landscape}}
\define@key{Geom}{portrait}[true]{%
            \lowercase{\expandafter\csname if#1\endcsname
            \Geom@landscapefalse\else\Geom@landscapetrue\fi}}
\define@key{Geom}{dvips}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@dvips}}
\define@key{Geom}{pdftex}[true]{%
            \lowercase{\Geom@setbool{#1}}{Geom@pdftex}}
%    \end{macrocode}
% \end{key}\end{key}\end{key}\end{key}\end{key}
% \end{key}\end{key}\end{key}\end{key}\end{key}
% \end{key}\end{key}\end{key}\end{key}
% \begin{key}{Geom}{papername}
% \begin{key}{Geom}{totalwidth}
% \begin{key}{Geom}{totalheight}
% \begin{key}{Geom}{text}
% \begin{key}{Geom}{left}
% \begin{key}{Geom}{right}
% \begin{key}{Geom}{top}
% \begin{key}{Geom}{bottom}
% \begin{key}{Geom}{head}
% \begin{key}{Geom}{foot}
% \begin{key}{Geom}{marginpar}
% The key aliases are defined.
%    \begin{macrocode}
\let\KV@Geom@papername\KV@Geom@paper
\let\KV@Geom@totalwidth\KV@Geom@width
\let\KV@Geom@totalheight\KV@Geom@height
\let\KV@Geom@text\KV@Geom@body
\let\KV@Geom@left\KV@Geom@lmargin
\let\KV@Geom@right\KV@Geom@rmargin
\let\KV@Geom@top\KV@Geom@tmargin
\let\KV@Geom@bottom\KV@Geom@bmargin
\let\KV@Geom@head\KV@Geom@headheight
\let\KV@Geom@foot\KV@Geom@footskip
\let\KV@Geom@marginpar\KV@Geom@marginparwidth
%    \end{macrocode}
% \end{key}\end{key}\end{key}
% \end{key}\end{key}\end{key}
% \end{key}\end{key}\end{key}
% \end{key}\end{key}
%
% \begin{macro}{\Geom@setbool}
% Macros for setting boolean options.
%    \begin{macrocode}
\def\Geom@setbool#1#2{%
  \csname #2\ifx\relax#1\relax true\else#1\fi\endcsname}
%    \end{macrocode}
% \end{macro}
%
% Package options are declared.
%    \begin{macrocode}
\DeclareOption{verbose}{\Geom@verbosetrue}
\DeclareOption{a0paper}{\setkeys{Geom}{a0paper}}
\DeclareOption{a1paper}{\setkeys{Geom}{a1paper}}
\DeclareOption{a2paper}{\setkeys{Geom}{a2paper}}
\DeclareOption{a3paper}{\setkeys{Geom}{a3paper}}
\DeclareOption{a4paper}{\setkeys{Geom}{a4paper}}
\DeclareOption{a5paper}{\setkeys{Geom}{a5paper}}
\DeclareOption{b0paper}{\setkeys{Geom}{b0paper}}
\DeclareOption{b1paper}{\setkeys{Geom}{b1paper}}
\DeclareOption{b2paper}{\setkeys{Geom}{b2paper}}
\DeclareOption{b3paper}{\setkeys{Geom}{b3paper}}
\DeclareOption{b4paper}{\setkeys{Geom}{b4paper}}
\DeclareOption{b5paper}{\setkeys{Geom}{b5paper}}
\DeclareOption{letterpaper}{\setkeys{Geom}{letterpaper}}
\DeclareOption{legalpaper}{\setkeys{Geom}{legalpaper}}
\DeclareOption{executivepaper}{\setkeys{Geom}{executivepaper}}
\DeclareOption{portrait}{\Geom@landscapefalse}
\DeclareOption{landscape}{\Geom@landscapetrue}
\DeclareOption{twoside}{\@twosidetrue}
\DeclareOption{nohead}{\Geom@noheadtrue}
\DeclareOption{nofoot}{\Geom@nofoottrue}
\DeclareOption{noheadfoot}{\Geom@noheadtrue\Geom@nofoottrue}
\DeclareOption{includemp}{\Geom@includemptrue}
\DeclareOption{reversemp}{\Geom@includemptrue\@reversemargintrue}
\DeclareOption{reversemarginpar}{\ExecuteOptions{reversemp}}
\DeclareOption{dvips}{\Geom@dvipstrue}
\DeclareOption{pdftex}{\Geom@pdftextrue}
\DeclareOption*{\PackageWarningNoLine{geometry}%
               {Unknown option `\CurrentOption'}}
%    \end{macrocode}
% \texttt{portrait} is a default option.
%    \begin{macrocode}
\ExecuteOptions{portrait}
%    \end{macrocode}
% A local configuration file may define more options. 
% If a site wants a default paper, it needs to put
% |\ExecuteOptions{a4paper}| in a \texttt{geometry.cfg} file.
%    \begin{macrocode}
\InputIfFileExists{geometry.cfg}{}{}
%    \end{macrocode}
%  Options are processed in the order that they appear in the
%  option-lists. First the global options, and then the local ones.
%    \begin{macrocode}
\ProcessOptions*\relax
%    \end{macrocode}
%
% \begin{macro}{\Geom@checkbool}
% \begin{macro}{\Geom@checkdef}
% Macros for printout of page layout parameters.
%    \begin{macrocode}
\def\Geom@checkbool#1{%
    \csname ifGeom@#1\endcsname #1\space\else\fi}
\def\Geom@checkdef#1{%
    \@ifundefined{Geom@#1}{---}{\@nameuse{Geom@#1}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Geom@det@one}
% Determine |#4| by |#1|(\len{paperwidth} or \len{paperheight}), 
% |#2| and |#3|.
%    \begin{macrocode}
\def\Geom@det@one#1#2#3#4{% determine #4.
    \setlength\@tempdima{\@nameuse{paper#1}}%
    \setlength\@tempdimb{\@nameuse{Geom@#2}}%
    \addtolength\@tempdima{-\@tempdimb}%
    \setlength\@tempdimb{\@nameuse{Geom@#3}}%
    \addtolength\@tempdima{-\@tempdimb}%
    \ifdim\@tempdima<\z@
       \Geom@warning{`#4' results in NEGATIVE (\the\@tempdima).%
            ^^J\@spaces Parameters of `#2' and `#3' should be shortened}%
    \fi
    \expandafter\edef\csname Geom@#4\endcsname{\the\@tempdima}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Geom@det@two}
% Determine |#2| and |#3| by |#1|(\len{paperwidth} or \len{paperheight})
% and |#1|(\len{width} or \len{height}).
%    \begin{macrocode}
\def\Geom@det@two#1#2#3{% determine #2 and #3.
    \setlength\@tempdima{\@nameuse{paper#1}}%
    \setlength\@tempdimb{\@nameuse{Geom@#1}}%
    \addtolength\@tempdima{-\@tempdimb}%
    \divide\@tempdima\tw@
    \ifdim\@tempdima<\z@
       \Geom@warning{`#2' and `#3' result in NEGATIVE (\the\@tempdima).%
              ^^J\@spaces Parameter for `#1' should be shortened}%
    \fi
    \expandafter\edef\csname Geom@#2\endcsname{\the\@tempdima}%
    \expandafter\edef\csname Geom@#3\endcsname{\the\@tempdima}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Geom@det@all}
% Determine directional partition. 
%    \begin{macrocode}
\def\Geom@det@all[#1]#2#3#4{%
    \@tempcnta\z@
    \if#1h
       \if!\Geom@lmargin!\else\advance\@tempcnta4\relax\fi
       \ifGeom@hbody\advance\@tempcnta2\relax\fi
       \if!\Geom@rmargin!\else\advance\@tempcnta1\relax\fi
    \else
       \if!\Geom@tmargin!\else\advance\@tempcnta4\relax\fi
       \ifGeom@vbody\advance\@tempcnta2\relax\fi
       \if!\Geom@bmargin!\else\advance\@tempcnta1\relax\fi
    \fi
    \ifcase\@tempcnta             % 0:(*,*,*)
       \if#1h
          \Geom@warning{Horizontal partition is set default\space
                        (hscale=\Geom@Dhscale)}%
          \edef\Geom@width{\Geom@Dhscale\paperwidth}%
       \else
          \Geom@warning{Vertical partition is set default\space
                        (vscale=\Geom@Dvscale)}%
          \edef\Geom@height{\Geom@Dvscale\paperheight}%
       \fi
       \Geom@det@two{#2}{#3}{#4}%
    \or                               % 1:(*,*,S) goto (5)
       \Geom@warning{`#3' was forced to equal `#4'}%
       \expandafter\edef\csname Geom@#3\endcsname{\@nameuse{Geom@#4}}%
       \Geom@det@one{#2}{#3}{#4}{#2}%
    \or\Geom@det@two{#2}{#3}{#4}      % 2:(*,S,*)
    \or\Geom@det@one{#2}{#2}{#4}{#3}  % 3:(*,S,S)
    \or                               % 4:(S,*,*) goto (5)
       \Geom@warning{`#4' was forced to equal `#3'}%
       \expandafter\edef\csname Geom@#4\endcsname{\@nameuse{Geom@#3}}%
       \Geom@det@one{#2}{#3}{#4}{#2}%
    \or\Geom@det@one{#2}{#3}{#4}{#2}  % 5:(S,*,S)
    \or\Geom@det@one{#2}{#2}{#3}{#4}  % 6:(S,S,*)
    \or                               % 7:(S,S,S) goto (5)      
       \Geom@warning{Redundant specification in `#1'-direction.%
                      ^^J\@spaces `#2' (\@nameuse{Geom@#2}) is ignored}%
       \Geom@det@one{#2}{#3}{#4}{#2}%
    \else\fi}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Geom@divideParser}
% The macro for parsing (\texttt{h},\texttt{v})\texttt{divide} options.
%    \begin{macrocode}
\def\Geom@divideParser#1#2#3#4{%
    \def\Geom@star{*}%
    \@tempcnta\z@
    \@for\Geom@tmp:=#1\do{%
       \expandafter\KV@@sp@def\expandafter\Geom@frag\expandafter{\Geom@tmp}%
       \edef\Geom@value{\Geom@frag}%
       \ifcase\@tempcnta\relax% cnta == 0
              \edef\Geom@key{#2}%
       \or    \edef\Geom@key{#3}%
       \else  \edef\Geom@key{#4}%
       \fi
       \@nameuse{Geom@set\Geom@key false}%
       \ifx\empty\Geom@value\else
       \ifx\Geom@star\Geom@value\else
           \setkeys{Geom}{\Geom@key=\Geom@value}%
       \fi\fi
       \advance\@tempcnta\@ne
    }%
    \let\Geom@star\relax}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Geom@branch}
% The macro for branching an option's value into the same two values.
%    \begin{macrocode}
\def\Geom@branch#1#2#3{%
    \@tempcnta\z@
    \@for\Geom@tmp:=#1\do{%
       \KV@@sp@def\Geom@frag{\Geom@tmp}%
       \edef\Geom@value{\Geom@frag}%
       \ifcase\@tempcnta\relax% cnta == 0
            \setkeys{Geom}{#2=\Geom@value}%
       \or% cnta == 1
            \setkeys{Geom}{#3=\Geom@value}%
       \else\fi
       \advance\@tempcnta\@ne
    }
    \ifnum\@tempcnta=\@ne
       \setkeys{Geom}{#2=\Geom@value}%
       \setkeys{Geom}{#3=\Geom@value}%
    \fi}
%    \end{macrocode}
% \end{macro}
% Various paper size are defined.
%    \begin{macrocode}
\@namedef{Geom@a0paper}{\Geom@setpaper(841mm,1189mm)}
\@namedef{Geom@a1paper}{\Geom@setpaper(595mm,841mm)}
\@namedef{Geom@a2paper}{\Geom@setpaper(420mm,595mm)}
\@namedef{Geom@a3paper}{\Geom@setpaper(297mm,420mm)}
\@namedef{Geom@a4paper}{\Geom@setpaper(210mm,297mm)}
\@namedef{Geom@a5paper}{\Geom@setpaper(149mm,210mm)}
\@namedef{Geom@b0paper}{\Geom@setpaper(1000mm,1414mm)}
\@namedef{Geom@b1paper}{\Geom@setpaper(707mm,1000mm)}
\@namedef{Geom@b2paper}{\Geom@setpaper(500mm,707mm)}
\@namedef{Geom@b3paper}{\Geom@setpaper(353mm,500mm)}
\@namedef{Geom@b4paper}{\Geom@setpaper(250mm,353mm)}
\@namedef{Geom@b5paper}{\Geom@setpaper(176mm,250mm)}
\@namedef{Geom@letterpaper}{\Geom@setpaper(8.5in,11in)}
\@namedef{Geom@legalpaper}{\Geom@setpaper(8.5in,14in)}
\@namedef{Geom@executivepaper}{\Geom@setpaper(7.25in,10.5in)}
%    \end{macrocode}
% \begin{macro}{\Geom@setpaper}
%    \begin{macrocode}
\def\Geom@setpaper(#1,#2){\setlength\paperwidth{#1}%
                          \setlength\paperheight{#2}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\Geom@showParam}
% The macro for typeout of geometry status and \LaTeX\ layout 
% dimensions.
%    \begin{macrocode}
\def\Geom@showParam{%
    \typeout{----------------------- Geometry parameters^^J%
    mode: %
    \Geom@checkbool{landscape}%
    \Geom@checkbool{nohead}%
    \Geom@checkbool{nofoot}%
    \Geom@checkbool{includemp}%
    \if@reversemargin reversemp\space\fi%
    \if@twoside twoside\space\fi%
    \Geom@checkbool{dvips}%
    \Geom@checkbool{pdftex}^^J%
    \if!\Geom@paper!\else
       paper: \Geom@paper^^J%
    \fi
    h-parts: \Geom@lmargin, \Geom@width, \Geom@rmargin^^J%
    v-parts: \Geom@tmargin, \Geom@height, \Geom@bmargin^^J%
    \if@twoside
       twosideshift: \Geom@twosideshift^^J%
    \fi
    ----------------------- Page layout dimensions^^J%
    \string\paperwidth\space\space\the\paperwidth^^J%
    \string\paperheight\space\the\paperheight^^J%
    \string\textwidth\space\space\the\textwidth^^J%
    \string\textheight\space\the\textheight^^J%
    \string\oddsidemargin\space\space\the\oddsidemargin^^J%
    \string\evensidemargin\space\the\evensidemargin^^J%
    \string\topmargin\space\space\the\topmargin^^J%
    \string\headheight\space\the\headheight^^J%
    \string\headsep\@spaces\the\headsep^^J%
    \string\footskip\space\space\space\the\footskip^^J%
    \ifGeom@includemp
       \string\marginparwidth\space\the\marginparwidth^^J%
       \string\marginparsep\space\space\space\the\marginparsep^^J%
    \fi
    \string\hoffset\space\the\hoffset^^J%
    \string\voffset\space\the\voffset^^J%
    (1in=72.27pt, 1cm=28.45pt)^^J%
    -----------------------}}
%    \end{macrocode}
% \end{macro}
%
% The \texttt{verbose}, \texttt{pdftex} and \texttt{dvips} options are
% checked in \cs{AtBeginDocument}.
%    \begin{macrocode}
\AtBeginDocument{%
%    \end{macrocode}
% Check effectiveness of \texttt{dvips} and \texttt{pdftex} options.
% For \textsl{latex},
%    \begin{macrocode}
    \ifx\undefined\pdfpagewidth
       \ifGeom@dvips
          \AtBeginDvi{\special{%
           papersize=\the\paperwidth,\the\paperheight}}%
       \fi
       \Geom@pdftexfalse
    \else
%    \end{macrocode}
% For \textsl{pdflatex} with \cs{pdfouput}\texttt{=1}, 
% checking again if \texttt{pdftex=false} is set explicitly,
%    \begin{macrocode}
       \ifnum\pdfoutput=1
          \ifGeom@pdftex
             \pdfpagewidth=\the\paperwidth
             \pdfpageheight=\the\paperheight
          \else
             \pdfoutput=0
          \fi
          \Geom@dvipsfalse
%    \end{macrocode}
% For \textsl{pdflatex} with \cs{pdfouput}\texttt{=0},
%    \begin{macrocode}
       \else
          \ifGeom@pdftex
             \pdfoutput=1
             \pdfpagewidth=\the\paperwidth
             \pdfpageheight=\the\paperheight
             \Geom@dvipsfalse
          \else
             \pdfoutput=0
             \ifGeom@dvips
                \AtBeginDvi{\special{%
                 papersize=\the\paperwidth,\the\paperheight}}%
             \fi
          \fi
       \fi
    \fi
%    \end{macrocode}
% if \texttt{verbose}, the page geometry parameters and options are
% displayed.
%    \begin{macrocode}
    \ifGeom@verbose
       \Geom@showParam
    \fi}
%    \end{macrocode}
%
% \begin{macro}{\geometry}
% The user interface \cs{geometry} is defined here.
%    \begin{macrocode}
\def\geometry#1{%
%    \end{macrocode}
%
% \begin{macro}{\w}
% \begin{macro}{\h}
% \cs{w} and \cs{h} are abbreviations for \cs{paperwidth} and \cs{paperheight}
% respectively. They are valid only in the argument of \cs{geometry}.
%    \begin{macrocode}
    \@ifundefined{w}{\let\Geom@ow\relax}{\let\Geom@ow\w}%
    \@ifundefined{h}{\let\Geom@oh\relax}{\let\Geom@oh\h}%
    \let\w\paperwidth
    \let\h\paperheight
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% Initialization of switches and dimensions.
%    \begin{macrocode}
    \Geom@hbodyfalse
    \Geom@vbodyfalse
    \let\Geom@width\empty
    \let\Geom@height\empty
    \let\Geom@textwidth\empty
    \let\Geom@textheight\empty
    \let\Geom@hscale\empty
    \let\Geom@vscale\empty
    \let\Geom@lmargin\empty
    \let\Geom@rmargin\empty
    \let\Geom@tmargin\empty
    \let\Geom@bmargin\empty
    \def\Geom@twosideshift{\Geom@Dtwosideshift}
%    \end{macrocode}
% The argument of \cs{geometry} is processed here.
%    \begin{macrocode}
    \setkeys{Geom}{#1}%
%    \end{macrocode}
% If \texttt{paper} option is specified, the predefined paper dimensions
% are used.
%    \begin{macrocode}
    \if!\Geom@paper!\else\@nameuse{Geom@\Geom@paper}\fi
%    \end{macrocode}
% If \texttt{landscape} option is specified, the paper orientation is
% changed to landscape.
%    \begin{macrocode}
    \ifGeom@landscape
        \setlength\@tempdima{\paperwidth}%
        \setlength\paperwidth{\paperheight}%
        \setlength\paperheight{\@tempdima}%
    \fi
%    \end{macrocode}
% If \texttt{nohead} option is specified, the vertical spaces for the
% head of page are all set to 0pt. If \texttt{nofoot}, the \cs{footskip}
% is set 0pt.
%    \begin{macrocode}
    \ifGeom@nohead
       \setlength\headheight{0pt}%
       \setlength\headsep{0pt}%
    \fi
    \ifGeom@nofoot
       \setlength\footskip{0pt}%
    \fi
%    \end{macrocode}
% The width of the total body \cs{Geom@width} is determined here.
%    \begin{macrocode}
    \ifGeom@hbody
       \if!\Geom@width!%
          \if!\Geom@hscale!%
             \edef\Geom@width{\Geom@Dhscale\paperwidth}%
          \else
             \edef\Geom@width{\Geom@hscale\paperwidth}%
          \fi
       \fi
       \if!\Geom@textwidth!\else
          \setlength\@tempdima{\Geom@textwidth}%
          \ifGeom@includemp
             \addtolength\@tempdima{\marginparwidth}%
             \addtolength\@tempdima{\marginparsep}%
          \fi
          \edef\Geom@width{\the\@tempdima}%
       \fi
    \fi
%    \end{macrocode}
% The height of the total body \cs{Geom@height} is determined here.
%    \begin{macrocode}
    \ifGeom@vbody
       \if!\Geom@height!%
          \if!\Geom@vscale!%
             \edef\Geom@height{\Geom@Dvscale\paperheight}%
          \else
             \edef\Geom@height{\Geom@vscale\paperheight}%
          \fi
       \fi
       \if!\Geom@textheight!\else%
          \setlength\@tempdima{\Geom@textheight}%
          \addtolength\@tempdima{\headheight}%
          \addtolength\@tempdima{\headsep}%
          \addtolength\@tempdima{\footskip}%
          \edef\Geom@height{\the\@tempdima}%
       \fi
    \fi
%    \end{macrocode}
% The horizontal and vertical partitionings are determined here.
%    \begin{macrocode}
    \Geom@det@all[h]{width}{lmargin}{rmargin}%
    \Geom@det@all[v]{height}{tmargin}{bmargin}%
%    \end{macrocode}
% \cs{textwidth}, \cs{textheight}, \cs{topmargin}, 
% \cs{oddsidemargin} and \cs{evensidemargin} are calculated below.
%    \begin{macrocode}
    \setlength\textwidth{\Geom@width}%
    \setlength\textheight{\Geom@height}%
    \setlength\topmargin{\Geom@tmargin}%
    \setlength\oddsidemargin{\Geom@lmargin}%
    \ifGeom@includemp
        \addtolength\textwidth{-\marginparwidth}%
        \addtolength\textwidth{-\marginparsep}%
        \if@reversemargin
           \addtolength\oddsidemargin{\marginparwidth}%
           \addtolength\oddsidemargin{\marginparsep}%
        \fi
    \fi
    \addtolength\textheight{-\headheight}%
    \addtolength\textheight{-\headsep}%
    \addtolength\textheight{-\footskip}%
    \addtolength\topmargin{-1in}%
    \addtolength\oddsidemargin{-1in}%
    \if@twoside
        \setlength\evensidemargin{\Geom@rmargin}%
        \addtolength\evensidemargin{-1in}%
        \setlength\@tempdima{\Geom@twosideshift}%
        \addtolength\oddsidemargin{\@tempdima}%
        \addtolength\evensidemargin{-\@tempdima}%
        \ifGeom@includemp
           \if@mparswitch
              \setlength\@tempdima{\marginparwidth}%
              \addtolength\@tempdima{\marginparsep}%
              \addtolength\evensidemargin{\@tempdima}%
              \if@reversemargin
                 \addtolength\evensidemargin{-\marginparwidth}%
                 \addtolength\evensidemargin{-\marginparsep}%
              \fi
           \fi
        \fi
    \else
        \setlength\evensidemargin{\oddsidemargin}%
    \fi
%    \end{macrocode}
% The local abbreviations \cs{w} and \cs{h} are replaced by the 
% original definitions or \cs{relax} if these are not predefined.
%    \begin{macrocode}
    \let\w\Geom@ow
    \let\h\Geom@oh
    }
%    \end{macrocode}
% \end{macro}
% A hack for silent execution of the default geometry setting.
%    \begin{macrocode}
\let\Geom@warning\@gobble
%    \end{macrocode}
% The default geometry command is executed in silent mode.
%    \begin{macrocode}
\geometry{}
%    \end{macrocode}
% \begin{macro}{\Geom@warning}
% The macro for typeout of warning is defined.
%    \begin{macrocode}
\def\Geom@warning#1{%
    \ifGeom@verbose
       \typeout{Geometry warning:\space #1.}%
    \fi}
%    \end{macrocode}
% \end{macro}
% The catcode of exclamation mark is restored here.
%    \begin{macrocode}
\Geom@exclcode
\let\Geom@exclcode\relax
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%<*config>

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

%</config>
%    \end{macrocode}
%
% \Finale
%
