<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% \iffalse meta-comment
% %%----------------------------------------------------------------------------
%
%% File: vmargin.dtx Copyright (C) 1993, 1994, 1995, 1996, 1999, 2000, 2002,
%%                                 2004
%%       by Volker Kuhlmann   &lt;VolkerKuhlmann@GMX.de&gt;
%% All rights are reserved.
%%
%
%&lt;*dtx&gt;
            \NeedsTeXFormat{LaTeX2e}[1999/06/01]
            \ProvidesFile{vmargin.dtx}
%&lt;/dtx&gt;
%
%&lt;driver&gt;   \ProvidesFile{vmargin.drv}
%
%^^A&lt;package&gt;\NeedsTeXFormat{LaTeX2e}[1998/06/01]
%^^A&lt;package&gt;\ProvidesPackage{vmargin}
%^^A         Can't have these 2 lines if package is to work with LaTeX 2.09
%
% ^^A NOTE: VERSION INFO DUPLICATED BELOW AND IN PACKAGE MACROCODE SECTION !!!
% ^^A       search tag:  mAcRoVeRsIoN    (total of 4 places to change!)
%&lt;*dtx|driver&gt;
%           \ProvidesFile{vmargin.dtx}
           [2004/07/15 v2.5 set document margins (VK)]
%^^A need to uncomment above line to get it into the .drv
%^^A alternatively we could scrap it altogether!
%&lt;/dtx|driver&gt;
%
% \fi
% ^^A The following 2 lines are required for the .drv file to correctly generate
% ^^A the documentation from the .dtx. It's needed for \GetFileInfo.
% ^^A The 2nd line generally is uncommented, but that would mean it ends up in
% ^^A the .sty which we can't allow for 2.09 compatibility.
%           \ProvidesFile{vmargin.dtx}
%           [2004/07/15 V2.5 set document margins (VK)]  %^^A mAcRoVeRsIoN
%
%%
%% \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
%%   Lower-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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&amp;
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \&lt;
%%   Equals        \=     Greater than  \&gt;     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
%
% \iffalse
%&lt;*driver&gt;

\NeedsTeXFormat{LaTeX2e}[1999/06/01]
\documentclass{ltxdoc}
%%\IfFileExists{ltxdoc.cfg}{}{\OnlyDescription\RecordChanges\CodelineIndex}

\IfFileExists{vmargin.sty}{%
    \usepackage{vmargin}%
    \setpapersize[portrait]{A4}%
    \setmarginsrb{55mm}{15mm}{22mm}{15mm}{10pt}{7mm}{}{12mm}%
    \marginparsep   3mm
    \relax
}{}

 %\OnlyDescription                  % uncomment to suppress code line listing
 \RecordChanges                    % uncomment for a change history
 \CodelineIndex\EnableCrossrefs    % uncomment for command index
\GetFileInfo{vmargin.dtx}

\begin{document}
\DocInput{vmargin.dtx}
%%\IfFileExists{ltxdoc.cfg}{}{\PrintChanges\PrintIndex}
 \PrintChanges                     % uncomment for a change history
 \PrintIndex                       % uncomment for command index
\end{document}

