%
% PARALLEL.STY                                             15.02.1994
% Matthias Eckermann, Munich        <ud311aa@sunmail.lrz-muenchen.de>
%
% ... provides a small tool to typeset two columns parallel,
% e.g. if you want to set two languages besides.
%
% simple-usage:
%   \begin{Parallel}{<left-width>}{<right-width>}
%     \ParallelLText{<left-text>}
%     \ParallelRText{<right-text>}
%   \end{Parallel}
%
% advanced-usage:
%   \begin{Parallel}{<left-width>}{<right-width>}
%     \ParallelLText{<left-text>}
%     \ParallelRText{<right-text>}
%     \ParallelPar
%     \ParallelLText{<left-text>}
%     ...
%   \end{Parallel}
%
%             Thanks to H.Kopka, B.Raichle. J.Schrod.
%                There is ABSOLUTELY NO WARRANTY!
% WARNINGs:
% - TABULARs, MINIPAGEs, ... inside of "\LeftText" or "\RightText"
%   will cause unexpected results. But you may use these constructions
%   outside "\LeftText" or "\RightText", but inside the environment.
% - FOOTNOTEs are printed at the end of the environment.
%   I hope, this is a begin of a solution on further footnote-problems.
% - The max. size of "left-text" and "right-text" is limited.
% - The lines are typesetted really parallel, i.e. large size-differences
%   will cause bad or dirty output. Who can help?
%
 
%
% Lengths
%
\newdimen\ParallelLWidth
\newdimen\ParallelRWidth
\newdimen\ParallelBreakHeight
\newdimen\Parallelvfuzz
\newdimen\ParallelOldvfuzz
 
%
% Boxes
%
\newbox\ParallelLBox
\newbox\ParallelRBox
\newbox\ParallelBoxVar
 
%
% Counts
%
\newcount\ParallelTestVar
\newcount\ParallelOldBadness
\newcount\ParallelFNCounter
\newcount\ParallelMaxFN
 
%
% internal Commands
%
\newcommand{\ParallelFootnote}[1]%
{\global\advance\ParallelFNCounter by 1%
\footnotemark[\number\ParallelFNCounter]%
\expandafter\global\expandafter\def\csname ParallelFootNote\romannumeral%
\ParallelFNCounter\endcsname{#1}}
%
\newcommand{\ParallelShowFN}%
{\ParallelMaxFN=\ParallelFNCounter
\global\ParallelFNCounter=0
\loop
  \ifnum\ParallelFNCounter<\ParallelMaxFN
    \advance\ParallelFNCounter by 1
    \footnotetext[\ParallelFNCounter]%
    {\csname ParallelFootNote\romannumeral\ParallelFNCounter\endcsname}
\repeat%
\global\ParallelFNCounter=0}
 
%
% User-Commands
%
\newcommand{\ParallelLText}[1]%
{\let\footnote=\ParallelFootnote%
\global\setbox\ParallelLBox=\vbox{\hsize=\ParallelLWidth#1}%
\let\footnote=\ParallelOldFootnote}
%
\newcommand{\ParallelRText}[1]%
{\let\footnote=\ParallelFootnote%
\global\setbox\ParallelRBox=\vbox{\hsize=\ParallelRWidth#1}%
\let\footnote=\ParallelOldFootnote}
%
\newcommand{\ParallelPar}{%
  \ParallelOldBadness=\vbadness \vbadness=10000
  \ParallelOldvfuzz=\vfuzz      \vfuzz=\Parallelvfuzz
  \splittopskip0ex
  \ParallelTestVar=1
  \par\loop%
    \ifvoid\ParallelLBox\ifvoid\ParallelRBox\ParallelTestVar=0\fi\fi%
    \ifnum\ParallelTestVar=1\hbox to \textwidth{%
      \vbox{\setbox\ParallelBoxVar=\vsplit\ParallelLBox to\ParallelBreakHeight%
      \unvbox\ParallelBoxVar}%
      \hfill%
      \vbox{\setbox\ParallelBoxVar=\vsplit\ParallelRBox to\ParallelBreakHeight%
      \unvbox\ParallelBoxVar}%
  }\repeat
  \vfuzz=\ParallelOldvfuzz
  \vbadness=\ParallelOldBadness
  \par%
}
 
%
% Environment "Parallel"
%
\newenvironment{Parallel}[2]{%
  \emergencystretch=10pt
  \parindent0em
  \ParallelLWidth=#1
  \ParallelRWidth=#2
  \ParallelBreakHeight=1pt
  \Parallelvfuzz=5ex
  \global\ParallelFNCounter=0
  \let\ParallelOldFootnote=\footnote
  \vrule width\textwidth height 0pt depth 0pt
  \parskip=0em\par\parskip=\lineskip
}{%
  \ParallelPar\relax
  \ParallelShowFN
  \let\footnote=\ParallelOldFootnote%
}
\endinput
%
% end of PARALLEL.STY
%
 
