1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Page Macros Facing floats}
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\unprotect
60
61
62
63
64
65
66
67\installcorenamespace {facingfloat}
68
69\installframedcommandhandler \??facingfloat {facingfloat} \??facingfloat
70
71\setupfacingfloat
72 [\c!spaceinbetween=\v!big,
73 \c!inbetween={\blank[\v!big]},
74 \c!width=\v!fit,
75
76
77 \c!page=\v!left]
78
79\appendtoks
80 \ifx\currentfacingfloatparent\empty
81 \normalexpanded{\definefacingfloat[\currentfacingfloat:\v!left ][\currentfacingfloat]}
82 \normalexpanded{\definefacingfloat[\currentfacingfloat:\v!right][\currentfacingfloat]}
83 \fi
84\to \everydefinefacingfloat
85
86\newcount\c_strc_floats_facing_saved
87\newcount\c_strc_floats_facing_flushed
88
89\newbox\b_strc_floats_facing_l
90\newbox\b_strc_floats_facing_r
91
92\let\m_strc_floats_state\relax
93
94\unexpanded\def\strc_floats_facing_flush
95 {\ifnum\c_strc_floats_facing_flushed<\c_strc_floats_facing_saved
96 \ifodd\c_strc_floats_facing_flushed
97 \ifodd\realpageno
98 \strc_floats_facing_flush_indeed
99 \doifelsependingpagecontent\relax{\null\page}
100 \else
101 \fi
102 \else
103 \ifodd\realpageno
104 \else
105 \strc_floats_facing_flush_indeed
106 \doifelsependingpagecontent\relax{\null\page}
107 \fi
108 \fi
109 \fi}
110
111\def\strc_floats_facing_flush_indeed
112 {\global\advance\c_strc_floats_facing_flushed\plusone
113 \floatingpenalty\zerocount
114 \insert\namedinsertionnumber\s!topfloat\bgroup
115 \forgetall
116 \ifconditional\c_page_one_top_of_insert
117 \ifconditional\c_page_one_correct_top_insert
118 \topskipcorrection
119 \kern\lineskip
120 \par
121 \prevdepth\maxdimen
122 \fi
123 \fi
124 \directboxfromcache{\currentfacingfloat}{\number\c_strc_floats_facing_flushed}
125 \vkern\s_page_one_between_top_insert
126 \egroup
127 \ifnum\c_strc_floats_facing_saved=\c_strc_floats_facing_flushed
128 \global\c_strc_floats_facing_saved \zerocount
129 \global\c_strc_floats_facing_flushed\zerocount
130 \resetboxesincache{\currentfacingfloat}
131 \fi}
132
133\let\flushfacingfloats\strc_floats_facing_flush
134
135\unexpanded\def\strc_floats_facing_setup
136 {\edef\currentfacingfloat{\currentfacingfloat:\m_strc_floats_state}
137 \usefacingfloatstyleandcolor\c!style\v!color}
138
139\unexpanded\def\strc_floats_facing_collect
140 {\ifx\m_strc_floats_state\v!left
141 \ifvoid\nextbox\else\ifzeropt\wd\nextbox\else
142 \ifvoid\b_strc_floats_facing_l
143 \setbox\b_strc_floats_facing_l\box\nextbox
144 \else
145 \setbox\b_strc_floats_facing_l\vbox\bgroup
146 \unvbox\b_strc_floats_facing_l
147 \facingfloatparameter\c!inbetween
148 \unvbox\nextbox
149 \egroup
150 \fi
151 \fi\fi
152 \let\m_strc_floats_state\v!right
153 \else\ifx\m_strc_floats_state\v!right
154 \ifvoid\nextbox\else\ifzeropt\wd\nextbox\else
155 \ifvoid\b_strc_floats_facing_r
156 \setbox\b_strc_floats_facing_r\box\nextbox
157 \else
158 \setbox\b_strc_floats_facing_r\vbox\bgroup
159 \unvbox\b_strc_floats_facing_r
160 \facingfloatparameter\c!inbetween
161 \unvbox\nextbox
162 \egroup
163 \fi
164 \fi\fi
165 \let\m_strc_floats_state\v!left
166 \else
167 \let\m_strc_floats_state\v!left
168 \fi\fi}
169
170\unexpanded\def\strc_floats_facing_handle
171 {\doifnextbgroupelse
172 \strc_floats_facing_handle_indeed
173 \strc_floats_facing_wrap_up}
174
175\unexpanded\def\strc_floats_facing_handle_indeed
176 {\dowithnextboxcontent
177 \strc_floats_facing_setup
178 {\strc_floats_facing_collect\strc_floats_facing_handle}
179 \vbox}
180
181\unexpanded\def\startfacingfloat[#1]
182 {\begingroup
183
184
185
186
187
188
189 \edef\currentfacingfloat{#1}
190 \edef\p_width{\facingfloatparameter\c!width}
191 \letfacingfloatparameter\c!width\v!fit
192 \ifx\p_width\v!frame
193 \setbox\scratchbox\hpack{\inheritedfacingfloatframed{}}
194 \advance\hsize\wd\scratchbox
195 \else\ifx\p_width\v!fit
196
197 \else
198 \hsize\p_width
199 \fi\fi
200 \let\startcontent\bgroup
201 \let\stopcontent\egroup
202 \let\m_strc_floats_state\v!left
203 \strc_floats_facing_handle}
204
205\unexpanded\def\stopfacingfloat
206 {\endgroup}
207
208\unexpanded\def\strc_floats_facing_wrap_up
209 {\edef\p_spaceinbetween{\facingfloatparameter\c!spaceinbetween}
210 \ifx\p_spaceinbetween\empty
211 \scratchdimen\zeropoint
212 \else
213 \setbox\scratchbox\vbox{\directvspacing\p_spaceinbetween}
214 \scratchdimen\htdp\scratchbox
215 \fi
216 \ifvoid\b_strc_floats_facing_l\else
217 \page_postprocessors_linenumbers_box\b_strc_floats_facing_l
218 \fi
219 \ifvoid\b_strc_floats_facing_r\else
220 \page_postprocessors_linenumbers_box\b_strc_floats_facing_r
221 \fi
222 \doloop{
223 \strc_floats_facing_flush_wrap\b_strc_floats_facing_l\v!left
224 \strc_floats_facing_flush_wrap\b_strc_floats_facing_r\v!right
225 \ifvoid\b_strc_floats_facing_l\relax\ifvoid\b_strc_floats_facing_r\relax
226 \exitloop
227 \fi\fi}}
228
229\def\strc_floats_facing_flush_wrap#1#2
230 {\ifvoid#1\relax
231
232 \else
233 \begingroup
234 \setbox\scratchbox\vsplit#1 upto \textheight
235 \setbox\scratchbox\hpack\bgroup
236 \edef\currentfacingfloat{\currentfacingfloat:#2}
237 \inheritedfacingfloatframed{\box\scratchbox}
238 \egroup
239 \ifdim\ht\scratchbox<\dimexpr\textheight\scratchdimen\relax
240 \setbox\scratchbox\vbox{\box\scratchbox\directvspacing\p_spaceinbetween}
241 \else
242 \setbox\scratchbox\vbox to \textheight{\box\scratchbox\vss}
243 \fi
244 \global\advance\c_strc_floats_facing_saved\plusone
245 \putboxincache{\currentfacingfloat}{\number\c_strc_floats_facing_saved}\scratchbox
246 \endgroup
247 \fi}
248
249\protect \endinput
250 |