summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/parrun/parrun.sty
blob: 5eecb5c075ef3c1022077860e159c4770f4d53be (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
%%
%% This is file `parrun.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% parrun.dtx  (with options: `parrun')
%% 
%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from parrun.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file parrun.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)
%% parrun.dtx
%% Copyright (C) 2003 Massimiliano Dominici
%% \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         \~}
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                   %
%%               ********************                                %
%%               * PARALLEL RUNNING *                                %
%%               ********************                                %
%%     This is package ``parrun.sty'', providing                     %
%%     a set of macro for typesetting two streams                    %
%%     of text running parallel on the same phy-                     %
%%     sical page, in a vertical layout.                             %
%%                                                                   %
%%     Author:   Massimiliano Dominici                               %
%%     Date:     18/11/2003                                          %
%%     Version:  1.1                                                 %
%%                                                                   %
%%     Released under the GNU General Public License.                %
%%     Please report any bugs to mlgdominici@interfree.it            %
%%                                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}[2001/06/01]
\ProvidesPackage{parrun}[2004/02/06 v1.1a Package for parallel text]
\RequirePackage{ifthen} \RequirePackage{calc}
\newif\ifmultic@l
\DeclareOption{multicol}{\multic@ltrue}
\ProcessOptions
\newbox\ffram
\newbox\sfram
\newcount\k
\newcount\cnum
\cnum=2
\newlength\flength
\newlength\slength
\newlength\ffrac
\newlength\sfrac
\newlength\nop
\newlength\total
\newlength\actualheight
\newlength\initskip
\setlength{\initskip}{0pt}
\newdimen\colframsep
\newdimen\h
\newdimen\test
\newdimen\temp
\colframsep=8pt
\newenvironment{fframe}{\global\setbox\ffram=\vbox\bgroup}{\vfill\egroup}
\newenvironment{sframe}{%
    \ifmultic@l \k=\cnum \advance\k by -1
        \dimen0=\textwidth \divide\dimen0 by
        \cnum \advance\dimen0 by -\k\colframsep
        \hsize=\dimen0
    \fi
    \global\setbox\sfram=\vbox\bgroup}
{\vfill\egroup}
\newcommand{\b@xbalance}{%
            \vbox to\initskip{}
            \vsplit\ffram to \flength
            \smallskip \hrule \smallskip
            \rigidbalance}
\newcommand{\v@idb@xbalance}{%
            \vbox to\initskip{}
            \vbox to \flength{}
            \smallskip \hrule \smallskip
            \rigidbalance}
\newcommand{\v@idb@xone}{%
            \vbox to\initskip{}
            \vbox to \flength{}
            \smallskip \hrule \smallskip
            \vsplit\sfram to \slength}
\newcommand{\v@idb@xtwo}{%
            \vbox to\initskip{}
            \vsplit\ffram to \flength
            \smallskip \hrule \smallskip
            \vbox to \slength{}}
\newcommand{\splitb@x}{%
            \vbox to\initskip{}
            \vsplit\ffram to \flength
            \smallskip \hrule \smallskip
            \vsplit\sfram to \slength}
