%%
%% This is file `parallel.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% parallel.dtx  (with options: `package')
%% 
%% This file is part of the 'parallel'-package
%% 
%% Copyright (c) 1994-2003 Matthias Eckermann
%% 
%% This program may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%% This program consists of the files parallel.dtx, parallel.ins, readme
%% 
 %%
 %% $Id: parallel.dtx,v 1.11 2003/04/13 16:54:40 mge Exp $
 %%
 %% $Log: parallel.dtx,v $
 %% Revision 1.11  2003/04/13 16:54:40  mge
 %% cleanups
 %%
 %% Revision 1.10  2003/04/13 16:52:04  mge
 %% Beta 4 fixed (not tagging:-)
 %%
 %% Revision 1.9  2003/04/13 16:47:07  mge
 %% correct checksum
 %%
 %% Revision 1.8  2003/04/13 16:46:14  mge
 %% cvs cleanups
 %%
 %% Revision 1.7  2003/04/13 16:36:22  mge
 %% changed \fileversion
 %%
 %% Revision 1.6  2003/04/13 16:27:30  mge
 %% added readme
 %%
 %% Revision 1.5  2003/04/13 16:17:18  mge
 %% added minor changes (fmi)
 %% License->LPPL       (mge)
 %%
 %% Revision 1.4  2003/04/13 15:51:44  mge
 %% minor changes (cosmetic)
 %%
 %% Revision 1.3  2000/04/01 08:44:40  mge
 %% updated \fileversion \filedate
 %%
 %% Revision 1.2  2000/04/01 08:42:39  mge
 %% initial checkin
 %%
 %% author(s)         :   Matthias Eckermann (mge), Berlin, Germany
 %%   - debugging     :   Bernd Raichle (br), Stuttgart, Germany
 %%   - contributions :   Wonkoo Kim (wk), Pittsburgh, PA, USA
 %%                       Frank Mittelbach (fmi) , Mainz, Germany
 %% history           :   2003-04-13   Minor corrections          (fmi)
 %%                                    License->LPPL              (mge)
 %%                       10.11.1997   (2.0 interim-public-beta)  (mge)
 %%                       28.02.1997   (option 'verbose')
 %%                       01.10.1996   (better spacing)           (br)
 %%                       29.09.1996   (smarter column support)   (wk)
 %%                         Sep.1996   (on pages, VLine, '.dtx')  (mge)
 %%                       26.03.1995   (works within {list}s)     (mge)
 %%                       15.02.1995   (first public release)     (mge)
 %%                       19.10.1994   (initial tests)            (mge)
 %% email             :   mge@arcor.de (private), mge@suse.de (job)
 %% description       :   provides a small tool to typeset in two columns
 %%                       or on two pages parallel, e.g. if you want to set
 %%                       two languages besides.
 %% thanks            :   R.Braun, H.Kopka, J.Schrod
 %%
