1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Typesetting Macros Balancing}
15
16\unprotect
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\installcorenamespace{balancing}
73
74\installcommandhandler \??balancing {balancing} \??balancing
75
76\setupbalancing
77 [\c!distance=\emwidth,
78 \c!height=\textheight,
79 \c!setups=,
80 \c!n=\plustwo]
81
82
83
84
85\permanent\tolerant\protected\def\startbalancing[#1]#*[#2]
86 {\par
87 \begingroup
88 \ifchknumber#2\or
89 \scratchcounter\lastchknumber
90 \cdef\currentbalancing{#1}
91 \orelse\ifchknumber#1\or
92 \scratchcounter\lastchknumber
93 \lettonothing\currentbalancing
94 \orelse\ifparameter#1\or
95 \scratchcounter\plusone
96 \cdef\currentbalancing{#1}
97 \else
98 \scratchcounter\plusone
99 \lettonothing\currentbalancing
100 \fi
101 \setrigidcolumnhsize\hsize{\balancingparameter\c!distance}\plustwo
102 \usealignparameter\balancingparameter
103 \beginmvl \scratchcounter}
104
105\permanent\protected\def\stopbalancing
106 {\endmvl
107 \endgroup
108 \par}
109
110\permanent\tolerant\protected\def\placebalancing[#1]#*[#2]
111 {\begingroup
112 \cdef\currentbalancing{#1}
113 \ifparameter#2\or
114 \setupcurrentbalancing[#2]
115 \fi
116
117 \setbox\scratchboxone \flushmvl \plusone
118 \setbox\scratchboxtwo \flushmvl \plustwo
119
120
121
122
123
124
125
126
127 \balancevsize {\balancingparameter\c!height}
128 \balancetolerance \plustwothousand
129 \balanceemergencystretch 2\lineheight
130 \balancetopskip \strutht
131 \balancebottomskip \zeropoint \s!plus 2\lineheight
132
133 \usesetupsparameter\balancingparameter
134
135 \setbox\scratchboxthree\ifvoid\scratchboxone\voidbox\else\vbalance\scratchboxone exactly\relax\fi
136 \setbox\scratchboxfour \ifvoid\scratchboxtwo\voidbox\else\vbalance\scratchboxtwo exactly\relax\fi
137
138 \doloop {
139 \ifvoid\scratchboxthree
140 \ifvoid\scratchboxfour
141 \donefalse
142 \else
143 \donetrue
144 \fi
145 \else
146 \donetrue
147 \fi
148 \ifdone
149 \balancingparameter\c!before\relax
150 \hpack to \hsize \bgroup
151 \setrigidcolumnhsize\hsize{\balancingparameter\c!distance}\plustwo
152 \hbox to \hsize{\ifvoid\scratchboxthree\else\vbalancedtop\scratchboxthree\fi}
153 \hss
154 \hbox to \hsize{\ifvoid\scratchboxfour \else\vbalancedtop\scratchboxfour \fi}
155 \egroup
156 \balancingparameter\c!after\relax
157 \else
158 \exitloop
159 \fi
160 }
161 \endgroup}
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\protect \endinput
190
191
192 |