Debian Codegraph @

texmf-dist/source/latex/preprint/balance.dtx

raw
1 % \iffalse THIS IS A META-COMMENT
2 %<*dtx>
3 \ProvidesFile
4 %========================================================================
5 {BALANCE.DTX}
6 %========================================================================
7 %</dtx>
8 %% Copyright 1993-1999 Patrick W Daly
9 %% Max-Planck-Institut f\"ur Aeronomie
10 %% Max-Planck-Str. 2
11 %% D-37191 Katlenburg-Lindau
12 %% Germany
13 %% E-mail: [email protected]
14 %
15 % This program can be redistributed and/or modified under the terms
16 % of the LaTeX Project Public License Distributed from CTAN
17 % archives in directory macros/latex/base/lppl.txt; either
18 % version 1 of the License, or any later version.
19 %
20 % This is a contributed file to the LaTeX2e system.
21 % -------------------------------------------------
22 % This is a LaTeX package to balance the last two columns in twocolumn mode.
23 % Installation:
24 % LaTeX this file: creates docstrip installation file balance.ins
25 % AND the (LaTeX2e) documentation
26 % (La)TeX balance.ins: creates package files balance.sty, and optionally
27 % documentation driver balance.drv
28 % (balance.ins may be edited as needed)
29 % Docstrip options available:
30 % package - to produce a (LaTeX2e) package .sty file
31 % driver - to produce a driver file to print the documentation
32 % 209 - (with package) for package that runs under LaTeX 2.09
33 % subpack - (with package) for coding included in other packages
34 %--------------------------------------------------------------------------
35 %<*!subpack>
36 %<package&209>\def\ProvidesPackage#1#2]
37 %<package&209> {\typeout{Style option `#1'#2]}}
38 %
39 % *** Identify the package file:-
40 %<package&!209>\NeedsTeXFormat{LaTeX2e}[1994/06/01]
41 %<package>\ProvidesPackage{balance}
42 %</!subpack>
43 %
44 % *** Provide command to dislay module version
45 %<package&subpack>\def\ModuleVersion#1[#2]{}
46 %<package&subpack> \ModuleVersion{balance}
47 %
48 % *** Identify the driver file:-
49 %<driver>\NeedsTeXFormat{LaTeX2e}
50 %<driver>\ProvidesFile{balance.drv}
51 %
52 % *** The DATE, VERSION, and other INFO
53 %\fi
54 %\ProvidesFile{balance}
55 [1999/02/23 4.3 (PWD)]
56 % \changes{4.0}{1993 Oct 10}{First release with \texttt{docstrip}}
57 % \changes{4.0}{1993 Oct 20}{Change so \cs{balance} makes redefinitions
58 % and does not just set flag}
59 % \changes{4.1}{1994 May 16}{Convert to \LaTeXe}
60 % \changes{4.1a}{1994 Jun 22}{Update to first official release of \LaTeXe}
61 % \changes{4.1b}{1995 Jan 2}{Update documentation to PWD standard}
62 % \changes{4.2}{1995 Nov 7}{Fix up \cmd{\cleardoublepage}}
63 % \changes{4.2a}{1997 Mar 16}{Fix copyright for subpackage and other minor
64 % things}
65 % \changes{4.2b}{1997 Apr 29}{Conform to new \texttt{docstrip}}
66 % \changes{4.3}{1999 Feb 23}{Update copyright notice}
67 %
68 % \CheckSum{168}
69 % \CharacterTable
70 % {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
71 % 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
72 % Digits \0\1\2\3\4\5\6\7\8\9
73 % Exclamation \! Double quote \" Hash (number) \#
74 % Dollar \$ Percent \% Ampersand \&
75 % Acute accent \' Left paren \( Right paren \)
76 % Asterisk \* Plus \+ Comma \,
77 % Minus \- Point \. Solidus \/
78 % Colon \: Semicolon \; Less than \<
79 % Equals \= Greater than \> Question mark \?
80 % Commercial at \@ Left bracket \[ Backslash \\
81 % Right bracket \] Circumflex \^ Underscore \_
82 % Grave accent \` Left brace \{ Vertical bar \|
83 % Right brace \} Tilde \~}
84 % \iffalse
85 %<*install>
86 %^^A =============================================
87 %^^A Here is the docstrip installation file
88 %^^A It is written on first LaTeX run if it
89 %^^A does not already exist
90 %^^A =============================================
91 \begin{filecontents*}{balance.ins}
92 % File: balance.ins
93 % Copyright 1999 Patrick W. Daly
94 %
95 % This file can be redistributed and/or modified under the terms
96 % of the LaTeX Project Public License Distributed from CTAN
97 % archives in directory macros/latex/base/lppl.txt; either
98 % version 1 of the License, or any later version.
99 %
100 % It is an installation file for extracting package and driver
101 % files from the original source file. Simply process it under
102 % TeX or LaTeX.
103
104 \input docstrip
105
106 \preamble
107 =============================================
108 IMPORTANT NOTICE:
109
110 This program can be redistributed and/or modified under the terms
111 of the LaTeX Project Public License Distributed from CTAN
112 archives in directory macros/latex/base/lppl.txt; either
113 version 1 of the License, or any later version.
114
115 This is a generated file.
116 It may not be distributed without the original source file \inFileName.
117
118 Full documentation can be obtained by LaTeXing that original file.
119 Only a few abbreviated comments remain here to describe the usage.
120 =============================================
121 \endpreamble
122 \postamble
123
124 <<<<< End of generated file <<<<<<
125 \endpostamble
126
127 \declarepreamble\driver
128 ============================================
129 This is the driver file to produce the LaTeX documentation
130 from the original source file \inFileName.
131
132 Make changes to it as needed. (Never change the file \inFileName!)
133 ============================================
134 \endpreamble
135
136 \declarepostamble\driverq
137
138 End of documentation driver file.
139 \endpostamble
140
141 \keepsilent
142 \askforoverwritefalse
143
144 \generate{\file{balance.sty}{\from{balance.dtx}{package}}
145 \file{balance.drv}{\usepreamble\driver\usepostamble\driverq
146 \from{balance.dtx}{driver}}
147 }
148
149 \obeyspaces
150 \Msg{******************************************}%
151 \Msg{* For documentation, process balance.dtx *}%
152 \Msg{* or the driver file balance.drv *}%
153 \Msg{******************************************}
154
155 \endbatchfile
156 \end{filecontents*}
157 %</install>
158 %<*driver>
159 \documentclass{ltxdoc}
160 %<driver>%\documentclass[twoside]{ltxdoc}
161 %<driver>%\documentclass[a4paper]{ltxdoc}
162 %<driver>%\documentclass[twoside,a4paper]{ltxdoc}
163 \raggedbottom
164
165 %** To include the detailed explanation of the coding, comment out
166 %** the next line
167 \OnlyDescription
168
169 %** To produce a command index: add the following line for one run,
170 %** then run makeindex -s gind.ist natbib
171 %** and reprocess, with or without this line (much faster without)
172 %<driver>% \EnableCrossrefs\CodelineIndex
173
174 %** To produce a change history: add the following line for one run,
175 %** then run makeindex -s gglo.ist -o natbib.gls natbib.glo
176 %** and reprocess, with or without this line (faster without)
177 %<driver>% \RecordChanges
178
179 \DisableCrossrefs %May stay; zapped by \EnableCrossrefs
180 \CodelineNumbered %May stay
181
182 \begin{document}
183 \DocInput{balance.dtx}
184 \end{document}
185 %</driver>
186 % \fi
187 %
188 % \DoNotIndex{\begin,\CodelineIndex,\CodelineNumbered,\def,\DisableCrossrefs}
189 % \DoNotIndex{\DocInput,\documentclass,\EnableCrossrefs,\end,\GetFileInfo}
190 % \DoNotIndex{\NeedsTeXFormat,\OnlyDescription,\RecordChanges,\usepackage}
191 % \DoNotIndex{\ProvidesClass,\ProvidesPackage,\ProvidesFile,\RequirePackage}
192 % \DoNotIndex{\LoadClass,\PassOptionsToClass,\PassOptionsToPackage}
193 % \DoNotIndex{\DeclareOption,\CurrentOption,\ProcessOptions,\ExecuteOptions}
194 % \DoNotIndex{\AtEndOfClass,\AtEndOfPackage,\AtBeginDocument,\AtEndDocument}
195 % \DoNotIndex{\InputIfFileExists,\IfFileExists,\ClassError,\PackageError}
196 % \DoNotIndex{\ClassWarning,\PackageWarning,\ClassWarningNoLine}
197 % \DoNotIndex{\PackageWarningNoLine,\ClassInfo,\PackageInfo,\MessageBreak}
198 % \DoNotIndex{\space,\protect,\DeclareRobustCommand,\CheckCommand}
199 % \DoNotIndex{\newcommand,\renewcommand,\providecommand\newenvironment}
200 % \DoNotIndex{\renewenvironment,\newif,\newlength,\newcounter,\setlength}
201 % \DoNotIndex{\setcounter,\if,\ifx,\ifcase,\ifnum,\ifdim,\else,\fi}
202 % \DoNotIndex{\texttt,\textbf,\textrm,\textsl,\textsc}
203 % \DoNotIndex{\textup,\textit,\textmd,\textsf,\emph}
204 % \DoNotIndex{\ttfamily,\rmfamily,\sffamily,\mdseries,\bfseries,\upshape}
205 % \DoNotIndex{\slshape,\scshape,\itshape,\em,\LaTeX,\LaTeXe}
206 % \DoNotIndex{\filename,\fileversion,\filedate,\let}
207 % \DoNotIndex{\@@warning,\@M,\@colht,\@combinedblfloats,\@dblfloatplacement}
208 % \DoNotIndex{\@firstcolumnfalse,\@firstcolumntrue,\@leftcolumn,\@outputbox}
209 % \DoNotIndex{\@outputdblcol,\@outputpage,\@startdblcolumn,\@tempdima}
210 % \DoNotIndex{\@whilesw,\advance,\baselineskip,\begingroup,\box,\columnseprule}
211 % \DoNotIndex{\columnwidth,\copy,\dimen,\divide,\dp,\else,\endgroup,\fi}
212 % \DoNotIndex{\global,\hbox,\hfil,\hss,\ht,\if@fcolmade,\if@firstcolumn}
213 % \DoNotIndex{\if@twocolumn,\ifdim,\kern,\loop,\multiply,\newdimen}
214 % \DoNotIndex{\outputpenalty,\penalty,\repeat,\setbox,\splittopskip}
215 % \DoNotIndex{\string,\textwidth,\topskip,\unvbox,\vbadness,\vbox}
216 % \DoNotIndex{\vfil,\vrule,\vsplit}
217 %
218 % \setcounter{IndexColumns}{2}
219 % \setlength{\IndexMin}{10cm}
220 % \setcounter{StandardModuleDepth}{1}
221 %
222 % \GetFileInfo{balance}
223 %
224 % \title{\bfseries Balancing the Two Columns of Text on the Last Page}
225 %
226 % \author{Patrick W. Daly}
227 %
228 % \date{This paper describes package \texttt{\filename}\\
229 % version \fileversion{} from \filedate\\[1ex]
230 % \textsl{It is part of the \texttt{preprint} collection of packages}
231 % }
232 %
233 % \maketitle
234 %
235 % \pagestyle{myheadings}
236 % \markboth{P. W. Daly}{BALANCING TWO COLUMN TEXT}
237 %
238 %^^A In order to keep all marginal notes on the one (left) side:
239 %^^A (otherwise they switch sides disasterously with twoside option)
240 % \makeatletter \@mparswitchfalse \makeatother
241 %
242 %\begin{small}\begin{center}\textbf{Summary}\end{center}
243 % The stripped version of this file contains the following brief description:
244 %\iffalse
245 %<*package&!subpack>
246 %\fi
247 % \begin{verbatim}
248 % In order to balance the columns on a page, \balance must be given
249 % somewhere within the first column. To turn off the feature, give
250 % \nobalance. One has to look at the unbalanced text first to decide
251 % where best to place \balance.
252 % \end{verbatim}
253 %\iffalse
254 %-----------------------------------------------------------
255 %</package&!subpack>
256 %\fi
257 %\end{small}
258 %
259 % \section{Introduction}
260 % When a \LaTeX{} document is to be set in two-column mode, one can
261 % add |twocolumn| as an option to |\documentstyle| (\LaTeX~2.09)
262 % or to |\documentclass| (\LaTeXe), or one can use the
263 % |\twocolumn| command in the text. In either case, the columns on the last
264 % page, or those before a |\cleardoublepage| command, will be of unequal
265 % height. This is because \LaTeX{} views the columns as pages which are
266 % just output as pairs, and it no longer knows about the left-hand column
267 % when a short right-hand one is finished.
268 %
269 % The macros in this package solve this problem by modifying the output
270 % routines in two-column mode.
271 %
272 % \section{Invoking the Package}
273 % The macros in this package are included in the main document
274 % with the |\usepackage| command of \LaTeXe,
275 % \begin{quote}
276 % |\documentclass[..,twocolumn,..]{...}|\\
277 % |\usepackage{|\texttt{\filename}|}|
278 % \end{quote}
279 % There are no \LaTeXe{} options for this package.
280 %
281 % Alternatively, the name of the package is added as an option to the
282 % |\documentstyle| command in \LaTeX~2.09 compatibility mode, as
283 % \begin{quote}
284 % |\documentstyle[..,twocolumn,|\texttt{\filename}|..]{...}|
285 % \end{quote}
286 %
287 % \section{Usage}
288 % Including the \texttt{\filename} package as shown above does not activate it
289 % immediately. There are a number of reasons for this.
290 % \begin{enumerate}
291 % \item It could be that a newer (or much older) version of \LaTeX{} is
292 % being used for which the modified |\output| routines are
293 % incompatible; in this case, the new routines must be left inactive.
294 %
295 % \item Sometimes the modified output routine does not work well for normal
296 % pages, especially with floats (figures and tables) or footnotes.
297 %
298 % \end{enumerate}
299 % For these reasons, it is thought better to have the modified output
300 % routines left inactive, and to turn them on only when needed.
301 % \DescribeMacro{\balance}
302 % This is done with the command |\balance|, which should be issued
303 % somewhere in the text of what would be the first column of the last page
304 % without balanced columns. If it is issued too late, i.e., in the second
305 % column, then a warning message is printed that balancing may not take
306 % place.
307 %
308 % \DescribeMacro{\nobalance}
309 % To turn off the balancing routines, call |\nobalance|. This might be
310 % useful where there are many `last' pages, say at the end of book
311 % chapters. The |\balance| command should be given for each page that
312 % needs balancing, and then turned off at the end of the second column.
313 %
314 % It might well be that |\balance| can be left on all the time, but one
315 % should check the output carefully, and turn it off if need be.
316 %
317 % \section{An Alternative}
318 % Making multicolumn text with Mittelbach's {\tt multicol} package is
319 % perhaps a better method. It balances automatically, and allows more than
320 % just two columns. Never use \texttt{\filename} together with {\tt multicol}!
321 %
322 % \StopEventually{\PrintIndex\PrintChanges}
323 %
324 % \section{Options with \texttt{docstrip}}
325 % The source \texttt{.dtx} file is meant to be processed with
326 % \texttt{docstrip}, for which a number of options are available:
327 % \begin{description}
328 % \item[\tt package] to produce a \texttt{.sty} package file with most
329 % comments removed;
330 % \item[\tt 209] for a package file that will also run under the older
331 % \LaTeX~2.09 and not just under the newer (mid-1994) \LaTeXe;
332 % \item[\tt subpack] (together with \texttt{package}) for coding that is to
333 % be included inside a larger package; even more comments are removed,
334 % as well as \LaTeXe{} option handling and identification;
335 % \item[\tt driver] to produce a driver \texttt{.drv} file that will print
336 % out the documentation under \LaTeXe; with the \texttt{209} option,
337 % a driver \texttt{.209} file is also produced, for printing the
338 % documentation under \LaTeX~2.09.
339 % \end{description}
340 % The source file \texttt{\filename.dtx} is itself a driver file and can
341 % be processed directly by \LaTeXe.
342 %
343 % \section{The Coding}
344 % This section presents and explains the actual coding of the macros.
345 % It is nested between |%<*package>| and |%</package>|, which
346 % are indicators to \texttt{docstrip} that this coding belongs to the package
347 % file.
348 %
349 % The \texttt{docstrip} option |<subpack>| should only be called if the
350 % coding is to be included as part of another package, in which case the
351 % announcement text and \LaTeXe{} options are suppressed.
352 %
353 % An inferior version of this coding is provided for running as a
354 % style file under \LaTeX~2.09. Code lines belonging to this are
355 % indicated with guard |<209>|; those for LaTeXe{} only with |<!209>|.
356 %
357 % \subsection{Altering the Standard {\tt\bslash output} Routines}
358 % The column balancing procedure here involves making changes to the
359 % standard output routines in \LaTeX. I normally do not like assuming
360 % anything from {\tt latex.tex} because it may have been different in
361 % earlier versions, and may change again. There I try as much as possible
362 % to save current definitions of internal macros and then simply add
363 % revisions.
364 %
365 % In this case, that is not possible. I have had to take the routine
366 % |\@outputdblcol| from \LaTeX{} version 2.09, (1992 March~25) as basis.
367 % However, I notice that they have not changed for many versions, so that
368 % maybe there is some stability here.
369 %
370 % The newer \LaTeXe{} version (1994 Dec.~01) also has the same definition
371 % of |\@outputdblcol|, so there should be no problems of compatibility
372 % here.
373 %
374 % In earlier versions of \texttt{\filename}, |\@outputdblcol| was changed
375 % such that
376 % a flag would activate the new coding if set, otherwise the old coding
377 % took place. This assumes that the `old' coding is known, because I give
378 % it explicitly in the new definition. This is where problems could arise
379 % if |\@outputdblcol| is ever changed.
380 %
381 % I now do this differently. The old definition of |\@outputdblcol| is
382 % stored (without knowing what it is), and the |\balance| command redefines
383 % it. Without giving |\balance|, one has the default output routines as
384 % though \texttt{\filename} were never selected. This gives the user the
385 % chance to turn everything off if any problems should arise.
386 %
387 % Since the balancing act does not always work for normal pages (where the
388 % two columns are full) especially when floats are involved, it is better
389 % to turn it on with |\balance| only where it is needed. It may then be
390 % turned off again with |\nobalance|.
391 %
392 % \subsection{The Principle Behind Balancing Columns}
393 % Let me first explain how |\@outputdblcol| normally works. By the time it
394 % is called, the accumulated text for the `page' (\TeX{} considers each
395 % column to be a page at this point) is contained in the box |\@outputbox|.
396 % The routine checks if this is the first column, and if so stuffs
397 % |\@outputbox| into the box |\@leftcolumn|; it then toggles the
398 % |\if@firstcolumn| flag. On the next call to |\@outputdblcol|, it combines
399 % |\@leftcolumn| with |\@outputbox| side by side on a single page, all
400 % stored in |\@outputbox|.
401 %
402 % For column balancing, the procedure is slightly different. If it is the
403 % first column, then the height of the column (|\@colht| = |\textheight|
404 % minus double-column floats and footnotes) is doubled and the contents of
405 % |\@outputbox| are dumped back into the processing. The height must be
406 % doubled temporarily to allow this, otherwise the |\output| routines will
407 % be immediately called again. On the second column, the new routine
408 % |\@BAlancecol| is called to split |\@outputbox| into two equally high
409 % pieces of text, stored in |\@leftcolumn| and |\@outputbox|, which are
410 % then placed side by side as usual.
411 %
412 % \subsection{Macro Definitions}
413 % \begin{macro}{\@BAlancecol}
414 % \changes{4.0}{1993 Nov 1}{Add \cmd{\vfil} after
415 % \cmd{\unvbox1} to prevent underfull vbox}
416 % \changes{4.1}{1994 May 16}{New name for \cmd{\@balancecol}, to conform
417 % more with newer conventions for package programming.}
418 % \changes{4.1a}{1994 Jun 22}{Use \cmd{\newcommand} instead of \cmd{\def}}
419 % We begin by defining |\@BAlancecol|, the routine that splits
420 % |\@outputbox| into two nearly equally high boxes, which are then stored
421 % in boxes |\@leftcolumn| and |\@outputbox|. This routine is almost
422 % identical with that of Knuth in the \TeX{}Book (macro |\balancecolumns|
423 % on page~417). The loop keeps going until the first column is less than
424 % the second in height, making 1~pt changes in the specification each time.
425 % \begin{macrocode}
426 %<*package>
427 \newcommand{\@BAlancecol}{\if@twocolumn
428 \setbox0=\vbox{\unvbox\@outputbox} \@tempdima=\ht0
429 \advance\@tempdima by \topskip \advance\@tempdima
430 by -\baselineskip \divide\@tempdima by 2
431 \splittopskip=\topskip
432 {\vbadness=\@M \loop \global\setbox3=\copy0
433 \global\setbox1=\vsplit3 to \@tempdima
434 \ifdim\ht3>\@tempdima \global\advance\@tempdima by 1pt \repeat}
435 \setbox\@leftcolumn=\vbox to \@tempdima{\unvbox1\vfil}
436 \setbox\@outputbox=\vbox to \@tempdima
437 {\dimen2=\dp3\unvbox3\kern-\dimen2
438 \vfil}
439 \fi}
440 % \end{macrocode}
441 % \end{macro}
442 %
443 % \begin{macro}{\@BAdblcol}
444 % \changes{4.1}{1994 May 16}{New name for \cmd{\@baldblcol}, to conform
445 % more with newer conventions for package programming.}
446 % \changes{4.1a}{1994 Jun 22}{Use \cmd{\newcommand} instead of \cmd{\def}}
447 % \changes{4.1a}{1994 Jun 22}{Use \cmd{\PackageWarningNoLine} instead of
448 % \cmd{\@@warning}}
449 % Now define the revised routine |\@outputdblcol|, and name it
450 % |\@BAdblcol|. In the first column, it just puts |\@outputbox| back into
451 % the processing with a doubled column height (|\@colht|). In the second
452 % column, it calls |\@BAlancecol| and the places the boxes |\@leftcolumn|
453 % and |\@outputbox| side by side in almost the same way that the original
454 % |\@outputdblcol| does. The difference is that the final vbox is made to
455 % be |\@colht| high and a |\vfil| must be added below to fill up the
456 % missing space. In the original, the column boxes themselves are |\@colht|
457 % high, so this is not necessary. If this feature were left off, then the
458 % final box would not have the correct height, something that is noticeable
459 % when a footline is added at the bottom.
460 % \begin{macrocode}
461 \newif\if@BAlanceone
462 \global\@BAlanceonefalse
463 \newdimen\oldvsize
464 \newcommand{\@BAdblcol}{\if@firstcolumn
465 \unvbox\@outputbox \penalty\outputpenalty
466 \global\oldvsize=\@colht \global\multiply \@colht by 2
467 \global\@BAlanceonetrue
468 \global\@firstcolumnfalse
469 \else \global\@firstcolumntrue
470 \if@BAlanceone
471 \global\@BAlanceonefalse\@BAlancecol
472 \global\@colht=\oldvsize \else
473 %<!209> \PackageWarningNoLine{balance}
474 %<209> \@@warning
475 {You have called \protect\balance\space
476 %<!209> in second column\MessageBreak
477 %<209> in second column^^J
478 Columns might not be balanced}\fi
479 \setbox\@outputbox\vbox to \@colht{\hbox to\textwidth
480 {\hbox to\columnwidth {\box\@leftcolumn \hss}\hfil
481 \vrule width\columnseprule\hfil \hbox to\columnwidth
482 {\box\@outputbox \hss}}\vfil}\@combinedblfloats
483 \@outputpage \begingroup \@dblfloatplacement
484 \@startdblcolumn \@whilesw\if@fcolmade \fi
485 {\@outputpage\@startdblcolumn}\endgroup
486 \fi}
487 % \end{macrocode}
488 % The flag |\if@BAlanceone| seems redundant, since it is always the
489 % complement of |\if@firstcolumn|. However, its function is to ensure that
490 % the |\balance| command, that activates |\@BAdblcol|, actually occurs
491 % before the first column of text is completed. If this is not the case, if
492 % |\balance| is issued too late, then the procedure cannot function. In
493 % this case, |\@BAdblcol| is entered with both |\if@firstcolumn| and
494 % |\if@BAlanceone| set \meta{false}, so that the call to |\@BAlancecol| is
495 % suppressed and warning message is printed.
496 % \end{macro}
497 %
498 % \begin{macro}{\cleardoublepage}
499 % \changes{4.2}{1995 Nov 07}{Add revised definition for balanced mode}
500 % A new version of |\cleardoublepage| is necessary when |\balance| is
501 % active. The regular command adds two |\newpage| commands on an even page
502 % in two column mode, since each |\newpage| only starts a new column.
503 % However, when |\balance| is active, each |\newpage| makes two balanced
504 % columns, to it actually starts a new page, and not just a new column.
505 % \begin{macrocode}
506 \newcommand{\@BAcleardblpage}{\clearpage\if@twoside \ifodd\c@page\else
507 \hbox{}\newpage\fi\fi}
508 \newcommand{\@@cleardblpage}{}
509 \let\@@cleardblpage=\cleardoublepage
510 % \end{macrocode}
511 % \end{macro}
512 %
513
514 % \begin{macro}{\balance}
515 % \changes{4.0}{1993 Oct 20}{Change from setting flag to redefining output
516 % routine.}
517 % \changes{4.1a}{1994 Jun 22}{Use \cmd{\newcommand} instead of \cmd{\def}}
518 % \changes{4.2}{1995 Nov 07}{Add revised \cmd{\cleardoublepage}}
519 % The command that activates the balancing replaces |\@outputdblcol|
520 % with the new |\@BAdblcol|.
521 % \begin{macrocode}
522 \newcommand{\@@utputdblcol}{}
523 \let\@@utputdblcol=\@outputdblcol
524 \newcommand{\balance}{\global\let\@outputdblcol=\@BAdblcol
525 \global\let\cleardoublepage=\@BAcleardblpage}
526 % \end{macrocode}
527 % \end{macro}
528 % \begin{macro}{\nobalance}
529 % \changes{4.0}{1993 Oct 20}{Change from setting flag to restoring
530 % original output routine.}
531 % \changes{4.1a}{1994 Jun 22}{Use \cmd{\newcommand} instead of \cmd{\def}}
532 % \changes{4.2}{1995 Nov 07}{Add revised \cmd{\cleardoublepage}}
533 % To turn off the balancing routine, call |\nobalance|.
534 % \begin{macrocode}
535 \newcommand{\nobalance}{\global\let\@outputdblcol=\@@utputdblcol
536 \global\let\cleardoublepage=\@@cleardblpage}
537 %</package>
538 % \end{macrocode}
539 % \end{macro}
540 %
541 % \Finale