%&lt;/driver&gt;
% \fi
%
%
% \GetFileInfo{vmargin.dtx}
% \CheckSum{395}
%
% %^^A This command extracts all index entries:
% %^^A sed &lt; vmargin.idx -e 's,indexentry{,,' -e 's,=.*$,,'
%
% \date{\filedate}
% \title{The \textsf{vmargin} Package\thanks
%        {This file has version number \fileversion,
%         last modified \filedate.}}
% \author{Volker Kuhlmann\thanks{%^^A
%         ^^AEmail:\ \url{v.kuhlmann@elec.canterbury.ac.nz}.
%   	  Email:\ \url{VolkerKuhlmann@GMX.de}.
%   	  For a postal address refer to the license section.}}
%
%
% %%%^^A  MACROS used for this document
% \let\package\textsf
% \let\env\textsf
% \let\url\texttt
% \newcommand\optmeta[1]{[\meta{#1}]}
% \begingroup
% \catcode`\^^M\active^^A%   Has to be active during definition!
% \gdef\makeNLnl{\catcode`\^^M\active \def^^M{\par}}
% \endgroup
% \newenvironment{pckcmd}{%^^A
%   \ifvmode \else \par\vspace{-\parskip}\fi
%   \vspace{1mm}\noindent \hangindent 4em\hangafter 0\ignorespaces
%   }{%^^A
%   \par\vspace{1mm}\vspace{-\parskip}}
% \newcommand\MargWord[1]{\marginpar{\raggedleft\PrintDescribeEnv{#1}}}
%
%
% ^^A  search tag:  mAcRoVeRsIoN  (adjust changelog)
%
% \changes{v2.5}{2004/07/15}
%   {\cs{margin@offset} now uses \hbox{-1truein} instead of -1in}
%
% \changes{v2.4.2}{2002/11/08}
%   {documentation only}
%
% \changes{v2.4}{2002/01/23}
%   {minor changes, mostly cosmetic}
%
% \changes{v2.3b}{2000/08/29}
%   {screen output of version info.}
%
% \changes{v2.3}{2000/08/01}
%   {Now setting page size for pdflatex.}
% 
% \changes{v2.2b}{2000/03/14}
%   {Changed into docstrip format.
%   Improved documentation.}
%
% \changes{V2.2}{1999/05/31}
%   {Released under LPPL.
%   Changed references to Vmargin to vmargin.
%   \LaTeX2e\ package options introduced.}
%
% \changes{V2.13}{1996/06/26}
%   {Fixed comment for \cs{setmarginsrb}.}
%
% \changes{V2.12}{1995/03/28}
%   {Fixed documentation for \cs{setmargrb}.}
%
% \changes{V2.1}{1994/09/20}
%   {\cs{@defmetricpaper} now defines \cs{w}, \cs{h}, \cs{s} locally.
%   Thanks to \url{branderhorst@fgg.eur.nl}!}
%
% \changes{V2.0}{1994/06/28}
%   {Added support for \LaTeX2e\ \cs{paperwidth}, \cs{paperheight}.}
%
% \changes{V1.9}{1994/06/22}
%   {Corrected spelling in comment.}
%
% \changes{V1.8}{1994/05/28}
%   {Commented \cs{chk@dimen};
%   reduced load on \TeX'sparameter stack (changed \cs{chk@dimen});
%   put a conditional around references to \cs{footheight}.}
%
% \changes{V1.72}{1994/05/21}
%   {Fixed bug in \cs{setpapersize\{custom\}}.}
%
% \changes{V1.7}{1994/05/21}
%   {Changed file header.}
%
% \changes{1.0}{1993}
%   {Created out of Vpage.sty V2.2, 18 June 1993}
%
%
% \maketitle
%
% \begin{abstract}
% LaTeX package which introduces paper sizes and provides macros for
% setting document margins. It still works with \LaTeX\ 2.09.
% This package supersedes package vpage.
%
% This package file can be made part of a format by typing |\input vmargin.sty|
% before dumping the format.
% \end{abstract}
%
% \tableofcontents
%
%
% \section{License}
%
% This package is copyright \textcopyright\ 1993, 1994, 1995, 1996, 1999, 2000,
% 2002, 2004 by:
%
% \begin{quote}
%   Volker Kuhlmann,
%   c/o University of Canterbury,
%   ELEC Dept, Creyke Road,
%   Christchurch, New Zealand\\
%   ^^AE-Mail: \url{v.kuhlmann@elec.canterbury.ac.nz}
%   E-Mail: \url{VolkerKuhlmann@GMX.de}
% \end{quote}
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License, distributed from CTAN
% archives as macros/latex/base/lppl.txt; either
% version 1 of the License, or (at your option) any later version.
%
%
% \section{History}
%
% This is the first package I ever wrote, to save a lot of typing when dealing
% with \TeX's 1in/1in margin offset, proper margin alignment for doublesided
% printing, and page layout parameters I always used. As there wasn't anything
% similar on CTAN I submitted the package, then called \package{Vpage}. I
% never heard back, and wasn't looking for it in the right place, so I
% thought it hadn't been accepted and never thought any more of it.
%
% In the meantime I realised its general-purpose potential and took the page
% layout code out, renaming it to \package{Vmargin}. First time I heard it
% was on CTAN was when I read the list of 3rd-party packages in the \LaTeX\
% Companion and it had \package{vpage} in it (CTAN doesn't deal in uppercase
% letters). So sorry for any confusion the name change caused\ldots
%
% Further development essentially ceased because I didn't see much scope
% for improvements. \package{vmargin} was doing its job. I could have gone
% overboard with package options, but didn't because I was more interested
% in a short efficient tool which doesn't load half of the tools and/or
% graphics bundle. It still works under both \LaTeX\ 2.09 and \LaTeXe.
%
%
% \section{User manual}
%
% \subsection{Page Size}
% 
% These macros make it easy to set page margins for a chosen paper size.
% Actual dimensions of the most common paper sizes are stored and need
% not be remembered.
% 
% Two sided printing is supported, meaning that if on odd pages the left
% margin is, say, 30mm and the right margin is 20mm, it will be vice
% versa on even pages. This gives equal margins on the outer and equal
% margins on the inner edge of the paper, as expected e.g.\ for a book.
% 
% \package{vmargin} is designed to be reasonably restricted in both memory
% usage and processing time, so that the common task of setting margins
% is not too distracting. If you are looking for something fancier try the
% \package{geometry} package.
% 
% The basic procedure of using \package{vmargin} is to first set a paper size,
% and then to set the margins. The margin setting functions depend on the paper
% size. Setting the paper size and margins are two independent operations,
% i.e.\ setting the paper size does not directly affect the margins but will
% affect the following margin setting command.
% 
% \DescribeMacro{\setpapersize}
% The size of the paper can be set with 
% ^^A
% \begin{pckcmd}
% 	|\setpapersize{|\meta{size}|}|
% \end{pckcmd}
% ^^A
% \meta{size} can be A0, A1, ..., A9, B0, B1, ..., B9, C0, ..., C9, USletter,
% USlegal, and USexecutive. The metric paper sizes are not stored but
% calculated. |\setpapersize| by default sets the orientation to portrait.
% 
% Landscape format is selected by using the optional argument
% ^^A
% \begin{pckcmd}
% 	|\setpapersize[landscape]{|\meta{size}|}|
% \end{pckcmd}
% ^^A
% which swaps the width and height dimensions of the paper.
% \begin{pckcmd}
%       |\setpapersize[portrait]{|\meta{size}|}|
% \end{pckcmd}
% is allowed but is the default.
% 
% If you have a size which is not pre-defined use
% ^^A
% \begin{pckcmd}
% 	|\setpapersize{custom}{|\meta{width}|}{|\meta{height}|}|
% \end{pckcmd}
% ^^A
% For \meta{width} and \meta{height} insert the respective dimensions of your
% paper.
% 
% \DescribeMacro{\PaperWidth}
% \DescribeMacro{\PaperHeight}
% |\setpapersize| stores the actual dimensions of the paper in the length
% variables
% ^^A
% \begin{pckcmd}
% 	|\PaperWidth|   \\
% 	|\PaperHeight|
% \end{pckcmd}
% 
% \DescribeMacro{\ifLandscape}
% which can be used further, if desired.
% ^^A
% \begin{pckcmd}
% 	|\ifLandscape|
% \end{pckcmd}
% ^^A
% yields true if a landscape format is selected. Do not write to
% |\PaperWidth|, |\PaperHeight|, or call |\Landscapetrue| or |\Landscapefalse|,
% it will not work!!
%
% \package{vmargin} detects when it runs under pdflatex, and in that case also
% sets the pdf page size (variables |\pdfpagewidth| and |\pdfpageheight|).
% 
% Default for the paper size is A4 portrait.
% 
% 
% \subsection{Margins}
% 
% \DescribeMacro{\setmargins}
% Once the paper size is selected, margins can be set with
% \begin{pckcmd}
% 	|\setmargins{|\meta{leftmargin}|}{|\meta{topmargin}^^A
%               |}{|\meta{textwidth}|}{|\meta{textheight}|}%| \\
%       |   {|\meta{headheight}|}{|\meta{headsep}|}{|\meta{footheight}^^A
%               |}{|\meta{footskip}|}|
% \end{pckcmd}
% or with
% \begin{pckcmd}
% 	|\setmarginsrb{|\meta{leftmargin}|}{|\meta{topmargin}^^A
%               |}{|\meta{rightmargin}|}{|\meta{bottommargin}|}%|  \\
% 	|   {|\meta{headheight}|}{|\meta{headsep}^^A
%               |}{|\meta{footheight}|}{|\meta{footskip}|}|
% \end{pckcmd}
% \DescribeMacro{\setmarginsrb}
% In the latter case |\textwidth| and |\textheight| are calculated using the
% width and height of the selected paper such as to effectively result in
% \meta{rightmargin} and \meta{bottommargin}. The first four parameters of the
% above two commands are used to set |\oddsidemargin|, |\evensidemargin|,
% |\textwidth|, |\topmargin|, and |\textheight|.
%
% \DescribeMacro{\setmargnohf}
% \DescribeMacro{\setmargnohfrb}
% |\setmargnohf|, |\setmargnohfrb|
% provide a page with no header and footer. They work the same as
% |\setmargins|, |\setmarginsrb| except that they only need the first 4
% parameters. The last 4 parameters are set to 0pt. These 2 commands set
% the pagestyle to empty (|\pagestyle{empty}|) as there is no space for
% headers or footers.
% \begin{pckcmd}
% 	|\setmargnohf{|\meta{leftmargin}|}{|\meta{topmargin}^^A
%               |}{|\meta{textwidth}|}{|\meta{textheight}|}%|   \\
% 	|\setmargnohfrb{|\meta{leftmargin}|}{|\meta{topmargin}^^A
%               |}{|\meta{rightmargin}|}{|\meta{bottommargin}|}%|
% \end{pckcmd}
%
% \DescribeMacro{\setmarg}
% \DescribeMacro{\setmargrb}
% |\setmarg|, |\setmargrb|
% are the same as |\setmargnohf|, |\setmargnohfrb| except that
% \meta{headheight}, \meta{headsep}, \meta{footheight}, and \meta{footskip} are
% unchanged instead of being set to 0pt.
% \begin{pckcmd}
% 	|\setmarg{|\meta{leftmargin}|}{|\meta{topmargin}^^A
%               |}{|\meta{textwidth}|}{|\meta{textheight}|}%|   \\
% 	|\setmargrb{|\meta{leftmargin}|}{|\meta{topmargin}^^A
%               |}{|\meta{rightmargin}|}{|\meta{bottommargin}|}%|
% \end{pckcmd}
% 
% Example:
% 
% 	A4 paper, left margin 30mm, top, right, and bottom margin 20mm
% 	each, no headers or footers:
% \begin{pckcmd}
% 	|\setpapersize{A4}| \\
% 	|\setmarginsrb{30mm}{20mm}{20mm}{20mm}{0pt}{0mm}{0pt}{0mm}| \\
% 	|\pagestyle{empty}|
% \end{pckcmd}
% The same settings would result with:
% \begin{pckcmd}
% 	|\setpapersize{A4}| \\
% 	|\setmargnohfrb{30mm}{20mm}{20mm}{20mm}|
% \end{pckcmd}
%
% Defaults are 
% \begin{pckcmd}
%   |\setmarginsrb{35mm}{20mm}{25mm}{15mm}{12pt}{11mm}{0pt}{11mm}|
% \end{pckcmd}
% or with package option nohf
% \begin{pckcmd}
%   |\setmargnohfrb{35mm}{20mm}{25mm}{15mm}|
% \end{pckcmd}
% 
%
% \subsection{Dealing with \TeX's Margin Offset}
% 
% The default top and left margins of TeX are +1in. |\setmargXXX| call
% ^^A
% 	|\margin@offset|
% ^^A
% \DescribeMacro{\margin@offset}
% \DescribeMacro{\hoffset}
% \DescribeMacro{\voffset}
% which initialises |\hoffset|, |\voffset| to -1truein and |\oddsidemargin|,
% |\evensidemargin|, |\topmargin| to 0in. |\setmargXXX| then add the given
% dimensions to |\topmargin|, |\oddsidemargin|, |\evensidemargin|. In some
% cases it might be desired to use |\XXXmargin| instead of |\Xoffset| for
% compensation. This can be achieved by telling |\margin@offset| to
% initialise |\Xoffset| to 0in and |\XXXmargin| to -1truein.
% This is what
% %^^A
% 	|\shiftmargins|
% %^^A
% does.
%
% If |\margin@offset| is already defined at the time \package{vmargin} is loaded
% it is \emph{not} redefined! Therefore if |\margin@offset| is defined before
% \package{vmargin} is loaded the above mentioned compensation can be replaced
% by a different mechanism. In any case |\setmargXXX| call |\margin@offset| and
% then expect that |\XXXmargin| are set to useful values. |\Xoffset| are not
% touched by |\setmargXXX|. |\margin@offset| should be defined in a separate
% file which is included \emph{before} \package{vmargin}, i.e. appears in the
% list of document-substyles of the |\documentstyle| command before
% \package{vmargin}.
% %^^A
% Any better way of doing this? (grumble)
% 
% Example:
% \begin{pckcmd}
%       |\documentclass[...]{...}|  \\
% 	|\usepackage{...,margins,vmargin,...}|
% \end{pckcmd}
% if |\margin@offset| is defined in a file called margins.sty.
% 
% or with \LaTeX\ 2.09:
% \begin{pckcmd}
%       |\documentstyle[...,margins,vmargin,...]{...}|
% \end{pckcmd}
% 
% 
% \subsection{\LaTeXe}
% 
% This package now uses some of the new \LaTeX2e\ features for package
% programming. It will still work with \LaTeX\ 2.09 (in which case the new
% features are not used).
% 
% \LaTeX2e\ (unless in compatibility mode) does not know |\footheight| any
% more. \package{vmargin} does not set this variable if it does not exist, and sets
% it if it does. As |\footheight| was not used by \LaTeX\ 2.09 all this has
% little significance.
% 
% \LaTeXe\ now has the dimensions |\paperwidth|, |\paperheight| which
% hold the size of the paper. |\PaperWidth|, |\PaperHeight| are copied
% into |\paperwidth|, |\paperheight| if the latter exist. This makes
% \package{vmargin} work correctly with anything that expects |\paperwidth|,
% |\paperheight| to be set properly. The names |\PaperWidth|, |\PaperHeight|
% had been chosen in the first place to avoid clashes with style files that
% also use these names (namely \package{pageframe.sty}).
% 
% The following package options are available with \LaTeXe:
% 
% \begin{description}
% \item[shiftmargins]   \MargWord{shiftmargins}
%       Same as |\shiftmargins|.
% \item[portrait]       \MargWord{portrait}
%       Keep the default of a portrait page layout.
% \item[landscape]      \MargWord{landscape}
%       Change the default page orientation to landscape.
%       Note: using |\setpapersize|
% 	after |\usepackage| causes package option landscape to be ignored.
% \item[A4, etc]        \MargWord{A4}
%       Same as using |\setpapersize[...]{...}|.
% 	Note: |\setpapersize| always sets the orientation to
% 	portrait unless landscape is given as an optional argument to
%       |\setpapersize|.
% \item[nohf]           \MargWord{nohf}
%       Do not make space for header and footer lines; this also
% 	sets the pagestyle to |empty|.
% \end{description}
% 
% All unknown options are treated as a paper size, if necessary
% generating an error that the requested paper size is not defined.
% 
% 
% \subsection{Inclusion in \TeX\ formats}
% 
% This file may be loaded in initex before dumping the format, by typing
% \begin{verbatim}
% 	\makeatletter
% 	\input vmargin.sty
% 	\makeatother
% \end{verbatim}\vspace{-\bigskipamount}
% Be aware that this generates a non-standard format. It is really only useful
% for slow computers. This feature has not been tested with \LaTeXe.
% 
% 
% \subsection{Hints for using pageframe.sty}
% 
% \package{vmargin.sty} and \package{pageframe.sty} can be used together if the
% following points are considered:
% 
% \package{vmargin} uses |\hoffset| and |\voffset| and writes negative values
% into it, \package{pageframe} expects them to be zero to give a 1in space
% on the left and the top where it prints additional information. Initially,
% set both to 0mm (in the preamble of your text) and adjust them later on.
% 
% \package{pageframe} needs to know the trimmed height of the paper (= the
% height of the ``page frame''). Unless the trimmed(!) size of the paper is
% equivalent to one of the standard paper sizes (unlikely\ldots) the size
% should be specified with
% 
% 	|\setpapersize{custom}{|\meta{width}|}{|\meta{height}|}|
% 
% The correct height of the trimmed page can then be given to
% \package{pageframe} using
% 
% 	|\paperheight{\PaperHeight}|
% 
% and the margins of the final product (inside the page frame) can be
% specified using |\setmargXXX|.
% 
% Warning: if |\setmargXXXrb| is used the 3rd parameter (right margin) is
% ignored. Instead, the dimension of the right margin has to be assigned to
% |\evensidemargin|. This is because \package{pageframe} re-defines the meaning
% of |\evensidemargin| to be the right margin of your text, on all pages.
% 
% Remember: all these assignments and macro calls have to be in the
% preamble of the document.
% 
% 
% \subsection{Bugs and To Do}
% 
% I have not tested this with older versions of \LaTeXe\ because I don't
% have any. If there are any problems please let me know and I'll do
% something about it.
% 
% The way the metric paper sizes are stored takes up a lot of space.
% A metric size could be computed by |\setpapersize|.
% 
% If you have any comments (positive or negative) please let me know!
% 
% 
% \subsection{Summary}
% 
% \begin{verbatim}
% new lengths:
%   \PaperWidth     (read-only)
%   \PaperHeight    (read-only)
% 
% new ifs:
%   \ifLandscape    (read-only)
% 
% new macros:
%   \setpapersize[&lt;orientation&gt;]{&lt;size&gt;}, 
%   \setpapersize[&lt;orientation&gt;]{custom}{&lt;width&gt;}{&lt;height&gt;}
%       &lt;orientation&gt; (optional) = landscape or portrait (default)
%       &lt;size&gt; = A4, B5, ...
%       &lt;width&gt;, &lt;height&gt; = actual dimensions of the paper
%   \setmargins{leftmargin}{topmargin}{textwidth}{textheight}%
%           {headheight}{headsep}{footheight}{footskip}
%   \setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%
%           {headheight}{headsep}{footheight}{footskip}
%   \setmargnohf{leftmargin}{topmargin}{textwidth}{textheight}
%   \setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
%   \setmarg{leftmargin}{topmargin}{textwidth}{textheight}
%   \setmargrb{leftmargin}{topmargin}{rightmargin}{bottommargin}
%
%   \margin@offset
%   \shiftmargins
% 
% LaTeX2e package options:
%   shiftmargins
%   portrait
%   landscape
%   nohf
%   all other options are treated as paper sizes
% \end{verbatim}\vspace{-\bigskipamount}
%
%
% \DoNotIndex{\ ,\.,\_}%^^A  DOES NOT WORK!!
% \DoNotIndex{\@ifnextchar,\@ifundefined,\@nameuse,\CurrentOption}
% \DoNotIndex{\DeclareOption,\NeedsTeXFormat,\PackageError}
% \DoNotIndex{\ProcessOptions,\ProvidesPackage,\advance,\begingroup}
% \DoNotIndex{\catcode,\count,\csname,\def,\dimen,\edef,\else}
% \DoNotIndex{\endcsname,\endgroup,\endinput,\evensidemargin}
% \DoNotIndex{\everyjob,\expandafter,\fi,\footheight,\footskip}
% \DoNotIndex{\headheight,\headsep,\if,\ifnum,\let,\loop}
% \DoNotIndex{\newcommand,\newdimen,\newif,\noexpand,\oddsidemargin}
% \DoNotIndex{\pagestyle,\relax,\repeat,\space,\string,\textheight}
% \DoNotIndex{\textwidth,\the,\topmargin,\typeout,\usename,\xdef}
% \DoNotIndex{\z@}
%
% \StopEventually{}
%
%
%
% \section{Implementation}
%
%    \begin{macrocode}
%&lt;*package&gt;
%    \end{macrocode}
%
%
% We use macros for the version info here.
%
% ^^A       search tag:  mAcRoVeRsIoN
%    \begin{macrocode}
%\def\filename{Vmargin}
\def\filename{vmargin}
\def\fileversion{V2.5}
\def\filedate{2004/07/15}
%    \end{macrocode}
%
% Allow \package{vmargin} to be |input| more than once.
% Important for embedding in formats.
%    \begin{macrocode}
\@ifundefined{Vmargin}{}{\endinput}
%    \end{macrocode}
%
% Make use of \LaTeX2e\ commands, but only if we are actually running with it.
%    \begin{macrocode}
\@ifundefined{documentclass}{
  \edef\Vmargin{Style `\filename', \fileversion, \filedate}
  \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
  \typeout{\Vmargin}
}{
  \NeedsTeXFormat{LaTeX2e}[1994/06/01]
  \edef\Vmargin{\filedate\space\fileversion\space set document margins (VK)}
  \ProvidesPackage{\filename}[\Vmargin]
  \edef\Vmargin{Package: \filename\space\Vmargin}
  \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
  \typeout{\Vmargin}
}
%    \end{macrocode}
%
%
% \begin{macro}{\PaperWidth}
% \begin{macro}{\PaperHeight}
% \begin{macro}{\ifLandscape}
% New lengths for paper width and height, and a new if, as flag for using
% landscape orientation.
%
%    \begin{macrocode}
\newdimen\PaperWidth
\newdimen\PaperHeight
\newif\ifLandscape
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\setpapersize}
% Setting a paper size. Kind of a data base lookup. Well, it looks up whether
% the control sequence is defined\ldots
% 
% When running pdflatex we also set the pdf page size (|\pdfpagewidth| and
% |\pdfpageheight|).
%    \begin{macrocode}
\def\setpapersize{\@ifnextchar[{\@@setps}{\@@setps[portrait]}}
\def\@@setps[#1]{%
  \@ifundefined{po@#1}{\@name@err{#1}}{\@nameuse{po@#1}}%
  \@@@setps}
\def\@@@setps#1{%
  \@ifundefined{paper@#1}{\@name@err{#1}}{}%
  \csname paper@#1\endcsname}
        % \usename{paper@#1} inside arg to \@ifundefined does not work
        % with papersize "custom".
\def\po@portrait{\Landscapefalse}
\def\po@landscape{\Landscapetrue}
\def\@po@{\ifLandscape
  \dimen0\PaperWidth\PaperWidth\PaperHeight\PaperHeight\dimen0
  \fi
  \@ifundefined{paperwidth}{}{\paperwidth\PaperWidth}%
  \@ifundefined{paperheight}{}{\paperheight\PaperHeight}%
  \@ifundefined{pdfpagewidth}{}{\pdfpagewidth\PaperWidth}%
  \@ifundefined{pdfpageheight}{}{\pdfpageheight\PaperHeight}%
  }
\@ifundefined{PackageError}{
  \def\@name@err#1{%
    \typeout{*****&gt; \string\setpapersize: illegal parameter: #1}}
}{
 \def\@name@err#1{\PackageError{\filename}%
                    {Paper size or orientation unknown: #1}{}}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@defmetricpaper}
% Calculate smaller sizes from largest one.
%
%    \begin{macrocode}
\def\@defmetricpaper#1#2#3{%
  \begingroup
  \count0=0
  \def\w{\dimen1 }\def\h{\dimen2 }\def\s{\dimen3 }%
  \w#2\h#3
  \def\l{11}
  \loop
    \begingroup
    \def\t{\the\count0}
    \catcode`\t=11	% letter
    \expandafter\xdef\csname paper@#1\the\count0\endcsname{%
      \PaperWidth\the\w\PaperHeight\the\h\noexpand\@po@}
    \endgroup
    \s\w\w.5\h\h\s
  \ifnum\the\count0&lt;9
    \advance\count0 by 1
  \repeat
  \endgroup
}
%    \end{macrocode}
% \end{macro}
%
% Pre-defined paper/envelope sizes:
%
% A0, A1, A2, ..., A9, B0, B1, ..., B9, C0, C1, ..., C9
%    \begin{macrocode}
\@defmetricpaper{A}{840.9mm}{1189.2mm}
\@defmetricpaper{B}{1000mm}{1414mm}
\@defmetricpaper{C}{917mm}{1297mm}
%    \end{macrocode}
%
% delete definition to save memory
%    \begin{macrocode}
\let\@defmetricpaper=\relax
%    \end{macrocode}
%
% USletter, USlegal, USexecutive
%    \begin{macrocode}
\def\paper@USletter{\PaperWidth 8.5in \PaperHeight 11in \@po@}
\def\paper@USlegal{\PaperWidth 8.5in \PaperHeight 14in \@po@}
\def\paper@USexecutive{\PaperWidth 7.25in\PaperHeight 10.5in \@po@}
%    \end{macrocode}
%
% custom
%    \begin{macrocode}
\def\paper@custom#1#2{\PaperWidth#1\PaperHeight#2\@po@}
%    \end{macrocode}
%
%
% \begin{macro}{\margin@offset}
% Initialise left margins (odd and even) and |\hoffset|, |\voffset|.
% Compensates for the +1in/+1in top/left corner used by \TeX\
% by either reducing the margins or |\hoffset|, |\voffset| by 1truein.
% This macro is only defined here if it is not already defined! Define this
% macro before loading \package{vmargin} to use your own definition.
%
%    \begin{macrocode}
\@ifundefined{margin@offset}{%
\def\margin@offset{%
  \if@shiftmargins
    \oddsidemargin -1truein\evensidemargin\oddsidemargin\topmargin\oddsidemargin
    \hoffset\z@\voffset\z@
  \else
    \oddsidemargin\z@\evensidemargin\z@\topmargin\z@
    \hoffset -1truein\voffset\hoffset
  \fi
}}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\shiftmargins}
% A new if, as flag for when to use margins instead of |\hoffset|/|\voffset| to
% compensate, and a user-command to set the flag.
%    \begin{macrocode}
\newif\if@shiftmargins
\@shiftmarginsfalse	% this MUST be default (pageframe.sty)
\def\shiftmargins{\@shiftmarginstrue}
%    \end{macrocode}
% \end{macro}
%
%
% Setting margins
%
% \begin{macro}{\setmargins}
% |\setmargins{leftmargin}{topmargin}{textwidth}{textheight}% |\\
% |   {headheight}{headsep}{footheight}{footskip}|
%
%    \begin{macrocode}
\newcommand\setmargins[8]{%
	\margin@offset
	\advance\oddsidemargin	#1
	\advance\evensidemargin	\PaperWidth	% = paperwidth - left - width
	\advance\evensidemargin	-#1
	\advance\evensidemargin	-#3
	\advance\topmargin	#2
	\textwidth	#3
	\textheight	#4
	\headheight	#5
	\headsep	#6
	\@ifundefined{footheight}{}{\footheight=#7}%
	\footskip	#8
	\chk@dimen{#1}{#2}{#3}{#4}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmarginsrb}
% |\setmarginsrb{leftmargin}{topmargin}{rightmargin}{bottommargin}%|\\
% |   {headheight}{headsep}{footheight}{footskip}|
%
%    \begin{macrocode}
\newcommand\setmarginsrb[8]{%
	\margin@offset
	\textwidth		\PaperWidth	% = paperwidth
	\advance\textwidth	-#1		%  - left - right
	\advance\textwidth	-#3
	\textheight		\PaperHeight	% = paperheight - top
	\advance\textheight	-#2		%  - headheight
	\advance\textheight	-#5		%  - headsep
	\advance\textheight	-#6		%  - footskip - bottom
	\advance\textheight	-#8
	\advance\textheight	-#4
	\advance\oddsidemargin	#1
	\advance\evensidemargin	\PaperWidth	% = paperwidth - left - width
	\advance\evensidemargin	-#1
	\advance\evensidemargin	-\textwidth
	\advance\topmargin	#2
	\headheight	#5
	\headsep	#6
	\@ifundefined{footheight}{}{\footheight=#7}%
	\footskip	#8
	\chk@dimen{#1}{#2}{#3}{#4}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmargnohf}
% |\setmargnohf{leftmargin}{topmargin}{textwidth}{textheight}|	\\
% headheight, headsep, footheight, footskip set to 0pt
%    \begin{macrocode}
\newcommand\setmargnohf[4]{%
	\setmargins{#1}{#2}{#3}{#4}\z@\z@\z@\z@
	\pagestyle{empty}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmargnohfrb}
% |\setmargnohfrb{leftmargin}{topmargin}{rightmargin}{bottommargin}|	\\
% headheight, headsep, footheight, footskip set to 0pt
%    \begin{macrocode}
\newcommand\setmargnohfrb[4]{%
	\setmarginsrb{#1}{#2}{#3}{#4}\z@\z@\z@\z@
	\pagestyle{empty}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmarg}
% |\setmarg{leftmargin}{topmargin}{textwidth}{textheight}|	\\
% headheight, headsep, footheight, footskip unchanged
%    \begin{macrocode}
\newcommand\setmarg[4]{%
	\setmargins{#1}{#2}{#3}{#4}%
            \headheight\headsep\footheight\footskip}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setmargrb}
% |\setmargrb{leftmargin}{topmargin}{rightmargin}{bottommargin}|	\\
% headheight, headsep, footheight, footskip unchanged
%    \begin{macrocode}
\newcommand\setmargrb[4]{%
	\setmarginsrb{#1}{#2}{#3}{#4}%
            \headheight\headsep\footheight\footskip}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\chk@dimen}
% A brief plausability check.\\
% h-warning:\\
%   \null\quad if [leftmarg + textwidth $&gt;$ paperwidth] resp.\\
%   \null\quad if [leftmarg + rightmarg $&gt;$ paperwidth].\\
% v-warning:\\
%   \null\quad if [topmarg + textheight $&gt;$ paperheight] resp.\\
%   \null\quad if [topmarg + bottommarg $&gt;$ paperheight].
%    \begin{macrocode}
\def\chk@dimen#1#2#3#4{%
	\dimen0=	#1
	\advance\dimen0 by#3
	\advance\dimen0 -\PaperWidth
	\dimen1=	#2
	\advance\dimen1 by#4
	\advance\dimen1 \headheight
	\advance\dimen1 \headsep
	\advance\dimen1 \footskip
	\advance\dimen1 -\PaperHeight
	\chk@dimen@err
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\chk@dimen@err}
% Make this work with both \LaTeX\ 2.09 and \LaTeXe.
%    \begin{macrocode}
\@ifundefined{PackageError}{
  \def\chk@dimen@err{%
    \ifnum\dimen0&gt;\z@\typeout{vmargin Warning: Horizontal dimensions
      exceed paper width by \the\dimen0}\fi
    \ifnum\dimen1&gt;\z@\typeout{vmargin Warning: Vertical dimensions
      exceed paper height by \the\dimen1}\fi
  }
}{
  \def\chk@dimen@err{%
    \ifnum\dimen0&gt;\z@\PackageError{\filename}{%
      Horizontal dimensions exceed paper width by \the\dimen0}{}\fi
    \ifnum\dimen1&gt;\z@\PackageError{\filename}{%
      Vertical dimensions exceed paper height by \the\dimen1}{}\fi
  }
}
%    \end{macrocode}
% \end{macro}
%
%
% Defaults, and \LaTeXe\ package options (ignored for 2.09).
%    \begin{macrocode}
\setpapersize{A4}
\def\@hf@dflt{}
\@ifundefined{DeclareOption}{
}{
  \DeclareOption{shiftmargins}{\shiftmargins}
  \DeclareOption{portrait}{\Landscapefalse}
  \DeclareOption{landscape}{\Landscapetrue}
  \DeclareOption{nohf}{\def\@hf@dflt{y}}
  \DeclareOption*{\@@@setps{\CurrentOption}}
  \ProcessOptions\relax  % process options in order of declaration!
}
\if y\@hf@dflt
  \setmargnohfrb{35mm}{20mm}{25mm}{15mm}%
\else
  \setmarginsrb{35mm}{20mm}{25mm}{15mm}{12pt}{11mm}{0pt}{11mm}%
\fi
%    \end{macrocode}
%
%
%    \begin{macrocode}
%&lt;/package&gt;
%    \end{macrocode}
%
%
% \Finale
%
% \iffalse
% %% EOF vmargin.dtx
% %%----------------------------------------------------------------------------
% \fi
</pre></body></html>