blob: 486986bd6e26921bb590279a627a64d67f7f6c52 (
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
|
%%
%% This is file `flushend.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% flushend.dtx (with options: `package')
%%
%% Copyright (C) 1997-2012 by Sigitas Tolu\v{s}is <sigitas@vtex.lt>
%% VTeX Ltd., Akademijos 4, Vilnius, Lithuania
%% http://www.vtex.lt/tex/download/macros/
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% 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.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% PURPOSE: Balanced columns on last page in twocolumn mode.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{flushend}
[2012/05/29 v1.1 Balancing columns at last page]
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{flushend}[1997/10/01]
\newbox\@aaa
\newbox\@ccc
\@ifundefined{@viper}{\newbox\@viper}{}
\@ifundefined{hold@viper}{\newbox\hold@viper}{}
\newtoks\atColsBreak \atColsBreak={}
\newdimen\@extra@skip \@extra@skip\z@
\newdimen\@nd@page@rule \@nd@page@rule\z@
\def\last@outputdblcol{%
\if@firstcolumn
\global \@firstcolumnfalse
\global \setbox\@leftcolumn \box\@outputbox
\else
\global \@firstcolumntrue
\if@lastpage
\@tempdima\ht\@leftcolumn
\splittopskip\topskip\splitmaxdepth\maxdepth
\setbox\@tempboxa\vbox{%
\unvbox\@leftcolumn\setbox0\lastbox\unskip
\the\atColsBreak
\unvbox\@outputbox\setbox0\lastbox\unskip
}%
\@tempdimb .5\ht\@tempboxa
\loop
\setbox\@aaa\copy\@tempboxa
\setbox\@ccc\vbox to\@tempdimb{%
\vsplit\@aaa to\@tempdimb
\vss
\vsplit\@aaa to\@tempdimb
}%
\wlog{Extra height:\the\ht\@aaa\space when \the\@tempdimb}%
\ifvoid\@aaa
\else
\advance\@tempdimb 1\p@
\repeat
\loop
\setbox\@aaa\copy\@tempboxa
\setbox\@ccc\vbox to\@tempdimb{%
\vsplit\@aaa to\@tempdimb
\vss
}%
\wlog{(2)Left:\the\ht\@ccc\space
Right:\the\ht\@aaa\space
Output:\the\@tempdimb
}%
\ifdim \ht\@ccc<\ht\@aaa
\@tempdimb \the\ht\@aaa
\repeat
\wlog{- LAST -^^JExtra skip:\the\@extra@skip
^^JLeft:\the\ht\@ccc
^^JRight:\the\ht\@aaa
^^JOutput:\the\@tempdimb
}%
\setbox\@ccc\vbox to\@tempdimb{%
\vsplit\@tempboxa to\@tempdimb
\vss
}%
\setbox\@leftcolumn\vbox to\@tempdima{%
\vbox to\@tempdimb{\unvbox\@ccc}%
\hrule\@height\@nd@page@rule
\vss
}%
\setbox\@outputbox\vbox to\@tempdima{%
\vbox to\@tempdimb{%
\unvbox\@tempboxa
\vfilneg
\vskip\@extra@skip
}%
\hrule\@height\@nd@page@rule
\vss
}%
\setbox\@outputbox \vbox {%
\hb@xt@\textwidth {%
\hb@xt@\columnwidth {\box\@leftcolumn \hss}%
\hfil
\vrule \@width\columnseprule
\hfil
\hb@xt@\columnwidth {\box\@outputbox \hss}%
}%
}%
\else
\setbox\@outputbox \vbox {%
\hb@xt@\textwidth {%
\hb@xt@\columnwidth {\box\@leftcolumn \hss}%
\hfil
\vrule \@width\columnseprule
\hfil
\hb@xt@\columnwidth {\box\@outputbox \hss}%
}%
}%
\fi
\ifvoid\hold@viper
\else
\setbox\@outputbox \vbox{\box\hold@viper\box\@outputbox}%
\fi
\@combinedblfloats
\@outputpage
\begingroup
\@dblfloatplacement
\@startdblcolumn
\@whilesw\if@fcolmade \fi
{\@outputpage \@startdblcolumn}%
\ifvoid\@viper
\else
\global\setbox\@viper\vbox{%
\vskip-\stripsep
\unvbox\@viper
}%
\@viperoutput
\fi
\endgroup
\fi
}
\let\prev@enddocument\enddocument
\newif\if@lastpage \@lastpagefalse
\def\enddocument{%
\global\@lastpagetrue
\let\@outputdblcol\last@outputdblcol
\prev@enddocument
}
\def\raggedend{\global\let\enddocument\prev@enddocument}
\def\flushend{%
\gdef\enddocument{%
\global\@lastpagetrue
\let\@outputdblcol\last@outputdblcol
\prev@enddocument
}%
}
\def\showcolsendrule{\global\@nd@page@rule=.4pt}
\endinput
%%
%% End of file `flushend.sty'.
|