summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/parallel/parallel.dtx
blob: 009ffeadab91c16633c2ccd842415324b227d6c1 (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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
%
% 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
%
%
% \iffalse meta-comment
%<*!example1>
%<*!example2>
%<*!driver>
%
%    \begin{macrocode}
 %%
 %% $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
 %%
%    \end{macrocode}
% \fi
%
% \CheckSum{808}
% \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         \~}
%
% \iffalse meta-comment
%</!driver>
% \fi
\def\fileversion{beta 4}
\def\filedate{2003/04/13}
%
% \MakeShortVerb{\|}
%
% \title{The \texttt{Parallel}-Package\thanks{%
%        I want to mention and thank
%        Bernd Raichle (Stuttgart) and Wonkoo Kim (Pittsburgh, PA),
%        who helped developing this packages with
%        their ideas, debugging and pieces of code.}\\
%        release \fileversion{}
%        }
%
% \author{Matthias Eckermann, Berlin\\
%        mge@arcor.de, mge@suse.de}
%
% \date{\filedate}
% \maketitle
%
% \begin{abstract}
%    This package provides a small tool to typeset in two columns or on
%    two pages parallel; this might be helpful,
%    e.g. if you want to set two languages besides in translations or
%    if you want to compare two texts. There are some caveats and some
%    limitations which are described in this documentation.\par
%    The gentle reader might excuse wrong words or bad constructions,
%    but I'm not a ``native speaker''.\par
%    Please remember: this is only an ``interim-public-beta''
%    until I'll have finished the complete documentation,
%    the code should be fine.
% \end{abstract}
%
% {\parskip 0pt\tableofcontents}
%
% \StopEventually{}
%
% \section{Usage}
% \subsection{Simple Usage -- for the Impatient}
% It is recommended, that you first read the complete section \emph{Usage}\
% to understand \texttt{Parallel}'s behavior and limitations, but if one
% wants to begin immediately and there is only one paragraph in two columns
% parallel, one may try this code:
% \begin{verbatim}
%    \usepackage{parallel}
%    ...
%    \begin{Parallel}{<left-width>}{<right-width>}
%       \ParallelLText{<left-text>}
%       \ParallelRText{<right-text>}
%    \end{Parallel}
% \end{verbatim}
% It generates the two texts typesetted parallel in two columns, footnotes
% at the end of the \texttt{Parallel}-Environment.
%
% \subsection{Advanced Usage}
% But, I think, most people want a more flexible handling of their parallel
% texts. So they will have to use a more difficult structure of environment
% \texttt{parallel}: 
% \begin{verbatim}
%   \usepackage[<package_options>]{parallel}
%   ...
%   \begin{Parallel}[<environment_options>]{<left-width>}{<right-width>}
%     \ParallelLText{<left-text>}
%     \ParallelRText{<right-text>}
%     \ParallelPar
%     \ParallelLText{<left-text>}
%     ...
%     \renewcommand{\ParallelAtEnd}{<text>}
%   \end{Parallel}
% \end{verbatim}
%
%    \DescribeMacro{\ParallelPar}
% |\ParallelPar| is the most important Macro of this package;
% it tells the environment to begin a new \emph{parallel paragraph}, 
% i.e.: left and right texts are printed out to their lengths
% and then we begin new on the same vertical position, as if you close the
% environment |Parallel| and begin a new one. Therefore |\ParallelPar| must
% not be left out after a pair of |\ParallelLText| -- |\ParallelRText|
% (only at the total end of the environment).
%
%    \DescribeMacro{\ParallelAtEnd}
% With the help of |\ParallelAtEnd|\par
% \hspace*{3em}(|\renewcommand{\ParallelAtEnd}{<Your text here>}|)\par
% you can set some text between the parallel columns and the footnotes.
%
%    \DescribeEnv{Parallel}
% Now we'll have a look at the options of |Parallel|.
%
% \begin{description}
%   \item[Package options] (the options, which can be chosen when loading
%   |parallel| in the document-preamble). The following options are
%   possible, but only |Verbose| and |SeparatedFootnotes| can be combined
%   with one of the others, while out of the |*Nums|-options only one can 
%   be set at one time. This behaviour may change in a later release.
%   \begin{description}
%     \item[OldStyleNums] set the footnote-numbers with \LaTeX's
%       |\oldstylnums|-command
%     \item[RaiseNums] like |\footnote|
%     \item[ItalicNums] the footnote-numbers are set in Italics
%     \item[RomanNums] using |\romannnumeral|
%     \item[SeparatedFootnotes] The footnotes of the left and right columns
%       are separately numbered and printed. The right footnotes are signed
%       with the content of |\ParallelDot| (usual |$\cdot$|).
%     \item[Verbose] tell the author used environment and its options\dots
%   \end{description}
%   \item[Environment options] Due to the work of W.Kim (see below)
%   the |<left-width>| and/or |<right-width>| may be left empty;
%   the package will set the two widths to about 50\%\ of |\textwidth|.
%   But it is also possible to set both widths with absolute (e.g. |3cm|)
%   or relative (e.g. |0.37\textwidth|) values.\par
%   One may use only one of the \emph{real} options; if none is used, 
%   ``c'' is assumed, if a bad character is chosen, an error-message 
%   will appear, but the user may go on by pressing |<return>|.
%   \begin{description}
%     \item[``c''] (\emph{Columns}) print in columns
%     \item[``v''] (\emph{Vertical line between columns}) print in columns,
%     but with intermediate |\vline|
%     \item[``p''] (\emph{Pages}) print on two pages;
%     if one box is empty, the corresponding page is left blank
%     (not a bug, but feature!)
% \task{me}{%
%     \item[``a''] (\emph{Autocomputed pages}) print on two pages,
%     autocompute the width of the text that holds less characters.
%     \item[``s''] (\emph{Save/Store once autocalculated widths})
%     Using this option, the widths autocalculated in the first
%     |\ParallelPar| will be used for the other paragraphs of this
%     \emph{environment}. This option is introduced, to enable
%     autocalculation \emph{and}\ the same look-alike of every paragraph
%     of an environment |Parallel|.
%     \item[``r''] (\emph{Resume/Reload once autocalculated widths})
%     This option allows to transfer the widths-values between
%     environments.%
% }%
%   \end{description}
% \end{description}
%
% \task{me}{%
%   \subsubsection{Typesetting in Columns}
%   \subsubsection{Typesetting on Pages}
% }
%
% \section{Limitations, Warnings}
% \begin{itemize}
%   \item \emph{tabular}s, \emph{minipage}s, ... inside of
%     |\ParallelLText| or |\ParallelRText| will cause unexpected results.
%     But you may use these constructions outside |\ParallelLText|
%     or |\ParallelRText|, but inside the environment,
%     when typesetting in columns; you \emph{must}\ not use those things
%     (within the environment), when typesetting on pages parallel.
%   \item \emph{footnote}s are printed at the end of the environment.
%     I hope, this is a begin of a solution on further footnote-problems.
%   \item The max. size of ``left-text'' and ``right-text'' is limited.
%   \item The lines are typesetted really parallel, i.e. large
%     size-differences will cause bad or dirty output.
% \end{itemize}
% 
% \section{Todo-List}
% There are some ideas and todos, that will be fixed in the final release
% or in later releases:
% \begin{itemize}
%   \item Most important: complete documentation.
%   \item Dominik Neidinger, Munich, asked for leaving out |\ParallelPar|
%     and setting to be done automatically by |\ParallelLText| and/or
%     |\ParallelRText|.
%   \item Add more environment-options:
%   \begin{itemize}
%     \item[``a''] (\emph{Autocomputed pages}) print on two pages,
%       autocompute the width of the text that holds less characters.
%     \item[``s''] (\emph{Save/Store once autocalculated widths})
%       Using this option, the widths autocalculated in the first
%       |\ParallelPar| will be used for the other paragraphs of this
%       \emph{environment}. This option is introduced, to enable
%       autocalculation \emph{and}\ the same look-alike of every paragraph
%       of an environment |Parallel|.
%     \item[``r''] (\emph{Resume/Reload once autocalculated widths})
%       This option allows to transfer the widths-values between
%       environments.
%   \end{itemize}
%   \item Use ``|\newif|'' instead of many integer variables.
%   \item different footnote-types for left and right footnotes
%   \item There might be a bug in the algorithm to typeset on two pages.
%     I must have a look at this later.
% \end{itemize}
%
% \section{Documentation-Driver}
%
%    \begin{macrocode}
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\documentclass[a4paper]{ltxdoc}
\usepackage{parallel}
\CodelineNumbered
\parskip2ex plus1ex minus1ex
\parindent0em
\setlength\hfuzz{10pt}
\setcounter{tocdepth}{2}
\hbadness=5000
\addtolength{\textwidth}{0.5in}
\pagestyle{myheadings}
\markboth{``Parallel''-package (\fileversion, \filedate)}%
{``Parallel''-package (\fileversion, \filedate)}
\begin{document}
  \DocInput{parallel.dtx}
  \begin{Parallel}[v]{0.4\textwidth}{0.51\textwidth}
  \tolerance=1000
