%%
%% This is file `vmargin.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% vmargin.dtx  (with options: `package')
%% 
%% File: vmargin.dtx Copyright (C) 1993, 1994, 1995, 1996, 1999, 2000
%%       by Volker Kuhlmann   <v.kuhlmann@elec.canterbury.ac.nz>
%% All rights are reserved.
%%
%%
%% \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     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
\def\filename{vmargin}
\def\fileversion{V2.3}
\def\filedate{2000/08/01}
\@ifundefined{Vmargin}{}{\endinput}
\@ifundefined{documentclass}{
  \edef\Vmargin{Style `\filename', \fileversion, \filedate}
  \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
  \typeout{\Vmargin}
}{
  \NeedsTeXFormat{LaTeX2e}[1994/06/01]
  \ProvidesPackage{\filename}[\filedate]
  \edef\Vmargin{Package: \filename\space\filedate\space\fileversion\space
                    (VK) set document margins}
  \expandafter\everyjob\expandafter{\the\everyjob\typeout{\Vmargin}}
  \typeout{\Vmargin}
}
\newdimen\PaperWidth
\newdimen\PaperHeight
\newif\ifLandscape
\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{*****> \string\setpapersize: illegal parameter: #1}}
}{
 \def\@name@err#1{\PackageError{\filename}%
                    {Paper size or orientation unknown: #1}{}}
}
\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<9
    \advance\count0 by 1
  \repeat
  \endgroup
}
\@defmetricpaper{A}{840.9mm}{1189.2mm}
\@defmetricpaper{B}{1000mm}{1414mm}
\@defmetricpaper{C}{917mm}{1297mm}
\let\@defmetricpaper=\relax
\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@}
\def\paper@custom#1#2{\PaperWidth#1\PaperHeight#2\@po@}
\@ifundefined{margin@offset}{%
\def\margin@offset{%
  \if@shiftmargins
    \oddsidemargin -1in\evensidemargin\oddsidemargin\topmargin\oddsidemargin
    \hoffset\z@\voffset\z@
  \else
    \oddsidemargin\z@\evensidemargin\z@\topmargin\z@
    \hoffset -1in\voffset\hoffset
  \fi
}}{}
\newif\if@shiftmargins
\@shiftmarginsfalse % this MUST be default (pageframe.sty)
\def\shiftmargins{\@shiftmarginstrue}
\newcommand\setmargins[8]{%
\margin@offset
\advance\oddsidemargin #1
\advance\evensidemargin \PaperWidth % = paperwidth - left
\advance\evensidemargin -#1 % - width
\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}%
}
\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
\advance\evensidemargin -#1 %  - left - width
\advance\evensidemargin -\textwidth
\advance\topmargin #2
\headheight #5
\headsep #6
\@ifundefined{footheight}{}{\footheight=#7}%
\footskip #8
\chk@dimen{#1}{#2}{#3}{#4}%
}
\newcommand\setmargnohf[4]{%
\setmargins{#1}{#2}{#3}{#4}\z@\z@\z@\z@
\pagestyle{empty}}
\newcommand\setmargnohfrb[4]{%
\setmarginsrb{#1}{#2}{#3}{#4}\z@\z@\z@\z@
\pagestyle{empty}}
\newcommand\setmarg[4]{%
\setmargins{#1}{#2}{#3}{#4}%
            \headheight\headsep\footheight\footskip}
\newcommand\setmargrb[4]{%
\setmarginsrb{#1}{#2}{#3}{#4}%
            \headheight\headsep\footheight\footskip}
\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
}
\@ifundefined{PackageError}{
  \def\chk@dimen@err{%
    \ifnum\dimen0>\z@\typeout{vmargin Warning: Horizontal dimensions
      exceed paper width by \the\dimen0}\fi
    \ifnum\dimen1>\z@\typeout{vmargin Warning: Vertical dimensions
      exceed paper height by \the\dimen1}\fi
  }
}{
  \def\chk@dimen@err{%
    \ifnum\dimen0>\z@\PackageError{\filename}{%
      Horizontal dimensions exceed paper width by \the\dimen0}{}\fi
    \ifnum\dimen1>\z@\PackageError{\filename}{%
      Vertical dimensions exceed paper height by \the\dimen1}{}\fi
  }
}
\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
\endinput
%%
%% End of file `vmargin.sty'.
