%%
%% This is file `twoup.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% twoup.dtx  (with options: `package')
%% 
%%  m This is the twoup package
%%  o Copyright 2005-07 by Mogens Lemvig Hansen,
%%  g Please find my e-mail address in the left margin
%%  e
%%  n Run twoup.dtx through LaTeX and read the documentation in twoup.dvi
%%  s
%%  @ This work may be distributed and/or modified under the
%%  k conditions of the LaTeX Project Public License, either version 1.3
%%  a of this license or (at your option) any later version.
%%  y The latest version of this license is in
%%  j   http://www.latex-project.org/lppl.txt
%%  u and version 1.3 or later is part of all distributions of LaTeX
%%  . version 2005/12/01 or later.
%%  c
%%  o This work has the LPPL maintenance status 'maintained'.
%%  m
%%    The Current Maintainer of this work is Mogens Lemvig Hansen.
%% 
%%    This work consists of the files twoup.dtx and twoup.ins
%%    and the derived file twoup.sty.
%% 
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{twoup}[2007/02/26 version 1.3]
\DeclareOption{noheadfoot}{%
   \setlength{\headheight}{0pt}%
   \setlength{\headsep}{0pt}%
   \setlength{\footskip}{0pt}%
   \let\ps@plain\ps@empty
   \pagestyle{empty}}
\DeclareOption{nofoot}{%
   \setlength{\footskip}{0pt}%
   \let\ps@plain\ps@empty
   \pagestyle{headings}}
\DeclareOption{nohead}{%
   \setlength{\headheight}{0pt}%
   \setlength{\headsep}{0pt}%
   \pagestyle{plain}}
\DeclareOption{letterpaper}{%
   \def\TwoUp@info{-pletter -W5.5in -H8.5in}%
   \def\TwoUp@paper{letter}}%
\DeclareOption{legalpaper}{%
   \def\TwoUp@info{-plegal -W7in -H8.5in}%
   \def\TwoUp@paper{legal}}%
\DeclareOption{executivepaper}{%
   \def\TwoUp@info{-pexecutive -W5.25in -H7.25in}%
   \def\TwoUp@paper{executive}}%
\DeclareOption{a4paper}{%
   \def\TwoUp@info{-pa4 -Pa5}%
   \def\TwoUp@paper{a4}}%
\DeclareOption{a5paper}{%
   \def\TwoUp@info{-pa5 -W105mm -H148mm}%
   \def\TwoUp@paper{a5}}%
\DeclareOption{b5paper}{%
   \def\TwoUp@info{-pb5 -W125mm -H176mm}%
   \def\TwoUp@paper{b5}}%
\DeclareOption{dvips}{%
   \def\TwoUp@special{%
      \special{papersize=\the\paperwidth,\the\paperheight}}}
\DeclareOption{nospecial}{%
   \def\TwoUp@special{\relax}}
\ExecuteOptions{dvips}
\ProcessOptions
\ifx\TwoUp@info\undefined
   \setlength{\@tempdima}{8.5in}
   \ifdim\paperwidth=\@tempdima
      \setlength{\@tempdima}{11in}
      \ifdim\paperheight=\@tempdima
         \def\TwoUp@info{-pletter -W5.5in -H8.5in}
      \fi
      \setlength{\@tempdima}{14in}
      \ifdim\paperheight=\@tempdima
         \def\TwoUp@info{-plegal -W7in -H8.5in}
      \fi
   \fi
   \setlength{\@tempdima}{210mm}
   \ifdim\paperwidth=\@tempdima
      \setlength{\@tempdima}{297mm}
      \ifdim\paperheight=\@tempdima
         \def\TwoUp@info{-pa4 -Pa5}
      \fi
   \fi