%</driver>
%    \end{macrocode}
%
% \section{macro package source code}
% \subsection{implementation rules}
%  Even if some people will find this confusing or too much to type: I
%  decided to use real long names for all dimensions, counters, boxes and
%  macros. Every name introduced in this package starts with |\Parallel|,
%  so that it is unary (I hope) in the \LaTeX{}-world.
%
% \subsection{preamble}
% Here is the standard header for a \LaTeX{}-package. This package is
% called \texttt{parallel}\ and we just work with release 2.
%    \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{parallel}[\filedate, setting two texts parallel (me)]
\message{`parallel': setting two texts parallel, (\fileversion) \filedate.}
%    \end{macrocode}
%
% \subsection{lengths}
% The two dimensions |\ParallelLWidth| and |\ParallelRWidth| hold the
% actual size of the left and right column (or page).
%    \begin{macrocode}
\newdimen\ParallelLWidth
\newdimen\ParallelRWidth
%    \end{macrocode}
%
% |\ParallelTextWidth| is mainly a copy of |\textwidth|, while
% |\ParallelLeftMargin| holds the |\leftmargin|, e.g. if one sets a
% Parallel-Environment inside of another construction (e.g. list).
%    \begin{macrocode}
\newdimen\ParallelTextWidth
\newdimen\ParallelLeftMargin
%    \end{macrocode}
%
% While the user can redefine |\ParallelUserMidSKip| (and this is used for
% calculating the sizes and skips), |\ParallelMainMidSkip| holds the skip
% which finally is used for typesetting.
%    \begin{macrocode}
\newdimen\ParallelUserMidSkip
\newdimen\ParallelMainMidSkip
%    \end{macrocode}
%
% \subsection{boxes}
%    \begin{macrocode}
\newbox\ParallelLBox
\newbox\ParallelRBox
\newbox\ParallelBoxVar
%    \end{macrocode}
%
% \subsection{tokens}
%    \begin{macrocode}
\newbox\ParallelLTok
\newbox\ParallelRTok
%    \end{macrocode}
%
% \subsection{counts}
% First we need some ``boolean'' variables. As you see, I'am a
% C-programmer using integer-variables for boolean operations.
% Perhaps it would be better, to use |\newif| here -- later!?
% \task{me}{Use ``|\newif|'' instead of integer variables}
%    \begin{macrocode}
\newcount\ParallelBoolVar
\newcount\ParallelBoolMid
%    \end{macrocode}
%
% |\ParallelWhichBox| tells the program, if the left ($=$0) or the right
% text-box ($=$1) shall be typesetted (when in page-mode).
%
% In |\ParallelMainMode| the information is stored, if the environment is
% ``on pages'', ``in columns'' or ``in columns with vertical line''.
%    \begin{macrocode}
\newcount\ParallelWhichBox
\newcount\ParallelMainMode
%    \end{macrocode}
%
% These are the variables dealing with the special footnote-implementation
% used in environment ``Parallel''. |\ParallelLFNCounter|,
% |\ParallelRFNCounter| and |\ParallelMaxFN| are self-explaining.
%
% |\ParallelFNMode| is again a boolean-like variable.
% If |\ParallelFNMode|$=$1, footnotes are countered and set separated
% for each columns, if |\ParallelFNMode|$\ne$1, only one
% footnote-counter is used: all footnotes are set in one block
% (columns mixed!).
%
% But |\ParallelFNNumMode| needs some description. It holds the style in
% which the footnote-numbers (not those in the text, but those before the
% footnote-text) are set:
% \begin{description}
%   \item[0] normal numbers
%   \item[1] old style numbers (|\oldstylenums|)
%   \item[2] raised numbers
%   \item[3] italic numbers
%   \item[4] roman numbers (|\romannumeral|)
% \end{description}
%    \begin{macrocode}
\newcount\ParallelFNMode
\newcount\ParallelLFNCounter
\newcount\ParallelRFNCounter
\newcount\ParallelMaxFN
\newcount\ParallelFNNumMode
%    \end{macrocode}
%
% \subsection{options}
% The following options (given to the package in |\usepackage|) set the
% footnote-variables in an appropriate way. Obviously only one of
% ``OldStyleNums'', ``RaiseNums'', ``ItalicNums'' or ``RomanNums'' is
% possible, but one can combine these with ``SeparatedFootnotes'' and
% ``Verbose''. Perhaps - one day far away --
% \task{me}{different footnote-types for left and right footnotes}
% it will be possible, to have arabic-numbered left-footnotes and
% roman-numbered right-footnotes; but today the right ones are marked by a
% little dot (or something like that, see below, |\ParallelDot|).
%    \begin{macrocode}
\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}}
%    \end{macrocode}
%
% \subsection{internal commands}
%   \subsubsection{footnotes}
%
% The |\footnote|s were the most important problem when first trying to
% implement our package. So here is a description of
% \begin{itemize}
%   \item why footnotes are a problem in our task,
%   \item which problems are solved and in which way,
%   \item what is not solved and what seems to be \emph{not}\ possible.
% \end{itemize}
%
% \task{me}{%
%   \paragraph{Problems}
%   \paragraph{Solutions}
%   \paragraph{Unsolved Tasks}
% }
%    \DescribeMacro{\ParallelLFootnote}
%    \begin{macrocode}
\newcommand{\ParallelLFootnote}[1]{%
  \global\advance\ParallelLFNCounter\@ne
  \footnotemark[\number\ParallelLFNCounter]%
  \expandafter\gdef%
    \csname ParallelLFN\romannumeral\ParallelLFNCounter\endcsname{#1}}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelRFootnote}
%    \begin{macrocode}
\newcommand{\ParallelRFootnote}[1]{%
  \global\advance\ParallelRFNCounter\@ne
  \footnotemark[\number\ParallelRFNCounter]%
  \expandafter\gdef%
    \csname ParallelRFN\romannumeral\ParallelRFNCounter\endcsname{#1}}
%    \end{macrocode}
%
%    \DescribeEnv{ParallelFNEnviron}
%    \begin{macrocode}
\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}%
}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelShowFNList}
%    \begin{macrocode}
\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
}
%    \end{macrocode}
%
%  \subsubsection{typesetting on one page}
%    \DescribeMacro{\ParallelParOnePage}
% I'm glad that Bernd Raichle\footnote{Stuttgart;%
% raichle@informatik.uni-stuttgart.de; 1996/10/01}\
% spent his rare time to debug the code of this function and of the
% environment |ParallelFNEnviron|. Frank Mittelbach enhanced it in 2002/2003.
%    \begin{macrocode}
\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}
%    \end{macrocode}
%
%  \subsubsection{typesetting on two page}
%
%    \DescribeMacro{\ParallelParTwoPages}
%    \begin{macrocode}
\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}
%    \end{macrocode}
%
% \subsection{user commands}
%
% \task{me}{BR: |\egroup| nicht notwendig, da durch Endeklammer des Arguments gegeben}
%    \DescribeMacro{\ParallelAfterText}
%    \begin{macrocode}
\newcommand{\ParallelAfterText}{%
  \global\ParallelBoolVar=\@ne
  \let\footnote=\ParallelOldFootnote\endgroup}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelCheckOpenBrace}
%    \begin{macrocode}
\newcommand{\ParallelCheckOpenBrace}{%
  \ifx\x\bgroup \else
    \errmessage{Missing opening brace}%
  \fi
  \endgroup}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelLText}
%    \begin{macrocode}
\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=}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelRText}
%    \begin{macrocode}
\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=}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelAtEnd}
% |\ParallelAtEnd| must be defined: the user just types |\renewcommand|,
% and everything is right (I hope); it's a dummy.
%    \begin{macrocode}
\newcommand{\ParallelAtEnd}{}
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelPar}
% Actually, this is a dummy again or a ``Pointer'' to the |\ParallelPar|,
% which is choosen.
% \task{me/dn}{Dominik Neidinger (dn) requested leaving out |\ParallelPar|
% and the setting to be done automatically by |\ParallelLText| or
% |\ParallelRText|; mh, let's think about that.}
%    \begin{macrocode}
\newcommand{\ParallelPar}{}  % Dummy
%    \end{macrocode}
%
%    \DescribeMacro{\ParallelDot}
%    \begin{macrocode}
\newcommand{\ParallelDot}{\ensuremath{\cdot}}
%    \end{macrocode}
%
% \subsection{Environment ``Parallel''}
%
%    \DescribeEnv{Parallel}
%    \begin{macrocode}
\newenvironment{Parallel}[3][c]{%
  \begingroup%
    \ParallelTextWidth=\linewidth
    \ParallelLeftMargin=\textwidth
    \advance\ParallelLeftMargin by-\linewidth
%    \end{macrocode}
%
% The following code checks for the optional argument: it tells the
% environment, if the user wants typesetting on page ('p'), in columns
% ('c') or in columns with an intermediate |\vline| ('v').
% If none of these options is given, column mode is chosen,
% but if there is a wrong char (as an argument),
% an error message appears, but the user may go on by pressing |<return>|.
%
%    \begin{macrocode}
    \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
%    \end{macrocode}
%
% Smart column width support was mainly done by
% Wonkoo Kim\footnote{Pittsburgh, PA; wkim+@pitt.edu; 1996/09/29}.
% |\ParallelLWidth| or |\ParallelRWidth| fields can be left blank in user
% document. Their default width (in column-mode) is
% $0.5$|\textwidth| $-$ |\ParallelUserMidSkip| for null widths.
% Even the |\ParallelUserMidSkip| can be set by user; its default value
% is 0.5em. If only one width is given, the other width will be computed.
%
% First we must see, if the arguments of the environment are given or
% not. If not, the value is set to zero inches, for that we have a value,
% that can be calculated.
%    \begin{macrocode}
    \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
%    \end{macrocode}
%
% If we are in column-mode (|\ParallelMainMode|$=1$):
%    \begin{macrocode}
    \ifnum\ParallelMainMode=\@ne
      \ifdim\ParallelLWidth>1em
        \ifdim\ParallelRWidth>1em
%    \end{macrocode}
% \begin{itemize}
%   \item If both dimensions are set, we calculate the left width and set
%   the vertical line centered (by calculating)
% \end{itemize}
%    \begin{macrocode}
          \ParallelMainMidSkip=\linewidth
          \advance\ParallelMainMidSkip by-\ParallelLWidth
          \advance\ParallelMainMidSkip by-\ParallelRWidth
          \advance\ParallelMainMidSkip by-.5pt
          \advance\ParallelMainMidSkip by-\ParallelLeftMargin
          \divide\ParallelMainMidSkip by 2
        \else
%    \end{macrocode}
% \begin{itemize}
%   \item If only the left width is given, the mid-skip (between vertical
%   line and text) is set to |\ParallelUserMidSkip|), the width of right
%   text is calculated.
% \end{itemize}
%    \begin{macrocode}
          \ParallelRWidth=\linewidth
          \advance\ParallelRWidth by-\ParallelLWidth
          \advance\ParallelRWidth by-2\ParallelUserMidSkip
          \advance\ParallelRWidth by-\ParallelLeftMargin
          \ParallelMainMidSkip=\ParallelUserMidSkip
        \fi
      \else
        \ifdim\ParallelRWidth>1em
%    \end{macrocode}
% \begin{itemize}
%   \item If only the right width is given, the mid-skip (between vertical
%   line and text) is set to |\ParallelUserMidSkip|), the width of left
%   text is calculated.
% \end{itemize}
%    \begin{macrocode}
          \ParallelLWidth=\linewidth
          \advance\ParallelLWidth by-\ParallelRWidth
          \advance\ParallelLWidth by-2\ParallelUserMidSkip
          \advance\ParallelLWidth by-\ParallelLeftMargin
          \ParallelMainMidSkip=\ParallelUserMidSkip
        \else
%    \end{macrocode}
% \begin{itemize}
%   \item If none of the dimensions is given, the mid-skip (between vertical
%   line and text) is set to |\ParallelUserMidSkip|, the left and right
%   dimensions are calculated -- each the same width:
%   $0.5$|\linewidth| $-$ |\ParallelLeftMargin| $-$ |\ParallelUserMidSkip|.
% \end{itemize}
%    \begin{macrocode}
          \ParallelLWidth=.5\linewidth
          \advance\ParallelLWidth by-\ParallelLeftMargin
          \advance\ParallelLWidth by-\ParallelUserMidSkip
          \ParallelRWidth=\ParallelLWidth
          \ParallelMainMidSkip=\ParallelUserMidSkip
        \fi
      \fi
    \else
%    \end{macrocode}
%
% If we are in page-mode (|\ParallelMainMode|$\ne$1):
% \begin{itemize}
%   \item If both dimensions are given (standard usage): nothing happens
%   \item If only left size is given: right is set to
%   |\linewidth| $-$ |\ParallelLeftMargin|.
% \end{itemize}
%    \begin{macrocode}
      \ifdim\ParallelLWidth>1em
        \ifdim\ParallelRWidth>1em
        \else
          \ParallelRWidth=\linewidth
          \advance\ParallelRWidth by-\ParallelLeftMargin
        \fi
      \else
%    \end{macrocode}
% \begin{itemize}
%   \item If only right size is given: left is set to
%   |\linewidth| $-$ |\ParallelLeftMargin|.
% \end{itemize}
%    \begin{macrocode}
        \ifdim\ParallelRWidth>1em
          \ParallelLWidth=\linewidth
          \advance\ParallelLWidth by-\ParallelLeftMargin
        \else
%    \end{macrocode}
% \begin{itemize}
%   \item If none of the sizes is given: each is set to
%   |\linewidth| $-$ |\ParallelLeftMargin|.
% \end{itemize}
%    \begin{macrocode}
          \ParallelLWidth=\linewidth
          \advance\ParallelLWidth by-\ParallelLeftMargin
          \ParallelRWidth=\linewidth
          \advance\ParallelRWidth by-\ParallelLeftMargin
        \fi
      \fi
    \fi
%    \end{macrocode}
%
% Now we do some standard-settings.
%    \begin{macrocode}
    \global\ParallelLFNCounter=\z@
    \global\ParallelRFNCounter=\z@
    \let\ParallelOldFootnote=\footnote
%    \end{macrocode}
%
% We finished the start-part of this environment with setting the
% footnote-counters to zero and saved the old |\footnote|-macro.
%    \begin{macrocode}
}{%
%    \end{macrocode}
%
% Before leaving Parallel-environment with |\end{Parallel}|, we enshure,
% that all text was typesetted (by invoking |\ParallelPar|), then we call
% |\ParallelAtEnd|, to display some (optional) text before the footnotes.
%    \begin{macrocode}
    \ParallelPar%
    \ParallelAtEnd%
  \endgroup%
%    \end{macrocode}
%
% Now, it's time to show the footnotes (by invoking |\ParallelShowFNList|)
% and to restore the original |\footnote|-macro. The only thing to do is,
% to close the message-braces opened at the beginning of our Environment.
%    \begin{macrocode}
  \ParallelShowFNList%
  \let\footnote=\ParallelOldFootnote
  \ParallelMessage{)}}
%    \end{macrocode}
%
% \subsection{postamble, settings}
% When the package is loaded, it's neccessary to reset some of our
% Variables to standard-values; the options must be processed.
%    \begin{macrocode}
\ParallelFNNumMode=\z@
\ParallelFNMode=\z@
\ParallelBoolMid=\z@
\ParallelUserMidSkip=.5em
\ProcessOptions
%</package>
%    \end{macrocode}
%
% \iffalse
%</!example2>
%</!example1>
% \fi
%
% \DeleteShortVerb{\|}
%
% \newpage \task{me}{necessary for correct setting of last example}
%
% \section{examples for \texttt{parallel.sty}}
%   \subsection{typesetting in columns}
%    \begin{macrocode}
%<*example1>
\NeedsTeXFormat{LaTeX2e}
\documentclass[12pt]{article}
\usepackage{parallel}
\linespread{1.9}
\textwidth10.5cm
\textheight15cm
\begin{document}
  This is a sample \LaTeX{}-file  for the \texttt{Parallel}-environment.
  It is typesetted with \verb+\linespread{1.9}+, \verb+\textheight15cm+,
  \verb+\textwidth10.5cm+, for that we need more space on
  the pages and some pagebreaks are visible. This really is no masterpiece
  of typesetting, but the user should see, what the package is able to do
  and what \texttt{not}.\par
  The following text is from St.~Augustin, De corr.~et gratia XII,~34%
  \footnote{De corr. et gratia XII, 34, ALG VII, 214f.},
  latin and german.\par
\begin{Parallel}[v]{0.4\textwidth}{0.51\textwidth}
  \tolerance=1000
%</example1>
%    \end{macrocode}
%
%   \subsection{typesetting on two pages}
% \task{me}{There is a bug in the algorithm to typeset on two pages.
% I must have a look at this later.}
%    \begin{macrocode}
%<*example2>
\NeedsTeXFormat{LaTeX2e}
\documentclass[12pt]{article}
\usepackage[Verbose]{parallel}
\linespread{1.9}
\textwidth10.5cm
\textheight14cm
\begin{document}
\Large\par
  This is a sample \LaTeX{}-file  for the \texttt{Parallel}-environment. It
  is typesetted with \verb+\linespread{1.9}+, \verb+\textheight14cm+,
  \verb+\textwidth10.5cm+ and \verb+\Large+ for that we need more space on
  the pages and some pagebreaks are visible. This really is no masterpiece
  of typesetting, but the user should see, what the package is able to do
  and what \texttt{not}.\par
  The following text is from St.~Augustin, De corr.~et gratia XII,~34%
  \footnote{De corr. et gratia XII, 34, ALG VII, 214f.},
  latin and german.\par
\begin{Parallel}[p]{}{}
%</example2>
%    \end{macrocode}
%
%   \subsection{Common Text for the two Examples}
% Here we see the common text for our examples.
%    \begin{macrocode}
%<*example1|example2|driver>
  \ParallelLText{Itemque ipsa adiutoria distinguenda sunt. Aliud est
    adiutorium sine quo aliquid non fit, et aliud est adiutorium quo
    aliquid fit.  \ldots}
  \ParallelRText{Und ebenso mu\ss\ man die Gnadenhilfen selbst
    unterscheiden. Etwas anderes ist eine Hilfe, ohne die etwas nicht
    geschieht, und etwas anderes eine Hilfe, durch die etwas
    geschieht.\ldots}
  \ParallelPar
  \ParallelLText{Primo itaque homini, qui in eo bono quo factus fuerat
    rectus acceperat posse non peccare, posse non mori, posse ipsum bonum
    non deserere, datum est adiutorium perseverantiae, non quo fieret ut
    perseveraret, sed sine quo per liberum arbitrium perseverare non
    posset. Nunc vero sanctis in regnum Dei per gratiam Dei praedestinatis
    non tale adiutorium perseverantiae datur, sed tale ut eis perseverantia
    ipsa donetur; non solum ut sine isto dono perseverantes esse non
    possint, verum etiam ut per hoc donum non nisi perseverantes sunt.}
  \ParallelRText{Dem ersten Menschen, der in dem Gute, worin er gerecht
    erschaffen war, die F\"ahigkeit empfangen hatte, nicht zu s\"undigen,
    nicht zu sterben und vom Guten selbst nicht ab\-zufallen, ist demnach
    die Gnade der Beharrlichkeit verliehen worden, nicht jene, wo\-durch
    seine Beharrlichkeit bewirkt worden w\"are, sondern jene, ohne die er
    nicht imstande gewesen w\"are, mit seinem freien Willen auszuharren.
    Jetzt aber wird den Heiligen, die durch die Gnade Gottes f\"ur das Reich
    Gottes vorher\-bestimmt sind, nicht eine solche Gnade der Beharrlichkeit
    gegeben, sondern eine derartige, da\ss\ ihnen die Beharrlichkeit selbst
    geschenkt wird; daher sind sie ohne dieses Gnadengeschenk nicht nur
    unf\"ahig zur Beharrlichkeit, sondern sind auch durch dieses Geschenk
    Nurbeharrende.}
\end{Parallel}
\end{document}
%</example1|example2|driver>
%    \end{macrocode}
%
% \Finale
%
% \subsection{Final commands}
%    \begin{macrocode}
%<*package>
\endinput
%
%% End of parallel.sty
%</package>
%    \end{macrocode}
%
%   \section{Sample-text}
% And finally we see the output of our sample-text typesetted parallel
% on one page with vertical-line. The text is from St.~Augustin,
% De correptione et gratia XII,~34\footnote{De corr. et gratia XII,~34,
% ALG VII, 214f.}, latin and german.\par\vspace*{1ex}\par
%