\def\fileversion{beta 4}
\def\filedate{2003/04/13}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{parallel}[\filedate, setting two texts parallel (me)]
\message{`parallel': setting two texts parallel, (\fileversion) \filedate.}
\newdimen\ParallelLWidth
\newdimen\ParallelRWidth
\newdimen\ParallelTextWidth
\newdimen\ParallelLeftMargin
\newdimen\ParallelUserMidSkip
\newdimen\ParallelMainMidSkip
\newbox\ParallelLBox
\newbox\ParallelRBox
\newbox\ParallelBoxVar
\newbox\ParallelLTok
\newbox\ParallelRTok
\newcount\ParallelBoolVar
\newcount\ParallelBoolMid
\newcount\ParallelWhichBox
\newcount\ParallelMainMode
\newcount\ParallelFNMode
\newcount\ParallelLFNCounter
\newcount\ParallelRFNCounter
\newcount\ParallelMaxFN
\newcount\ParallelFNNumMode
\newcommand{\ParallelMessage}[1]{\relax}
\DeclareOption{Verbose}{%
  \renewcommand{\ParallelMessage}[1]{\message{#1}}
  \message{Verbose}
}
\DeclareOption{OldStyleNums}{%
  \ParallelFNNumMode=1\ParallelMessage{OldStyleNums}}
\DeclareOption{RaiseNums}{%
  \ParallelFNNumMode=2\ParallelMessage{RaiseNums}}
\DeclareOption{ItalicNums}{%
  \ParallelFNNumMode=3\ParallelMessage{ItalicNums}}
\DeclareOption{RomanNums}{%
  \ParallelFNNumMode=4\ParallelMessage{RomanNums}}
\DeclareOption{SeparatedFootnotes}{%
  \ParallelFNMode=1\ParallelMessage{SeparatedFootnotes}}
\newcommand{\ParallelLFootnote}[1]{%
  \global\advance\ParallelLFNCounter\@ne
  \footnotemark[\number\ParallelLFNCounter]%
  \expandafter\gdef%
    \csname ParallelLFN\romannumeral\ParallelLFNCounter\endcsname{#1}}
\newcommand{\ParallelRFootnote}[1]{%
  \global\advance\ParallelRFNCounter\@ne
  \footnotemark[\number\ParallelRFNCounter]%
  \expandafter\gdef%
    \csname ParallelRFN\romannumeral\ParallelRFNCounter\endcsname{#1}}
\newenvironment{ParallelFNEnviron}{%
  \footnotesize
  \begin{list}{}{%
    \leftmargin=4em \rightmargin=\z@
    \topsep=\z@skip \itemsep=\z@skip
    \labelwidth=3em \labelsep=1em%
    \renewcommand{\makelabel}[1]{{\hfill\footnotesize ##1}}%
    }%
}{%
  \end{list}%
}
\newcommand{\ParallelShowFNList}{%
  % footnotes in left or right column, i.e. left+right>0?
  \ParallelMaxFN=\ParallelLFNCounter
  \advance\ParallelMaxFN \ParallelRFNCounter
  \ifnum\ParallelMaxFN>\z@
    \ParallelMessage{Parallel Footnotes (}%
    \begin{ParallelFNEnviron}%
      \ParallelMaxFN=\ParallelLFNCounter
      \global\ParallelLFNCounter=\z@
      \loop
        \ifnum\ParallelLFNCounter<\ParallelMaxFN
          \global\advance\ParallelLFNCounter \@ne
          \item[\ifcase\ParallelFNNumMode \number\ParallelLFNCounter%
                \or \oldstylenums{\the\ParallelLFNCounter}%
                \or \raisebox{1ex}{\the\ParallelLFNCounter}%
                \or \textit{\number\ParallelLFNCounter}%
                \or \romannumeral\ParallelLFNCounter%
                \else  \number\ParallelLFNCounter \fi]%
            \par
            {\csname ParallelLFN\romannumeral\ParallelLFNCounter\endcsname}%
            \par
      \repeat
    \end{ParallelFNEnviron}%
    \ifnum\ParallelFNMode=\@ne
      \begin{ParallelFNEnviron}%
        \ParallelMaxFN=\ParallelRFNCounter
        \global\ParallelRFNCounter=\z@
        \loop
          \ifnum\ParallelRFNCounter<\ParallelMaxFN
            \global\advance\ParallelRFNCounter \@ne
            \item[\ifcase\ParallelFNNumMode
                     \number\ParallelRFNCounter\ParallelDot
                  \or \oldstylenums{\the\ParallelRFNCounter}\ParallelDot
                  \or \raisebox{1ex}{\the\ParallelRFNCounter\ParallelDot}%
                  \or \textit{\number\ParallelRFNCounter\ParallelDot}%
                  \or \romannumeral\ParallelLFNCounter%
                  \else \number\ParallelRFNCounter\ParallelDot \fi]%
              \par
              {\csname ParallelRFN\romannumeral\ParallelRFNCounter\endcsname}%
              \par
        \repeat
      \end{ParallelFNEnviron}%
    \fi
    \global\ParallelLFNCounter=\z@
    \global\ParallelRFNCounter=\z@
    \ParallelMessage{)}%
  \else
    \ParallelMessage{No Parallel Footnotes}%
  \fi
}
\newcommand{\ParallelParOnePage}{%
  \ifnum\ParallelBoolVar=\@ne
    \par\begingroup
    \leftmargin=\z@ \rightmargin=\z@
    \parskip=\z@skip \parindent=\z@
    \vbadness=10000
    \vfuzz=3ex
    \splittopskip=\z@skip
    \loop%
      \ifnum\ParallelBoolVar=\@ne%
        \noindent
        \hbox to\textwidth{%
          \hskip\ParallelLeftMargin
          \hbox to\ParallelTextWidth{%
            \ifvoid\ParallelLBox
              \hskip\ParallelLWidth
            \else
              \ParallelWhichBox=\z@
              \vbox{\setbox\ParallelBoxVar
                    =\vsplit\ParallelLBox to\dp\strutbox%
                    \unvbox\ParallelBoxVar}%
            \fi
            \strut
            \ifnum\ParallelBoolMid=\@ne
              \hskip\ParallelMainMidSkip
              \vrule
            \else
              \hss
            \fi
            \hss
            \ifvoid\ParallelRBox
              \hskip\ParallelRWidth
            \else
              \ParallelWhichBox=\@ne
              \vbox{\setbox\ParallelBoxVar
                    =\vsplit\ParallelRBox to\dp\strutbox%
                    \unvbox\ParallelBoxVar}%
            \fi}}%
        \ifvoid\ParallelLBox \ifvoid\ParallelRBox
          \global\ParallelBoolVar=\z@
        \fi\fi%
      \fi%
      \ifnum\ParallelBoolVar=\@ne%
         \penalty\interlinepenalty
    \repeat
    \par
    \endgroup
  \fi}
\newcommand{\ParallelParTwoPages}{%
  \ifnum\ParallelBoolVar=\@ne
    \par\begingroup
    \global\ParallelWhichBox=\@ne
    \newpage
    \vbadness=10000
    \vfuzz=3ex
    \splittopskip=\z@skip
    \loop%
      \ifnum\ParallelBoolVar=\@ne%
        \ifnum\ParallelWhichBox=\@ne
          \ifvoid\ParallelLBox \mbox{} \newpage
          \else\global\ParallelWhichBox=\z@\fi
        \else
          \ifvoid\ParallelRBox \mbox{} \newpage
          \else\global\ParallelWhichBox=\@ne\fi
        \fi
        \ifnum\ParallelWhichBox=\z@
          \ifodd\thepage \mbox{} \newpage \fi
          \hbox to\textwidth{%
            \vbox{\vsplit\ParallelLBox to.98\textheight}}%
        \else
          \ifodd\thepage\relax\else \mbox{} \newpage \fi
          \hbox to\textwidth{%
            \vbox{\vsplit\ParallelRBox to.98\textheight}}%
        \fi
        \vspace*{\fill}\newpage
      \fi
      \ifvoid\ParallelLBox\ifvoid\ParallelRBox
        \global\ParallelBoolVar=\z@
      \fi\fi
      \ifnum\ParallelBoolVar=\@ne
    \repeat
    \par
    \endgroup
  \fi}
\newcommand{\ParallelAfterText}{%
  \global\ParallelBoolVar=\@ne
  \let\footnote=\ParallelOldFootnote\endgroup}
\newcommand{\ParallelCheckOpenBrace}{%
  \ifx\x\bgroup \else
    \errmessage{Missing opening brace}%
  \fi
  \endgroup}
\newcommand{\ParallelLText}{%
  \everypar{}\@restorepar\begingroup
  \hbadness=3000
  \let\footnote=\ParallelLFootnote
  \ParallelWhichBox=0
  \global\setbox\ParallelLBox=\vbox\bgroup \hsize=\ParallelLWidth
  \aftergroup\ParallelAfterText
  \begingroup \afterassignment\ParallelCheckOpenBrace \let\x=}
\newcommand{\ParallelRText}{%
  \everypar{}\@restorepar\begingroup
  \hbadness=3000
  \ifnum\ParallelFNMode=\@ne
    \let\footnote=\ParallelRFootnote
  \else
    \let\footnote=\ParallelLFootnote
  \fi
  \ParallelWhichBox=\@ne
  \global\setbox\ParallelRBox=\vbox\bgroup \hsize=\ParallelRWidth
  \aftergroup\ParallelAfterText
  \begingroup \afterassignment\ParallelCheckOpenBrace \let\x=}
\newcommand{\ParallelAtEnd}{}
\newcommand{\ParallelPar}{}  % Dummy
\newcommand{\ParallelDot}{\ensuremath{\cdot}}
\newenvironment{Parallel}[3][c]{%
  \begingroup%
    \ParallelTextWidth=\linewidth
    \ParallelLeftMargin=\textwidth
    \advance\ParallelLeftMargin by-\linewidth
    \if #1p\relax
      \ParallelMessage{ on Pages (}%
      \ParallelMainMode=\z@
      \renewcommand{\ParallelPar}{\ParallelParTwoPages}
    \else
      \if #1a\relax
        \ParallelMessage{ autocomputed Pages (}%
        \ParallelMainMode=\tw@
        \renewcommand{\ParallelPar}{\ParallelParTwoPages}
      \else
        \tolerance=600         % sorry, but neccessary
        \emergencystretch=.5em % dto.
        \ParallelMainMode=\@ne
        \renewcommand{\ParallelPar}{\ParallelParOnePage}
        \if #1v\relax
          \ParallelBoolMid=\@ne
          \ParallelMessage{ in Columns, with VLine (}%
        \else
          \if #1c\relax\else
            \errhelp{possible options:
            'p'age, 'c'olumn or columns with 'v'line ---
            type <return> to proceed in column-mode}
            \errmessage{bad option '#1' to environment 'Parallel'}
          \fi
          \ParallelMessage{ in Columns (}%
    \fi\fi\fi
    \def\ParallelArgL{#2} \def\ParallelArgR{#3}
    \ifx\ParallelArgL\empty\ParallelLWidth=0in\else\ifx\ParallelArgL\space
        \ParallelLWidth=0in\else\setlength\ParallelLWidth{#2}\fi\fi
    \ifx\ParallelArgR\empty\ParallelRWidth=0in\else\ifx\ParallelArgR\space
        \ParallelRWidth=0in\else\setlength\ParallelRWidth{#3}\fi\fi
    \ifnum\ParallelMainMode=\@ne
      \ifdim\ParallelLWidth>1em
        \ifdim\ParallelRWidth>1em
          \ParallelMainMidSkip=\linewidth
          \advance\ParallelMainMidSkip by-\ParallelLWidth
          \advance\ParallelMainMidSkip by-\ParallelRWidth
          \advance\ParallelMainMidSkip by-.5pt
          \advance\ParallelMainMidSkip by-\ParallelLeftMargin
          \divide\ParallelMainMidSkip by 2
        \else
          \ParallelRWidth=\linewidth
          \advance\ParallelRWidth by-\ParallelLWidth
          \advance\ParallelRWidth by-2\ParallelUserMidSkip
          \advance\ParallelRWidth by-\ParallelLeftMargin
          \ParallelMainMidSkip=\ParallelUserMidSkip
        \fi
      \else
        \ifdim\ParallelRWidth>1em
          \ParallelLWidth=\linewidth
          \advance\ParallelLWidth by-\ParallelRWidth
          \advance\ParallelLWidth by-2\ParallelUserMidSkip
          \advance\ParallelLWidth by-\ParallelLeftMargin
          \ParallelMainMidSkip=\ParallelUserMidSkip
        \else
          \ParallelLWidth=.5\linewidth
          \advance\ParallelLWidth by-\ParallelLeftMargin
          \advance\ParallelLWidth by-\ParallelUserMidSkip
          \ParallelRWidth=\ParallelLWidth
          \ParallelMainMidSkip=\ParallelUserMidSkip
        \fi
      \fi
    \else
      \ifdim\ParallelLWidth>1em
        \ifdim\ParallelRWidth>1em
        \else
          \ParallelRWidth=\linewidth
          \advance\ParallelRWidth by-\ParallelLeftMargin
        \fi
      \else
        \ifdim\ParallelRWidth>1em
          \ParallelLWidth=\linewidth
          \advance\ParallelLWidth by-\ParallelLeftMargin
        \else
          \ParallelLWidth=\linewidth
          \advance\ParallelLWidth by-\ParallelLeftMargin
          \ParallelRWidth=\linewidth
          \advance\ParallelRWidth by-\ParallelLeftMargin
        \fi
      \fi
    \fi
    \global\ParallelLFNCounter=\z@
    \global\ParallelRFNCounter=\z@
    \let\ParallelOldFootnote=\footnote
}{%
    \ParallelPar%
    \ParallelAtEnd%
  \endgroup%
  \ParallelShowFNList%
  \let\footnote=\ParallelOldFootnote
  \ParallelMessage{)}}
\ParallelFNNumMode=\z@
\ParallelFNMode=\z@
\ParallelBoolMid=\z@
\ParallelUserMidSkip=.5em
\ProcessOptions
\endinput
%%
%% End of file `parallel.sty'.