\newcommand{\rigidbalance}{\hsize=\textwidth \k=\cnum
    \ifdim\ht\sfram>\cnum\slength
        \myline{\splittopskip=\h \vbadness=10000 \hfilneg
        \valign{##\vfil\cr\dosplits}}
    \else
        \myline{\temp=\ht\sfram \advance\temp by \baselineskip
        \divide\temp by \cnum \splittopskip=\h \vbadness=10000
        \hfilneg \valign{##\vfil\cr\dobalance}}
    \fi}
\newcommand{\dosplits}{\ifnum\k>0 \noalign{\hfil}
    \splitoff\global\advance\k-1\cr\dosplits\fi}
\newcommand{\splitoff}{
    \vsplit\sfram to \slength}
\newcommand{\dobalance}{\ifnum\k>0 \noalign{\hfil}
    \finalbalance\global\advance\k-1\cr\dobalance\fi}
\newcommand{\finalbalance}{
    \vsplit\sfram to \temp}
\newcommand{\myline}{\hbox to\hsize}
\newcommand{\m@kelayout}{%
\ifmultic@l
    \whiledo{\ht\ffram>0 \AND \ht\sfram>0}{\b@xbalance}
    \ifthenelse{\ht\ffram>0 \AND \ht\sfram=0}{\whiledo{\ht\ffram>0
    \AND \ht\sfram=0}{\v@idb@xtwo}
        \sec@nderror}
    \ifthenelse{\ht\ffram=0 \AND \ht\sfram>0}{\whiledo{\ht\ffram=0
    \AND \ht\sfram>0}{\v@idb@xbalance}
        \sec@nderror}
\else
    \whiledo{\ht\ffram>0 \AND \ht\sfram>0}{\splitb@x}
    \ifthenelse{\ht\ffram>0 \AND \ht\sfram=0}{\whiledo{\ht\ffram>0
    \AND \ht\sfram=0}{\v@idb@xtwo}
        \sec@nderror}
    \ifthenelse{\ht\ffram=0 \AND \ht\sfram>0}{\whiledo{\ht\ffram=0
    \AND \ht\sfram>0}{\v@idb@xone}
        \sec@nderror}
\fi
\UsefulLengthsTable}
\newcommand{\UserDefWidths}[2]{
    \setlength{\actualheight}{%
    \textheight-2\smallskipamount-\topskip-\baselineskip}
    \flength=.#1\actualheight \slength=.#2\actualheight
  \test=\flength \advance\test by \slength
  \ifdim\test>\actualheight
    \firsterror
  \fi
  \m@kelayout
}
\newcommand{\AutoCompute}{%
    \setlength{\actualheight}{%
    \textheight-2\smallskipamount-\topskip-\baselineskip-\initskip}
        \ifmultic@l
            \setlength{\total}{\cnum\ht\ffram+\ht\sfram}
            \divide\total by 10 \divide\actualheight by 10%
            \setlength{\nop}{1pt*\ratio{\total}{\cnum\actualheight}}
            \setlength{\flength}{1pt*\ratio{\ht\ffram}{\nop}}
            \setlength{\slength}{1pt*\ratio{\ht\sfram}{\cnum\nop}}
        \else
            \setlength{\total}{\ht\ffram+\ht\sfram}
            \divide\total by 10 \divide\actualheight by 10%
            \setlength{\nop}{1pt*\ratio{\total}{\actualheight}}
            \setlength{\flength}{1pt*\ratio{\ht\ffram}{\nop}}
            \setlength{\slength}{1pt*\ratio{\ht\sfram}{\nop}}
        \fi
    \setlength{\ffrac}{1pt*\ratio{\flength}{10\actualheight}}
    \setlength{\sfrac}{1pt*\ratio{\slength}{10\actualheight}}
    \m@kelayout
}
\newcommand{\Place}{%
    \@ifstar{\AutoCompute}{\UserDefWidths}}
\newcommand{\UsefulLengthsTable}{%
\AtEndDocument{\immediate\write\m@ne{******************************************^^J%
                                     ffrac=\the\ffrac, sfrac=\the\sfrac^^J%
                                     flength=\the\flength, slength=\the\slength^^J%
                                     ******************************************}}
}
\newcommand{\firsterror}{\PackageError{parrun}{%
        Warning: Text fractions exceeding \string\textheight}
        {The total dimension of
        the single fractions of text exceeds \string\textheight.^^J%
        You probably should reconsider the parameters in \string\Place.^^J%
        However, if you are sure of what you have done, you can go on.^^J%
        Luck!}}
\newcommand{\sec@nderror}{\PackageError{parrun}{%
            Warning: the box still contains some text}
            {Your text is not well balanced. Probably you'll get a bad ^^J%
            output. You should reconsider your document's layout.^^J%
            You will find at the end of the log file some useful^^J%
            length for dealing with.}
}

\endinput
%%
%% End of file `parrun.sty'.