summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r--Master/texmf-dist/source/latex/geometry/geometry.drv7
-rw-r--r--Master/texmf-dist/source/latex/geometry/geometry.dtx2884
-rw-r--r--Master/texmf-dist/source/latex/geometry/geometry.ins12
3 files changed, 1646 insertions, 1257 deletions
diff --git a/Master/texmf-dist/source/latex/geometry/geometry.drv b/Master/texmf-dist/source/latex/geometry/geometry.drv
index 4e9d7185a39..1a87ba0f6f3 100644
--- a/Master/texmf-dist/source/latex/geometry/geometry.drv
+++ b/Master/texmf-dist/source/latex/geometry/geometry.drv
@@ -6,7 +6,8 @@
%%
%% geometry.dtx (with options: `driver')
%%
-%% Copyright (C) 1996-2002, 2008 by Hideo Umeki <latexgeometry@gmail.com>
+%% Copyright (C) 1996-2010
+%% by Hideo Umeki <latexgeometry@gmail.com>
%%
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c of this license
@@ -26,8 +27,8 @@
\ProvidesFile{geometry.drv}
\documentclass{ltxdoc}
\usepackage[colorlinks, linkcolor=blue]{hyperref}
-\usepackage[a4paper, hmargin={3.8cm,1.5cm},vmargin={1.5cm,1cm},
- includeheadfoot, marginpar=3.5cm]{geometry}
+\usepackage[a4paper, hmargin=2.5cm, vmargin=1cm,
+ includeheadfoot]{geometry}
\begin{document}
\DocInput{geometry.dtx}
\end{document}
diff --git a/Master/texmf-dist/source/latex/geometry/geometry.dtx b/Master/texmf-dist/source/latex/geometry/geometry.dtx
index 3a521b4af5f..448a26a3603 100644
--- a/Master/texmf-dist/source/latex/geometry/geometry.dtx
+++ b/Master/texmf-dist/source/latex/geometry/geometry.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright 1996-2002, 2008 by Hideo Umeki <latexgeometry@gmail.com>
+% Copyright 1996-2010 by Hideo Umeki <latexgeometry@gmail.com>
%
% LaTeX Package: Geometry
% -----------------------
@@ -19,26 +19,22 @@
% This work consists of the files geometry.dtx and
% the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
%
-% Distribution:
+% * Distribution
+% CTAN: macros/latex/contrib/geometry/README
+% CTAN: macros/latex/contrib/geometry/changes.txt
+% CTAN: macros/latex/contrib/geometry/geometry.ins
% CTAN: macros/latex/contrib/geometry/geometry.dtx
% CTAN: macros/latex/contrib/geometry/geometry.pdf
%
-% Unpacking: to get geometry.sty
-% (a) Directly
-% tex geometry.dtx
-% (b) If geometry.ins is present, you can go
-% tex geometry.ins
-% (c) If you insist on using LaTeX,
-% latex \let\install=y\input{geometry.dtx}
-% (quote the arguments according to the demands of your shell)
-%
-% Documentation: to get geometry.dvi or pdf
-% (a) Directly
-% (pdf)latex geometry.dtx
-% (b) If geometry.drv is present, you can go
-% (pdf)latex geometry.drv
-%
-% Installation:
+% * To get geometry.sty out of geometry.dtx
+% $ tex geometry.dtx
+% or $ tex geometry.ins
+%
+% * To build documentation
+% $ latex geometry.dtx
+% or $ latex geometry.drv
+%
+% * Installation
% TDS:tex/latex/geometry/geometry.sty
% TDS:doc/latex/geometry/geometry.pdf
% TDS:source/latex/geometry/geometry.dtx
@@ -54,20 +50,20 @@
%</ignore>
%<package|driver>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{geometry}
-%<package> [2008/12/21 v4.2 Page Geometry]
+%<package> [2010/02/12 v5.0 Page Geometry]
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: geometry 2008/12/21 v4.2 Page Geometry}
+\Msg{* Package: geometry 2010/02/12 v5.0 Page Geometry}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
-
\preamble
-Copyright (C) 1996-2002, 2008 by Hideo Umeki <latexgeometry@gmail.com>
+Copyright (C) 1996-2010
+by Hideo Umeki <latexgeometry@gmail.com>
This work may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3c of this license
@@ -103,12 +99,11 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\Msg{* \space\space geometry.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `geometry.drv'}
-\Msg{* through (PDF)LaTeX.}
+\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
-
\endbatchfile
%</install>
%<*ignore>
@@ -118,15 +113,15 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\ProvidesFile{geometry.drv}
\documentclass{ltxdoc}
\usepackage[colorlinks, linkcolor=blue]{hyperref}
-\usepackage[a4paper, hmargin={3.8cm,1.5cm},vmargin={1.5cm,1cm},
- includeheadfoot, marginpar=3.5cm]{geometry}
+\usepackage[a4paper, hmargin=2.5cm, vmargin=1cm,
+ includeheadfoot]{geometry}
\begin{document}
\DocInput{geometry.dtx}
\end{document}
%</driver>
% \fi
%
-% \CheckSum{2601}
+% \CheckSum{2719}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -150,9 +145,12 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \date{\filedate\ \fileversion}
% \author{Hideo Umeki\\\texttt{latexgeometry@gmail.com}}
%
+% \MakeShortVerb{|}
+%
% \def\OpenB{{\ttfamily\char`\{}}
% \def\Comma{{\ttfamily\char`,}}
% \def\CloseB{{\ttfamily\char`\}}}
+% \def\Gm{\textsf{geometry}}
% \newcommand\argii[2]{\OpenB\meta{#1}\Comma\meta{#2}\CloseB}
% \newcommand\argiii[3]{\OpenB\meta{#1}\Comma\meta{#2}\Comma\meta{#3}\CloseB}
% \newcommand\vargii[2]{\OpenB#1\Comma#2\CloseB}
@@ -160,8 +158,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \newcommand\OR{\ \strut\vrule width .4pt\ }
% \newcommand\gpart[1]{\textsl{#1}}
% \newcommand\glen[1]{\textsf{#1}}
-% \newcommand\New[1]{\llap{$^{\star#1\:}$}}
-% \newcommand\Mod[1]{\llap{$^{\dagger#1\:}$}}
% \newenvironment{key}[2]{\expandafter\macro\expandafter{`#2'}}{\endmacro}
% \newenvironment{Options}%
% {\begin{list}{}{%
@@ -172,163 +168,83 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \addtolength{\leftmargin}{\labelsep}}%
% \raggedright}
% {\end{list}}
+% \newenvironment{Spec}%
+% {\begin{list}{}{%
+% \renewcommand{\makelabel}[1]{\fbox{##1}\hfil}%
+% \setlength{\itemsep}{-.5\parsep}
+% \settowidth{\labelwidth}{\texttt{S(x,x)}}%
+% \setlength{\leftmargin}{\labelwidth}%
+% \addtolength{\leftmargin}{\labelsep}%
+% \addtolength{\leftmargin}{2em}%
+% \setlength{\rightmargin}{2em}}%
+% \raggedright}
+% {\end{list}}
+% \def\Ss(#1,#2){\textsf{S(#1,#2)}}%
+% \def\Sp(#1,#2,#3){\mbox{|(#1,#2,#3)|}}%
+% \def\onlypre{\llap{$^{\dagger\:}$}}%
%
% \maketitle
%
-% \MakeShortVerb{|}
-%
% \begin{abstract}
% This package provides a flexible and easy interface to page dimensions.
-% You can set the page layout with intuitive parameters. For instance,
+% You can change the page layout with intuitive parameters. For instance,
% if you want to set a margin to 2cm from each edge of the paper,
-% you can go just |\usepackage[margin=2cm]{geometry}|.
+% you can go just |\usepackage[margin=2cm]{geometry}|. With
+% |\newgeometry| command you can change the layout anywhere in the
+% document.
% \end{abstract}
%
-% \newif\ifmulticols
-% \IfFileExists{multicol.sty}{\multicolstrue}{}
-% \ifmulticols
-% \addtocontents{toc}{%
-% \protect\setlength{\columnsep}{3pc}%
-% \protect\begin{multicols}{2}}
-% \fi
-% {\parskip 0pt
-% \tableofcontents
-% }
-%
-% \section{Preface to version 4}
+% \section{Preface to version 5}
%
-% Many improvements to the code and documentation were made according to
-% suggestions and comments from users.
-% Main changes are listed below.
% \begin{itemize}
-% \item \textbf{More robust driver detection.}\par
-% The driver detection method has been totally rewritten so that
-% it can automatically detect the driver appropriate for the
-% typesetting program in use. Therefore, explicit driver setting is no longer
-% needed in most cases, except for the driver |dvipdfm|.
-% This improvement makes \textsf{geometry} work more robustly
-% for typesetting programs under e\TeX, Xe\TeX{} and
-% V\TeX{} as well as normal \TeX{} environment. The packages
-% \textsf{ifpdf} and \textsf{ifvtex} are used, which are available in CTAN.
-% See Section~\ref{sec:drivers} for details.
-% Note that \textsf{ifvtex} package v1.3 (2007/09/09) had a
-% bug (a typo) that made the detection of VTeX wrong.
-% So make sure \textsf{ifvtex} v1.4 or later is being used.
-% \item \textbf{New option: |resetpaper|.}\par
-% This option disables explicit paper setting in \textsf{geometry} and
-% uses the paper size specified before \textsf{geometry}. This option
-% may be useful to print nonstandard sized documents with normal
-% printers and papers.
-% \item \textbf{Added adjustment to |topskip|.}\par
-% When |lines| option and large font sizes are specified, \cs{topskip}
-% can be adjusted so that the formula
-% ``$\cs{textheight} = (lines - 1) \times \cs{baselineskip} + \cs{topskip}$''
-% to be correct. To do this, \cs{topskip} is set to \cs{ht}\cs{strutbox},
-% if \cs{topskip} is smaller than \cs{ht}\cs{strutbox}.
-% \item \textbf{Added ANSI paper sizes.}\par
-% New paper size definitions for ANSI A to E are added.
-% \item \textbf{Fixed wrong ISO paper sizes.}\par
-% The paper sizes for A1,A2,A5 and A6 were wrong (by 1mm).
-% \item \textbf{Fixed pdf\TeX{} magnification problem.}\par
-% PDF paper offset is adjusted properly when magnification is set by |mag|
-% option with pdf\TeX{}.
-% \item \textbf{Changed package source organization.}\par
-% Files |geometry.ins| and |geometry-samples.tex| as well as |geometry.sty|
-% are integrated into |geometry.dtx| so that they can be generated from
-% |geometry.dtx| by `tex' command. Documentation can be also generated
-% directly from |geometry.dtx| by `(pdf)latex' command.
+% \item \textbf{Changing page layout mid-document.}\par
+% The new commands \cs{newgeometry\{$\cdots$\}} and
+% \cs{restoregeometry} allow users to change page dimensions in the
+% middle of the document. \cs{newgeometry} is almost similar to
+% \cs{geometry} except that \cs{newgeometry} disables all the options
+% specified in the preamble and skips the papersize-related options:
+% |landscape|,|portrait| and paper size options (such as
+% |papersize|, |paper=a4paper| and so forth).
+% \item \textbf{A new set of options to specify the layout area.}\par
+% The options specified for the area, in which the page dimensions
+% are calculated, are added: \textsf{layout}, \textsf{layoutsize},
+% \textsf{layoutwidth}, \textsf{layoutheight} and so forth.
+% These options would help to print the specified
+% layout to a different sized paper. For example, with |a4paper|
+% and |layout=a5paper|, the \Gm\ package uses `A5' layout to
+% calculate margins with the paper size still `A4'.
+% \item \textbf{A new driver option |xetex|.}\par
+% The new driver option |xetex| is added. The driver auto-detection
+% routine has been revised so as to avoid an error with undefined
+% control sequences. Note that `geometry.cfg' in TeXLive, which
+% disables the auto-detection routine and sets |pdftex|, is no
+% longer necessary and has no problem even though it still exists.
+% To set |xetex| is strongly recommended with XeLaTeX.
+% \item \textbf{New paper size presets for JIS B-series.}\par
+% The papersize presets |b0j| to |b6j| for JIS (Japanese Industrial
+% Standards) B-series are added.
+% \item \textbf{Changing default for underspecified margin.}\par
+% In the previous version, if only one margin was specified,
+% |bottom=1cm| for example, then \Gm\ set the other margin with
+% the margin ratio (1:1 by default for the vertical dimensions)
+% and got |top|=1cm in this case.
+% The version 5 sets the text-body size with the default |scale|
+% (=0.7) and determine the unspecified margin. (See Section~\ref{sec:rules})
+% \item \textbf{The option |showframe| works on every page.}\par
+% With |showframe| option, the page frames are shown on every page.
+% In addition, the new option |showcrop| would print cropmarks showing
+% the corners of the layout (the same as paper by default) on every page.
+% \item \textbf{Loading geometry.cfg precedes processing class options.}\par
+% The previous version loaded \textsf{geometry.cfg} after
+% processing the document class options. Now that the config file is
+% loaded before processing the class options, you can change the
+% behavior specified in \textsf{geometry.cfg} by adding options
+% into |\documentclass| as well as |\usepackage| and |\geometry|.
+% \item \textbf{Deleted options: |compat2| and |twosideshift|.}
+% The version 5 has no longer compatibility with the previous ones.
+% |compat2| and |twosideshift| are gone for simplicity.
% \end{itemize}
%
-% \section{Preface to version 3}
-%
-% The \textsf{geometry} package becomes even more flexible and powerful with
-% the release of version 3. This new release contains major changes and
-% enhancements in user interface, calculation schemes and the default settings
-% of the page dimensions.
-% \begin{itemize}
-% \item \textbf{New default layout.}\par
-% The `automatic' centering is no longer default layout. Instead of
-% centering, the idea of margin ratio and common values for default settings
-% are introduced: the ratio of left (inner) margin to right (outer) margin
-% is set 1:1 (2:3 for twoside), and the ratio of top to bottom is set 2:3.
-% The margin ratios can be specified by newly introduced options,
-% e.g. |marginratio| (see Section~\ref{sec:completion} and \ref{sec:margin}
-% for the detail). In addition, the spaces for the head and foot of the
-% page are disregarded in calculating the placement of the text area by
-% default. Furthermore the default |scale| of the type area is set to
-% |0.7| with 70\% of the width and height of the paper.
-% If you want to use the old default layout of version 2.3 or earlier,
-% add |compat2| as a first option, e.g.,
-% |\usepackage[compat2,left=1.5in]{geometry}|, which sets
-% the old default options
-% \texttt{[scale=\{0.8,0.9\}, centering, includeheadfoot]} and allows
-% the subsequent options to behave as if they are used in the old version.
-% See also Section~\ref{sec:default} for the detail of the default layout.
-%
-% \item \textbf{Option |twosideshift| is obsoleted.} \par
-% |twoside| and other geometry options can substitute for it.
-% A new option |bindingoffset| might be also helpful to control margins for
-% oneside/twoside. For the detail, see Section~\ref{sec:margin}.
-%
-% \item \textbf{Option |includemp| becomes independent of |marginparwidth|
-% and |marginparsep|.} \par
-% In the previous version, |marginparwidth| or |marginparsep|
-% automatically set |includemp=true|. Now if you want |includemp| mode,
-% |includemp| should be set explicitly.
-%
-% \item \textbf{Options |nohead|, |nofoot| and |noheadfoot| become
-% order-dependent and overwritable} \par
-% In the previous version, these options was order-independent:
-% |nohead,headsep=10pt| resulted in just |nohead| (\cs{headsep}|=0pt|,
-% \cs{headheight}|=0pt|), for example. But now they are overwritable
-% by subsequent options. The above case results in \cs{headheight}|=0pt|
-% and \cs{headsep}|=10pt|.
-%
-% \item \textbf{A complete set of options |ignore*| and |include*| for
-% head, foot and marginpar.}\par
-% The previous version has only |includemp|, which denotes that the width
-% of marginpar is included in the total body width.
-% Now |ignore|\{|head|, |foot|, |headfoot|, |mp|, |all|\} and
-% |include|\{|head|, |foot|, |headfoot|, |all|\} are newly added.
-% If one of these |ignore*| is set, the corresponding space(s) are
-% disregarded in auto-completion calculation.
-% In version 3, |ignoreall| is set by default. So if you need to include
-% the spaces for the head, foot and marginpar, the corresponding |include*|
-% should be set explicitly. In addition, unlike the previous version,
-% neither |reversemp|, |marginparwidth| nor |marginparsep| sets |includemp|
-% automatically.
-%
-% \item \textbf{New option |lines|.}\par
-% The option enables users to specify \cs{textheight} by the number of
-% lines included in \cs{textheight}, e.g., |lines=20|.
-%
-% \item \textbf{New option |heightrounded|.}\par
-% The option rounds \cs{textheight} to \textit{n}-times (\textit{n}:
-% an integer) of \cs{baselineskip} plus \cs{topskip} to avoid ``underfull
-% vbox'' in some cases.
-%
-% \item \textbf{New option |screen|.}\par
-% To make presentation with PC and video projector, geometry option
-% |screen,centering| with `slide' documentclass would be the best choice.
-%
-% \item \textbf{New option |asymmetric|.}\par
-% The option implements a twosided layout in which margins are not swapped
-% on alternate pages and the marginal notes stay always on the same side.
-%
-% \item \textbf{New option |showframe|.}\par
-% The option displays visible frames for the text area and page, and lines
-% for the head and foot to check layout in detail. Therefore |showframe.sty|
-% is excluded from the \textsf{geometry} package distribution.
-%
-% \item \textbf{New option |pass|.}\par
-% The option disables auto-layout and all of the geometry settings except
-% |verbose| and |showframe|. It can be used for checking out the page
-% layout of the documentclass, other packages and manual settings
-% without \textsf{geometry}.
-% \end{itemize}
-% See the text for the detail. All the new and modified options in this
-% release are marked with `$\star3$' and `$\dagger3$' respectively.
-%
% \section{Introduction}
%
% To set dimensions for page layout in \LaTeX\ is not straightforward.
@@ -345,21 +261,22 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% | -\headheight-\headsep-\footskip)/2 - 1in}|.
% \end{quote}
% Without package \textsl{calc}, the above example would need
-% more tedious settings. Package \textsf{geometry} provides an easy
+% more tedious settings. Package \Gm\ provides an easy
% way to set page layout parameters. In this case, what you have to do
% is just
% \begin{quote}
% |\usepackage[text={7in,10in},centering]{geometry}|.
% \end{quote}
% Besides centering problem, setting margins from each edge of the paper is
-% also troublesome. But \textsf{geometry} also make it easy.
+% also troublesome. But \Gm\ also make it easy.
% If you want to set each margin 1.5in, you can go
% \begin{quote}
% |\usepackage[margin=1.5in]{geometry}|
% \end{quote}
-% In both cases, the unspecified dimensions are automatically determined.
-% The package will be also useful when you have to set page layout obeying
-% the following strict instructions: for example,
+% Thus, the geometry package has an auto-completion mechanisim, in which
+% unspecified dimensions are automatically determined.
+% The \Gm\ package will be also useful when you have to set page layout
+% obeying the following strict instructions: for example,
% \begin{quote}\slshape
% The total allowable width of the text area is 6.5 inches wide by 8.75
% inches high. The top margin on each page should be 1.2 inches from
@@ -367,7 +284,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% the left edge. The footer with page number should be at the bottom
% of the text area.
% \end{quote}
-% In this case, using \textsf{geometry} you can go
+% In this case, using \Gm\ you can go
% \begin{quote}
% |\usepackage[total={6.5in,8.75in},|\\
% | top=1.2in, left=0.9in, includefoot]{geometry}|.
@@ -379,13 +296,15 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% a size and location of a window in X Window System.
%
% \section{Page geometry}
-% \subsection{Layout dimensions}
-% To realize a straightforward setting for page layout, the following page
-% structure is introduced: A paper contains a total body (printable area)
-% and margins. The total body consists of a body (text area) with optional
-% a header, a footer and marginal notes (marginpar). There are four margins:
-% the left, right, top and bottom margins. For twosided documents, horizontal
-% margins should be called the inner and outer margins.
+%
+% Figure~\ref{fig:layout} shows the page layout dimensions defined
+% in the \Gm\ package.
+% The page layout contains a \gpart{total body} (printable area) and \gpart{margins}.
+% The \gpart{total body} consists of a \gpart{body} (text area) with an
+% optional \gpart{header}, \gpart{footer} and marginal notes (marginpar).
+% There are four margins: \gpart{left}, \gpart{right}, \gpart{top} and
+% \gpart{bottom}. For twosided documents, horizontal
+% margins should be called \gpart{inner} and \gpart{outer}.
% \begin{quote}
% \begin{tabular}{rcl}
% \gpart{paper}&:&\gpart{total body} and
@@ -399,24 +318,30 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% Each margin is measured from the corresponding edge of a paper.
% For example, left margin (inner margin) means a horizontal distance
% between the left (inner) edge of the paper and that of the total body.
-% Therefore the left and top margins defined in \textsf{geometry}
-% are different from the native dimensions \cs{leftmargin}
-% and \cs{topmargin}.
+% Therefore the left and top margins defined in \Gm\ are different
+% from the native dimensions \cs{leftmargin} and \cs{topmargin}.
% The size of a body (text area) can be modified by \cs{textwidth} and
% \cs{textheight}.
+% The dimensions for paper, total body and margins have the following
+% relations.
+% \begin{eqnarray}
+% \label{eq:paperwidth}
+% |paperwidth| &=& |left|+|width|+|right| \\
+% |paperheight| &=& |top|+|height|+|bottom|
+% \label{eq:paperheight}
+% \end{eqnarray}
%
-% The layout parts and the corresponding dimension names used in this
-% package are showed schematically in Figure~\ref{fig:layout}.
% \begin{figure}
% \centering\small
% {\unitlength=.65pt
% \begin{picture}(450,250)(0,-10)
% \put(20,0){\framebox(170,230){}}
% \put(20,235){\makebox(170,230)[br]{\gpart{paper}}}
-% \put(40,30){\framebox(120,170){}}
+% \begingroup\thicklines
+% \put(40,30){\framebox(120,170){}}\endgroup
% \put(40,30){\makebox(120,165)[tr]{\gpart{total body}~}}
% \put(45,30){\makebox(0,170)[l]{|height|}}
-% \put(50,35){\makebox(120,0)[bc]{|width|}}
+% \put(40,35){\makebox(120,0)[bc]{|width|}}
% \put(50,-20){\makebox(120,0)[bc]{|paperwidth|}}
% \put(10,45){\makebox(0,170)[r]{|paperheight|}}
% \put(90,200){\makebox(0,30)[lc]{|top|}}
@@ -431,23 +356,35 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \put(160,70){\vector(1,0){30}}\put(190,70){\vector(-1,0){30}}
% \multiput(160,30)(5,0){24}{\line(1,0){2}}
% \multiput(160,200)(5,0){24}{\line(1,0){2}}
-% \put(280,30){\framebox(120,170){}}
-% \put(280,30){\makebox(120,165)[tr]{\gpart{total body}~}}
-% \put(280,220){\line(1,0){120}}
+% \begingroup\thicklines
+% \put(280,30){\framebox(120,170){}}\endgroup
+% \put(283,133){\makebox(0,12)[l]{|textheight|}}
+% \put(295,130){\vector(0,-1){100}}\put(295,150){\vector(0,1){50}}
+% \multiput(280,220)(5,0){24}{\line(1,0){3}}
% \put(280,208){\makebox(120,20)[bc]{\gpart{head}}}
-% \put(280,207){\line(1,0){120}}
-% \put(410,215){\makebox(0,0)[l]{|headheight|}}
-% \put(410,203){\makebox(0,0)[l]{|headsep|}}
-% \put(410,110){\makebox(0,0)[l]{|textheight|}}
-% \put(280,35){\makebox(120,0)[bc]{|textwidth|}}
-% \put(410,20){\makebox(0,0)[l]{|footskip|}}
+% \multiput(280,207)(5,0){24}{\line(1,0){3}}
+% \put(420,225){\makebox(0,0)[l]{|headheight|}}
+% \put(418,225){\line(-2,-1){20}}
+% \put(420,213){\makebox(0,0)[l]{|headsep|}}
+% \put(418,213){\line(-2,-1){20}}
+% \put(420,12){\makebox(0,0)[l]{|footskip|}}
+% \put(418,12){\line(-2,1){20}}
% \put(280,40){\makebox(120,140)[c]{\gpart{body}}}
+% \put(305,45){\vector(-1,0){25}}\put(375,45){\vector(1,0){25}}
+% \put(80,230){\vector(0,-1){30}}\put(80,30){\vector(0,-1){30}}
+% \put(280,48){\makebox(120,0)[c]{|textwidth|}}
% \put(280,15){\makebox(120,10)[c]{\gpart{foot}}}
-% \put(280,14){\line(1,0){120}}
+% \multiput(280,14)(5,0){24}{\line(1,0){2}}
+% \put(410,30){\dashbox{3}(30,170){}}
+% \put(415,30){\makebox(30,170)[l]{\gpart{marginal note}}}
+% \put(425,45){\vector(-1,0){15}}\put(425,45){\vector(1,0){15}}
+% \put(450,70){\makebox(0,0)[l]{|marginparsep|}}
+% \put(448,70){\line(-3,-1){43}}
+% \put(450,45){\makebox(0,0)[l]{|marginparwidth|}}
% \end{picture}}
-% \caption[Dimension names for \textsf{geometry}]{%
+% \caption[Dimension names for \Gm]{%
% \begin{minipage}[t]{.8\textwidth}\raggedright\small
-% Dimension names used in the \textsf{geometry} package.
+% Dimension names used in the \Gm\ package.
% |width|=|textwidth| and |height|=|textheight| by default.
% |left|, |right|, |top| and |bottom| are margins.
% If margins on verso pages are swapped by |twoside| option,
@@ -458,40 +395,32 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{minipage}}
% \label{fig:layout}
% \end{figure}
-% The dimensions for paper, total body and margins have the following
-% relations.
-% \begin{eqnarray}
-% \label{eq:paperwidth}
-% |paperwidth| &=& |left|+|width|+|right| \\
-% |paperheight| &=& |top|+|height|+|bottom|
-% \label{eq:paperheight}
-% \end{eqnarray}
-% The dimensions of the total body, |width| and |height|, are defined
-% as follows:
+%
+% The total body |width| and |height| would be defined:
% \begin{eqnarray}
% \label{eq:width}
% |width| &:=& |textwidth| \quad( + |marginparsep| + |marginparwidth| )\\
% |height| &:=& |textheight| \quad(+ |headheight| + |headsep| + |footskip| )
% \label{eq:height}
% \end{eqnarray}
-% In Equation (\ref{eq:width}), |width:=textwidth| by default,
-% but |marginparsep| and |marginparwidth| are included in |width|
+% In Equation (\ref{eq:width}) |width:=textwidth| by default,
+% while |marginparsep| and |marginparwidth| are included in |width|
% if |includemp| option is set |true|.
% In Equation (\ref{eq:height}), |height:=textheight| by default.
% If |includehead| is set to |true|, |headheight| and |headsep| are
-% considered as a part of |height| in the the vertical completion calculation.
-% In the same way, |includefoot| includes
-% |footskip|. Note that options |ignore*| just exclude the corresponding
-% spaces from |textheight|, but do not change those lengths themselves.
-% Figure~\ref{fig:includes} shows how these options work.
+% considered as a part of |height|.
+% In the same way, |includefoot| takes |footskip| into |height|.
+% Figure~\ref{fig:includes} shows how these options
+% work in the vertical direction.
% \begin{figure}
% \centering\small
% {\unitlength=.65pt
% \begin{picture}(490,280)(0,-10)
-% \put(25,255){\makebox(120,0)[bl]{\textbf{(a)}~\textit{default}}}%
+% \put(60,250){\makebox(120,0)[bl]{\textbf{(a)}~\textit{default}}}%
% \put(20,0){\framebox(170,230){}}
-% \put(20,230){\makebox(170,230)[br]{\gpart{paper}}}
-% \put(40,30){\framebox(120,165){}}
+% \put(20,230){\makebox(170,15)[r]{\gpart{paper}}}
+% \begingroup\thicklines
+% \put(40,30){\framebox(120,165){}}\endgroup
% \put(70,165){\vector(0,1){30}}
% \put(55,145){\makebox(0,20)[lc]{|textheight|}}
% \put(70,145){\vector(0,-1){115}}
@@ -500,29 +429,30 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \multiput(40,10)(5,0){24}{\line(1,0){3}}
% \put(40,203){\makebox(120,20)[bc]{\gpart{head}}}
% \put(40,40){\makebox(120,140)[c]{\gpart{body}}}
-% \put(40,10){\makebox(120,10)[c]{\gpart{foot}}}
+% \put(40,11){\makebox(120,10)[c]{\gpart{foot}}}
% \put(150,230){\vector(0,-1){35}}\put(150,30){\vector(0,-1){30}}
% \put(150,195){\vector(0,1){35}}\put(150,0){\vector(0,1){30}}
% \put(160,197){\makebox(0,30)[lc]{|top|}}
% \put(160,0){\makebox(0,30)[lc]{|bottom|}}
% \multiput(160,30)(5,0){24}{\line(1,0){2}}
% \multiput(160,195)(5,0){24}{\line(1,0){2}}
-% \put(265,255){\makebox(120,0)[bl]
+% \put(255,250){\makebox(120,0)[bl]
% {\textbf{(b)}~|includehead| and |includefoot|}}%
% \put(260,0){\framebox(170,230){}}
-% \put(260,230){\makebox(170,230)[br]{\gpart{paper}}}
-% \put(280,30){\framebox(120,165){}}
-% \put(310,150){\vector(0,1){25}}
+% \put(260,230){\makebox(170,15)[r]{\gpart{paper}}}
+% \begingroup\thicklines
+% \put(280,30){\framebox(120,165){}}\endgroup
+% \put(310,152){\vector(0,1){25}}
% \put(295,130){\makebox(0,20)[lc]{|textheight|}}
% \put(310,130){\vector(0,-1){80}}
-% \multiput(280,183)(5,0){24}{\line(1,0){3}}
-% \multiput(280,175)(5,0){24}{\line(1,0){3}}
+% \multiput(280,184)(5,0){24}{\line(1,0){3}}
+% \multiput(280,177)(5,0){24}{\line(1,0){3}}
% \multiput(280,50)(5,0){24}{\line(1,0){3}}
-% \put(280,183){\makebox(120,20)[bc]{\gpart{head}}}
+% \put(280,184){\makebox(120,10)[c]{\gpart{head}}}
% \put(280,40){\makebox(120,140)[c]{\gpart{body}}}
% \put(400,140){\line(1,1){45}}
% \put(437,187){\makebox(50,10)[l]{\gpart{total body}}}
-% \put(280,30){\makebox(120,10)[c]{\gpart{foot}}}
+% \put(280,31){\makebox(120,10)[c]{\gpart{foot}}}
% \put(370,230){\vector(0,-1){35}}\put(370,30){\vector(0,-1){30}}
% \put(370,195){\vector(0,1){35}}\put(370,0){\vector(0,1){30}}
% \put(380,197){\makebox(0,30)[lc]{|top|}}
@@ -534,247 +464,116 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% into \gpart{total body}. \textbf{(a)} |height| $=$ |textheight| (default).
% \textbf{(b)} |height| $=$ |textheight| $+$ |headheight| $+$ |headsep| $+$
% |footskip| if |includehead| and |includefoot|. If the top and bottom
-% margins are fixed, |includehead| and |includefoot| make |textheight|
-% shorter than default.
+% margins are specified, |includehead| and |includefoot| result in
+% shorter |textheight|.
% \end{minipage}}
% \label{fig:includes}
% \end{figure}
-% Each of the seven dimensions in the right-hand side of Equations
-% (\ref{eq:width}) and (\ref{eq:height}) corresponds to the ordinary
-% \LaTeX\ control sequence with the same name.
%
-% Figure~\ref{fig:modes} illustrates various layouts with different layout
-% modes. The dimensions for a header and a footer can be controlled by
-% |nohead| or |nofoot| mode, which sets each length to 0pt directly.
-% On the other hand, options |ignore*| do \textit{not} change
-% the corresponding native dimensions.
+% Thus, the page layout consists of three parts (lengths) in each
+% direction: one body and two margins. If the two of them are explicitly
+% specified, the other length is obvious and no need to be specified.
+% Figure~\ref{fig:Labc} shows a simple model of page dimensions.
+% When a length |L| is given and is partitioned into the body |b|, the
+% margins |a| and |c|, it's obvious that
+% \begin{equation}
+% |L|=|a|+|b|+|c| \label{eq:Labc}
+% \end{equation}
+% The specification with two of the three (|a|,|b| and |c|) fixed
+% explicitly is solvable. If two or more are left unspecified
+% or `underspecified', Equation~(\ref{eq:Labc}) cannot be solved
+% without any other relation between them. If all of them are
+% specified, then it needs to check whether or not they
+% satisfy Equation~(\ref{eq:Labc}), that is too much specification or
+% `overspecified'.
% \begin{figure}
-% \centering\small
-% {\unitlength=.65pt
-% \begin{picture}(460,525)(0,0)
-% \put( 20,310){\framebox(120,170){}}
-% \put( 20,507){\makebox(120,0)[bl]%
-% {\textbf{(a)}~|includeheadfoot|}}
-% \put( 20,460){\line(1,0){120}}\put( 20,450){\line(1,0){120}}
-% \put( 20,330){\line(1,0){120}}
-% \put( 20,485){\makebox(120,0)[br]{\gpart{total body}}}
-% \put( 20,335){\makebox(120,0)[bc]{|textwidth|}}
-% \put(150,470){\makebox(0,0)[l]{|headheight|}}
-% \put(150,450){\makebox(0,0)[l]{|headsep|}}
-% \put(150,390){\makebox(0,0)[l]{|textheight|}}
-% \put(150,320){\makebox(0,0)[l]{|footskip|}}
-% \put( 10,460){\makebox(120,20)[bc]{\gpart{head}}}
-% \put( 10,320){\makebox(120,140)[c]{\gpart{body}}}
-% \put( 10,310){\makebox(120,10)[c]{\gpart{foot}}}
-% \put(250,310){\framebox(120,170){}}
-% \put(250,507){\makebox(120,0)[bl]%
-% {\textbf{(b)}~|includeall|}}
-% \put(250,460){\line(1,0){95}}\put(250,450){\line(1,0){95}}
-% \put(250,330){\line(1,0){95}}\put(345,330){\line(0,1){120}}
-% \put(350,330){\line(0,1){120}}\put(350,450){\line(1,0){20}}
-% \put(350,330){\line(1,0){20}}
-% \put(250,485){\makebox(120,0)[br]{\gpart{total body}}}
-% \put(250,460){\makebox(95,20)[bc]{\gpart{head}}}
-% \put(250,320){\makebox(95,140)[c]{\gpart{body}}}
-% \put(385,390){\makebox(95,0)[cl]%
-% {\gpart{\shortstack[l]{marginal\\note}}}}
-% \put(250,310){\makebox(95,10)[c]{\gpart{foot}}}
-% \put(250,335){\makebox(95,0)[bc]{|textwidth|}}
-% \multiput(360, 390)(4,0){6}{\line(1,0){2}}
-% \multiput(348,333)(0,-4){12}{\line(0,1){2}}
-% \multiput(360,333)(0,-4){8}{\line(0,1){2}}
-% \put(355,292){\makebox(0,0)[bl]{|marginparwidth|}}
-% \put(345,275){\makebox(0,0)[bl]{|marginparsep|}}
-% \put( 20, 40){\framebox(120,170){}}
-% \put( 20,237){\makebox(120,0)[bl]%
-% {\textbf{(c)}~|includefoot|}}
-% \put( 20, 60){\line(1,0){120}}
-% \put( 20,215){\makebox(120,0)[br]{\gpart{total body}}}
-% \put(150,130){\makebox(0,0)[l]{|textheight|}}
-% \put(150, 50){\makebox(0,0)[l]{|footskip|}}
-% \put( 20, 50){\makebox(120,160)[c]{\gpart{body}}}
-% \put( 20, 40){\makebox(120,10)[c]{\gpart{foot}}}
-% \put( 20, 65){\makebox(120,10)[c]{|textwidth|}}
-% \put(250, 40){\framebox(120,170){}}
-% \put(250,237){\makebox(120,0)[bl]%
-% {\textbf{(d)}~|includefoot,includemp|}}
-% \put(250, 60){\line(1,0){95}}\put(350, 60){\line(1,0){20}}
-% \put(250,215){\makebox(120,0)[br]{\gpart{total body}}}
-% \put(250, 50){\makebox(95,160)[c]{\gpart{body}}}
-% \put(385,130){\makebox(95,0)[cl]%
-% {\gpart{\shortstack[l]{marginal\\note}}}}
-% \put(250, 40){\makebox(95,10)[c]{\gpart{foot}}}
-% \put(250, 65){\makebox(95,0)[bc]{|textwidth|}}
-% \put(345, 60){\line(0,1){150}}\put(350, 60){\line(0,1){150}}
-% \multiput(360, 130)(4,0){6}{\line(1,0){2}}
-% \multiput(348, 63)(0,-4){12}{\line(0,1){2}}
-% \multiput(360, 63)(0,-4){8}{\line(0,1){2}}
-% \put(355,22){\makebox(0,0)[bl]{|marginparwidth|}}
-% \put(345, 5){\makebox(0,0)[bl]{|marginparsep|}}
+% \centering
+% {\unitlength=0.8pt
+% \begin{picture}(300,60)(0,-5)
+% \begingroup\linethickness{5pt}
+% \put(0,5){\textcolor{green}{\line(1,0){60}}}
+% \put(60,5){\textcolor{black}{\line(1,0){160}}}
+% \put(220,5){\textcolor{green}{\line(1,0){80}}}
+% \endgroup
+% \put(0,15){\makebox(60,10)[b]{|a|}}
+% \put(60,0){\line(0,1){20}}
+% \put(60,15){\makebox(160,10)[b]{|b|}}
+% \put(220,0){\line(0,1){20}}
+% \put(220,15){\makebox(80,10)[b]{|c|}}
+% \put(0,0){\line(0,1){50}}
+% \put(150,35){\vector(-1,0){150}}
+% \put(0,40){\makebox(300,10){|L|}}
+% \put(150,35){\vector(1,0){150}}
+% \put(300,0){\line(0,1){50}}
% \end{picture}}
-% \caption[Sample layouts for \gpart{total body} with different
-% layout modes]{%
-% \begin{minipage}[t]{.8\textwidth}\small
-% Sample layouts for \gpart{total body} with different switches.
-% (a) |includeheadfoot|, (b) |includeall|, (c) |includefoot|
-% and (d) |includefoot,includemp|.
-% If |reversemp| is set to |true|, the location of the
-% marginal notes are swapped on every page.
-% Option |twoside| swaps both margins and marginal notes on verso pages.
-% Note that the marginal notes are printed on the page, even when
-% |ignoremp| or |includemp=false|, but can fall off the page in some cases.
-% \end{minipage}}
-% \label{fig:modes}
+% \caption{A simple model of page dimensions.}
+% \label{fig:Labc}
% \end{figure}
%
-% \subsection{Auto-completion scheme}\label{sec:completion}
-%
-% Suppose that the paper size is pre-defined in Equation~(\ref{eq:paperwidth})
-% or (\ref{eq:paperheight}), if two dimensions out of the three dimensions
-% in the right-hand side of each equation are specified, the rest of the
-% dimensions can be determined by the specified ones. However, when none or
-% only one of the three dimensions is specified, the rest of the dimensions
-% can't generally be determined without some assumptions.
-%
-% The \textsf{geometry} package has an auto-completion scheme with some
-% default parameters to determine the unspecified dimensions independently
-% for each direction. If the size of \gpart{total body} (i.e., |width| in
-% the horizontal direction) is specified, the margins (|left| and |right|)
-% can be determined with a default ratio of one margin to the other
-% (|left/right|).
-% If one margin is specified, the rest of dimensions can also be determined
-% by the default margin ratio.
-% Page margin setting by margin ratio was introduced in KOMA
-% script\footnote{CTAN:~\texttt{macros/latex/contrib/koma-script}
-% by Frank Neukam and Markus Kohm.}.
+% The \Gm\ package has auto-completion mechanism that saves the
+% trouble of specifying the page layout dimensions. For example,
+% you can set
+% \begin{quote}
+% |\usepackage[width=14cm, left=3cm]{geometry}|
+% \end{quote}
+% on A4 paper. In this case you don't have to set the right margin
+% The details of auto-completion will be described in
+% Section~\ref{sec:rules}.
%
-% The default vertical margin ratio is $2/3$, namely,
-% \begin{equation}
-% |top| : |bottom| = 2 : 3 \qquad\textit{default}.
-% \end{equation}
-% As for the horizontal margin ratio, the default value depends on
-% whether the document is onesided or twosided,
-% \begin{equation}
-% |left|\;(|inner|) : |right|\;(|outer|)
-% = \left\{ \begin{array}{ll}
-% 1 : 1 \qquad\textit{default for oneside},\\
-% 2 : 3 \qquad\textit{default for twoside}.
-% \end{array}\right.
-% \end{equation}
-% Obviously the default horizontal margin ratio for oneside is `centering'.
+% \section{User interface}
%
-% For example, if one specifies |right=2.4cm| with a \textit{twosided}
-% layout in A4 paper (21.0cm$\times$29.7cm), unspecified |left| and |width|
-% are automatically determined using the default horizontal margin ratio
-% (2/3) as follows:
-% \begin{eqnarray}
-% |left| &=& \langle\textsf{horizontal-margin-ratio}\rangle
-% \times |right| \nonumber\\
-% &=& |2/3| \times |2.4cm| = |1.6cm|\\[1ex]
-% |width| &=& |paperwidth| - |left| - |right| \nonumber\\
-% &=& |21.0cm| - |1.6cm| - |2.4cm| = |17.0cm|.
-% \end{eqnarray}
-% In this case, the vertical dimensions |top|, |height| and |bottom|
-% are determined by the default vertical margin ratio with 2:3
-% and the default size of \gpart{total body} with 70\% of the paper height:
-% \begin{eqnarray}\displaystyle
-% |height| &=& |0.7| \times |paperheight|\nonumber\\
-% &=& |0.7| \times |29.7cm| = |20.79cm| \\[1ex]
-% |top| &=& \frac{\langle\textsf{vertical-margin-ratio}\rangle}
-% {1+\langle\textsf{vertical-margin-ratio}\rangle}
-% \times (|paperheight| - |height|) \nonumber\\
-% &=& \frac{2}{2+3}\times(|29.7cm| - |20.79cm|)\nonumber\\[1ex]
-% &=& 0.4\times |8.91cm| = |3.564cm|\\[2ex]
-% |bottom| &=& 0.6\times |8.91cm| = |5.346cm|
-% \end{eqnarray}
+% \subsection{Commands}
%
-% The auto-completion rules are shown in Table~\ref{tab:completion}
-% and Equation~(\ref{eq:completion}).
-% $A$, $B$ and $C$ in Table~\ref{tab:completion} are user-specified values,
-% $*$ denotes unspecified ones. The right-hand side table shows the
-% corresponding results of auto-completion. The unspecified values can be
-% determined by $A$, $B$ and $L$ (|paperwidth| or |paperheight|).
-% In Table~\ref{tab:completion}, functions ${\cal R}(x)$ and ${\cal M}(x)$
-% are defined as follows:
-% \begin{equation}
-% \begin{array}{rcl}
-% {\cal R}(x) &=& L-x\\
-% {\cal M}(x) &=& {\cal R}(x)\;/\;(1+\sigma)\\
-% \end{array}
-% \label{eq:completion}
-% \end{equation}
-% Here $\sigma$ denotes the ratio of left margin (inner) to right margin
-% (outer) or the ratio of top to bottom. To set $\sigma$ as a geometry option,
-% you can use \{|h|,|v|\}|marginratio| options with |a:b|-type value,
-% for example, |hmarginratio=2:3|.
-% \begin{eqnarray}
-% \label{eq:hratios}
-% |hmarginratio| &=& |left| : |right|\\
-% |vmarginratio| &=& |top| : |bottom|
-% \label{eq:vratios}
-% \end{eqnarray}
-% By default, $\sigma$ is 1/1 (=1) for oneside and 2/3 for twoside
-% in the horizontal direction, and 2/3 in the vertical.
-% If none of three dimensions is specified in each direction, the default
-% setting is used: width and height is set to 70\% of the paper width
-% and height respectively. If all the three dimensions would be specified,
-% margins remain and width or height is ignored.
-%
-% \begin{table}
-% \def\AST{\texttt{*}}\centering
-% \begin{tabular}{cccccccl}
-% \multicolumn{3}{c}{Settings}& &\multicolumn{3}{c}{Results}\\
-% \noalign{\vspace{.1em}}
-% \cline{1-3}\cline{5-7}
-% \parbox{3em}{\hfil\glen{left}}&\parbox{3em}{\hfil\glen{width}}&
-% \parbox{3em}{\hfil\glen{right}}&&%
-% \parbox{3em}{\hfil\glen{left}}&\parbox{3em}{\hfil\glen{width}}&
-% \parbox{3em}{\hfil\glen{right}}&\\
-% \cline{1-3}\cline{5-7}
-% \glen{top}&\glen{height}&\glen{bottom}&&%
-% \glen{top}&\glen{height}&\glen{bottom}&\\
-% \cline{1-3}\cline{5-7}
-% \noalign{\vspace{.2em}}
-% \AST & \AST & \AST && $\sigma{\cal M}(0.7L)$ & $0.7L$ & ${\cal M}(0.7L)$&\\
-% \AST & $A$ & \AST && $\sigma{\cal M}(A)$ & $A$ & ${\cal M}(A)$ &\\
-% $A$ & \AST & \AST && $A$ & ${\cal R}(A+A/\sigma)$ & $A/\sigma$ &\\
-% \AST & \AST & $A$ &$\Longrightarrow$%
-% & $\sigma A$ & ${\cal R}(A+\sigma{}A)$ & $A$ &\\
-% $A$ & $B$ & \AST && $A$ & $B$ & ${\cal R}(A+B)$ &\\
-% \AST & $A$ & $B$ && ${\cal R}(A+B)$ & $A$ & $B$ &\\
-% $A$ & \AST & $B$ && $A$ & ${\cal R}(A+B)$ & $B$ &\\
-% $A$ & $C$ & $B$ && $A$ & ${\cal R}(A+B)$ & $B$ &\\
-% \cline{1-3}\cline{5-7}
-% \end{tabular}
-% \caption[Auto-comletion rules]{%
-% \begin{minipage}[t]{.8\textwidth}\small
-% Auto-completion rules. The mark `|*|' in each row (left table) denotes
-% the dimensions not specified explicitly, which can be determined as the
-% corresponding Results (right table). $\sigma$ denotes the value of
-% margin ratio. Functions ${\cal R}(x)$ and ${\cal M}(x)$ are defined
-% in Equation~(\ref{eq:completion}). The bottom case shows
-% over-specification, which gives in the same result as the $A$-\AST-$B$ case.
-% \end{minipage}}
-% \label{tab:completion}
-% \end{table}
+% The \Gm\ package provides the following commands:
+% \begin{itemize}\setlength{\itemsep}{-.5\parsep}
+% \item |\geometry{|\meta{options}|}|
+% \item |\newgeometry{|\meta{options}|}| and |\restoregeometry|
+% \item |\savegeometry{|\meta{name}|}| and |\loadgeometry{|\meta{name}|}|
+% \end{itemize}
%
-% \section{User interface}
-% \subsection{General features}
-%
-% The geometry options using the \textsf{keyval} interface
-% `\meta{key}=\meta{value}' can be set either in the optional argument to
-% the \cs{usepackage} command, or in the argument of the
-% \cs{geometry} macro. This macro, if necessary, should be used only in the
-% preamble, i.e., before |\begin{document}|.
-% In either case, the argument consists of a list of
-% comma-separated \textsf{keyval} options.
-% The main features of setting options are listed below.
-% \begin{itemize}\itemsep=0pt
-% \item Multiple lines are allowed. (But blank lines are not allowed.)
+% |\geometry{|\meta{options}|}|
+% changes the page layout according to the options specified in the
+% argument. This command, if any, should be placed only in the
+% preamble (before |\begin{document}|).
+%
+% The \Gm\ package may be used as part of a class or another package
+% you use in your document. The command \cs{geometry} can overwrite
+% some of the settings in the preamble. Multiple use of \cs{geometry}
+% is allowed and then processed with the options concatenated.
+% If \Gm\ is not yet loaded, you can use only
+% |\usepackage[|\meta{options}|]{geometry}| instead of \cs{geometry}.
+%
+% \medskip
+% |\newgeometry{|\meta{options}|}|
+% changes the page layout mid-document. \cs{newgeometry} is almost
+% similar to \cs{geometry} except that \cs{newgeometry} disables all
+% the options specified by \cs{usepackage} and \cs{geometry} in
+% the preamble and skips papersize-related options.
+% \cs{restoregeometry}
+% restores the page layout specified in the preamble. This command
+% has no arguments. See Section~\ref{sec:midchange} for details.
+%
+% \medskip
+% |\savegeometry{|\meta{name}|}|
+% saves the page dimensions as \meta{name} where you put
+% this command.
+% |\loadgeometry{|\meta{name}|}|
+% loads the page dimensions saved as \meta{name}. See
+% Section~\ref{sec:midchange} for details.
+%
+% \subsection{Optional argument}
+%
+% The \Gm\ package adopts \textsf{keyval} interface
+% `\meta{key}=\meta{value}' for the optional argument to
+% \cs{usepackage}, \cs{geometry} and \cs{newgeometry}.
+%
+% The argument includes a list of comma-separated \textsf{keyval}
+% options and has basic rules as follows:
+% \begin{itemize}\setlength{\itemsep}{-.5\parsep}
+% \item Multiple lines are allowed, while blank lines are not.
% \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.)
+% \item Options are basically order-independent.
+% (There are some exceptions. See Section~\ref{sec:optionorder} for details.)
% \end{itemize}
% For example,
% \begin{quote}
@@ -801,7 +600,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{quote}
% Thus, multiple use of \cs{geometry} just appends options.
%
-% \textsf{Geometry} supports package
+% \Gm\ supports package
% \textsl{calc}\footnote{CTAN:~\texttt{macros/latex/required/tools}}.
% For example,
% \begin{quote}
@@ -810,7 +609,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{quote}
%
% \subsection{Option types}
-% \textsf{Geometry} options are categorized into four types:
+% \Gm\ options are categorized into four types:
%
% \begin{enumerate}\itemsep=0pt
% \item \textbf{Boolean type}
@@ -865,50 +664,128 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% |divide={1in,*,1in}|.
% \end{enumerate}
%
-% \section{Option specification}
+% \section{Option details}
%
-% This section describes all the options provided by \textsf{geometry}.
+% This section describes all the options available in \Gm.
+% Options with a dagger $^\dagger$ are not available
+% as a argument of \cs{newgeometry} (See Section~\ref{sec:midchange}).
%
-% \subsection{Paper size}
+% \subsection{Paper size}\label{sec:paper}
%
% The options below set paper/media size and orientation.
% \begin{Options}
-% \item[paper\OR papername] ~\\
-% specifies a paper name. The paper names available in \textsf{geometry}.
-% |paper=|\meta{paper-name}. For example |paper=a4paper|, which is
-% equivalent to just |a4paper|.
-% \item[\vtop{
-% \hbox{a0paper, a1paper, a2paper, a3paper, a4paper, a5paper, a6paper}
-% \hbox{b0paper, b1paper, b2paper, b3paper, b4paper, b5paper, b6paper}
-% \hbox{ansiapaper, ansibpaper, ansicpaper, ansidpaper, ansiepaper}
+% \item[\onlypre paper\OR papername] ~\\
+% specifies the paper size by name. |paper=|\meta{paper-name}.
+% For convenience, you can specify the paper name without |paper=|.
+% For example, |a4paper| is equivalent to |paper=a4paper|.
+% \item[\onlypre \vtop{
+% \hbox{a0paper, a1paper, a2paper, a3paper, a4paper, a5paper, a6paper,}
+% \hbox{b0paper, b1paper, b2paper, b3paper, b4paper, b5paper, b6paper,}
+% \hbox{b0j, b1j, b2j, b3j, b4j, b5j, b6j,}
+% \hbox{ansiapaper, ansibpaper, ansicpaper, ansidpaper, ansiepaper,}
% \hbox{letterpaper, executivepaper, legalpaper}}]~\\[1ex]
-% specifies paper name. They can typically be used with no values.
-% Note that whatever value (even |false|) is given to this option, the
-% value will be ignored. For example, the followings have the same effect:
-% |a5paper|, |a5paper=true|, |a5paper=false| and |a5paper=XXXX|.
-% \item[screen] a special paper size with (W,H) = (225mm,180mm).
+% specifies paper name. The value part is ignored even if any.
+% For example, the followings have the same effect:
+% |a5paper|, |a5paper=true|, |a5paper=false| and so forth.
+% |a[0-6]paper| and |b[0-6]paper| are ISO A and B series of paper sizes.
+% The JIS (Japanese Industrial Standards) A-series is identical to the ISO A-series,
+% but the JIS B-series is different from the ISO B-series.
+% |b[0-6]j| should be used for the JIS B-series.
+% \item[\onlypre screen] a special paper size with (W,H) = (225mm,180mm).
% For presentation with PC and video projector, ``|screen,centering|''
% with `slide' documentclass would be useful.
-% \item[paperwidth] width of the paper. |paperwidth=|\meta{length}.
-% \item[paperheight] height of the paper. |paperheight=|\meta{length}.
-% \item[papersize] width and height of the paper.\\
+% \item[\onlypre paperwidth] width of the paper. |paperwidth=|\meta{length}.
+% \item[\onlypre paperheight] height of the paper. |paperheight=|\meta{length}.
+% \item[\onlypre papersize] width and height of the paper.
% |papersize=|\argii{width}{height} or |papersize=|\meta{length}.
-% \item[landscape] switches the paper orientation to landscape mode.
-% \item[portrait] switches the paper orientation to portrait mode.
+% \item[\onlypre landscape] switches the paper orientation to landscape mode.
+% \item[\onlypre portrait] switches the paper orientation to portrait mode.
% This is equivalent to |landscape=false|.
% \end{Options}
%
-% Options for paper names (e.g., |a4paper|) and orientation
+% The options for paper names (e.g., |a4paper|) and orientation
% (|portrait| and |landscape|) can be set as document class options.
% For example, you can set |\documentclass[a4paper,landscape]{article}|,
-% then |a4paper| and |landscape| are processed in \textsf{geometry} as well.
+% then |a4paper| and |landscape| are processed in \Gm\ as well.
% This is also the case for |twoside| and |twocolumn|
% (see also Section~\ref{sec:dimension}).
%
+% \subsection{Layout size}
+%
+% You can specify the layout area with options described in this
+% section regardless of the paper size.
+% The options would help to print the specified layout to a different
+% sized paper. For example, with |a4paper| and |layout=a5paper|, the
+% package uses `A5' layout to calculate margins on 'A4' paper.
+% The layout size defaults to the same as the paper.
+% The options for the layout size are available in \cs{newgeometry},
+% so that you can change the layout size in the middle of the document.
+% The paper size itself can't be changed though.
+% Figure~\ref{fig:layoutandpaper} shows what the difference between
+% |layout| and |paper| is.
+% \begin{Options}
+% \item[layout] specifies the layout size by paper
+% name. |layout=|\meta{paper-name}. All th paper names defined in \Gm\
+% are available. See Section~\ref{sec:paper} for details.
+% \item[layoutwidth] width of the layout. |layoutwidth=|\meta{length}.
+% \item[layoutheight] height of the layout. |layoutheight=|\meta{length}.
+% \item[layoutsize] width and height of the layout.
+% |layoutsize=|\argii{width}{height} or |layoutsize=|\meta{length}.
+% \item[layouthoffset] specifies the horizontal offset from the left edge of
+% the paper. |layouthoffset=|\meta{length}.
+% \item[layoutvoffset] specifies the vertical offset from the top edge of
+% the paper. |layoutvoffset=|\meta{length}.
+% \item[layoutoffset] specifies both horizontal and vertical offsets.
+% |layoutoffset=|\argii{hoffset}{voffset} or |layoutsize=|\meta{length}.
+% \end{Options}
+% \begin{figure}
+% \centering\small
+% {\unitlength=.6pt
+% \begin{picture}(450,250)(0,-10)
+% \put(20,0){\makebox(168,12)[r]{\gpart{paper}}}
+% \put(20,0){\framebox(170,230){}}
+% \put(21,40){\dashbox{3}(140,189){}}
+% \put(21,28){\makebox(140,12)[r]{\gpart{layout}}}
+% \put(40,50){\makebox(100,10){\gpart{foot}}}
+% \put(40,50){\line(1,0){100}}
+% \put(40,65){\framebox(100,125){\gpart{body}}}
+% \put(40,200){\framebox(100,10){\gpart{head}}}
+% \put(20,230){\makebox(140,20){|layoutwidth|}}
+% \put(40,240){\vector(-1,0){20}}
+% \put(140,240){\vector(1,0){20}}
+% \put(10,145){\vector(0,1){85}}
+% \put(15,125){\makebox(0,20)[r]{|layoutwidth|}}
+% \put(10,125){\vector(0,-1){85}}
+% \put(280,0){\makebox(168,12)[r]{\gpart{paper}}}
+% \put(280,0){\framebox(170,230){}}
+% \put(293,35){\dashbox{3}(140,189){}}
+% \put(293,23){\makebox(140,12)[r]{\gpart{layout}}}
+% \put(312,45){\makebox(100,10){\gpart{foot}}}
+% \put(312,45){\line(1,0){100}}
+% \put(312,60){\framebox(100,125){\gpart{body}}}
+% \put(312,195){\framebox(100,10){\gpart{head}}}
+% \put(235,230){\makebox(80,20)[l]{|layouthoffset|}}
+% \put(260,210){\vector(1,0){20}}
+% \put(308,210){\vector(-1,0){15}}
+% \put(260,210){\line(-1,2){10}}
+% \put(355,230){\makebox(100,20){|layoutvoffset|}}
+% \put(350,250){\vector(0,-1){20}}
+% \put(350,209){\vector(0,1){15}}
+% \end{picture}}
+% \caption[layout and paper]{%
+% \begin{minipage}[t]{.7\textwidth}\raggedright\small
+% The dimensions related to the layout size. Note that the layout size
+% defaults to the same size as the paper, so you don't have to specify
+% layout-related options explicitly in most cases.
+% \end{minipage}}
+% \label{fig:layoutandpaper}
+% \end{figure}
+%
% \subsection{Body size}\label{sec:body}
%
% The options specifying the size of \gpart{total body} are described in this
% section.
+%
% \begin{Options}
% \item[hscale]
% ratio of width of \gpart{total body} to \cs{paperwidth}.
@@ -923,11 +800,11 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% (|0.7| by default)
% \item[width\OR totalwidth] ~\\
% width of \gpart{total body}. |width=|\meta{length} or
-% |totalwidth=|\meta{length}. This dimension should not be confused with
-% |textwidth|. Generally, |width| $\ge$ |textwidth| because |width|
-% includes the width of the marginal notes if |includemp| is set to |true|.
-% If |textwidth| and |width| are specified at the same time, |width| is
-% ignored.
+% |totalwidth=|\meta{length}. This dimension defaults to |textwidth|,
+% but if |includemp| is set to |true|, |width| $\ge$ |textwidth|
+% because |width| includes the width of the marginal notes.
+% If |textwidth| and |width| are specified at the same time,
+% |textwidth| takes priority over |width|.
% \item[height\OR totalheight] ~\\
% height of \gpart{total body}, excluding header and footer by default.
% If |includehead| or |includefoot| is set, |height| includes
@@ -936,42 +813,45 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% |textheight| and |height| are specified, |height| will be ignored.
% \item[total] width and height of \gpart{total body}.\\
% |total=|\argii{width}{height} or |total=|\meta{length}.
-% \item[textwidth] modifies \cs{textwidth}, the width of \gpart{body}
-% (the text are). |textwidth=|\meta{length}.
-% \item[textheight] modifies \cs{textheight}, the height of \gpart{body}.
-% |textheight=|\meta{length}.
-% \item[text\OR body] sets both \cs{textwidth} and \cs{textheight} of the body
-% of page. |body=|\argii{width}{height} or |text=|\meta{length}.
+% \item[textwidth] specifies \cs{textwidth}, the width of \gpart{body}
+% (the text area). |textwidth=|\meta{length}.
+% \item[textheight] specifies \cs{textheight}, the height of
+% \gpart{body} (the text area). |textheight=|\meta{length}.
+% \item[text\OR body] specifies both \cs{textwidth} and \cs{textheight}
+% of the body of page. |body=|\argii{width}{height} or
+% |text=|\meta{length}.
% \item[lines] enables users to specify \cs{textheight} by the number
% of lines. |lines|=\meta{integer}.
% \item[includehead] includes the head of the page, \cs{headheight}
% and \cs{headsep}, into \gpart{total body}. It is set to |false| by
-% default. It is opposite to |ignorehead|. See Figure~\ref{fig:includes}.
+% default. It is opposite to |ignorehead|. See
+% Figure~\ref{fig:includes} and Figure~\ref{fig:modes}.
% \item[includefoot] includes the foot of the page, \cs{footskip},
% into \gpart{total body}. It is opposite to |ignorefoot|.
-% It is |false| by default. See Figure~\ref{fig:includes}.
+% It is |false| by default. See Figure~\ref{fig:includes} and
+% Figure~\ref{fig:modes}.
% \item[includeheadfoot]~\\
% sets both |includehead| and |includefoot| to |true|, which is opposite
-% to |ignoreheadfoot|. See Figure~\ref{fig:includes}.
+% to |ignoreheadfoot|. See Figure~\ref{fig:includes} and
+% Figure~\ref{fig:modes}.
% \item[includemp] includes the margin notes, \cs{marginparwidth}
% and \cs{marginparsep}, into \gpart{body} when calculating horizontal
-% calculation. In version 3, |includemp| is independent of options
-% |marginparwidth| and |marginparsep|, and set to |false| by default.
+% calculation.
% \item[includeall] sets both |includeheadfoot| and |includemp| to
-% |true|. See Figure~\ref{fig:includes} and Figure~\ref{fig:modes}.
+% |true|. See Figure~\ref{fig:modes}.
% \item[ignorehead] disregards the head of the page,
% |headheight| and |headsep|, in determining vertical layout, but does not
% change those lengths. It is equivalent to |includehead=false|. It is set
% to |true| by default. See also |includehead|.
% \item[ignorefoot] disregards the foot of page, |footskip|,
% in determining vertical layout, but does not change that length.
-% This option is set to |true| by default. See also |includefoot|.
+% This option defaults to |true|. See also |includefoot|.
% \item[ignoreheadfoot]~\\ sets both |ignorehead| and |ignorefoot|
% to |true|. See also |includeheadfoot|.
% \item[ignoremp] disregards the marginal notes in determining the
-% horizontal margins (|true| is set by default). If marginal notes fall off
+% horizontal margins (defaults to |true|). If marginal notes overrun
% the page, the warning message will be displayed when |verbose=true|.
-% See also Figure~\ref{fig:modes} and |includemp|.
+% See also |includemp| and Figure~\ref{fig:modes}.
% \item[ignoreall] sets both |ignoreheadfoot| and |ignoremp| to |true|.
% See also |includeall|.
% \item[heightrounded]~\\
@@ -988,8 +868,93 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% by default.
% \end{Options}
%
+% Figure~\ref{fig:modes} illustrates various layouts with different layout
+% modes. The dimensions for a header and a footer can be controlled by
+% |nohead| or |nofoot| mode, which sets each length to 0pt directly.
+% On the other hand, options with the prefix |ignore| do \textit{not}
+% change the corresponding native dimensions.
+% \begin{figure}
+% \centering\small
+% {\unitlength=.65pt
+% \begin{picture}(460,525)(0,0)
+% \put( 20,310){\framebox(120,170){}}
+% \put( 20,507){\makebox(120,0)[bl]%
+% {\textbf{(a)}~|includeheadfoot|}}
+% \put( 20,460){\line(1,0){120}}\put( 20,450){\line(1,0){120}}
+% \put( 20,330){\line(1,0){120}}
+% \put( 20,485){\makebox(120,0)[br]{\gpart{total body}}}
+% \put( 20,335){\makebox(120,0)[bc]{|textwidth|}}
+% \put(150,470){\makebox(0,0)[l]{|headheight|}}
+% \put(150,450){\makebox(0,0)[l]{|headsep|}}
+% \put(150,390){\makebox(0,0)[l]{|textheight|}}
+% \put(150,320){\makebox(0,0)[l]{|footskip|}}
+% \put( 10,460){\makebox(120,20)[bc]{\gpart{head}}}
+% \put( 10,320){\makebox(120,140)[c]{\gpart{body}}}
+% \put( 10,310){\makebox(120,10)[c]{\gpart{foot}}}
+% \put(250,310){\framebox(120,170){}}
+% \put(250,507){\makebox(120,0)[bl]%
+% {\textbf{(b)}~|includeall|}}
+% \put(250,460){\line(1,0){95}}\put(250,450){\line(1,0){95}}
+% \put(250,330){\line(1,0){95}}\put(345,330){\line(0,1){120}}
+% \put(350,330){\line(0,1){120}}\put(350,450){\line(1,0){20}}
+% \put(350,330){\line(1,0){20}}
+% \put(250,485){\makebox(120,0)[br]{\gpart{total body}}}
+% \put(250,460){\makebox(95,20)[bc]{\gpart{head}}}
+% \put(250,320){\makebox(95,140)[c]{\gpart{body}}}
+% \put(385,390){\makebox(95,0)[cl]%
+% {\gpart{\shortstack[l]{marginal\\note}}}}
+% \put(250,310){\makebox(95,10)[c]{\gpart{foot}}}
+% \put(250,335){\makebox(95,0)[bc]{|textwidth|}}
+% \multiput(360, 390)(4,0){6}{\line(1,0){2}}
+% \multiput(348,333)(0,-4){12}{\line(0,1){2}}
+% \multiput(360,333)(0,-4){8}{\line(0,1){2}}
+% \put(355,292){\makebox(0,0)[bl]{|marginparwidth|}}
+% \put(345,275){\makebox(0,0)[bl]{|marginparsep|}}
+% \put( 20, 40){\framebox(120,170){}}
+% \put( 20,237){\makebox(120,0)[bl]%
+% {\textbf{(c)}~|includefoot|}}
+% \put( 20, 60){\line(1,0){120}}
+% \put( 20,215){\makebox(120,0)[br]{\gpart{total body}}}
+% \put(150,130){\makebox(0,0)[l]{|textheight|}}
+% \put(150, 50){\makebox(0,0)[l]{|footskip|}}
+% \put( 20, 50){\makebox(120,160)[c]{\gpart{body}}}
+% \put( 20, 40){\makebox(120,10)[c]{\gpart{foot}}}
+% \put( 20, 65){\makebox(120,10)[c]{|textwidth|}}
+% \put(250, 40){\framebox(120,170){}}
+% \put(250,237){\makebox(120,0)[bl]%
+% {\textbf{(d)}~|includefoot,includemp|}}
+% \put(250, 60){\line(1,0){95}}\put(350, 60){\line(1,0){20}}
+% \put(250,215){\makebox(120,0)[br]{\gpart{total body}}}
+% \put(250, 50){\makebox(95,160)[c]{\gpart{body}}}
+% \put(385,130){\makebox(95,0)[cl]%
+% {\gpart{\shortstack[l]{marginal\\note}}}}
+% \put(250, 40){\makebox(95,10)[c]{\gpart{foot}}}
+% \put(250, 65){\makebox(95,0)[bc]{|textwidth|}}
+% \put(345, 60){\line(0,1){150}}\put(350, 60){\line(0,1){150}}
+% \multiput(360, 130)(4,0){6}{\line(1,0){2}}
+% \multiput(348, 63)(0,-4){12}{\line(0,1){2}}
+% \multiput(360, 63)(0,-4){8}{\line(0,1){2}}
+% \put(355,22){\makebox(0,0)[bl]{|marginparwidth|}}
+% \put(345, 5){\makebox(0,0)[bl]{|marginparsep|}}
+% \end{picture}}
+% \caption[Sample layouts for \gpart{total body} with different
+% layout modes]{%
+% \begin{minipage}[t]{.8\textwidth}\small
+% Sample layouts for \gpart{total body} with different switches.
+% (a) |includeheadfoot|, (b) |includeall|, (c) |includefoot|
+% and (d) |includefoot,includemp|.
+% If |reversemp| is set to |true|, the location of the
+% marginal notes are swapped on every page.
+% Option |twoside| swaps both margins and marginal notes on verso pages.
+% Note that the marginal note, if any, is printed despite
+% |ignoremp| or |includemp=false| and overrun the page in some cases.
+% \end{minipage}}
+% \label{fig:modes}
+% \end{figure}
+%
% The following options can specify body and margins simultaneously with
% three comma-separated values in braces.
+%
% \begin{Options}
% \item[hdivide] horizontal partitions (left,width,right).
% |hdivide=|\argiii{left margin}{width}{right margin}.
@@ -1006,7 +971,8 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
%
% \subsection{Margin size}\label{sec:margin}
%
-% The options specifying the size of visible margins are listed below.
+% The options specifying the size of the margins are listed below.
+%
% \begin{Options}
% \item[left\OR lmargin\OR inner]~\\
% left margin (for oneside) or inner margin (for twoside) of
@@ -1099,21 +1065,19 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{picture}}
% \caption[\texttt{bindingoffset} option]{%
% \begin{minipage}[t]{.8\textwidth}\raggedright\small
-% |bindingoffset| option. Note that |twoside| option swaps the horizontal
-% margins and the marginal notes together with |bindingoffset| on even
-% pages (see \textbf{b)}), but |asymmetric| option suppresses the swap
-% of the margins and marginal notes (but |bindingoffset| is still swapped).
+% The option |bindingoffset| adds the specified length to the inner margin.
+% Note that |twoside| option swaps the horizontal margins and the
+% marginal notes together with |bindingoffset| on even pages (see
+% \textbf{b)}), but |asymmetric| option suppresses the swap of the
+% margins and marginal notes (but |bindingoffset| is still swapped).
% \end{minipage}}
% \label{fig:bindingoffset}
% \end{figure}
%
% \subsection{Native dimensions}\label{sec:dimension}
%
-% The options below specify \LaTeX\ native dimensions and switches for page
-% layout. See Figure~\ref{fig:layout}. Note that unlike version 2.3,
-% |nohead|, |nofoot| and |noheadfoot| become overwritable, in other words,
-% just shorthand for setting the corresponding LaTeX dimensions
-% (\cs{headheight}, \cs{headsep} and \cs{footskip}) to 0pt.
+% The options below overwrite \LaTeX\ native dimensions and switches for page
+% layout (See the right-hand side in Figure~\ref{fig:layout}).
%
% \begin{Options}
% \item[headheight\OR head]~\\
@@ -1135,10 +1099,8 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \item[marginparwidth\OR marginpar]~\\
% modifies \cs{marginparwidth}, width of the marginal notes.
% |marginparwidth=|\meta{length}.
-% Unlike version 2.3, it does \textit{not} set |includemp=true|.
% \item[marginparsep] modifies \cs{marginparsep}, separation between
% body and marginal notes. |marginparsep=|\meta{length}.
-% Unlike version 2.3, it does \textit{not} set |includemp=true|.
% \item[nomarginpar] shrinks spaces for marginal notes to 0pt, which
% is equivalent to \cs{marginparwidth}|=0pt| and \cs{marginparsep}|=0pt|.
% \item[columnsep] modifies \cs{columnsep}, the separation between two
@@ -1155,39 +1117,53 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \item[textheight] sets \cs{textheight} directly. See Section~\ref{sec:body}.
% \item[reversemp\OR reversemarginpar]~\\
% makes the marginal notes appear in the left (inner) margin with
-% \cs{@reversemargintrue}. Unlike version 2.3 or earlier,
-% it does \textit{not} change |includemp| mode. This is |false| by default.
+% \cs{@reversemargintrue}. The option doesn't change |includemp| mode.
+% It's set |false| by default.
% \end{Options}
%
-% \subsection{drivers}\label{sec:drivers}
+% \subsection{Drivers}\label{sec:drivers}
%
-% Package \textsf{geometry} supports |dvips|, |dvipdfm| including its
-% derivatives \textsf{dvipdfmx} and \textsf{xdvipdfmx}, |pdftex|
-% for \textsf{pdflatex}, and |vtex| for V\TeX{} environment.
-% These driver options are exclusive. The driver can be set by either
+% The package supports drivers |dvips|, |dvipdfm|, |pdftex|, |xetex| and
+% |vtex|. You can also set |dvipdfm| for \textsf{dvipdfmx} and
+% \textsf{xdvipdfmx}. |pdftex| for \textsf{pdflatex}, and |vtex| for
+% V\TeX{} environment.
+% The driver options are exclusive. The driver can be set by either
% |driver=|\meta{driver name} or any of the drivers directly like |pdftex|.
-% A driver auto-detection mechanism is introduced in version 4.
-% Therefore, you don't have to set a driver in most cases, except for
-% |dvipdfm|.
-% Setting |driver=auto| makes the auto-detection work whatever
-% the previous setting is. Setting |driver=none| does nothing for driver.
-% \begin{Options}
-% \item[driver] sets driver. |driver=|\meta{driver name}.
-% |dvips|, |dvipdfm|, |pdftex|, |vtex|, |auto| and |none| are available as a
-% driver name.
-% \end{Options}
-% The options below can be set directly instead of |driver=|\meta{value}.
+% By default, \Gm\ guesses the driver appropriate to the system
+% in use. Therefore, you don't have to set a driver in most cases.
+% However, if you want to use |dvipdfm|, you should specify it explicitly.
+%
% \begin{Options}
-% \item[dvips] writes the paper size in dvi output with the \cs{special}
+% \item[\onlypre driver] specifies the driver with |driver=|\meta{driver name}.
+% |dvips|, |dvipdfm|, |pdftex|, |vtex|, |xetex|, |auto| and |none| are
+% available as a driver name. The names except for |auto| and |none| can
+% be specified directly with the name without |driver=|.
+% |driver=auto| makes the auto-detection work whatever the previous setting is.
+% |driver=none| disables the auto-detection and sets no driver, which
+% may be useful when you want to let other package work out the driver
+% setting. For example, if you want to use \textsf{crop} package with \Gm,
+% you should call |\usepackage[driver=none]{geometry}| before
+% the \textsf{crop} package.
+% \item[\onlypre dvips] writes the paper size in dvi output with the \cs{special}
% macro. If you use \textsl{dvips} as a DVI-to-PS driver,
% for example, to print a document with |\geometry{a3paper,landscape}|
% on A3 paper in landscape orientation, you don't need options
% ``|-t a3 -t landscape|'' to \textsl{dvips}.
-% \item[dvipdfm] works like |dvips| except landscape correction.
-% \item[pdftex] sets \cs{pdfpagewidth} and \cs{pdfpageheight} internally.
-% \item[vtex] sets dimensions \cs{mediawidth} and \cs{mediaheight}
+% \item[\onlypre dvipdfm] works like |dvips| except for landscape correction.
+% You can set this option when using \textsf{dvipdfmx} and
+% \textsf{xdvipdfmx} to process the dvi output.
+% \item[\onlypre pdftex] sets \cs{pdfpagewidth} and \cs{pdfpageheight}
+% internally.
+% \item[\onlypre xetex] is the same as |pdftex| except for ignoring
+% |\pdf{h,v}origin| undefined in XeLaTeX. This option is introduced in
+% the version 5. Note that `geometry.cfg' in TeXLive, which disables the
+% auto-detection routine and sets |pdftex|, is no longer necessary,
+% but has no problem even though it's left undeleted.
+% Instead of |xetex|, you can specify |dvipdfm| with XeLaTeX
+% if you want to use specials of dvipdfm XeTeX supports.
+% \item[\onlypre vtex] sets dimensions \cs{mediawidth} and \cs{mediaheight}
% for V\TeX. When this driver is selected (explicitly or
-% automatically), \textsf{geometry} will auto-detect which output mode
+% automatically), \Gm\ will auto-detect which output mode
% (DVI, PDF or PS) is selected in V\TeX, and do proper
% settings for it.
% \end{Options}
@@ -1197,11 +1173,12 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \subsection{Other options}
%
% The other useful options are described here.
+%
% \begin{Options}
-% \item[verbose] displays parameter results on the terminal.
+% \item[\onlypre verbose] displays the parameter results on the terminal.
% |verbose=false| (default) still puts them into the log file.
-% \item[reset] sets back the layout dimensions and switches to the
-% settings before \textsf{geometry} is loaded. Options given in
+% \item[\onlypre reset] sets back the layout dimensions and switches to the
+% settings before \Gm\ is loaded. Options given in
% |geometry.cfg| are also cleared.
% Note that this cannot reset |pass| and |mag| with |truedimen|.
% |reset=false| has no effect and cannot cancel the previous
@@ -1213,7 +1190,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% with |\ExecuteOptions{scale=0.9}| in |geometry.cfg|,
% then as a result, |landscape| and |left=2cm| remain effective,
% and |scale=0.9| and |twoside| are ineffective.
-% \item[mag] sets magnification value (\cs{mag}) and automatically modifies
+% \item[\onlypre mag] sets magnification value (\cs{mag}) and automatically modifies
% \cs{hoffset} and \cs{voffset} according to the magnification.
% |mag=|\meta{value}. Note that \meta{value} should be an integer value
% with 1000 as a normal size. For example, |mag=1414| with |a4paper|
@@ -1222,96 +1199,60 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% disk space. \textbf{Note that setting |mag| should precede any other
% settings with `true' dimensions, such as |1.5truein|, |2truecm|
% and so on.} See also |truedimen| option.
-% \item[truedimen] changes all internal explicit dimension values into
+% \item[\onlypre truedimen] changes all internal explicit dimension values into
% \textit{true} dimensions, e.g., |1in| is changed to |1truein|.
% Typically this option will be used together with |mag| option. Note that
% this is ineffective against externally specified dimensions. For example,
% when you set ``\texttt{mag=1440, margin=10pt, truedimen}'', margins are
% not `true' but magnified. If you want to set exact margins, you should
% set like ``\texttt{mag=1440, margin=10truept, truedimen}'' instead.
-% \item[pass] disables all of the geometry options and calculations
+% \item[\onlypre pass] disables all of the geometry options and calculations
% except |verbose| and |showframe|. It can be used for checking
% out the page layout of the documentclass, other packages and manual
-% settings without \textsf{geometry}.
-% \item[showframe] shows visible frames for the text area and page,
+% settings without \Gm.
+% \item[\onlypre showframe] shows visible frames for the text area and page,
% and the lines for the head and foot on the first page.
-% \item[compat2] sets all kind of options so that
-% |\usepackage[compat2]{geometry}| would behave as if one is using
-% the old version (v2.3) with the old default layout:
-% \texttt{[scale=\{0.8,0.9\}, centering, includeheadfoot]},
-% which is here expressed by options available in version 3.
-% Note this option should be set as a first option.
% \end{Options}
%
-% \section{Default settings}
-%
-% \subsection{Default layout}\label{sec:default}
-%
-% Let us recapitulate the default layout here.
-% The \textsf{geometry} package has the following default page layout
-% for onesided documents:
-% \begin{quote}
-% |scale=0.7, marginratio={1:1, 2:3}, ignoreall|
-% \end{quote}
-% For twoside, the horizontal margin ratio is also set |2:3|,
-% \begin{quote}
-% |scale=0.7, marginratio=2:3, ignoreall|.
-% \end{quote}
-% Of course, you don't need to set them explicitly. |\usepackage{geometry}|
-% will internally set the above options.
-% Additional options will overwrite the layout dimensions. For example,
-% \begin{quote}
-% |\usepackage[hmargin=2cm]{geometry}|
-% \end{quote}
-% will overwrite horizontal dimensions, but use the default for vertical
-% layout. Page dimensions specified by the documentclass being used
-% and other direct settings before \textsf{geometry} is loaded are passed
-% down to \textsf{geometry}.
-%
-% Note version 2.3 or earlier had default layout different from the
-% version 3. The old default options can be expressed with options
-% available in the current version:
-% \begin{quote}
-% |scale={0.8,0.9}, centering, includeheadfoot|.
-% \end{quote}
-% Adding |compat2| as a first option sets those options so that, for example,
-% \begin{quote}
-% |\usepackage[compat2, width=10cm]{geometry}|
-% \end{quote}
-% would behave as if one is using the old version (v2.3).
-%
-% \subsection{Configuration file}
-%
-% One can set up a configuration file to make default options. To do this,
-% produce a file |geometry.cfg| containing an \cs{ExecuteOptions} macro,
-% for example,
-% \begin{quote}
-% |\ExecuteOptions{a4paper,dvips}|
-% \end{quote}
-% and install it somewhere \TeX{} can find it.
+% \section{Processing options}\label{sec:process}
%
-% The options specified in the |geometry.cfg| can be cleared by
-% option |reset|.
+% \subsection{Order of loading}\label{sec:loadorder}
%
-% \section{Relations between options}
-% This section shows how complexity is solved when options are over-specified.
+% If there's |geometry.cfg| somewhere \TeX{} can find it, \Gm\ loads
+% it first. For example, in |geometry.cfg| you may write
+% |\ExecuteOptions{a4paper}|, which specifies A4 paper as the default
+% paper. Basically you can use all the options defined in \Gm\ with
+% |\ExecuteOptions{}|.
+%
+% The order of loading in the preamble of your document is as follows:
+% \begin{enumerate}
+% \item |geometry.cfg| if it exists.
+% \item Options specified with |\documentclass[|\meta{options}|]{...}|.
+% \item Options specified with |\usepackage[|\meta{options}|]{geometry}|
+% \item Options specified with |\geometry{|\meta{options}|}|, which
+% can be called multiple times. (|reset| option will cancel the
+% specified options ever given in |\usepackage{geometry}| or
+% |\geometry|.)
+% \end{enumerate}
%
-% \subsection{Order dependence}\label{sec:order-depend}
+% \subsection{Order of options}\label{sec:optionorder}
%
-% The \textsf{geometry} options are basically order-independent, but there
-% are some exceptions. For multiple specification of the same option,
-% the last setting is adopted. For example,
-% \begin{quote}
-% |verbose=true, verbose=false|
-% \end{quote}
-% obviously results in |verbose=false|.
-% If you set
-% \begin{quote}
-% |hmargin={3cm,2cm}, left=1cm|
-% \end{quote}
-% the left(or inner) margin is overwritten by |left=1cm|. As a result, it is
-% equivalent to |hmargin={1cm,2cm}|.
-%
+% The specification of \Gm\ options is order-independent,
+% and overwrites the previous one for the same setting.
+% For example,
+% \begin{center}
+% |[left=2cm, right=3cm]| is equivalent to
+% |[right=3cm, left=2cm]|.
+% \end{center}
+% The options called multiple times overwrite the previous
+% settings. For example,
+% \begin{center}
+% |[verbose=true, verbose=false]| results in |verbose=false|.
+% \end{center}
+% |[hmargin={3cm,2cm}, left=1cm]| is the same as |hmargin={1cm,2cm}|,
+% where the left (or inner) margin is overwritten by |left=1cm|.
+%
+% |reset| and |mag| are exceptions.
% The |reset| option removes all the geometry options (except |pass|)
% before it. If you set
% \begin{quote}
@@ -1319,8 +1260,8 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% |\usepackage[margin=1cm,twoside]{geometry}|\\
% |\geometry{a5paper, reset, left=2cm}|
% \end{quote}
-% then |margin=1cm|, |twoside| and |a5paper| are removed.
-% As a result, this case is equivalent to
+% then |margin=1cm|, |twoside| and |a5paper| are removed, and
+% is eventually equivalent to
% \begin{quote}
% |\documentclass[landscape]{article}|\\
% |\usepackage[left=2cm]{geometry}|
@@ -1330,14 +1271,15 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% `true' length, such as |left=1.5truecm|, |width=5truein| and so on.
% The |\mag| primitive can be set before this package is called.
%
-% \subsection{Priority}
+% \subsection{Priority}\label{sec:priority}
%
-% There are several ways to set dimensions of the printable area:
-% |scale|, |total|, |text| and |lines|. Basically specification with the more
-% concrete dimension has the higher priority:
+% There are several ways to set dimensions of the \gpart{body}:
+% |scale|, |total|, |text| and |lines|. The \Gm\ package gives higer
+% priority to the more concrete specificaion. Here is the priority
+% rule for \gpart{body}.
% \[\begin{array}{c}
-% \textrm{low}\quad\longrightarrow\quad\textrm{high}
-% \quad(\textrm{priority})\\[1em]
+% \textrm{priority:}\qquad\textrm{low}\quad
+% \longrightarrow\quad\textrm{high}\\[1em]
% \left\{\begin{array}{l}|hscale|\\|vscale|\\|scale|
% \end{array}\right\} <
% \left\{\begin{array}{l}|width|\\|height|\\|total|
@@ -1355,23 +1297,307 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{quote}
% results in \texttt{[lines=30, textwidth=7in]}.
%
-% Options determining margin size also have priority rule:
-% margin ratios versus margin length. For example, if both |marginratio=1:2|
-% and |margin=1cm| are set at the same time, |margin=1cm| wins because
-% |margin=1cm| is more concrete dimension than ratios. That is why normal
-% margin options work well with default margin ratios
-% (|marginratio={1:1, 2:3}| for oneside).
-% \[\begin{array}{c}
-% \textrm{low}\quad\longrightarrow\quad\textrm{high}
-% \quad(\textrm{priority})\\[1em]
-% \left\{\begin{array}{l}|hmarginratio|\\|vmarginratio|\\|marginratio|
-% \end{array}\right\} <
-% \left\{\begin{array}{l}
-% |hmargin|\:\textit{or}\:|left|\:\textrm{\&}\:|right|\\
-% |vmargin|\:\textit{or}\:|top|\:\textrm{\&}\:|bottom|\\
-% |margin|
-% \end{array}\right\}.
-% \end{array}\]
+% \subsection{Defaults}\label{sec:defaults}
+%
+% This section sums up the default settings for the auto-completion
+% described later.
+%
+% The default vertical margin ratio is $2/3$, namely,
+% \begin{equation}
+% |top| : |bottom| = 2 : 3 \qquad\textit{default}.
+% \end{equation}
+% As for the horizontal margin ratio, the default value depends on
+% whether the document is onesided or twosided,
+% \begin{equation}
+% |left|\;(|inner|) : |right|\;(|outer|)
+% = \left\{ \begin{array}{ll}
+% 1 : 1 \qquad\textit{default for oneside},\\
+% 2 : 3 \qquad\textit{default for twoside}.
+% \end{array}\right.
+% \end{equation}
+% Obviously the default horizontal margin ratio for oneside is `centering'.
+%
+% The \Gm\ package has the following default setting for
+% \textit{onesided} documents:
+% \begin{itemize}\setlength{\itemsep}{-.5\parsep}
+% \item |scale=0.7| (\gpart{body} is $0.7 \times \gpart{paper}$)
+% \item |marginratio={1:1, 2:3}| (1:1 for horizontal and 2:3 for vertical margins)
+% \item |ignoreall| (the header, footer, marginal notes are excluded
+% when calculating the size of \gpart{body}.)
+% \end{itemize}
+% For \textit{twosided} document with |twoside| option, the default
+% setting is the same as \textit{onesided} except that the horizontal
+% margin ratio is set |2:3| as well.
+%
+% Additional options overwrite the previous specified dimensions.
+%
+% \subsection{Auto-completion} \label{sec:rules}
+%
+% Figure~\ref{fig:specrule} shows schematically how many specification
+% patterns exist and how to solve the ambiguity of the
+% specifications. Each axis shows the numbers of lengths
+% explicitly specified for body and margins. \Ss(m,b) presents the
+% specification with a set of numbers (margin,body)=(m,b).
+%
+% For example, the specification |width=14cm, left=3cm| is categorized
+% into \Ss(1,1), which is an adequate specification. If you add
+% |right=4cm|, it would be in \Ss(2,1) and overspecified.
+% if only |width=14cm|, it's in \Ss(0,1), underspecified.
+%
+% The \Gm\ package has the auto-completion mechanism, in which
+% if the layout parameters are underspecified or overspecified,
+% \Gm\ works out the ambiguity using the defaults and other
+% relations. Here are the specifications and the completion rules.
+%
+% \begin{figure}
+% \centering
+% {\unitlength=1pt
+% \begin{picture}(400,150)(40,0)
+% \put(1,49){\makebox(90,49)[r]{\large 0}}
+% \put(1,1){\makebox(70,99)[r]{\large body}}
+% \put(1,1){\makebox(90,49)[r]{\large 1}}
+% \put(100,100){\makebox(99,20){\large 0}}
+% \put(100,50){\framebox(99,49){}}
+% \put(100,80){\makebox(99,15){\Ss(0,0)}}
+% \put(100,50){\makebox(99,49){use |scale|}}
+% {\linethickness{1pt}%
+% \put(150,35){\line(0,1){30}}
+% \put(150,35){\line(-1,3){4}}
+% \put(150,35){\line(1,3){4}}}
+% \put(100,0){\framebox(99,49){}}
+% \put(100,2){\makebox(99,15){\Ss(0,1)}}
+% \put(100,0){\makebox(99,49){use |marginratio|}}
+% \put(200,120){\makebox(99,12){\large margin}}
+% \put(200,100){\makebox(99,20){\large 1}}
+% \put(200,50){\framebox(99,49){use |scale|}}
+% \put(200,55){\makebox(89,10)[r]{\scriptsize\shortstack[l]{if |ratio|\\specified}}}
+% \put(200,2){\makebox(99,15){\Ss(1,1)}}
+% {\linethickness{1pt}%
+% \put(250,35){\line(0,1){30}}
+% \put(250,35){\line(-1,3){4}}
+% \put(250,35){\line(1,3){4}}}
+% {\linethickness{1pt}%
+% \put(225,25){\line(-1,0){35}}
+% \put(225,25){\line(-3,-1){12}}
+% \put(225,25){\line(-3,1){12}}}
+% \put(200,80){\makebox(99,15){\Ss(1,0)}}
+% \put(200,0){\framebox(99,49){\textcolor{red}{\textsl{solvable}}}}
+% \put(300,100){\makebox(99,20){\large 2}}
+% \put(300,80){\makebox(99,15){\Ss(2,0)}}
+% \put(300,50){\framebox(99,49){\textcolor{red}{\textsl{solvable}}}}
+% \put(300,0){\framebox(99,49){forget |body|}}
+% \put(300,2){\makebox(99,15){\Ss(2,1)}}
+% {\linethickness{1pt}%
+% \multiput(290,65)(5,0){6}{\line(1,0){3}}
+% \put(320,65){\line(-3,-1){12}}
+% \put(320,65){\line(-3,1){12}}}
+% {\linethickness{1pt}%
+% \put(350,65){\line(0,-1){30}}
+% \put(350,65){\line(-1,-3){4}}
+% \put(350,65){\line(1,-3){4}}}
+% \end{picture}}
+% \caption[Specifications and completion rules]{%
+% \begin{minipage}[t]{.7\textwidth}\raggedright\small
+% Specifications \Ss(0,0) to \Ss(2,1) and the completion rules
+% (arrows). The horizonal and vertical denote the number of explicitly
+% specified lengths for margin and body respectively. \Ss(m,b) denote a
+% specification with a set of the numbers (margin,body)=(m,b).
+% \end{minipage}}
+% \label{fig:specrule}
+% \end{figure}
+%
+% \begin{Spec}
+% \item[\Ss(0,0)]
+% Nothing is specified. The \Gm\ package sets \gpart{body} with the
+% default |scale| ($=$0.7). \\ For example, |width| is set to be
+% |0.7\paperwidth|. Thus \Ss(0,0) goes to \Ss(0,1). See \Ss(0,1).
+% \bigskip
+%
+% \item[\Ss(0,1)]
+% Only \gpart{body} is specified, such as |width=7in|, |lines=20|,
+% |body={20cm,24cm}|, |scale=0.9| and so forth.
+% Then \Gm\ sets margins with the margin ratio.
+% If the margin ratio is not specified, the default is used.
+% The default vertical margin ratio is defined as
+% \begin{equation}
+% |top| : |bottom| = 2 : 3 \qquad\textit{default}.
+% \end{equation}
+% As for the horizontal margin ratio, the default value depends on
+% whether the document is onesided or twosided,
+% \begin{equation}
+% |left|\;(|inner|) : |right|\;(|outer|)
+% = \left\{ \begin{array}{ll}
+% 1 : 1 \qquad\textit{default for oneside},\\
+% 2 : 3 \qquad\textit{default for twoside}.
+% \end{array}\right.
+% \end{equation}
+% For example, if |height=22cm| is specified on A4 paper,
+% \Gm\ calculates |top| margin as follows:
+% \begin{equation}
+% \begin{array}{ll}
+% |top| &= ( |paperheight| - |height| ) \times 2/5 \\
+% &= (29.7-22)\times2/5 = 3.08\textrm{(cm)}
+% \end{array}
+% \end{equation}
+% Thus |top| margin and body |height| have been determined, the
+% specification for the vertical goes to \Ss(1,1) and
+% all the parameters can be solved.
+% \bigskip
+%
+% \item[\Ss(1,0)]
+% Only one margin is specified, such as |bottom=2cm|, |left=1in|,
+% |top=3cm|, and so forth.
+%
+% \begin{itemize}
+% \item \textbf{If the margin ratio is \textit{not} specified}, \Gm\ sets
+% \gpart{body} with the default |scale| ($=0.7$).
+% For example, if |top=2.4cm| is specified, \Gm\ sets
+% \begin{center}
+% $|height|= |0.7\paperheight|$,
+% \end{center}
+% then \Ss(1,0) goes to \Ss(1,1), in which |bottom| is calculated
+% with $|paperheight|-(|height|+|top|)$ and results in 6.51cm on A4
+% paper.
+% \medskip
+% \item \textbf{If the margin ratio is specified}, such as
+% |hmarginratio={1:2}|, |vratio={3:4}| and so forth,
+% \Gm\ sets the other% margin with the specified margin ratio.
+% For example, if a set of options ``|top=2.4cm, vratio={3:4}|'' is
+% specified, \Gm\ sets |bottom| to be |3.2cm| calculating
+% \begin{center}
+% $|bottom|= |top|/3\times4 = 3.2\textrm{cm}$
+% \end{center}
+% Thus \Ss(1,0) goes to \Ss(2,0).
+% \end{itemize}
+%
+% Notes that the version 4 or earlier used to set the other margin
+% with the margin ratio. In the version 5, therefore, with the
+% same specification, the result will be different from the one in the
+% version 4. For example, if only |top=2.4cm| is specified,
+% you got |bottom=2.4cm| in the version 4 or earlier, but you will get
+% |bottom=6.51cm| in the version 5.
+% \bigskip
+%
+% \item[\Ss(2,1)]
+% The \gpart{body} and two \gpart{margins} are all specified, such as
+% |vdivide={1in,8in,1.5in}|, ``|left=3cm,width=13cm,right=4cm|'' and
+% so forth. Since \Gm\ basically gives priority to \gpart{margins}
+% if dimensions are overspecified, \Gm\ forgets and resets
+% \gpart{body}. For example, if you specify
+% \begin{center}
+% |\usepackage[a4paper,left=3cm,width=13cm,right=4cm]{geometry}|,
+% \end{center}
+% |width| is reset to be 14cm because the width of a A4 paper is 21cm
+% long.
+% \end{Spec}
+%
+% \section{Changing layout mid-document}\label{sec:midchange}
+%
+% The version 5 provides the new commands \cs{newgeometry\{$\cdots$\}}
+% and \cs{restoregeometry}, which allow you to change page dimensions
+% in the middle of the document. Unlike \cs{geometry} in the preamble,
+% \cs{newgeometry} is available only after |\begin{document}|,
+% resets all the options ever specified except for the
+% papersize-related options: |landscape|,|portrait|, and paper size
+% options (such as |papersize|, |paper=a4paper| and so forth), which
+% can't be changed with \cs{newgeometry}.
+%
+% The command \cs{restoregeometry} restores the page layout specified
+% in the preamble (before |\begin{document}|) with the options to
+% |\usepackage{geometry}| and \cs{geometry}.
+%
+% Note that both \cs{newgeometry} and \cs{restoregeometry} insert
+% |\clearpage| where they are called.
+%
+% Below is an example of changing layout mid-document. The layout L1
+% specified with |hmargin=3cm| (|left| and |right| margins are |3cm|
+% long) is changed to L2 with |left=3cm|,|right=1cm| and
+% |bottom=0.1cm|. The layout L1 is restored with
+% \cs{restoregeometry}.
+% \begin{center}
+% \begin{minipage}{.8\textwidth}
+% |\usepackage[hmargin=3cm]{geometry}|\\
+% |\begin{document}|\\
+% \medskip
+% \hspace{1cm}\fbox{Layout L1}\\
+% \medskip
+% |\newgeometry{left=3cm,right=1cm,bottom=0.1cm}|\\
+% \medskip
+% \hspace{1cm}\fbox{Layout L2 (new)}\\
+% \medskip
+% |\restoregeometry|\\
+% \medskip
+% \hspace{1cm}\fbox{Layout L1 (restored)}\\
+% \medskip
+% |\newgeometry{margin=1cm,includefoot}|\\
+% \medskip
+% \hspace{1cm}\fbox{Layout L3 (new)}\\
+% \medskip
+% |\end{document}|
+% \end{minipage}%
+% \end{center}
+% \begin{center}
+% \centering\small
+% {\unitlength=.8pt
+% \begin{picture}(450,180)(0,0)
+% \put(0,165){\makebox(95,12){(saved)}}
+% \put(15,135){\framebox(65,10){\gpart{head}}}
+% \put(15,60){\framebox(65,70){\gpart{body}}}
+% \put(15,45){\makebox(65,12){\gpart{foot}}}
+% \put(15,45){\line(1,0){65}}
+% \put(0,20){\framebox(95,140){}}
+% \put(0,0){\makebox(95,20){L1}}
+% \put(104,90){\circle*{4}}
+% \put(110,90){\circle*{4}}
+% \put(116,90){\circle*{4}}
+% \put(125,165){\makebox(95,12){\cs{newgeometry}}}
+% \put(140,135){\framebox(71,10){\gpart{head}}}
+% \put(140,33){\framebox(71,97){\gpart{body}}}
+% \put(140,21){\makebox(71,12){\gpart{foot}}}
+% \put(125,20){\framebox(95,140){}}
+% \put(125,0){\makebox(95,20){L2 (new)}}
+% \put(229,90){\circle*{4}}
+% \put(235,90){\circle*{4}}
+% \put(241,90){\circle*{4}}
+% \put(250,165){\makebox(95,12){\cs{restoregeometry}}}
+% \put(265,135){\framebox(65,10){\gpart{head}}}
+% \put(265,60){\framebox(65,70){\gpart{body}}}
+% \put(265,45){\makebox(65,12){\gpart{foot}}}
+% \put(265,45){\line(1,0){65}}
+% \put(250,20){\framebox(95,140){}}
+% \put(250,0){\makebox(95,20){L1 (restored)}}
+% \put(354,90){\circle*{4}}
+% \put(360,90){\circle*{4}}
+% \put(366,90){\circle*{4}}
+% \put(375,165){\makebox(95,12){\cs{newgeometry}}}
+% \put(383,33){\framebox(80,120){\gpart{body}}}
+% \put(383,21){\makebox(80,12){\gpart{foot}}}
+% \put(375,20){\framebox(95,140){}}
+% \put(375,0){\makebox(95,20){L3 (new)}}
+% \end{picture}}
+% \end{center}
+%
+% A set of commands |\savegeometry{|\meta{name}|}| and
+% |\loadgeometry{|\meta{name}|}| is handy if you want to
+% reuse more different layouts in your document.
+% For example,
+% \begin{center}
+% \begin{verbatim}
+% \usepackage[hmargin=3cm]{geometry}
+% \begin{document}
+% L1
+% \newgeometry{left=3cm,right=1cm,bottom=0.1cm}
+% \savegeometry{L2}
+% L2 (new, saved)
+% \restoregeometry
+% L1 (restored)
+% \newgeometry{margin=1cm,includefoot}
+% L3 (new)
+% \loadgeometry{L2}
+% L2 (loaded)
+% \end{document}
+% \end{verbatim}
+% \end{center}
%
% \section{Examples}
%
@@ -1389,8 +1615,10 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{itemize}
% \item |twoside, bindingoffset=1cm|
% \end{itemize}
-% In this case, |textwidth| is shorter than the case without
-% |bindingoffset=1cm| by $0.7\times|1cm|$ ($=$|0.7cm|).
+% In this case, |textwidth| is shorter than that of the default twosided
+% document by $0.7\times|1cm|$ ($=$|0.7cm|) because the default width of
+% \gpart{body} is set with |scale=0.7| (which means
+% $|width|=0.7|\paperwidth|$).
%
% \item A layout with the left, right, and top margin |3cm|, |2cm| and
% |2.5in| respectively, with textheight of 40 lines, and with the head and
@@ -1473,22 +1701,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% You can add |dvips| option, that is useful to preview it with proper
% paper size by |dviout| or |xdvi|.
%
-% \item An old style setting with v2.3 or earlier
-% \begin{verbatim}
-% \usepackage[a4paper,mag=1200,truedimen,margin=2cm,
-% twosideshift=10pt,
-% headsep=7pt,headheight=14.5pt,
-% marginparwidth=30pt]{geometry}\end{verbatim}
-% can be rewritten with options in version 3 without |compat2|:
-% \begin{verbatim}
-% \usepackage{calc}
-% \usepackage[a4paper,mag=1200,truedimen,margin=2cm,
-% twoside, left=2cm+10pt, right=2cm-10pt,
-% includeheadfoot, headsep=7pt,headheight=14.5pt,
-% includemp, marginparwidth=30pt]{geometry}\end{verbatim}
-% In this case, |includeall| can be used instead of |includeheadfoot| and
-% |includemp|.
-%
% \item A complex page layout.
% \begin{verbatim}
% \usepackage[a5paper, landscape, twocolumn, twoside,
@@ -1506,30 +1718,37 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
%
% \item With |pdftex=true|, |mag| $\neq 1000$, \textit{no} |truedimen|,
% and \textsf{hyperref}, \textsf{hyperref} should be loaded
-% by \cs{usepackage} before \textsf{geometry}.
+% by \cs{usepackage} before \Gm.
% Otherwise the resulted PDF size will become wrong.
%
% \item With \textsf{crop} package and |mag| $\neq 1000$,
% |center| option of \textsf{crop} doesn't work well.
+%
% \end{itemize}
%
% \section{Acknowledgments}
-% The author appreciates helpful suggestions and comments from
-% Jean-Bernard Addor,
+% The author appreciates helpful suggestions and comments from many
+% people including (in alphabetical order of family name):
+% Jean-Bernard Addor,
% Frank Bennett,
% Alexis Dimitriadis,
% Friedrich Flender,
+% Adrian Heathcote,
% Stephan Hennig,
% Morten H\o{}gholm,
% Jonathan Kew,
% James Kilfiger,
% Jean-Marc Lasgouttes,
% Wlodzimierz Macewicz,
+% Frank Mittelbach,
+% Eckhard Neber,
% Rolf Niepraschk,
% Hans Fr.~Nordhaug,
+% Heiko Oberdiek,
% Keith Reckdahl,
% Peter Riocreux,
% Will Robertson,
+% Pablo Rodriguez,
% Nico Schl\"{o}emer,
% Perry C.~Stearns,
% Frank Stengel,
@@ -1537,24 +1756,20 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% Petr Uher,
% Piet van Oostrum,
% Vladimir Volovich,
-% and
% Michael Vulis.
-%
-% The author is deeply grateful to Frank Mittelbach for checking the codes patiently
-% and providing extremely helpful insight and suggestions for version 3.
%
% \StopEventually{%
-% \ifmulticols
-% \addtocontents{toc}{\protect\end{multicols}}
-% \fi
% }
-%
+%
+% \newgeometry{hmargin={4.2cm,1.5cm},vmargin={1cm,1cm},
+% includeheadfoot, marginpar=3.8cm}
% \section{Implementation}
% \begin{macrocode}
%<*package>
% \end{macrocode}
-% This package requires three other packages: \textsf{keyval} in \LaTeX\ graphics bundle,
-% \textsf{ifpdf} and \textsf{ifvtex} in `oberdiek' bundle.
+% This package requires three other packages: \textsf{keyval} in
+% \LaTeX\ graphics bundle, \textsf{ifpdf} and \textsf{ifvtex} in
+% `oberdiek' bundle.
% \begin{macrocode}
\RequirePackage{keyval}%
\RequirePackage{ifpdf}%
@@ -1565,6 +1780,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{macrocode}
\newif\ifGm@verbose
\newif\ifGm@landscape
+\newif\ifGm@swap@papersize\Gm@swap@papersizefalse
\newif\ifGm@includehead
\newif\ifGm@includefoot
\newif\ifGm@includemp
@@ -1572,10 +1788,11 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\newif\ifGm@vbody
\newif\ifGm@heightrounded
\newif\ifGm@showframe
-\newif\ifGm@compatii
-\newif\ifGm@sworient\Gm@sworientfalse
+\newif\ifGm@showcrop
\newif\ifGm@pass\Gm@passfalse
\newif\ifGm@resetpaper
+\newif\ifGm@layout
+\newif\ifGm@newgm
% \end{macrocode}
% \begin{macro}{\Gm@cnth}
% \begin{macro}{\Gm@cntv}
@@ -1608,8 +1825,20 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\newdimen\Gm@even@mp
% \end{macrocode}
% \end{macro}\end{macro}\end{macro}
+% \begin{macro}{\Gm@layoutwidth}
+% \begin{macro}{\Gm@layoutheight}
+% \begin{macro}{\Gm@layouthoffset}
+% \begin{macro}{\Gm@layoutvoffset}
+% The dimensions for the layout.
+% \begin{macrocode}
+\newdimen\Gm@layoutwidth
+\newdimen\Gm@layoutheight
+\newdimen\Gm@layouthoffset
+\newdimen\Gm@layoutvoffset
+% \end{macrocode}
+% \end{macro}\end{macro}\end{macro}\end{macro}
% \begin{macro}{\Gm@dimlist}
-% Native dimension setting list.
+% The token in which \LaTeX{} Native dimensions are stored.
% \begin{macrocode}
\newtoks\Gm@dimlist
% \end{macrocode}
@@ -1619,7 +1848,17 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% Macro for printing warning messages.
% \begin{macrocode}
\def\Gm@warning#1{\PackageWarningNoLine{geometry}{#1}}%
-\@onlypreamble\Gm@warning
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\ifGm@preamble}
+% process the options only if it's specified in the preamble.
+% \begin{macrocode}
+\def\ifGm@preamble#1{%
+ \ifGm@newgm
+ \Gm@warning{`#1': not available in `\string\newgeometry'; skipped}%
+ \else
+ \expandafter\@firstofone
+ \fi}%
% \end{macrocode}
% \end{macro}
%
@@ -1635,41 +1874,33 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\def\Gm@Dhratio{1:1}% = left:right default for oneside
\def\Gm@Dhratiotwo{2:3}% = inner:outer default for twoside.
\def\Gm@Dvratio{2:3}% = top:bottom default
-\@onlypreamble\Gm@Dhratio
-\@onlypreamble\Gm@Dhratiotwo
-\@onlypreamble\Gm@Dvratio
% \end{macrocode}
% \end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\Gm@Dhscale}
% \begin{macro}{\Gm@Dvscale}
% The default values for the horizontal and vertical \textsl{scale}
-% are defined. In version 3 the default scale has been changed from
-% \{0.8, 0.9\} to \{0.7, 0.7\} in each direction.
+% are defined.
% \begin{macrocode}
\def\Gm@Dhscale{0.7}%
\def\Gm@Dvscale{0.7}%
-\@onlypreamble\Gm@Dhscale
-\@onlypreamble\Gm@Dvscale
% \end{macrocode}
% \end{macro}\end{macro}
%
% \begin{macro}{\Gm@dvips}%
% \begin{macro}{\Gm@dvipdfm}%
% \begin{macro}{\Gm@pdftex}%
+% \begin{macro}{\Gm@xetex}%
% \begin{macro}{\Gm@vtex}%
% The driver names.
% \begin{macrocode}
\def\Gm@dvips{dvips}%
\def\Gm@dvipdfm{dvipdfm}%
\def\Gm@pdftex{pdftex}%
+\def\Gm@xetex{xetex}%
\def\Gm@vtex{vtex}%
-\@onlypreamble\Gm@dvips
-\@onlypreamble\Gm@dvipdfm
-\@onlypreamble\Gm@pdftex
-\@onlypreamble\Gm@vtex
% \end{macrocode}
-% \end{macro}\end{macro}\end{macro}\end{macro}
+% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro}
%
% \begin{macro}{\Gm@true}%
% \begin{macro}{\Gm@false}%
@@ -1688,60 +1919,99 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{macrocode}
% \end{macro}\end{macro}
%
-% \begin{macro}{\Gm@dorg}
-% The macro saves \LaTeX{} native dimensions and switches before
-% processing \textsf{geometry} options, and is called when |reset|
-% or |pass| is set.
-% \begin{macrocode}
-\edef\Gm@dorg{%
- \noexpand\setlength{\paperwidth}{\the\paperwidth}%
- \noexpand\setlength{\paperheight}{\the\paperheight}%
- \noexpand\setlength{\textheight}{\the\textheight}%
- \noexpand\setlength{\textwidth}{\the\textwidth}%
- \noexpand\setlength{\oddsidemargin}{\the\oddsidemargin}%
- \noexpand\setlength{\evensidemargin}{\the\evensidemargin}%
- \noexpand\setlength{\topmargin}{\the\topmargin}%
- \noexpand\setlength{\headsep}{\the\headsep}%
- \noexpand\setlength{\headheight}{\the\headheight}%
- \noexpand\setlength{\footskip}{\the\footskip}%
- \noexpand\setlength{\marginparwidth}{\the\marginparwidth}%
- \noexpand\setlength{\marginparsep}{\the\marginparsep}%
- \noexpand\setlength{\columnsep}{\the\columnsep}%
- \noexpand\setlength{\skip\footins}{\the\skip\footins}%
- \noexpand\setlength{\hoffset}{\the\hoffset}%
- \noexpand\setlength{\voffset}{\the\voffset}%
- \expandafter\noexpand\csname @twocolumn\if@twocolumn
- \Gm@true\else\Gm@false\fi\endcsname
- \expandafter\noexpand\csname @twoside\if@twoside
- \Gm@true\else\Gm@false\fi\endcsname
- \expandafter\noexpand\csname @mparswitch\if@mparswitch
- \Gm@true\else\Gm@false\fi\endcsname
- \expandafter\noexpand\csname @reversemargin\if@reversemargin
- \Gm@true\else\Gm@false\fi\endcsname
- \noexpand\mag=\the\mag}%
-\@onlypreamble\Gm@dorg
+% \begin{macro}{\Gm@savelength}
+% \begin{macrocode}
+\def\Gm@savelength#1{%
+ \edef\@@tmp{\expandafter\the\csname #1\endcsname}%
+ \g@addto@macro\Gm@restore{\expandafter\noexpand\expandafter\csname
+ #1\endcsname\expandafter=\expandafter\the\csname #1\endcsname\relax}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gm@saveboolean}
+% \begin{macrocode}
+\def\Gm@saveboolean#1{%
+ \csname if#1\endcsname
+ \g@addto@macro\Gm@restore{\expandafter\noexpand\csname #1true\endcsname}%
+ \else
+ \g@addto@macro\Gm@restore{\expandafter\noexpand\csname #1false\endcsname}%
+ \fi}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gm@restore}
+% \begin{macrocode}
+\def\Gm@restore{}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gm@save}
+% \begin{macrocode}
+\def\Gm@save{%
+ \Gm@savelength{paperwidth}%
+ \Gm@savelength{paperheight}%
+ \Gm@savelength{textwidth}%
+ \Gm@savelength{textheight}%
+ \Gm@savelength{evensidemargin}%
+ \Gm@savelength{oddsidemargin}%
+ \Gm@savelength{topmargin}%
+ \Gm@savelength{headheight}%
+ \Gm@savelength{headsep}%
+ \Gm@savelength{topskip}%
+ \Gm@savelength{footskip}%
+ \Gm@savelength{baselineskip}%
+ \Gm@savelength{marginparwidth}%
+ \Gm@savelength{marginparsep}%
+ \Gm@savelength{columnsep}%
+ \Gm@savelength{hoffset}%
+ \Gm@savelength{voffset}
+ \Gm@savelength{Gm@layouthoffset}%
+ \Gm@savelength{Gm@layoutvoffset}%
+ \Gm@saveboolean{@twocolumn}%
+ \Gm@saveboolean{@twoside}%
+ \Gm@saveboolean{@mparswitch}%
+ \Gm@saveboolean{@reversemargin}}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gm@initnewgm}
+% \begin{macrocode}
+\def\Gm@initnewgm{%
+ \Gm@dimlist={}
+ \Gm@hbodyfalse
+ \Gm@vbodyfalse
+ \Gm@heightroundedfalse
+ \Gm@includeheadfalse
+ \Gm@includefootfalse
+ \Gm@includempfalse
+ \let\Gm@width\@undefined
+ \let\Gm@height\@undefined
+ \let\Gm@textwidth\@undefined
+ \let\Gm@textheight\@undefined
+ \let\Gm@hscale\@undefined
+ \let\Gm@vscale\@undefined
+ \let\Gm@hmarginratio\@undefined
+ \let\Gm@vmarginratio\@undefined
+ \let\Gm@lmargin\@undefined
+ \let\Gm@rmargin\@undefined
+ \let\Gm@tmargin\@undefined
+ \let\Gm@bmargin\@undefined
+ \Gm@layoutfalse
+ \Gm@layouthoffset\z@
+ \Gm@layoutvoffset\z@
+ \Gm@bindingoffset\z@}%
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Gm@init}
-% The macro for initializing modes and flags is defined here. This macro
-% is called at the beginning of the package and when |reset| is specified.
+% \begin{macro}{\Gm@initall}
% \begin{macrocode}
-\def\Gm@init{%
- \Gm@hbodyfalse\Gm@vbodyfalse
- \Gm@includeheadfalse\Gm@includefootfalse\Gm@includempfalse
- \Gm@landscapefalse\Gm@compatiifalse\Gm@heightroundedfalse
- \Gm@verbosefalse\Gm@showframefalse\Gm@resetpaperfalse
+\def\Gm@initall{%
+ \let\Gm@driver\@empty
+ \let\Gm@truedimen\@empty
\let\Gm@paper\@undefined
- \let\Gm@width\@undefined\let\Gm@height\@undefined
- \let\Gm@textwidth\@undefined\let\Gm@textheight\@undefined
- \let\Gm@hscale\@undefined\let\Gm@vscale\@undefined
- \let\Gm@hmarginratio\@undefined\let\Gm@vmarginratio\@undefined
- \let\Gm@lmargin\@undefined\let\Gm@rmargin\@undefined
- \let\Gm@tmargin\@undefined\let\Gm@bmargin\@undefined
- \let\Gm@driver\@empty\let\Gm@truedimen\@empty
- \Gm@bindingoffset\z@\Gm@dimlist={}}%
-\@onlypreamble\Gm@init
+ \Gm@resetpaperfalse
+ \Gm@landscapefalse
+ \Gm@verbosefalse
+ \Gm@showframefalse
+ \Gm@showcropfalse
+ \Gm@newgmfalse
+ \Gm@initnewgm}%
% \end{macrocode}
% \end{macro}
%
@@ -1756,9 +2026,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% The macro unsets the specified driver if it has been set.
% \begin{macrocode}
\def\Gm@unsetdriver#1{%
- \expandafter\ifx\csname Gm@#1\endcsname\Gm@driver
- \let\Gm@driver\@empty
- \fi}%
+ \expandafter\ifx\csname Gm@#1\endcsname\Gm@driver\let\Gm@driver\@empty\fi}%
% \end{macrocode}
% \end{macro}
%
@@ -1771,10 +2039,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\def\Gm@@setbool[#1]#2#3{\Gm@doif{#1}{#3}{\csname Gm@#2\Gm@bool\endcsname}}%
\def\Gm@@setboolrev[#1]#2#3{\Gm@doifelse{#1}{#3}%
{\csname Gm@#2\Gm@false\endcsname}{\csname Gm@#2\Gm@true\endcsname}}%
-\@onlypreamble\Gm@setbool
-\@onlypreamble\Gm@setboolrev
-\@onlypreamble\Gm@@setbool
-\@onlypreamble\Gm@@setboolrev
% \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\Gm@doif}
@@ -1803,8 +2067,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\fi}%
\def\Gm@doifelse#1#2#3#4{%
\Gm@doif{#1}{#2}{\ifx\Gm@bool\Gm@true #3\else #4\fi}}%
-\@onlypreamble\Gm@doif
-\@onlypreamble\Gm@doifelse
% \end{macrocode}
% \end{macro}\end{macro}
%
@@ -1814,14 +2076,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\def\Gm@reverse#1{%
\csname ifGm@#1\endcsname
\csname Gm@#1false\endcsname\else\csname Gm@#1true\endcsname\fi}%
-\@onlypreamble\Gm@reverse
-% \end{macrocode}
-% \end{macro}
-% \begin{macro}{\Gm@checkbool}
-% The macro is used in \cs{Gm@showparams} to print |true| or nothing.
-% \begin{macrocode}
-\def\Gm@checkbool#1{#1: \csname ifGm@#1\endcsname true\else --\fi^^J}%
-\@onlypreamble\Gm@checkbool
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Gm@defbylen}
@@ -1836,8 +2090,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\def\Gm@defbycnt#1#2{%
\setcounter{Gm@tempcnt}{#2}%
\expandafter\edef\csname Gm@#1\endcsname{\the\value{Gm@tempcnt}}}%
-\@onlypreamble\Gm@defbylen
-\@onlypreamble\Gm@defbycnt
% \end{macrocode}
% \end{macro}\end{macro}
% \begin{macro}{\Gm@set@ratio}
@@ -1845,7 +2097,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% which is used in \cs{Gm@setbyratio} macro.
% \begin{macrocode}
\def\Gm@sep@ratio#1:#2{\@tempcnta=#1\@tempcntb=#2}%
-\@onlypreamble\Gm@set@ratio
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Gm@setbyratio}
@@ -1869,18 +2120,17 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\divide\@tempdimb\@tempcntb
\fi
\expandafter\edef\csname Gm@#4\endcsname{\the\@tempdimb}}%
-\@onlypreamble\Gm@setbyratio
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Gm@detiv}
-% This macro determines the fourth length(|#4|) from |#1|(\glen{paperwidth}
-% or \glen{paperheight}), |#2| and |#3|. It is used in
+% This macro determines the fourth length(|#4|) from |#1|(\glen{layoutwidth}
+% or \glen{layoutheight}), |#2| and |#3|. It is used in
% \cs{Gm@detall} macro.
% \begin{macrocode}
\def\Gm@detiv#1#2#3#4{% determine #4.
\expandafter\setlength\expandafter\@tempdima\expandafter
- {\csname paper#1\endcsname}%
+ {\csname Gm@layout#1\endcsname}%
\expandafter\setlength\expandafter\@tempdimb\expandafter
{\csname Gm@#2\endcsname}%
\addtolength\@tempdima{-\@tempdimb}%
@@ -1892,7 +2142,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
^^J\@spaces `#2' or `#3' should be shortened in length}%
\fi
\expandafter\edef\csname Gm@#4\endcsname{\the\@tempdima}}%
-\@onlypreamble\Gm@detiv
% \end{macrocode}
% \end{macro}
% \begin{macro}{\Gm@detiiandiii}
@@ -1902,7 +2151,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{macrocode}
\def\Gm@detiiandiii#1#2#3{% determine #2 and #3.
\expandafter\setlength\expandafter\@tempdima\expandafter
- {\csname paper#1\endcsname}%
+ {\csname Gm@layout#1\endcsname}%
\expandafter\setlength\expandafter\@tempdimb\expandafter
{\csname Gm@#1\endcsname}%
\addtolength\@tempdima{-\@tempdimb}%
@@ -1911,28 +2160,25 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
^^J\@spaces `#1' should be shortened in length}%
\fi
\ifx\Gm@mratio\@undefined
- \divide\@tempdima\tw@
- \@tempdimb=\@tempdima
+ \expandafter\Gm@sep@ratio\Gm@Dmratio\relax
\else
- \@tempdimb=\@tempdima
\expandafter\Gm@sep@ratio\Gm@mratio\relax
- \advance\@tempcntb\@tempcnta
- \ifnum\@tempcntb>\z@
- \divide\@tempdima\@tempcntb
- \multiply\@tempdima\@tempcnta
- \advance\@tempdimb-\@tempdima
- \else
- \divide\@tempdima\tw@
- \@tempdimb=\@tempdima
+ \ifnum\@tempcntb>\z@\else
+ \Gm@warning{margin ratio a:b should be non-zero; default used}%
+ \expandafter\Gm@sep@ratio\Gm@Dmratio\relax
\fi
- \fi
+ \fi
+ \@tempdimb=\@tempdima
+ \advance\@tempcntb\@tempcnta
+ \divide\@tempdima\@tempcntb
+ \multiply\@tempdima\@tempcnta
+ \advance\@tempdimb-\@tempdima
\expandafter\edef\csname Gm@#2\endcsname{\the\@tempdima}%
\expandafter\edef\csname Gm@#3\endcsname{\the\@tempdimb}}%
-\@onlypreamble\Gm@detiiandiii
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Gm@detall}
+% \begin{macro}{\Gm@detall}
% This macro determines partition of each direction.
% The first argument (|#1|) should be |h| or |v|, the second (|#2|)
% |width| or |height|, the third (|#3|) |lmargin| or |top|, and
@@ -1940,7 +2186,13 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{macrocode}
\def\Gm@detall#1#2#3#4{%
\@tempcnta\z@
- \edef\Gm@mratio{\@nameuse{Gm@#1marginratio}}%
+ \if#1h
+ \let\Gm@mratio\Gm@hmarginratio
+ \edef\Gm@Dmratio{\if@twoside\Gm@Dhratiotwo\else\Gm@Dhratio\fi}%
+ \else
+ \let\Gm@mratio\Gm@vmarginratio
+ \edef\Gm@Dmratio{\Gm@Dvratio}%
+ \fi
% \end{macrocode}
% \cs{@tempcnta} is treated as a three-digit binary value with
% top, middle and bottom denoted |left|(|top|), |width|(|height|)
@@ -1962,15 +2214,29 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{macrocode}
\ifcase\@tempcnta
\if#1h
- \edef\Gm@width{\Gm@Dhscale\paperwidth}%
+ \edef\Gm@width{\Gm@Dhscale\Gm@layoutwidth}%
\else
- \edef\Gm@height{\Gm@Dvscale\paperheight}%
+ \edef\Gm@height{\Gm@Dvscale\Gm@layoutheight}%
\fi
\Gm@detiiandiii{#2}{#3}{#4}%
% \end{macrocode}
% Case |001| (=1) with |right|(|bottom|) fixed:
% \begin{macrocode}
- \or\Gm@setbyratio[f]{#1}{#4}{#3}\Gm@detiv{#2}{#3}{#4}{#2}%
+ \or
+ \ifx\Gm@mratio\@undefined
+ \if#1h
+ \edef\Gm@width{\Gm@Dhscale\Gm@layoutwidth}%
+ \else
+ \edef\Gm@height{\Gm@Dvscale\Gm@layoutheight}%
+ \fi
+ \setlength\@tempdimc{\@nameuse{Gm@#4}}%
+ \Gm@detiiandiii{#2}{#3}{#4}%
+ \expandafter\let\csname Gm@#2\endcsname\@undefined
+ \expandafter\edef\csname Gm@#4\endcsname{\the\@tempdimc}%
+ \else
+ \Gm@setbyratio[f]{#1}{#4}{#3}%
+ \fi
+ \Gm@detiv{#2}{#3}{#4}{#2}%
% \end{macrocode}
% Case |010| (=2) with |width|(|height|) fixed:
% \begin{macrocode}
@@ -1982,7 +2248,21 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{macrocode}
% Case |100| (=4) with |left|(|top|) fixed:
% \begin{macrocode}
- \or\Gm@setbyratio[b]{#1}{#3}{#4}\Gm@detiv{#2}{#3}{#4}{#2}%
+ \or
+ \ifx\Gm@mratio\@undefined
+ \if#1h
+ \edef\Gm@width{\Gm@Dhscale\Gm@layoutwidth}%
+ \else
+ \edef\Gm@height{\Gm@Dvscale\Gm@layoutheight}%
+ \fi
+ \setlength\@tempdimc{\@nameuse{Gm@#3}}%
+ \Gm@detiiandiii{#2}{#4}{#3}%
+ \expandafter\let\csname Gm@#2\endcsname\@undefined
+ \expandafter\edef\csname Gm@#3\endcsname{\the\@tempdimc}%
+ \else
+ \Gm@setbyratio[b]{#1}{#3}{#4}%
+ \fi
+ \Gm@detiv{#2}{#3}{#4}{#2}%
% \end{macrocode}
% Case |101| (=5) with both |left|(|top|) and |right|(|bottom|) fixed:
% \begin{macrocode}
@@ -1998,7 +2278,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
^^J\@spaces `#2' (\@nameuse{Gm@#2}) is ignored}%
\Gm@detiv{#2}{#3}{#4}{#2}%
\else\fi}%
-\@onlypreamble\Gm@detall
% \end{macrocode}
% \end{macro}
%
@@ -2021,16 +2300,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\let\Gm@height\@undefined
\let\Gm@textheight\@undefined
\fi
- \if@twoside
- \ifx\Gm@hmarginratio\Gm@Dhratiotwo
- \let\Gm@hmarginratio\@undefined
- \fi
- \else
- \ifx\Gm@hmarginratio\Gm@Dhratio
- \let\Gm@hmarginratio\@undefined
- \fi
- \fi}%
-\@onlypreamble\Gm@clean
+ }%
% \end{macrocode}
% \end{macro}
%
@@ -2054,7 +2324,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\fi\fi
\advance\@tempcnta\@ne}%
\let\Gm@star\relax}%
-\@onlypreamble\Gm@parse@divide
% \end{macrocode}
% \end{macro}
%
@@ -2075,7 +2344,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\ifnum\@tempcnta=\@ne
\setkeys{Gm}{#3=\Gm@value}%
\fi}%
-\@onlypreamble\Gm@branch
% \end{macrocode}
% \end{macro}
%
@@ -2091,82 +2359,83 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\addtolength{\voffset}{1\Gm@truedimen in}%
\addtolength{\hoffset}{-\the\@tempdimb}%
\addtolength{\voffset}{-\the\@tempdimb}}%
-\@onlypreamble\Gm@magtooffset
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Gm@setafter}
+% \begin{macro}{\Gm@setlength}
% This macro stores \LaTeX{} native dimensions, which are stored and
% set afterwards.
% \begin{macrocode}
-\def\Gm@setafter#1#2{%
+\def\Gm@setlength#1#2{%
\let\Gm@len=\relax\let\Gm@td=\relax
\edef\addtolist{\noexpand\Gm@dimlist=%
{\the\Gm@dimlist \Gm@len{#1}{#2}}}\addtolist}%
-\@onlypreamble\Gm@setafter
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\Gm@processdimlist}
+% \begin{macro}{\Gm@expandlengths}
% This macro processes \cs{Gm@dimlist}.
% \begin{macrocode}
-\def\Gm@processdimlist{%
+\def\Gm@expandlengths{%
\def\Gm@td{\Gm@truedimen}%
\def\Gm@len##1##2{\setlength{##1}{##2}}%
\the\Gm@dimlist}%
-\@onlypreamble\Gm@processdimlist
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Gm@setpaper}
+% \begin{macro}{\Gm@setsize}
% The macro sets |paperwidth| and |paperheight| dimensions
-% using \cs{Gm@setafter} macro.
+% using \cs{Gm@setlength} macro.
% \begin{macrocode}
-\def\Gm@setpaper(#1,#2)#3{%
+\def\Gm@setsize#1(#2,#3)#4{%
\let\Gm@td\relax
- \Gm@setafter\paperwidth{#1\Gm@td #3}%
- \Gm@setafter\paperheight{#2\Gm@td #3}%
- \ifGm@landscape\Gm@sworienttrue\else\Gm@sworientfalse\fi}%
-\@onlypreamble\Gm@setpaper
+ \expandafter\Gm@setlength\csname #1width\endcsname{#2\Gm@td #4}%
+ \expandafter\Gm@setlength\csname #1height\endcsname{#3\Gm@td #4}%
+ \ifGm@landscape\Gm@swap@papersizetrue\else\Gm@swap@papersizefalse\fi}%
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\Gm@chpaper}
+% \begin{macro}{\Gm@setpaper@ifpre}
% The macro changes the paper size.
% \begin{macrocode}
-\def\Gm@chpaper{\@nameuse{Gm@\Gm@paper}}%
-\@onlypreamble\Gm@chpaper
+\def\Gm@setpaper@ifpre#1{%
+ \ifGm@preamble{#1}{\def\Gm@paper{#1}\@nameuse{Gm@#1}{paper}}}%
% \end{macrocode}
% \end{macro}
% Various paper size are defined here.
% \begin{macrocode}
-\@namedef{Gm@a0paper}{\Gm@setpaper(841,1189){mm}}%
-\@namedef{Gm@a1paper}{\Gm@setpaper(594,841){mm}}%
-\@namedef{Gm@a2paper}{\Gm@setpaper(420,594){mm}}%
-\@namedef{Gm@a3paper}{\Gm@setpaper(297,420){mm}}%
-\@namedef{Gm@a4paper}{\Gm@setpaper(210,297){mm}}%
-\@namedef{Gm@a5paper}{\Gm@setpaper(148,210){mm}}%
-\@namedef{Gm@a6paper}{\Gm@setpaper(105,148){mm}}%
-\@namedef{Gm@b0paper}{\Gm@setpaper(1000,1414){mm}}%
-\@namedef{Gm@b1paper}{\Gm@setpaper(707,1000){mm}}%
-\@namedef{Gm@b2paper}{\Gm@setpaper(500,707){mm}}%
-\@namedef{Gm@b3paper}{\Gm@setpaper(353,500){mm}}%
-\@namedef{Gm@b4paper}{\Gm@setpaper(250,353){mm}}%
-\@namedef{Gm@b5paper}{\Gm@setpaper(176,250){mm}}%
-\@namedef{Gm@b6paper}{\Gm@setpaper(125,176){mm}}%
-\@namedef{Gm@ansiapaper}{\Gm@setpaper(8.5,11){in}}%
-\@namedef{Gm@ansibpaper}{\Gm@setpaper(11,17){in}}%
-\@namedef{Gm@ansicpaper}{\Gm@setpaper(17,22){in}}%
-\@namedef{Gm@ansidpaper}{\Gm@setpaper(22,34){in}}%
-\@namedef{Gm@ansiepaper}{\Gm@setpaper(34,44){in}}%
-\@namedef{Gm@letterpaper}{\Gm@setpaper(8.5,11){in}}%
-\@namedef{Gm@legalpaper}{\Gm@setpaper(8.5,14){in}}%
-\@namedef{Gm@executivepaper}{\Gm@setpaper(7.25,10.5){in}}%
-\@namedef{Gm@screen}{\Gm@setpaper(225,180){mm}}%
-% \end{macrocode}
-%
-% All the available options are defined below.
+\@namedef{Gm@a0paper}#1{\Gm@setsize{#1}(841,1189){mm}}% ISO A0
+\@namedef{Gm@a1paper}#1{\Gm@setsize{#1}(594,841){mm}}% ISO A1
+\@namedef{Gm@a2paper}#1{\Gm@setsize{#1}(420,594){mm}}% ISO A2
+\@namedef{Gm@a3paper}#1{\Gm@setsize{#1}(297,420){mm}}% ISO A3
+\@namedef{Gm@a4paper}#1{\Gm@setsize{#1}(210,297){mm}}% ISO A4
+\@namedef{Gm@a5paper}#1{\Gm@setsize{#1}(148,210){mm}}% ISO A5
+\@namedef{Gm@a6paper}#1{\Gm@setsize{#1}(105,148){mm}}% ISO A6
+\@namedef{Gm@b0paper}#1{\Gm@setsize{#1}(1000,1414){mm}}% ISO B0
+\@namedef{Gm@b1paper}#1{\Gm@setsize{#1}(707,1000){mm}}% ISO B1
+\@namedef{Gm@b2paper}#1{\Gm@setsize{#1}(500,707){mm}}% ISO B2
+\@namedef{Gm@b3paper}#1{\Gm@setsize{#1}(353,500){mm}}% ISO B3
+\@namedef{Gm@b4paper}#1{\Gm@setsize{#1}(250,353){mm}}% ISO B4
+\@namedef{Gm@b5paper}#1{\Gm@setsize{#1}(176,250){mm}}% ISO B5
+\@namedef{Gm@b6paper}#1{\Gm@setsize{#1}(125,176){mm}}% ISO B6
+\@namedef{Gm@b0j}#1{\Gm@setsize{#1}(1030,1456){mm}}% JIS B0
+\@namedef{Gm@b1j}#1{\Gm@setsize{#1}(728,1030){mm}}% JIS B1
+\@namedef{Gm@b2j}#1{\Gm@setsize{#1}(515,728){mm}}% JIS B2
+\@namedef{Gm@b3j}#1{\Gm@setsize{#1}(364,515){mm}}% JIS B3
+\@namedef{Gm@b4j}#1{\Gm@setsize{#1}(257,364){mm}}% JIS B4
+\@namedef{Gm@b5j}#1{\Gm@setsize{#1}(182,257){mm}}% JIS B5
+\@namedef{Gm@b6j}#1{\Gm@setsize{#1}(128,182){mm}}% JIS B6
+\@namedef{Gm@ansiapaper}#1{\Gm@setsize{#1}(8.5,11){in}}%
+\@namedef{Gm@ansibpaper}#1{\Gm@setsize{#1}(11,17){in}}%
+\@namedef{Gm@ansicpaper}#1{\Gm@setsize{#1}(17,22){in}}%
+\@namedef{Gm@ansidpaper}#1{\Gm@setsize{#1}(22,34){in}}%
+\@namedef{Gm@ansiepaper}#1{\Gm@setsize{#1}(34,44){in}}%
+\@namedef{Gm@letterpaper}#1{\Gm@setsize{#1}(8.5,11){in}}%
+\@namedef{Gm@legalpaper}#1{\Gm@setsize{#1}(8.5,14){in}}%
+\@namedef{Gm@executivepaper}#1{\Gm@setsize{#1}(7.25,10.5){in}}%
+\@namedef{Gm@screen}#1{\Gm@setsize{#1}(225,180){mm}}%
+% \end{macrocode}
+%
% \begin{key}{Gm}{paper}
-% |paper| takes paper name as its value. Available paper names are listed
-% below.
+% |paper| takes a paper name as its value.
% \begin{macrocode}
\define@key{Gm}{paper}{\setkeys{Gm}{#1}}%
\let\KV@Gm@papername\KV@Gm@paper
@@ -2174,64 +2443,85 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{key}
% \begin{key}{Gm}{a[0-6]paper}
% \begin{key}{Gm}{b[0-6]paper}
+% \begin{key}{Gm}{b[0-6]j}
% \begin{key}{Gm}{ansi[a-e]paper}
% \begin{key}{Gm}{letterpaper}
% \begin{key}{Gm}{legalpaper}
% \begin{key}{Gm}{executivepaper}
% \begin{key}{Gm}{screen}
-% The following paper names are available. |screen| and ANSI paper sizes
-% have been introduced in ver.3, but of course they can't be used as
-% a documentclass option.
-% \begin{macrocode}
-\define@key{Gm}{a0paper}[true]{\def\Gm@paper{a0paper}\Gm@chpaper}%
-\define@key{Gm}{a1paper}[true]{\def\Gm@paper{a1paper}\Gm@chpaper}%
-\define@key{Gm}{a2paper}[true]{\def\Gm@paper{a2paper}\Gm@chpaper}%
-\define@key{Gm}{a3paper}[true]{\def\Gm@paper{a3paper}\Gm@chpaper}%
-\define@key{Gm}{a4paper}[true]{\def\Gm@paper{a4paper}\Gm@chpaper}%
-\define@key{Gm}{a5paper}[true]{\def\Gm@paper{a5paper}\Gm@chpaper}%
-\define@key{Gm}{a6paper}[true]{\def\Gm@paper{a6paper}\Gm@chpaper}%
-\define@key{Gm}{b0paper}[true]{\def\Gm@paper{b0paper}\Gm@chpaper}%
-\define@key{Gm}{b1paper}[true]{\def\Gm@paper{b1paper}\Gm@chpaper}%
-\define@key{Gm}{b2paper}[true]{\def\Gm@paper{b2paper}\Gm@chpaper}%
-\define@key{Gm}{b3paper}[true]{\def\Gm@paper{b3paper}\Gm@chpaper}%
-\define@key{Gm}{b4paper}[true]{\def\Gm@paper{b4paper}\Gm@chpaper}%
-\define@key{Gm}{b5paper}[true]{\def\Gm@paper{b5paper}\Gm@chpaper}%
-\define@key{Gm}{b6paper}[true]{\def\Gm@paper{b6paper}\Gm@chpaper}%
-\define@key{Gm}{ansiapaper}[true]{\def\Gm@paper{ansiapaper}\Gm@chpaper}%
-\define@key{Gm}{ansibpaper}[true]{\def\Gm@paper{ansibpaper}\Gm@chpaper}%
-\define@key{Gm}{ansicpaper}[true]{\def\Gm@paper{ansicpaper}\Gm@chpaper}%
-\define@key{Gm}{ansidpaper}[true]{\def\Gm@paper{ansidpaper}\Gm@chpaper}%
-\define@key{Gm}{ansiepaper}[true]{\def\Gm@paper{ansiepaper}\Gm@chpaper}%
-\define@key{Gm}{letterpaper}[true]{\def\Gm@paper{letterpaper}\Gm@chpaper}%
-\define@key{Gm}{legalpaper}[true]{\def\Gm@paper{legalpaper}\Gm@chpaper}%
-\define@key{Gm}{executivepaper}[true]{\def\Gm@paper{executivepaper}%
- \Gm@chpaper}%
-\define@key{Gm}{screen}[true]{\def\Gm@paper{screen}\Gm@chpaper}%
+% The following paper names are available.
+% \begin{macrocode}
+\define@key{Gm}{a0paper}[true]{\Gm@setpaper@ifpre{a0paper}}%
+\define@key{Gm}{a1paper}[true]{\Gm@setpaper@ifpre{a1paper}}%
+\define@key{Gm}{a2paper}[true]{\Gm@setpaper@ifpre{a2paper}}%
+\define@key{Gm}{a3paper}[true]{\Gm@setpaper@ifpre{a3paper}}%
+\define@key{Gm}{a4paper}[true]{\Gm@setpaper@ifpre{a4paper}}%
+\define@key{Gm}{a5paper}[true]{\Gm@setpaper@ifpre{a5paper}}%
+\define@key{Gm}{a6paper}[true]{\Gm@setpaper@ifpre{a6paper}}%
+\define@key{Gm}{b0paper}[true]{\Gm@setpaper@ifpre{b0paper}}%
+\define@key{Gm}{b1paper}[true]{\Gm@setpaper@ifpre{b1paper}}%
+\define@key{Gm}{b2paper}[true]{\Gm@setpaper@ifpre{b2paper}}%
+\define@key{Gm}{b3paper}[true]{\Gm@setpaper@ifpre{b3paper}}%
+\define@key{Gm}{b4paper}[true]{\Gm@setpaper@ifpre{b4paper}}%
+\define@key{Gm}{b5paper}[true]{\Gm@setpaper@ifpre{b5paper}}%
+\define@key{Gm}{b6paper}[true]{\Gm@setpaper@ifpre{b6paper}}%
+\define@key{Gm}{b0j}[true]{\Gm@setpaper@ifpre{b0j}}%
+\define@key{Gm}{b1j}[true]{\Gm@setpaper@ifpre{b1j}}%
+\define@key{Gm}{b2j}[true]{\Gm@setpaper@ifpre{b2j}}%
+\define@key{Gm}{b3j}[true]{\Gm@setpaper@ifpre{b3j}}%
+\define@key{Gm}{b4j}[true]{\Gm@setpaper@ifpre{b4j}}%
+\define@key{Gm}{b5j}[true]{\Gm@setpaper@ifpre{b5j}}%
+\define@key{Gm}{b6j}[true]{\Gm@setpaper@ifpre{b6j}}%
+\define@key{Gm}{ansiapaper}[true]{\Gm@setpaper@ifpre{ansiapaper}}%
+\define@key{Gm}{ansibpaper}[true]{\Gm@setpaper@ifpre{ansibpaper}}%
+\define@key{Gm}{ansicpaper}[true]{\Gm@setpaper@ifpre{ansicpaper}}%
+\define@key{Gm}{ansidpaper}[true]{\Gm@setpaper@ifpre{ansidpaper}}%
+\define@key{Gm}{ansiepaper}[true]{\Gm@setpaper@ifpre{ansiepaper}}%
+\define@key{Gm}{letterpaper}[true]{\Gm@setpaper@ifpre{letterpaper}}%
+\define@key{Gm}{legalpaper}[true]{\Gm@setpaper@ifpre{legalpaper}}%
+\define@key{Gm}{executivepaper}[true]{\Gm@setpaper@ifpre{executivepaper}}%
+\define@key{Gm}{screen}[true]{\Gm@setpaper@ifpre{screen}}%
% \end{macrocode}
% \end{key}\end{key}\end{key}\end{key}\end{key}
-% \end{key}\end{key}
+% \end{key}\end{key}\end{key}
% \begin{key}{Gm}{paperwidth}
% \begin{key}{Gm}{paperheight}
% \begin{key}{Gm}{papersize}
% Direct specification for paper size is also possible.
% \begin{macrocode}
-\define@key{Gm}{paperwidth}{%
- \Gm@setafter\paperwidth{#1}\def\Gm@paper{user defined}}%
-\define@key{Gm}{paperheight}{%
- \Gm@setafter\paperheight{#1}\def\Gm@paper{user defined}}%
-\define@key{Gm}{papersize}{\Gm@branch{#1}{paperwidth}{paperheight}}%
+\define@key{Gm}{paperwidth}{\ifGm@preamble{paperwidth}{%
+ \Gm@setlength\paperwidth{#1}}}%
+\define@key{Gm}{paperheight}{\ifGm@preamble{paperheight}{%
+ \Gm@setlength\paperheight{#1}}}%
+\define@key{Gm}{papersize}{\ifGm@preamble{papersize}{%
+ \Gm@branch{#1}{paperwidth}{paperheight}}}%
% \end{macrocode}
% \end{key}\end{key}\end{key}
+% \begin{key}{Gm}{layout}
+% \begin{key}{Gm}{layoutwidth}
+% \begin{key}{Gm}{layoutheight}
+% \begin{key}{Gm}{layoutsize}
+% Direct specification for layout size is also possible.
+% \begin{macrocode}
+\define@key{Gm}{layout}{\Gm@layouttrue\@nameuse{Gm@#1}{Gm@layout}}%
+\let\KV@Gm@layoutname\KV@Gm@layout
+\define@key{Gm}{layoutwidth}{\Gm@layouttrue\Gm@setlength\Gm@layoutwidth{#1}}%
+\define@key{Gm}{layoutheight}{\Gm@layouttrue\Gm@setlength\Gm@layoutheight{#1}}%
+\define@key{Gm}{layoutsize}{\Gm@branch{#1}{layoutwidth}{layoutheight}}%
+% \end{macrocode}
+% \end{key}\end{key}\end{key}\end{key}
% \begin{key}{Gm}{landscape}
% \begin{key}{Gm}{portrait}
-% Paper orientation setting is also available.
+% Paper orientation setting.
% \begin{macrocode}
-\define@key{Gm}{landscape}[true]{\Gm@doifelse{landscape}{#1}%
- {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{sworient}\fi}%
- {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{sworient}\fi}}%
-\define@key{Gm}{portrait}[true]{\Gm@doifelse{portrait}{#1}%
- {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{sworient}\fi}%
- {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{sworient}\fi}}%
+\define@key{Gm}{landscape}[true]{\ifGm@preamble{landscape}{%
+ \Gm@doifelse{landscape}{#1}%
+ {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{swap@papersize}\fi}%
+ {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{swap@papersize}\fi}}}%
+\define@key{Gm}{portrait}[true]{\ifGm@preamble{portrait}{%
+ \Gm@doifelse{portrait}{#1}%
+ {\ifGm@landscape\Gm@landscapefalse\Gm@reverse{swap@papersize}\fi}%
+ {\ifGm@landscape\else\Gm@landscapetrue\Gm@reverse{swap@papersize}\fi}}}%
% \end{macrocode}
% \end{key}\end{key}
% \begin{key}{Gm}{hscale}
@@ -2285,8 +2575,8 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{key}{Gm}{includeheadfoot}
% \begin{key}{Gm}{includemp}
% \begin{key}{Gm}{includeall}
-% |include*| options include the corresponding part(s) in
-% \gpart{total body}.
+% The options take the corresponding dimensions as part of
+% \gpart{body}.
% \begin{macrocode}
\define@key{Gm}{includehead}[true]{\Gm@setbool{includehead}{#1}}%
\define@key{Gm}{includefoot}[true]{\Gm@setbool{includefoot}{#1}}%
@@ -2304,8 +2594,8 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{key}{Gm}{ignoreheadfoot}
% \begin{key}{Gm}{ignoremp}
% \begin{key}{Gm}{ignoreall}
-% |ignore*| options disregard \gpart{head}, \gpart{foot}
-% and \gpart{marginpars} in determining the location of \gpart{total body}.
+% These options exclude \gpart{head}, \gpart{foot}
+% and \gpart{marginpars} when determining \gpart{body}.
% \begin{macrocode}
\define@key{Gm}{ignorehead}[true]{%
\Gm@setboolrev[ignorehead]{includehead}{#1}}%
@@ -2405,7 +2695,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{key}{Gm}{hcentering}
% \begin{key}{Gm}{vcentering}
% \begin{key}{Gm}{centering}
-% Useful shorthands to make \gpart{body} centered.
+% Useful shorthands to place \gpart{body} centered.
% \begin{macrocode}
\define@key{Gm}{hcentering}[true]{\Gm@doifelse{hcentering}{#1}%
{\def\Gm@hmarginratio{1:1}}{}}%
@@ -2431,9 +2721,9 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{bindingoffset}
-% The macro specifies a white space added to the left or inner margin.
+% The macro adds the specified space to the inner margin.
% \begin{macrocode}
-\define@key{Gm}{bindingoffset}{\Gm@setafter\Gm@bindingoffset{#1}}%
+\define@key{Gm}{bindingoffset}{\Gm@setlength\Gm@bindingoffset{#1}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{headheight}
@@ -2443,9 +2733,9 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \begin{key}{Gm}{foot}
% The direct settings of \gpart{head} and/or \gpart{foot} dimensions.
% \begin{macrocode}
-\define@key{Gm}{headheight}{\Gm@setafter\headheight{#1}}%
-\define@key{Gm}{headsep}{\Gm@setafter\headsep{#1}}%
-\define@key{Gm}{footskip}{\Gm@setafter\footskip{#1}}%
+\define@key{Gm}{headheight}{\Gm@setlength\headheight{#1}}%
+\define@key{Gm}{headsep}{\Gm@setlength\headsep{#1}}%
+\define@key{Gm}{footskip}{\Gm@setlength\footskip{#1}}%
\let\KV@Gm@head\KV@Gm@headheight
\let\KV@Gm@foot\KV@Gm@footskip
% \end{macrocode}
@@ -2457,32 +2747,29 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% to be |0pt|.
% \begin{macrocode}
\define@key{Gm}{nohead}[true]{\Gm@doifelse{nohead}{#1}%
- {\Gm@setafter\headheight\z@\Gm@setafter\headsep\z@}{}}%
+ {\Gm@setlength\headheight\z@\Gm@setlength\headsep\z@}{}}%
\define@key{Gm}{nofoot}[true]{\Gm@doifelse{nofoot}{#1}%
- {\Gm@setafter\footskip\z@}{}}%
+ {\Gm@setlength\footskip\z@}{}}%
\define@key{Gm}{noheadfoot}[true]{\Gm@doifelse{noheadfoot}{#1}%
- {\Gm@setafter\headheight\z@\Gm@setafter\headsep
- \z@\Gm@setafter\footskip\z@}{}}%
+ {\Gm@setlength\headheight\z@\Gm@setlength\headsep
+ \z@\Gm@setlength\footskip\z@}{}}%
% \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Gm}{footnotesep}
% The option directly sets a native dimension \cs{footnotesep}.
% \begin{macrocode}
-\define@key{Gm}{footnotesep}{\Gm@setafter{\skip\footins}{#1}}%
+\define@key{Gm}{footnotesep}{\Gm@setlength{\skip\footins}{#1}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{marginparwidth}
% \begin{key}{Gm}{marginpar}
% \begin{key}{Gm}{marginparsep}
% They directly set native dimensions \cs{marginparwidth} and
-% \cs{marginparsep}. For compatibility, |includemp| is set to |true|
-% if |compat2| is set.
+% \cs{marginparsep}.
% \begin{macrocode}
-\define@key{Gm}{marginparwidth}{\ifGm@compatii\Gm@includemptrue\fi
- \Gm@setafter\marginparwidth{#1}}%
+\define@key{Gm}{marginparwidth}{\Gm@setlength\marginparwidth{#1}}%
\let\KV@Gm@marginpar\KV@Gm@marginparwidth
-\define@key{Gm}{marginparsep}{\ifGm@compatii\Gm@includemptrue\fi
- \Gm@setafter\marginparsep{#1}}%
+\define@key{Gm}{marginparsep}{\Gm@setlength\marginparsep{#1}}%
% \end{macrocode}
% \end{key}\end{key}\end{key}
% \begin{key}{Gm}{nomarginpar}
@@ -2490,13 +2777,13 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \cs{marginparsep}|=0pt|.
% \begin{macrocode}
\define@key{Gm}{nomarginpar}[true]{\Gm@doifelse{nomarginpar}{#1}%
- {\Gm@setafter\marginparwidth\z@\Gm@setafter\marginparsep\z@}{}}%
+ {\Gm@setlength\marginparwidth\z@\Gm@setlength\marginparsep\z@}{}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{columnsep}
% The option sets a native dimension \cs{columnsep}.
% \begin{macrocode}
-\define@key{Gm}{columnsep}{\Gm@setafter\columnsep{#1}}%
+\define@key{Gm}{columnsep}{\Gm@setlength\columnsep{#1}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{hoffset}
@@ -2505,11 +2792,20 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% The former two options set native dimensions \cs{hoffset} and
% \cs{voffset}. |offset| can set both of them with the same value.
% \begin{macrocode}
-\define@key{Gm}{hoffset}{\Gm@setafter\hoffset{#1}}%
-\define@key{Gm}{voffset}{\Gm@setafter\voffset{#1}}%
+\define@key{Gm}{hoffset}{\Gm@setlength\hoffset{#1}}%
+\define@key{Gm}{voffset}{\Gm@setlength\voffset{#1}}%
\define@key{Gm}{offset}{\Gm@branch{#1}{hoffset}{voffset}}%
% \end{macrocode}
% \end{key}\end{key}\end{key}
+% \begin{key}{Gm}{layouthoffset}
+% \begin{key}{Gm}{layoutvoffset}
+% \begin{key}{Gm}{layoutoffset}
+% \begin{macrocode}
+\define@key{Gm}{layouthoffset}{\Gm@setlength\Gm@layouthoffset{#1}}%
+\define@key{Gm}{layoutvoffset}{\Gm@setlength\Gm@layoutvoffset{#1}}%
+\define@key{Gm}{layoutoffset}{\Gm@branch{#1}{layouthoffset}{layoutvoffset}}%
+% \end{macrocode}
+% \end{key}\end{key}\end{key}
% \begin{key}{Gm}{twocolumn}
% The option sets \cs{twocolumn} switch.
% \begin{macrocode}
@@ -2529,34 +2825,38 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{key}\end{key}
% \begin{key}{Gm}{dviver}
% \begin{macrocode}
-\define@key{Gm}{driver}{\edef\@@tempa{#1}\edef\@@auto{auto}\edef\@@none{none}%
+\define@key{Gm}{driver}{\ifGm@preamble{driver}{%
+ \edef\@@tempa{#1}\edef\@@auto{auto}\edef\@@none{none}%
\ifx\@@tempa\@empty\let\Gm@driver\relax\else
\ifx\@@tempa\@@none\let\Gm@driver\relax\else
\ifx\@@tempa\@@auto\let\Gm@driver\@empty\else
- \setkeys{Gm}{#1}\fi\fi\fi\let\@@auto\relax\let\@@none\relax}%
+ \setkeys{Gm}{#1}\fi\fi\fi\let\@@auto\relax\let\@@none\relax}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{dvips}
% \begin{key}{Gm}{dvipdfm}
% \begin{key}{Gm}{pdftex}
+% \begin{key}{Gm}{xetex}
% \begin{key}{Gm}{vtex}
-% The \textsf{geometry} package supports |dvips|, |dvipdfm|,
+% The \Gm\ package supports |dvips|, |dvipdfm|,
% |pdflatex| and |vtex|. |dvipdfm| works like |dvips|.
% \begin{macrocode}
-\define@key{Gm}{dvips}[true]{%
- \Gm@doifelse{dvips}{#1}{\Gm@setdriver{dvips}}{\Gm@unsetdriver{dvips}}}%
-\define@key{Gm}{dvipdfm}[true]{%
- \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}%
-\define@key{Gm}{pdftex}[true]{%
- \Gm@doifelse{pdftex}{#1}{\Gm@setdriver{pdftex}}{\Gm@unsetdriver{pdftex}}}%
-\define@key{Gm}{vtex}[true]{%
- \Gm@doifelse{vtex}{#1}{\Gm@setdriver{vtex}}{\Gm@unsetdriver{vtex}}}%
+\define@key{Gm}{dvips}[true]{\ifGm@preamble{dvips}{%
+ \Gm@doifelse{dvips}{#1}{\Gm@setdriver{dvips}}{\Gm@unsetdriver{dvips}}}}%
+\define@key{Gm}{dvipdfm}[true]{\ifGm@preamble{dvipdfm}{%
+ \Gm@doifelse{dvipdfm}{#1}{\Gm@setdriver{dvipdfm}}{\Gm@unsetdriver{dvipdfm}}}}%
+\define@key{Gm}{pdftex}[true]{\ifGm@preamble{pdftex}{%
+ \Gm@doifelse{pdftex}{#1}{\Gm@setdriver{pdftex}}{\Gm@unsetdriver{pdftex}}}}%
+\define@key{Gm}{xetex}[true]{\ifGm@preamble{xetex}{%
+ \Gm@doifelse{xetex}{#1}{\Gm@setdriver{xetex}}{\Gm@unsetdriver{xetex}}}}%
+\define@key{Gm}{vtex}[true]{\ifGm@preamble{vtex}{%
+ \Gm@doifelse{vtex}{#1}{\Gm@setdriver{vtex}}{\Gm@unsetdriver{vtex}}}}%
% \end{macrocode}
-% \end{key}\end{key}\end{key}\end{key}
+% \end{key}\end{key}\end{key}\end{key}\end{key}
% \begin{key}{Gm}{verbose}
% The verbose mode.
% \begin{macrocode}
-\define@key{Gm}{verbose}[true]{\Gm@setbool{verbose}{#1}}%
+\define@key{Gm}{verbose}[true]{\ifGm@preamble{verbose}{\Gm@setbool{verbose}{#1}}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{reset}
@@ -2564,8 +2864,9 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% except |pass|. |mag| ($\neq1000$) with |truedimen| cannot be also
% reset.
% \begin{macrocode}
-\define@key{Gm}{reset}[true]{\Gm@doifelse{reset}{#1}%
- {\Gm@init\Gm@dorg\ProcessOptionsKV[c]{Gm}\Gm@setdefaultpaper}{}}%
+\define@key{Gm}{reset}[true]{\ifGm@preamble{reset}{%
+ \Gm@doifelse{reset}{#1}{\Gm@restore@org\Gm@initall
+ \ProcessOptionsKV[c]{Gm}\Gm@setdefaultpaper}{}}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{resetpaper}
@@ -2573,14 +2874,15 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% is discarded and the original one is restored. This option may be useful
% to print nonstandard sized documents with normal printers and papers.
% \begin{macrocode}
-\define@key{Gm}{resetpaper}[true]{\Gm@setbool{resetpaper}{#1}}%
+\define@key{Gm}{resetpaper}[true]{\ifGm@preamble{resetpaper}{%
+ \Gm@setbool{resetpaper}{#1}}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{mag}
% |mag| is expanded immediately when it is specified. So |reset| can't
% reset |mag| when it is set with |truedimen|.
% \begin{macrocode}
-\define@key{Gm}{mag}{\mag=#1}%
+\define@key{Gm}{mag}{\ifGm@preamble{mag}{\mag=#1}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{truedimen}
@@ -2588,15 +2890,16 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% is changed to \textit{true} dimensions, e.g., |1in| is changed to
% |1truein|.
% \begin{macrocode}
-\define@key{Gm}{truedimen}[true]{\Gm@doifelse{truedimen}{#1}%
- {\let\Gm@truedimen\Gm@true}{\let\Gm@truedimen\@empty}}%
+\define@key{Gm}{truedimen}[true]{\ifGm@preamble{truedimen}{%
+ \Gm@doifelse{truedimen}{#1}{\let\Gm@truedimen\Gm@true}%
+ {\let\Gm@truedimen\@empty}}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{pass}
% The option makes all the options specified ineffective except
% verbose switch.
% \begin{macrocode}
-\define@key{Gm}{pass}[true]{\Gm@setbool{pass}{#1}}%
+\define@key{Gm}{pass}[true]{\ifGm@preamble{truedimen}{\Gm@setbool{pass}{#1}}}%
% \end{macrocode}
% \end{key}
% \begin{key}{Gm}{showframe}
@@ -2605,59 +2908,57 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\define@key{Gm}{showframe}[true]{\Gm@setbool{showframe}{#1}}%
% \end{macrocode}
% \end{key}
-% \begin{key}{Gm}{compat2}
-% The option sets the old default options for compatibility
-% with version 2. |compat2=false| does nothing.
+% \begin{key}{Gm}{showcrop}
+% The showcrop option.
% \begin{macrocode}
-\define@key{Gm}{compat2}[true]{%
- \Gm@doifelse{compat2}{#1}{\Gm@compatiitrue
- \setkeys{Gm}{scale={0.8,0.9},centering,includeheadfoot}}{}}%
+\define@key{Gm}{showcrop}[true]{\Gm@setbool{showcrop}{#1}}%
% \end{macrocode}
% \end{key}
-% Option |twosideshift| has been obsoleted. But for compatibility
-% with version 2, one can use |twosideshift| when |compat2| is set
-% to |true|.
-% \begin{macrocode}
-\define@key{Gm}{twosideshift}{%
- \ifGm@compatii\@twosidetrue\@mparswitchtrue\Gm@defbylen{twosideshift}{#1}%
- \else\Gm@warning{`twosideshift' is obsolete}%
- \fi}%
-% \end{macrocode}
-%
% \begin{macro}{\Gm@setdefaultpaper}
% The macro stores paper dimensions.
% This macro should be called after |\ProcessOptionsKV[c]{Gm}|.
+% If the |landscape| option in |\documentclass| is
+% specified, the class immediately swaps the paper dimensions.
% \begin{macrocode}
\def\Gm@setdefaultpaper{%
\ifx\Gm@paper\@undefined
- \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
- \Gm@sworientfalse
+ \Gm@setsize{paper}(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
+ \Gm@setsize{Gm@layout}(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
+ \Gm@swap@papersizefalse
\fi}%
-\@onlypreamble\Gm@setdefaultpaper
% \end{macrocode}
% \end{macro}
-% \begin{macro}{\Gm@checkpaper}
+% \begin{macro}{\Gm@adjustpaper}
% The macro checks if paperwidth/height is larger than 0pt,
% which is used in \cs{Gm@process}.
+% The paper dimensions can be swapped when paper orientation
+% is changed over by |landscape| and |portrait| options.
% \begin{macrocode}
-\def\Gm@checkpaper{%
+\def\Gm@adjustpaper{%
\ifdim\paperwidth>\p@\else
\PackageError{geometry}{%
- You must set \string\paperwidth\space properly}{%
- Set your paper type (e.g., `a4paper' for A4) as a class option^^J%
- or as a geometry package option.}%
+ \string\paperwidth\space(\the\paperwidth) too short}{%
+ Set a paper type (e.g., `a4paper').}%
\fi
\ifdim\paperheight>\p@\else
\PackageError{geometry}{%
- You must set \string\paperheight\space properly}{%
- Set your paper type (e.g., `a4paper' for A4) as a class option^^J%
- or as a geometry package option.}%
+ \string\paperheight\space(\the\paperheight) too short}{%
+ Set a paper type (e.g., `a4paper').}%
+ \fi
+ \ifGm@swap@papersize
+ \setlength\@tempdima{\paperwidth}%
+ \setlength\paperwidth{\paperheight}%
+ \setlength\paperheight{\@tempdima}%
+ \fi
+ \ifGm@layout\else
+ \let\Gm@layoutwidth\paperwidth
+ \let\Gm@layoutheight\paperheight
\fi}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\Gm@checkmp}
-% The macro checks if marginpars fall off the page.
+% The macro checks whether or not marginpars overrun the page.
% \begin{macrocode}
\def\Gm@checkmp{%
\ifGm@includemp\else
@@ -2676,7 +2977,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\setlength\@tempdimb{\Gm@lmargin}%
\advance\@tempdimc-\@tempdimb
\ifdim\@tempdimc>\z@
- \Gm@warning{The marginal notes would fall off the page.^^J
+ \Gm@warning{The marginal notes overrun the paper edge.^^J
\@spaces Add \the\@tempdimc\space and more to the left margin}%
\fi
\fi
@@ -2685,167 +2986,59 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\setlength\@tempdimb{\Gm@rmargin}%
\advance\@tempdimc-\@tempdimb
\ifdim\@tempdimc>\z@
- \Gm@warning{The marginal notes would fall off the page.^^J
+ \Gm@warning{The marginal notes overrun the paper.^^J
\@spaces Add \the\@tempdimc\space and more to the right margin}%
\fi
\fi
\fi}%
-\@onlypreamble\Gm@checkmp
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Gm@checkdrivers}
-% The macro checks the typeset environment and changes the driver option
-% if necessary. To make the engine detection more robust, the macro is
-% rewritten in version 4 with packages \textsf{ifpdf} and \textsf{ifvtex}.
-% \begin{macrocode}
-\def\Gm@checkdrivers{%
-% \end{macrocode}
-% If the driver option is not specified explicitly, then driver
-% auto-detection works.
-% \begin{macrocode}
- \ifx\Gm@driver\@empty
- \typeout{*geometry auto-detecting driver*}%
-% \end{macrocode}
-% \cs{ifpdf} is defined in \textsf{ifpdf} package in `oberdiek' bundle.
-% \begin{macrocode}
- \ifpdf
- \Gm@setdriver{pdftex}%
- \else
- \Gm@setdriver{dvips}%
- \fi
-% \end{macrocode}
-% Xe\TeX{} supports the same page size parameter as pdf\TeX.
-% \begin{macrocode}
- \@ifundefined{XeTeXrevision}{}{\Gm@setdriver{pdftex}}%
-% \end{macrocode}
-% \cs{ifvtex} is defined in \textsf{ifvtex} package in `oberdiek'
-% bundle.
-% \begin{macrocode}
- \ifvtex
- \Gm@setdriver{vtex}%
- \fi
-% \end{macrocode}
-% When the driver option is set by the user, check if it is valid or not.
-% \begin{macrocode}
- \else
- \ifx\Gm@driver\Gm@pdftex
- \ifpdf\else
- \@ifundefined{XeTeXrevision}{\Gm@warning{%
- Wrong driver setting: `pdftex'; using default driver}%
- \Gm@setdriver{dvips}}{}%
- \fi
- \fi
- \ifx\Gm@driver\Gm@vtex
- \ifvtex\else
- \Gm@warning{Wrong driver setting: `vtex'; using default driver}%
- \Gm@setdriver{dvips}%
- \fi
- \fi
- \fi}%
-\@onlypreamble\Gm@checkdrivers
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\Gm@mpfix}
+% \begin{macro}{\Gm@adjustmp}
% The macro sets marginpar correction when |includemp| is set,
% which is used in \cs{Gm@process}.
% Local variables \cs{Gm@wd@mp}, \cs{Gm@odd@mp} and \cs{Gm@even@mp}
% are set here. Note that \cs{Gm@even@mp} should be used only for twoside
% layout.
% \begin{macrocode}
-\def\Gm@mpfix{%
- \@tempdimb\marginparwidth
- \advance\@tempdimb\marginparsep
- \Gm@wd@mp\@tempdimb
- \Gm@odd@mp\z@
- \Gm@even@mp\z@
- \if@twocolumn
- \Gm@wd@mp2\@tempdimb
- \Gm@odd@mp\@tempdimb
- \Gm@even@mp\@tempdimb
- \else
- \if@reversemargin
+\def\Gm@adjustmp{%
+ \ifGm@includemp
+ \@tempdimb\marginparwidth
+ \advance\@tempdimb\marginparsep
+ \Gm@wd@mp\@tempdimb
+ \Gm@odd@mp\z@
+ \Gm@even@mp\z@
+ \if@twocolumn
+ \Gm@wd@mp2\@tempdimb
\Gm@odd@mp\@tempdimb
- \if@mparswitch\else
- \Gm@even@mp\@tempdimb
- \fi
+ \Gm@even@mp\@tempdimb
\else
- \if@mparswitch
- \Gm@even@mp\@tempdimb
+ \if@reversemargin
+ \Gm@odd@mp\@tempdimb
+ \if@mparswitch\else
+ \Gm@even@mp\@tempdimb
+ \fi
+ \else
+ \if@mparswitch
+ \Gm@even@mp\@tempdimb
+ \fi
\fi
\fi
\fi}%
-\@onlypreamble\Gm@mpfix
% \end{macrocode}
% \end{macro}
-%
-% \begin{macro}{\Gm@process}
-% The main macro processing specified layout dimensions is defined.
-% \begin{macrocode}
-\def\Gm@process{%
-% \end{macrocode}
-% If |pass| is set, the original dimensions and switches are restored
-% and process is ended here.
-% \begin{macrocode}
- \ifGm@pass
- \Gm@dorg
- \else
-% \end{macrocode}
-% The stored native dimension settings are processed here.
-% \begin{macrocode}
- \Gm@processdimlist
-% \end{macrocode}
-% The margin ratios are set to the default if not specified.
-% \begin{macrocode}
- \ifx\Gm@hmarginratio\@undefined
- \if@twoside
- \edef\Gm@hmarginratio{\Gm@Dhratiotwo}%
- \else
- \edef\Gm@hmarginratio{\Gm@Dhratio}%
- \fi
- \fi
- \ifx\Gm@vmarginratio\@undefined
- \edef\Gm@vmarginratio{\Gm@Dvratio}%
- \fi
-% \end{macrocode}
-% The paper size is checked here.
-% \begin{macrocode}
- \Gm@checkpaper
-% \end{macrocode}
-% The paper dimensions can be swapped when paper orientation
-% is changed over by |landscape| and |portrait| options.
-% \begin{macrocode}
- \ifGm@sworient
- \setlength\@tempdima{\paperwidth}%
- \setlength\paperwidth{\paperheight}%
- \setlength\paperheight{\@tempdima}%
- \Gm@setpaper(\strip@pt\paperwidth,\strip@pt\paperheight){pt}%
- \Gm@sworientfalse
- \fi
-% \end{macrocode}
-% The bindingoffset value is removed from the paper width,
-% which will be set back after auto-completion calculation.
-% \begin{macrocode}
- \addtolength\paperwidth{-\Gm@bindingoffset}%
-% \end{macrocode}
-% The local variables are set here for marginpar correction
-% \cs{Gm@wd@mp}, \cs{Gm@odd@mp} and \cs{Gm@even@mp}
-% when |includemp| is set.
-% \begin{macrocode}
- \ifGm@includemp
- \Gm@mpfix
- \fi
-% \end{macrocode}
+%
+% \begin{macro}{\Gm@adjustbody}
% If the horizontal dimension of \gpart{body} is specified by user,
% \cs{Gm@width} is set properly here.
% \begin{macrocode}
+\def\Gm@adjustbody{
\ifGm@hbody
\ifx\Gm@width\@undefined
\ifx\Gm@hscale\@undefined
- \edef\Gm@width{\Gm@Dhscale\paperwidth}%
+ \edef\Gm@width{\Gm@Dhscale\Gm@layoutwidth}%
\else
- \edef\Gm@width{\Gm@hscale\paperwidth}%
+ \edef\Gm@width{\Gm@hscale\Gm@layoutwidth}%
\fi
\fi
\ifx\Gm@textwidth\@undefined\else
@@ -2857,15 +3050,17 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\fi
\fi
% \end{macrocode}
+% \end{macro}
+%
% If the vertical dimension of \gpart{body} is specified by user,
% \cs{Gm@height} is set properly here.
% \begin{macrocode}
\ifGm@vbody
\ifx\Gm@height\@undefined
\ifx\Gm@vscale\@undefined
- \edef\Gm@height{\Gm@Dvscale\paperheight}%
+ \edef\Gm@height{\Gm@Dvscale\Gm@layoutheight}%
\else
- \edef\Gm@height{\Gm@vscale\paperheight}%
+ \edef\Gm@height{\Gm@vscale\Gm@layoutheight}%
\fi
\fi
\ifx\Gm@lines\@undefined\else
@@ -2899,10 +3094,31 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\fi
\edef\Gm@height{\the\@tempdima}%
\fi
- \fi
+ \fi}%
% \end{macrocode}
-% The auto-completion calculation is executed for each direction.
+%
+% \begin{macro}{\Gm@process}
+% The main macro processing specified layout dimensions is defined.
% \begin{macrocode}
+\def\Gm@process{%
+% \end{macrocode}
+% If |pass| is set, the original dimensions and switches are restored
+% and process is ended here.
+% \begin{macrocode}
+ \ifGm@pass
+ \Gm@restore@org
+ \else
+ \Gm@@process
+ \fi}%
+% \end{macrocode}
+% The main processing macro.
+% \begin{macrocode}
+\def\Gm@@process{%
+ \Gm@expandlengths
+ \Gm@adjustpaper
+ \addtolength\Gm@layoutwidth{-\Gm@bindingoffset}%
+ \Gm@adjustmp
+ \Gm@adjustbody
\Gm@detall{h}{width}{lmargin}{rmargin}%
\Gm@detall{v}{height}{tmargin}{bmargin}%
% \end{macrocode}
@@ -2924,8 +3140,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\fi
% \end{macrocode}
% Determining \cs{evensidemargin}.
-% In the twoside page layout, the right margin value
-% \cs{Gm@rmargin} is used.
+% In the twoside page layout, the right margin value \cs{Gm@rmargin} is used.
% If the marginal note width is included,
% \cs{evensidemargin} should be corrected by \cs{Gm@even@mp}.
% \begin{macrocode}
@@ -2935,13 +3150,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\ifGm@includemp
\advance\evensidemargin\Gm@even@mp
\fi
- \ifGm@compatii
- \ifx\Gm@twosideshift\@undefined
- \def\Gm@twosideshift{20\Gm@truedimen pt}%
- \fi
- \addtolength\oddsidemargin{\Gm@twosideshift}%
- \addtolength\evensidemargin{-\Gm@twosideshift}%
- \fi
\else
\evensidemargin\oddsidemargin
\fi
@@ -2949,9 +3157,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% The bindingoffset correction for \cs{oddsidemargin}.
% \begin{macrocode}
\advance\oddsidemargin\Gm@bindingoffset
-% \end{macrocode}
-% \cs{topmargin} is adjusted here.
-% \begin{macrocode}
\addtolength\topmargin{-1\Gm@truedimen in}%
% \end{macrocode}
% If the head of the page is included in \gpart{total body},
@@ -2994,71 +3199,211 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{macrocode}
% The paper width is set back by adding \cs{Gm@bindingoffset}.
% \begin{macrocode}
- \addtolength\paperwidth{\Gm@bindingoffset}%
- \fi}%
-\@onlypreamble\Gm@process
+ \advance\oddsidemargin\Gm@layouthoffset%
+ \advance\evensidemargin\Gm@layouthoffset%
+ \advance\topmargin\Gm@layoutvoffset%
+ \addtolength\Gm@layoutwidth{\Gm@bindingoffset}%
+ }% end of \Gm@@process
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\Gm@showparam}
-% The macro for typeout of geometry status and native dimensions for
+% \begin{macro}{\Gm@detectdriver}
+% The macro checks the typeset environment and changes the driver option
+% if necessary. To make the engine detection more robust, the macro is
+% rewritten in the version 4 with packages \textsf{ifpdf} and \textsf{ifvtex}.
+% \begin{macrocode}
+\def\Gm@detectdriver{%
+% \end{macrocode}
+% If the driver option is not specified explicitly, then driver
+% auto-detection works.
+% \begin{macrocode}
+ \ifx\Gm@driver\@empty
+ \typeout{*geometry* driver: auto-detecting}%
+% \end{macrocode}
+% \cs{ifpdf} is defined in \textsf{ifpdf} package in `oberdiek' bundle.
+% \begin{macrocode}
+ \ifpdf
+ \Gm@setdriver{pdftex}%
+ \else
+ \Gm@setdriver{dvips}%
+ \fi
+% \end{macrocode}
+% \cs{ifvtex} is defined in \textsf{ifvtex} package in `oberdiek'
+% bundle.
+% \begin{macrocode}
+ \ifvtex
+ \Gm@setdriver{vtex}%
+ \fi
+% \end{macrocode}
+% xetex
+% \begin{macrocode}
+ \@ifundefined{XeTeXversion}{}{\Gm@setdriver{xetex}}%
+% \end{macrocode}
+% When the driver option is set by the user, check if it is valid or not.
+% \begin{macrocode}
+ \else
+ \ifx\Gm@driver\Gm@xetex %%
+ \@ifundefined{XeTeXversion}{\Gm@warning{%
+ Wrong driver setting: `xetex'; trying `pdftex' driver}%
+ \Gm@setdriver{pdftex}}{}%
+ \fi
+ \ifx\Gm@driver\Gm@vtex
+ \ifvtex\else
+ \Gm@warning{Wrong driver setting: `vtex'; trying `dvips' driver}%
+ \Gm@setdriver{dvips}%
+ \fi
+ \fi
+ \fi
+ \ifx\Gm@driver\relax
+ \typeout{*geometry* detected driver: <none>}%
+ \else
+ \typeout{*geometry* detected driver: \Gm@driver}%
+ \fi}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gm@showparams}
+% \begin{macrocode}
+\def\Gm@showparams#1{%
+ \ifGm@verbose\expandafter\typeout\else\expandafter\wlog\fi
+ {\Gm@logcontent{#1}}}%
+\def\Gm@showbool#1{\@nameuse{ifGm@#1}#1\space\fi}%
+\def\Gm@showdim#1{*gm \string#1=\the#1^^J}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\Gm@logcontent}
+% The content of geometry paramenters and native dimensions for the
% page layout.
% \begin{macrocode}
-\def\Gm@showparams{%
- -------------------- Geometry parameters^^J%
- \ifGm@pass
- 'pass' is specified!! (disables the geometry layouter)^^J%
+\def\Gm@logcontent#1{%
+ *geometry* verbose: parameters #1^^J%
+ \ifGm@pass *gm: pass (ignores the geometry layout)^^J%
\else
- paper: \ifx\Gm@paper\@undefined class default\else\Gm@paper\fi^^J%
- \Gm@checkbool{landscape}%
- twocolumn: \if@twocolumn\Gm@true\else--\fi^^J%
- twoside: \if@twoside\Gm@true\else--\fi^^J%
- asymmetric: \if@mparswitch --\else\if@twoside\Gm@true\else --\fi\fi^^J%
- h-parts: \Gm@lmargin, \Gm@width, \Gm@rmargin%
- \ifnum\Gm@cnth=\z@\space(default)\fi^^J%
- v-parts: \Gm@tmargin, \Gm@height, \Gm@bmargin%
- \ifnum\Gm@cntv=\z@\space(default)\fi^^J%
- hmarginratio: \ifnum\Gm@cnth<5 \ifnum\Gm@cnth=3--\else%
- \Gm@hmarginratio\fi\else--\fi^^J%
- vmarginratio: \ifnum\Gm@cntv<5 \ifnum\Gm@cntv=3--\else%
- \Gm@vmarginratio\fi\else--\fi^^J%
- lines: \@ifundefined{Gm@lines}{--}{\Gm@lines}^^J%
- \Gm@checkbool{heightrounded}%
- bindingoffset: \the\Gm@bindingoffset^^J%
- truedimen: \ifx\Gm@truedimen\@empty --\else\Gm@true\fi^^J%
- \Gm@checkbool{includehead}%
- \Gm@checkbool{includefoot}%
- \Gm@checkbool{includemp}%
- driver: \if\Gm@driver\relax --\else\Gm@driver\fi^^J%
+ \if\Gm@driver\relax *gm driver: <none>^^J\else *gm driver: \Gm@driver^^J\fi
+ \ifx\Gm@paper\@undefined *gm paper: \the\paperwidth, \the\paperheight^^J%
+ \else *gm paper: \Gm@paper^^J\fi
+ \ifGm@layout *gm layout: \the\Gm@layoutwidth, \the\Gm@layoutheight^^J%
+ \else *gm layout: (same as paper)^^J\fi
+ \@ifundefined{Gm@lines}{}{*gm lines: \Gm@lines^^J}%
+ \@ifundefined{Gm@hmarginratio}{}{*gm hratio: \Gm@hmarginratio^^J}%
+ \@ifundefined{Gm@vmarginratio}{}{*gm vratio: \Gm@vmarginratio^^J}%
+ \ifdim\Gm@bindingoffset=\z@\else *gm bindingoffset: \the\Gm@bindingoffset^^J\fi
+ *gm L,W,R: \Gm@lmargin, \Gm@width, \Gm@rmargin^^J%
+ *gm T,H,B: \Gm@tmargin, \Gm@height, \Gm@bmargin^^J%
+ *gm switch-on: %
+ \Gm@showbool{landscape}%
+ \Gm@showbool{includehead}%
+ \Gm@showbool{includefoot}%
+ \Gm@showbool{includemp}%
+ \if@twoside twoside\space\fi%
+ \if@mparswitch\else\if@twoside asymmetric\space\fi\fi%
+ \Gm@showbool{heightrounded}%
+ \ifx\Gm@truedimen\@empty\else *gm truedimen\space\fi%
+ ^^J%
\fi
- -------------------- Page layout dimensions and switches^^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%
- \string\marginparwidth\space\the\marginparwidth^^J%
- \string\marginparsep\space\space\space\the\marginparsep^^J%
- \string\columnsep\space\space\the\columnsep^^J%
- \string\skip\string\footins\space\space\the\skip\footins^^J%
- \string\hoffset\space\the\hoffset^^J%
- \string\voffset\space\the\voffset^^J%
- \string\mag\space\the\mag^^J%
- \if@twocolumn\string\@twocolumntrue\space\fi%
- \if@twoside\string\@twosidetrue\space\fi%
- \if@mparswitch\string\@mparswitchtrue\space\fi%
- \if@reversemargin\string\@reversemargintrue\space\fi^^J%
- (1in=72.27pt, 1cm=28.45pt)^^J%
- -----------------------}%
-\@onlypreamble\Gm@showparams
+ \Gm@showdim{\paperwidth}%
+ \Gm@showdim{\paperheight}%
+ \Gm@showdim{\textwidth}%
+ \Gm@showdim{\textheight}%
+ \Gm@showdim{\oddsidemargin}%
+ \Gm@showdim{\evensidemargin}%
+ \Gm@showdim{\topmargin}%
+ \Gm@showdim{\headheight}%
+ \Gm@showdim{\headsep}%
+ \Gm@showdim{\footskip}%
+ \Gm@showdim{\marginparwidth}%
+ \Gm@showdim{\marginparsep}%
+ \Gm@showdim{\columnsep}%
+ *gm \string\skip\string\footins=\the\skip\footins^^J%
+ \Gm@showdim{\hoffset}%
+ \Gm@showdim{\voffset}%
+ \Gm@showdim{\mag}%
+ \if@twocolumn *gm\space\string\@twocolumntrue^^J\fi%
+ \if@twoside *gm\space\string\@twosidetrue^^J\fi%
+ \if@mparswitch *gm\space\string\@mparswitchtrue^^J\fi%
+ \if@reversemargin *gm\space\string\@reversemargintrue^^J\fi%
+ *gm (1in=72.27pt, 1cm=28.4528pt)}%
% \end{macrocode}
% \end{macro}
%
+% macros for frames and cropmarks
+% \begin{macrocode}
+\def\Gm@cropmark(#1,#2,#3,#4){%
+ \begin{picture}(0,0)
+ \setlength\unitlength{1truemm}\thinlines
+ \put(0,0){\line(#1,#2){5}}
+ \put(0,0){\line(#3,#4){5}}
+ \end{picture}}%
+\newcommand*{\Gm@vrules@mpi}{%
+ \hb@xt@\@tempdima{\llap{\vrule height\textheight}\ignorespaces
+ \hskip \textwidth\vrule height\textheight\hskip \marginparsep
+ \llap{\vrule height\textheight}\hfil\vrule height\textheight}}%
+\newcommand*{\Gm@vrules@mpii}{%
+ \hb@xt@\@tempdima{\hskip-\marginparwidth\hskip-\marginparsep
+ \llap{\vrule height\textheight}\ignorespaces
+ \hskip \marginparwidth\rlap{\vrule height\textheight}\hskip \marginparsep
+ \llap{\vrule height\textheight}\hskip\textwidth\rlap{\vrule height\textheight}\hss}}%
+\providecommand*\vb@xt@{\vbox to}%
+\newcommand*{\Gm@pageframes}{%
+ \vb@xt@\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
+ \ifGm@showcrop
+ \vb@xt@\z@{\vskip-1\Gm@truedimen in\vskip\Gm@layoutvoffset%
+ \hb@xt@\z@{\hskip-1\Gm@truedimen in\hskip\Gm@layouthoffset%
+ \vb@xt@\Gm@layoutheight{%
+ \let\protect\relax
+ \hb@xt@\Gm@layoutwidth{\Gm@cropmark(1,0,0,-1)\hfil\Gm@cropmark(-1,0,0,-1)}%
+ \vfil
+ \hb@xt@\Gm@layoutwidth{\Gm@cropmark(1,0,0,1)\hfil\Gm@cropmark(-1,0,0,1)}}%
+ \hss}%
+ \vss}%
+ \fi%
+ \ifGm@showframe
+ \if@twoside
+ \ifodd\count\z@
+ \let\@themargin\oddsidemargin
+ \else
+ \let\@themargin\evensidemargin
+ \fi
+ \fi
+ \moveright\@themargin%
+ \vb@xt@\z@{%
+ \vskip\topmargin\vb@xt@\z@{\vss\hrule width\textwidth}%
+ \vskip\headheight\vb@xt@\z@{\vss\hrule width\textwidth}%
+ \vskip\headsep\vb@xt@\z@{\vss\hrule width\textwidth}
+ \@tempdima\textwidth
+ \advance\@tempdima by \marginparsep
+ \advance\@tempdima by \marginparwidth
+ \if@mparswitch
+ \ifodd\count\z@
+ \Gm@vrules@mpi
+ \else
+ \Gm@vrules@mpii
+ \fi
+ \else
+ \Gm@vrules@mpi
+ \fi
+ \vb@xt@\z@{\vss\hrule width\textwidth}%
+ \vskip\footskip\vb@xt@\z@{\vss\hrule width\textwidth}%
+ \vss}%
+ \fi%
+ }}%
+\let\Gm@shipout\shipout
+\newcommand*{\gm@shipi}{%
+ \ifvoid\@cclv\expandafter\aftergroup\fi\gm@shipii}%
+\newcommand*\gm@shipii{%
+ \ifvoid\@cclv
+ \Gm@shipout\box\@cclv
+ \else
+ \ifGm@showframe
+ \Gm@shipout\vbox{\Gm@pageframes\ifvbox\@cclv\unvbox\else\box\fi\@cclv}%
+ \else\ifGm@showcrop
+ \Gm@shipout\vbox{\Gm@pageframes\ifvbox\@cclv\unvbox\else\box\fi\@cclv}%
+ \else
+ \Gm@shipout\box\@cclv
+ \fi\fi
+ \fi}
+% \end{macrocode}
+%
% \begin{macro}{\ProcessOptionsKV}
% This macro can process class and package options using `key=value'
% scheme. Only class options are processed with an optional argument `|c|',
@@ -3075,7 +3420,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\else
\@for\CurrentOption:=\@classoptionslist\do{%
\@ifundefined{KV@#2@\CurrentOption}%
- {}{\edef\@tempa{\@tempa,\CurrentOption,}}}%
+ {}{\edef\@tempa{\@tempa,\CurrentOption,}}}%
\ifnum\@tempcnta=\z@
\edef\@tempa{\@tempa,\@ptionlist{\@currname.\@currext}}%
\fi
@@ -3083,43 +3428,42 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\edef\@tempa{\noexpand\setkeys{#2}{\@tempa}}%
\@tempa
\AtEndOfPackage{\let\@unprocessedoptions\relax}}%
-\@onlypreamble\ProcessOptionsKV
-\@onlypreamble\@ProcessOptionsKV
% \end{macrocode}
% \end{macro}
-%
-% Geometry parameters are initialized here.
-% \cs{Gm@init} can be called by |reset| or |pass| options.
% \begin{macrocode}
-\Gm@init
+\def\Gm@setkeys{\setkeys{Gm}}%
% \end{macrocode}
-% The optional arguments to \cs{documentclass} are processed here.
+% \begin{macro}{\Gm@processconf}
+% \cs{ExecuteOptions} is replaced with \cs{Gm@setkey} to make it
+% possible to deal with '\meta{key}=\meta{value}' as its argument.
% \begin{macrocode}
-\ProcessOptionsKV[c]{Gm}%
+\def\Gm@processconfig{%
+ \let\Gm@origExecuteOptions\ExecuteOptions
+ \let\ExecuteOptions\Gm@setkeys
+ \InputIfFileExists{geometry.cfg}{}{}
+ \let\ExecuteOptions\Gm@origExecuteOptions}%
% \end{macrocode}
-% Paper dimensions given by class default are stored.
+% \end{macro}
+%
+% The original page layout before loading \Gm\ is saved with
+% |\Gm@save| and can be called by |\Gm@restore@org|.
+% which will be used when |reset| or |pass| is specified.
% \begin{macrocode}
-\Gm@setdefaultpaper
+\Gm@save
+\edef\Gm@restore@org{\Gm@restore}%
+\Gm@initall
% \end{macrocode}
-% \begin{macro}{\Gm@setkey}
-% \cs{ExecuteOptions} is replaced with \cs{Gm@setkey} to make it
-% possible to deal with '\meta{key}=\meta{value}' as its argument.
+% Processing config file.
% \begin{macrocode}
-\def\Gm@setkeys{\setkeys{Gm}}%
-\@onlypreamble\Gm@setkeys
-\let\Gm@origExecuteOptions\ExecuteOptions
-\let\ExecuteOptions\Gm@setkeys
+\Gm@processconfig
% \end{macrocode}
-% \end{macro}
-% A local configuration file may define more options.
-% To set A4 paper as default, \texttt{geometry.cfg} gg to contain
-% |\ExecuteOptions{a4paper}|.
+% The optional arguments to \cs{documentclass} are processed here.
% \begin{macrocode}
-\InputIfFileExists{geometry.cfg}{}{}%
+\ProcessOptionsKV[c]{Gm}%
% \end{macrocode}
-% The original definition for \cs{ExecuteOptions} macro is restored.
+% Paper dimensions given by class default are stored.
% \begin{macrocode}
-\let\ExecuteOptions\Gm@origExecuteOptions
+\Gm@setdefaultpaper
% \end{macrocode}
% The optional arguments to \cs{usepackage} are processed here.
% \begin{macrocode}
@@ -3144,7 +3488,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\else
\edef\Gm@pw{\the\paperwidth}%
\edef\Gm@ph{\the\paperheight}%
- \fi
+ \fi
% \end{macrocode}
% If |pass| is set to |true|, no adjustment for page dimensions is done.
% \begin{macrocode}
@@ -3160,11 +3504,20 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \end{macrocode}
% Checking the driver options.
% \begin{macrocode}
- \Gm@checkdrivers
- \ifx\Gm@driver\relax
- \typeout{*geometry detected driver: <none>*}%
- \else
- \typeout{*geometry detected driver: \Gm@driver*}%
+ \Gm@detectdriver
+% \end{macrocode}
+% |xetex|
+% \begin{macrocode}
+ \ifx\Gm@driver\Gm@xetex
+ \@ifundefined{pdfpagewidth}{}{%
+ \setlength\pdfpagewidth{\Gm@pw}%
+ \setlength\pdfpageheight{\Gm@ph}}%
+ \ifnum\mag=\@m\else
+ \ifx\Gm@truedimen\Gm@true
+ \setlength\paperwidth{\Gm@pw}%
+ \setlength\paperheight{\Gm@ph}%
+ \fi
+ \fi
\fi
% \end{macrocode}
% If |pdftex| is set to |true|, pdf-commands are set properly.
@@ -3172,14 +3525,16 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \cs{pdfvorigin} are adjusted for \cs{mag}.
% \begin{macrocode}
\ifx\Gm@driver\Gm@pdftex
- \setlength\pdfpagewidth{\Gm@pw}%
- \setlength\pdfpageheight{\Gm@ph}%
+ \@ifundefined{pdfpagewidth}{}{%
+ \setlength\pdfpagewidth{\Gm@pw}%
+ \setlength\pdfpageheight{\Gm@ph}}%
\ifnum\mag=\@m\else
\@tempdima=\mag sp%
- \divide\pdfhorigin\@tempdima
- \multiply\pdfhorigin\@m
- \divide\pdfvorigin\@tempdima
- \multiply\pdfvorigin\@m
+ \@ifundefined{pdfhorigin}{}{%
+ \divide\pdfhorigin\@tempdima
+ \multiply\pdfhorigin\@m
+ \divide\pdfvorigin\@tempdima
+ \multiply\pdfvorigin\@m}%
\ifx\Gm@truedimen\Gm@true
\setlength\paperwidth{\Gm@pw}%
\setlength\paperheight{\Gm@ph}%
@@ -3190,14 +3545,15 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% With V\TeX{} environment, V\TeX{} variables are set here.
% \begin{macrocode}
\ifx\Gm@driver\Gm@vtex
- \mediawidth=\paperwidth
- \mediaheight=\paperheight
+ \@ifundefined{mediawidth}{}{%
+ \mediawidth=\paperwidth
+ \mediaheight=\paperheight}%
\ifvtexdvi
\AtBeginDvi{\special{papersize=\the\paperwidth,\the\paperheight}}%
\fi
\fi
% \end{macrocode}
-% If |dvips| or |dvipdfm| is set to |true|, paper size is embedded in dvi
+% If |dvips| or |dvipdfm| is specified, paper size is embedded in dvi
% file with \cs{special}. For dvips, a landscape correction is added
% because a landscape document converted by dvips is upside-down in
% PostScript viewers.
@@ -3208,7 +3564,7 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\AtBeginDvi{\special{! /landplus90 true store}}%
\fi\fi
% \end{macrocode}
-% When |dvipdfm| option is set and \textsf{atbegshi} package in
+% If |dvipdfm| is specified and \textsf{atbegshi} package in
% `oberdiek' bundle is loaded, \cs{AtBeginShipoutFirst} is used
% instead of \cs{AtBeginDvi} for compatibility with \textsf{hyperref}
% and |dvipdfm| program.
@@ -3226,63 +3582,96 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% on the first page.
% \begin{macrocode}
\ifGm@showframe
- \AtBeginDvi{%
- \moveright\@themargin%
- \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
- \vskip\topmargin\vbox to\z@{\vss\hrule width\textwidth}%
- \vskip\headheight\vbox to\z@{\vss\hrule width\textwidth}%
- \vskip\headsep\vbox to\z@{\vss\hrule width\textwidth}%
- \hbox to\textwidth{\llap{\vrule height\textheight}\hfil%
- \vrule height\textheight}%
- \vbox to\z@{\vss\hrule width\textwidth}%
- \vskip\footskip\vbox to\z@{\vss\hrule width\textwidth}%
- \vss}}%
- \AtBeginDvi{%
- \vbox to\z@{\baselineskip\z@skip\lineskip\z@skip\lineskiplimit\z@%
- \vskip-1\Gm@truedimen in\rlap{\hskip-1\Gm@truedimen in%
- \vbox to\z@{\vbox to\z@{\vss\hrule width\paperwidth}%
- \hbox to \paperwidth{\llap{\vrule height\paperheight}\hfil%
- \vrule height\paperheight}%
- \vbox to\z@{\vss\hrule width\paperwidth}%
- \vss}}\vss}}%
- \fi
+ \renewcommand*{\shipout}{\afterassignment\gm@shipi\setbox\@cclv=}
+ \else\ifGm@showcrop
+ \renewcommand*{\shipout}{\afterassignment\gm@shipi\setbox\@cclv=}
+ \fi\fi
+% \end{macrocode}
+% Here the layout dimensions are saved. The layout can be restored
+% by \cs{restoregeometry} command.
+% \begin{macrocode}
+ \Gm@save
+ \edef\Gm@restore@pkg{\Gm@restore}%
% \end{macrocode}
% If |verbose=true| and |pass=false|, the system checks
-% if marginpars fall off the page.
+% if marginpars overrun the page.
% \begin{macrocode}
\ifGm@verbose\ifGm@pass\else\Gm@checkmp\fi\fi
% \end{macrocode}
% If |verbose=true| the parameter results are displayed on the terminal.
% |verbose=false| (default) still puts them into the log file.
% \begin{macrocode}
- \ifGm@verbose\expandafter\typeout\else\expandafter\wlog\fi
- {\Gm@showparams}%
-% \end{macrocode}
-% save memory.
-% \begin{macrocode}
- \let\Gm@cnth\relax
- \let\Gm@cntv\relax
- \let\c@Gm@tempcnt\relax
- \let\Gm@bindingoffset\relax
- \let\Gm@wd@mp\relax
- \let\Gm@odd@mp\relax
- \let\Gm@even@mp\relax
- \let\Gm@orgpw\relax
- \let\Gm@orgph\relax
- \let\Gm@pw\relax
- \let\Gm@ph\relax
- \let\Gm@dimlist\relax}%
+ \setlength\@tempdima{\Gm@width}\edef\Gm@width{\the\@tempdima}%
+ \setlength\@tempdima{\Gm@height}\edef\Gm@height{\the\@tempdima}%
+ \Gm@showparams{in the preamble}%
+ }% end of \AtBeginDocument
% \end{macrocode}
%
% \begin{macro}{\geometry}
% The user-interface macro \cs{geometry} is defined here.
% This command should be used in the preamble.
% \begin{macrocode}
-\def\geometry#1{%
+\newcommand{\geometry}[1]{%
\Gm@clean
\setkeys{Gm}{#1}%
\Gm@process}%
\@onlypreamble\geometry
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\Gm@changelayout}
+% \begin{macrocode}
+\DeclareRobustCommand\Gm@changelayout{%
+ \setlength{\@colht}{\textheight}\setlength{\@colroom}{\textheight}%
+ \setlength{\vsize}{\textheight}\setlength{\columnwidth}{\textwidth}%
+ \if@twocolumn%
+ \advance\columnwidth-\columnsep \divide\columnwidth\tw@%
+ \@firstcolumntrue%
+ \fi%
+ \setlength{\hsize}{\columnwidth}%
+ \setlength{\linewidth}{\hsize}}%
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newgeometry}
+% \begin{macrocode}
+\newcommand\newgeometry[1]{%
+ \clearpage
+ \Gm@restore@org
+ \Gm@initnewgm
+ \Gm@newgmtrue
+ \setkeys{Gm}{#1}%
+ \Gm@newgmfalse
+ \Gm@process
+ \Gm@changelayout
+ \Gm@showparams{by \string\newgeometry}}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\restoregeometry}
+% \begin{macrocode}
+\newcommand\restoregeometry{%
+ \clearpage
+ \Gm@restore@pkg
+ \Gm@changelayout}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\savegeometry}
+% \begin{macrocode}
+\newcommand*\savegeometry[1]{%
+ \Gm@save
+ \expandafter\edef\csname Gm@restore@@#1\endcsname{\Gm@restore}}%
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\loadgeometry}
+% \begin{macrocode}
+\newcommand*\loadgeometry[1]{%
+ \clearpage
+ \@ifundefined{Gm@restore@@#1}{%
+ \PackageError{geometry}{%
+ \string\loadgeometry : name `#1' undefined}{%
+ The name `#1' should be predefined with \string\savegeometry}%
+ }{\@nameuse{Gm@restore@@#1}%
+ \Gm@changelayout}}%
%</package>
% \end{macrocode}
% \end{macro}
@@ -3331,7 +3720,6 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
% \usepackage[centering,includemp,twoside,landscape]{geometry}
% \usepackage[mag=1414,margin=2cm]{geometry}
% \usepackage[mag=1414,margin=2truecm,truedimen]{geometry}
-% \usepackage[compat2,marginpar=50pt,twosideshift=50pt]{geometry}
% \usepackage[a5paper, landscape, twocolumn, twoside,
% left=2cm, hmarginratio=2:1, includemp, marginparwidth=43pt,
% bottom=1cm, foot=.7cm, includefoot, textheight=11cm, heightrounded,
@@ -3358,4 +3746,4 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
%
% \Finale
%
-\endinput \ No newline at end of file
+\endinput
diff --git a/Master/texmf-dist/source/latex/geometry/geometry.ins b/Master/texmf-dist/source/latex/geometry/geometry.ins
index af2f59d45de..708705bb796 100644
--- a/Master/texmf-dist/source/latex/geometry/geometry.ins
+++ b/Master/texmf-dist/source/latex/geometry/geometry.ins
@@ -6,7 +6,8 @@
%%
%% geometry.dtx (with options: `install')
%%
-%% Copyright (C) 1996-2002, 2008 by Hideo Umeki <latexgeometry@gmail.com>
+%% Copyright (C) 1996-2010
+%% by Hideo Umeki <latexgeometry@gmail.com>
%%
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c of this license
@@ -25,15 +26,15 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: geometry 2008/12/21 v4.2 Page Geometry}
+\Msg{* Package: geometry 2010/02/12 v5.0 Page Geometry}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
-
\preamble
-Copyright (C) 1996-2002, 2008 by Hideo Umeki <latexgeometry@gmail.com>
+Copyright (C) 1996-2010
+by Hideo Umeki <latexgeometry@gmail.com>
This work may be distributed and/or modified under the conditions of
the LaTeX Project Public License, either version 1.3c of this license
@@ -69,12 +70,11 @@ the derived files: geometry.{sty,ins,drv}, geometry-samples.tex.
\Msg{* \space\space geometry.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `geometry.drv'}
-\Msg{* through (PDF)LaTeX.}
+\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
-
\endbatchfile
\endinput
%%