\fi
\ifx\TwoUp@info\undefined
   \PackageWarningNoLine{twoup}{Unknown paper size.
      You may want to use a \MessageBreak
      paper size option like letterpaper}
   \setlength{\@tempdima}{0.99627\paperwidth}
   \@settopoint\@tempdima
   \edef\TwoUp@info{-w\the\@tempdima}
   \setlength{\@tempdima}{0.99627\paperheight}
   \@settopoint\@tempdima
   \edef\TwoUp@info{\TwoUp@info\space -h\the\@tempdima}
   \setlength{\@tempdima}{0.5\paperheight}
   \setlength{\@tempdima}{0.99627\@tempdima}
   \@settopoint\@tempdima
   \edef\TwoUp@info{\TwoUp@info\space -W\the\@tempdima}
   \setlength{\@tempdima}{0.99627\paperwidth}
   \@settopoint\@tempdima
   \edef\TwoUp@info{\TwoUp@info\space -H\the\@tempdima}
\fi
\setlength{\@tempdima}{\paperwidth}
\setlength{\paperwidth}{0.5\paperheight}
\setlength{\paperheight}{\@tempdima}
\@ifpackageloaded{2up}{%
   \source{\magstep0}{\paperwidth}{\paperheight}%
   \target{\magstep0}{2\paperwidth}{\paperheight}%
}{%
\@ifpackageloaded{booklet}{%
   \source{\magstep0}{\paperwidth}{\paperheight}%
   \target{\magstep0}{2\paperwidth}{\paperheight}%
}{%
   \TwoUp@special
   \AtEndDocument{\typeout{^^J%
      Package twoup Info: Use psnup with these options:^^J%
      psnup \TwoUp@info\space -2 \jobname.ps twoup.ps^^J}}
   \ifx\TwoUp@paper\undefined\else
      \AtEndDocument{\typeout{^^J%
         Package twoup Info: You may have to add these
         three lines to your .ps file:^^J%
         \@percentchar\@percentchar BeginPaperSize: \TwoUp@paper^^J%
         \TwoUp@paper^^J%
         \@percentchar\@percentchar EndPaperSize^^J}}
   \fi%
}}%
\setlength{\@tempdima}{1in}
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-\@tempdima}
\if@twoside
   \setlength{\evensidemargin}{0.33\@tempdima}
   \setlength{\oddsidemargin}{\@tempdima}
   \addtolength{\oddsidemargin}{-\evensidemargin}
\else
   \setlength{\oddsidemargin}{0.5\@tempdima}
   \setlength{\evensidemargin}{\oddsidemargin}
\fi
\addtolength{\oddsidemargin}{-1in}
\addtolength{\evensidemargin}{-1in}
\setlength{\topmargin}{0.5in}
\setlength{\textheight}{\paperheight}
\addtolength{\textheight}{-2\topmargin}
\addtolength{\textheight}{-\headheight}
\addtolength{\textheight}{-\headsep}
\addtolength{\textheight}{-\footskip}
\addtolength{\textheight}{-\topskip}
\divide\textheight\baselineskip
\@tempcnta\textheight
\setlength{\textheight}{\@tempcnta\baselineskip}
\addtolength{\textheight}{\topskip}
\addtolength{\topmargin}{-1in}
\newcommand{\cleartolastpage}{%
   \clearpage
   \@ifstar
      {\def\TwoUp@blankpagestyle{\thispagestyle{empty}}\cleartolastp@ge}
      {\let\TwoUp@blankpagestyle\relax\cleartolastp@ge}}
\if@twoside
   \newcommand{\cleartolastp@ge}[1][4]{%
      \@tempcnta#1\relax
      \cleartol@stp@ge}%
\else
   \newcommand{\cleartolastp@ge}[1][2]{%
      \@tempcnta#1\relax
      \cleartol@stp@ge}%
\fi
\newcommand{\cleartol@stp@ge}[1][0]{%
   \@tempcntb\c@page
   \divide\@tempcntb\@tempcnta
   \multiply\@tempcntb\@tempcnta
   \advance\@tempcntb#1\relax
   \ifnum\@tempcntb<\c@page
      \advance\@tempcntb\@tempcnta
   \fi
   \loop\ifnum\c@page<\@tempcntb
      \hbox{}\TwoUp@blankpagestyle\newpage
   \repeat
}
\endinput
%%
%% End of file `twoup.sty'.
