summaryrefslogtreecommitdiff
path: root/macros/latex209/contrib/misc/multicolpar.sty
blob: ade42b158526ef892bb236aca2fc201c17d7e17a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
%% Save file as: MULTICOLPAR.STY        Source: FILESERV@SHSU.BITNET  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  File multicolpar.sty
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% by
% Mauro Orlandini <orlandini@lheavx.gsfc.nasa.gov>
% Modified by Max Hailperin <max@nic.gac.edu>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%   This LaTeX style, writes different paragraphs in different columns
% the number of columns is free), as
%   This is the first paragraph  |  This is the second paragraph and its
%   and text follows...          |  own text follows...
%
%   This is the third paragraph  |  This is the fourth paragraph...
%   and text follows...          |
%
% This format is useful for translated articles, in which there is the
% original language in the first column and the translated version in
% the second.
%
% Usage: \begin{multicolpar}{N}
%         ... text ...
%        \end{multicolpar}
%
% where N is the number of columns in which the text will be displayed.
% Warning: Inside the environment, each blank line (ie a \par) will correspond
%          to a paragraph, therefore do not leave blank lines soon after the
%          \begin{multicolpar}{N} command and soon before the \end{multicolpar}
%          command (unless you want so).
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{multicolpar}[1]{\begin{trivlist}\item[]%
\multicolumnparallelparagraphs{#1}{2em}}%
{\endmulticolumnparallelparagraphs\end{trivlist}}

\newcount\columnsleft   \newcount\totalcolumns   \newdimen\separation

\def\multicolumnparallelparagraphs#1#2{%
    \hbadness5000 \vbadness9999 \tolerance9999
    \totalcolumns=#1   \separation=#2   \let\xpar=\par
    \vskip\parskip
    \columnsleft=#1\relax
    \hbox to\hsize\bgroup
    \let\par\nextmulticolumnparallelparagraph
    \dimen0=#2\advance\hsize-\columnsleft\dimen0 \advance\hsize\dimen0
    \divide\hsize\columnsleft\relax
    \vtop\bgroup}
\def\nextmulticolumnparallelparagraph{%
    \egroup
    \advance\columnsleft-1
    \ifnum\columnsleft>0
        \hfil\vtop\bgroup
    \else
	\egroup
        \xpar\vskip\baselineskip\xpar
        \multicolumnparallelparagraphs\totalcolumns\separation
    \fi}

\def\endmulticolumnparallelparagraphs{%
    \egroup
    \advance\columnsleft-1
    \ifnum\columnsleft>0
        \hfil\vtop\bgroup\hbox to \hsize{}
        \endmulticolumnparallelparagraphs
    \else
	\egroup
        \xpar
    \fi}