page-txt.mkvi /size: 37 Kb    last modification: 2020-07-01 14:35
1
% macros=mkvi
2 3
%D \module
4
%D [ file=page-txt, % copied from main-001,
5
%D version=1997.03.31,
6
%D title=\CONTEXT\ Page Macros,
7
%D subtitle=Texts,
8
%D author=Hans Hagen,
9
%D date=\currentdate,
10
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
11
%C
12
%C This module is part of the \CONTEXT\ macro||package and is
13
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
14
%C details.
15 16
\writestatus
{
loading
}{
ConTeXt
Page
Macros
/
Texts
}
17 18
\unprotect
19 20
\newtoks
\toptextcontent
\newtoks
\leftedgetextcontent
21
\newtoks
\headertextcontent
\newtoks
\leftmargintextcontent
22
\newtoks
\footertextcontent
\newtoks
\rightmargintextcontent
23
\newtoks
\bottomtextcontent
\newtoks
\rightedgetextcontent
24 25
\newtoks
\texttextcontent
26 27
%D \macros
28
%D {setuptop, setupheader, setuptext,setupfooter, setupbottom}
29
%D
30
%D The macros in this module sometimes look a bit more complicated than needed,
31
%D which is a direct result of the fact that their ancestors are quite old and
32
%D upward compatibility is a must.
33
%D
34
%D \showsetup{setuptop}
35
%D \showsetup{setupheader}
36
%D \showsetup{setuptext}
37
%D \showsetup{setupfooter}
38
%D \showsetup{setupbottom}
39 40
\installcorenamespace
{
layouttexts
}
41
\installcorenamespace
{
layouttextsline
}
42
\installcorenamespace
{
layouttextsreset
}
43
\installcorenamespace
{
layouttextssynchronize
}
44
\installcorenamespace
{
layouttextstrut
}
45
\installcorenamespace
{
layouttextspecial
}
46
\installcorenamespace
{
layouttextcontent
}
47 48
\installcommandhandler
\??layouttexts
{
layoutelement
}
\??layouttexts
49 50
% \appendtoks
51
% \resetlayoutelementparameter\c!lefttext % resolves better
52
% \resetlayoutelementparameter\c!middletext
53
% \resetlayoutelementparameter\c!righttext
54
% \to \everydefinelayoutelement
55 56
\definelayoutelement
[
\v!top
]
57
\definelayoutelement
[
\v!header
]
58
\definelayoutelement
[
\v!text
]
59
\definelayoutelement
[
\v!footer
]
60
\definelayoutelement
[
\v!bottom
]
61 62
\definelayoutelement
[
\v!top
:
\v!text
]
[
\v!top
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
63
\definelayoutelement
[
\v!header
:
\v!text
]
[
\v!header
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
64
\definelayoutelement
[
\v!text
:
\v!text
]
[
\v!text
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
65
\definelayoutelement
[
\v!footer
:
\v!text
]
[
\v!footer
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
66
\definelayoutelement
[
\v!bottom
:
\v!text
]
[
\v!bottom
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
67 68
\definelayoutelement
[
\v!top
:
\v!margin
][
\v!top
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
69
\definelayoutelement
[
\v!header
:
\v!margin
][
\v!header
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
70
\definelayoutelement
[
\v!text
:
\v!margin
][
\v!text
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
71
\definelayoutelement
[
\v!footer
:
\v!margin
][
\v!footer
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
72
\definelayoutelement
[
\v!bottom
:
\v!margin
][
\v!bottom
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
73 74
\definelayoutelement
[
\v!top
:
\v!edge
]
[
\v!top
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
75
\definelayoutelement
[
\v!header
:
\v!edge
]
[
\v!header
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
76
\definelayoutelement
[
\v!text
:
\v!edge
]
[
\v!text
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
77
\definelayoutelement
[
\v!footer
:
\v!edge
]
[
\v!footer
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
78
\definelayoutelement
[
\v!bottom
:
\v!edge
]
[
\v!bottom
][
\c!lefttext
=
,
\c!middletext
=
,
\c!righttext
=]
79 80
\unexpanded
\def
\setuplayouttext
81
{
\dotripleempty
\page_layouts_setup_text
}
82 83
\def
\page_layouts_setup_text
[#
vertical
][#
horizontal
][#
settings
]
%
84
{
\ifthirdargument
85
\setuplayoutelement
[#
vertical
:
#
horizontal
][#
settings
]
%
86
\else
87
\setuplayoutelement
[#
vertical
][#
horizontal
]
%
88
\fi
}
89 90
\appendtoks
91
\ifx
\currentlayoutelement
\empty
\else
92
\page_layouts_synchronize_element
\currentlayoutelement
% brr, can be vertical:horizontal
93
\fi
94
\to
\everysetuplayoutelement
95 96
\def
\page_layouts_reset_element_status
#
vertical
%
97
{
\expandafter\normalgdef\csname
\??layouttextsreset
#
vertical
\endcsname
{
\page_layouts_set_element_status_normal
#
vertical
}}
98 99
\def
\page_layouts_set_element_status_normal
#
vertical
%
100
{
\expandafter
\glet
\csname
\namedlayoutelementhash
#
vertical
\c!state
\endcsname
\v!normal
101
\expandafter
\glet
\csname
\??layouttextsreset
#
vertical
\endcsname\relax
102
\page_layouts_synchronize_element
{
#
vertical
}}
103 104
\def
\page_layouts_synchronize_element
#
vertical
%
105
{
\xdef
\previoustextstate
{
\csname
\??layouttextssynchronize
#
vertical
\endcsname
}
% can be a let
106
\edef
\currenttextstate
{
\namedlayoutelementparameter
{
#
vertical
}
\c!state
}
%
107
%\writestatus{>>}{[#vertical:\currenttextstate/\previoustextstate]}%
108
\ifx
\currenttextstate
\previoustextstate
\else
109
\page_layouts_synchronize_element_indeed
{
#
vertical
}
%
110
\fi
}
111 112
\def
\page_layouts_synchronize_element_indeed
#
vertical
%
113
{
\ifx
\currenttextstate
\v!high
\calculatevsizes
\page_backgrounds_recalculate
\else
114
\ifx
\previoustextstate
\v!high
\calculatevsizes
\page_backgrounds_recalculate
\else
115
\ifx
\currenttextstate
\v!none
\calculatevsizes
\page_backgrounds_recalculate
\else
116
\ifx
\previoustextstate
\v!none
\calculatevsizes
\page_backgrounds_recalculate
\fi\fi\fi\fi
117
\letgvalue
{
\??layouttextssynchronize
#
vertical
}
\currenttextstate
}
118 119
\unexpanded
\def
\setuptop
{
\dotripleempty
\page_layouts_setup_text
[
\v!top
]
}
120
\unexpanded
\def
\setupheader
{
\dotripleempty
\page_layouts_setup_text
[
\v!header
]
}
121
\unexpanded
\def
\setuptext
{
\dotripleempty
\page_layouts_setup_text
[
\v!text
]
}
122
\unexpanded
\def
\setupfooter
{
\dotripleempty
\page_layouts_setup_text
[
\v!footer
]
}
123
\unexpanded
\def
\setupbottom
{
\dotripleempty
\page_layouts_setup_text
[
\v!bottom
]
}
124 125
%D We inherit some settings:
126 127
\setuplayoutelement
128
[
\c!leftstyle
=
\layoutelementparameter
\c!style
,
129
\c!rightstyle
=
\layoutelementparameter
\c!style
,
130
\c!leftcolor
=
\layoutelementparameter
\c!color
,
131
\c!rightcolor
=
\layoutelementparameter
\c!color
,
132
\c!leftwidth
=
\layoutelementparameter
\c!width
,
133
\c!rightwidth
=
\layoutelementparameter
\c!width
]
134 135
%D \macros
136
%D {noheaderandfooterlines,notopandbottomlines}
137
%D
138
%D Although not really needed, the following shortcuts sometimes come in handy.
139
%D
140
%D \showsetup{noheaderandfooterlines}
141
%D \showsetup{notopandbottomlines}
142 143
\unexpanded
\def
\noheaderandfooterlines
144
{
\setuplayoutelement
[
\v!header
][
\c!state
=
\v!empty
]
%
145
\setuplayoutelement
[
\v!footer
][
\c!state
=
\v!empty
]
}
146 147
\unexpanded
\def
\notopandbottomlines
148
{
\setuplayoutelement
[
\v!top
][
\c!state
=
\v!empty
]
%
149
\setuplayoutelement
[
\v!bottom
][
\c!state
=
\v!empty
]
}
150 151
%D \macros
152
%D {setuptoptexts,setupheadertexts,setuptexttexts,setupfootertexts,setupbottomtexts}
153
%D
154
%D The next macros take one or more arguments. The exact setup depends on the number
155
%D of arguments. Although not that intuitive, the current scheme evolved out of the
156
%D original. When margin and edge texts as well as middle texts showed up, the
157
%D current odd|/|even scheme surfaced.
158
%D
159
%D \showsetup{setuptoptexts}
160
%D \showsetup{setupheadertexts}
161
%D \showsetup{setuptexttexts}
162
%D \showsetup{setupfootertexts}
163
%D \showsetup{setupbottomtexts}
164 165
\unexpanded
\def
\setuptoptexts
{
\dosixtupleempty
\page_layouts_setup_texts
[
\v!top
]
}
166
\unexpanded
\def
\setupheadertexts
{
\dosixtupleempty
\page_layouts_setup_texts
[
\v!header
]
}
167
\unexpanded
\def
\setuptexttexts
{
\dosixtupleempty
\page_layouts_setup_texts
[
\v!text
]
}
168
\unexpanded
\def
\setupfootertexts
{
\dosixtupleempty
\page_layouts_setup_texts
[
\v!footer
]
}
169
\unexpanded
\def
\setupbottomtexts
{
\dosixtupleempty
\page_layouts_setup_texts
[
\v!bottom
]
}
170 171
\unexpanded
\def
\page_layouts_setup_text_six
#
vertical
#
horizontal
#
a
#
b
#
c
#
d
%
172
{
\edef
\currentlayoutelement
{
#
vertical
:
#
horizontal
}
%
173
\setlayoutelementparameter
\c!lefttext
174
{
\page_layouts_process_element_double
175
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
a
}
%
176
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
d
}}
%
177
\setlayoutelementparameter
\c!righttext
178
{
\page_layouts_process_element_double
179
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
b
}
%
180
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
c
}}}
181 182
\unexpanded
\def
\page_layouts_setup_text_five
#
vertical
#
horizontal
#
a
#
b
#
c
%
183
{
\edef
\currentlayoutelement
{
#
vertical
:
\v!text
}
%
184
\setlayoutelementparameter
\c!lefttext
185
{
\page_layouts_process_element_double
186
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
horizontal
}
%
187
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
c
}}
%
188
\setlayoutelementparameter
\c!righttext
189
{
\page_layouts_process_element_double
190
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
a
}
%
191
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
b
}}}
192 193
\unexpanded
\def
\page_layouts_setup_text_four
#
vertical
#
horizontal
#
a
#
b
%
194
{
\edef
\currentlayoutelement
{
#
vertical
:
#
horizontal
}
%
195
\doifelsenothing
{
\detokenize
{
#
a
}}
196
{
\resetlayoutelementparameter
\c!lefttext
}
197
{
\setlayoutelementparameter
\c!lefttext
198
{
\page_layouts_process_element_double
199
\c!leftstyle\c!leftcolor\c!leftwidth
{
#
a
}
%
200
\c!leftstyle\c!leftcolor\c!leftwidth
{
#
a
}}}
%
201
\doifelsenothing
{
\detokenize
{
#
b
}}
202
{
\resetlayoutelementparameter
\c!righttext
}
203
{
\setlayoutelementparameter
\c!righttext
204
{
\page_layouts_process_element_double
205
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
b
}
%
206
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
b
}}}}
207 208
\unexpanded
\def
\page_layouts_setup_text_three
#
vertical
#
horizontal
#
a
%
209
{
\edef
\currentlayoutelement
{
#
vertical
:
\v!text
}
%
210
\doifelsenothing
{
\detokenize
{
#
horizontal
}}
211
{
\resetlayoutelementparameter
\c!lefttext
}
212
{
\setlayoutelementparameter
\c!lefttext
213
{
\page_layouts_process_element_double
214
\c!leftstyle\c!leftcolor\c!leftwidth
{
#
horizontal
}
%
215
\c!leftstyle\c!leftcolor\c!leftwidth
{
#
horizontal
}}}
%
216
\doifelsenothing
{
\detokenize
{
#
a
}}
217
{
\resetlayoutelementparameter
\c!righttext
}
218
{
\setlayoutelementparameter
\c!righttext
219
{
\page_layouts_process_element_double
220
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
a
}
%
221
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
a
}}}}
222 223
\unexpanded
\def
\page_layouts_setup_text_two
#
vertical
#
horizontal
%
224
{
\edef
\currentlayoutelement
{
#
vertical
:
\v!text
}
%
225
\resetlayoutelementparameter
\c!lefttext
226
\resetlayoutelementparameter
\c!righttext
227
\doifelsenothing
{
\detokenize
{
#
horizontal
}}
228
{
\resetlayoutelementparameter
\c!middletext
}
229
{
\setlayoutelementparameter
\c!middletext
230
{
\page_layouts_process_element_single
\c!style\c!color\c!width
{
#
horizontal
}}}}
231 232
\unexpanded
\def
\page_layouts_setup_text_one
#
vertical
%
233
{
\edef
\currentlayoutelement
{
#
vertical
:
\v!text
}
%
234
\resetlayoutelementparameter
\c!lefttext
235
\resetlayoutelementparameter
\c!righttext
236
\resetlayoutelementparameter
\c!middletext
237
\edef
\currentlayoutelement
{
#
vertical
:
\v!margin
}
%
238
\resetlayoutelementparameter
\c!lefttext
239
\resetlayoutelementparameter
\c!righttext
240
\resetlayoutelementparameter
\c!middletext
241
\edef
\currentlayoutelement
{
#
vertical
:
\v!edge
}
%
242
\resetlayoutelementparameter
\c!lefttext
243
\resetlayoutelementparameter
\c!righttext
244
\resetlayoutelementparameter
\c!middletext
}
245 246
\unexpanded
\def
\page_layouts_setup_texts
[#
vertical
][#
horizontal
][#
a
][#
b
][#
c
][#
d
]
%
247
{
\ifsixthargument
\page_layouts_setup_text_six
{
#
vertical
}{
#
horizontal
}{
#
a
}{
#
b
}{
#
c
}{
#
d
}
\else
248
\iffifthargument
\page_layouts_setup_text_five
{
#
vertical
}{
#
horizontal
}{
#
a
}{
#
b
}{
#
c
}
\else
249
\iffourthargument
\page_layouts_setup_text_four
{
#
vertical
}{
#
horizontal
}{
#
a
}{
#
b
}
\else
250
\ifthirdargument
\page_layouts_setup_text_three
{
#
vertical
}{
#
horizontal
}{
#
a
}
\else
251
\ifsecondargument
\page_layouts_setup_text_two
{
#
vertical
}{
#
horizontal
}
\else
252
\page_layouts_setup_text_one
{
#
vertical
}
\fi\fi\fi\fi\fi
}
253 254
%D Left and right texts are swapped on odd and even pages, but only when double
255
%D sided typesetting is enabled.
256 257
\unexpanded
\def
\page_layouts_process_element_double
258
{
\doifelseoddpage
259
\page_layouts_process_element_double_odd
260
\page_layouts_process_element_double_even
}
261 262
\def
\page_layouts_process_element_double_odd
#
lstyle
#
lcolor
#
lwidth
#
lcontent
#
rstyle
#
rcolor
#
rwidth
#
rcontent
%
263
{
\page_layouts_process_element_single
#
lstyle
#
lcolor
#
lwidth
{
#
lcontent
}}
264 265
\def
\page_layouts_process_element_double_even
#
lstyle
#
color
#
lwidth
#
lcontent
#
rstyle
#
rcolor
#
rwidth
#
rcontent
%
266
{
\page_layouts_process_element_single
#
rstyle
#
rcolor
#
rwidth
{
#
rcontent
}}
267 268
%D The next macro will be cleaned up and made less messy and dependent.
269 270
\let
\m_page_layouts_element_content
\empty
271 272
\unexpanded
\def
\page_layouts_process_element_single
#
style
#
color
#
width
#
content
%
273
{
\edef
\m_page_layouts_element_content
{
\detokenize
{
#
content
}}
% so no \v!xxx
274
\ifx
\m_page_layouts_element_content
\empty
275
% should not happen too often
276
\else
277
\page_layouts_process_element_single_indeed
#
style
#
color
#
width
{
#
content
}
%
278
\fi
}
279 280
\setvalue
{
\??layouttextstrut\v!yes
}{
\setstrut\strut
}
% maybe more variants
281 282
\def
\page_layouts_process_element_single_indeed
#
style
#
color
#
width
#
content
%
283
{
\begingroup
284
\uselayoutelementstyleandcolor
#
style
#
color
%
285
\csname
\??layouttextstrut
\layoutelementparameter
\c!strut
\endcsname
286
\ifcsname
\??layouttextspecial
\m_page_layouts_element_content
\endcsname
287
\lastnamedcs
288
\else
289
\edef
\currentlayoutelementwidth
{
\layoutelementparameter
#
width
}
%
290
\ifx
\currentlayoutelementwidth
\empty
291
\expandafter
\page_layouts_process_element_single_normal
292
\else
293
\expandafter
\page_layouts_process_element_single_limited
294
\fi
{
#
content
}
%
295
\fi
296
\endgroup
}
297 298
% {}{}{} prevents lookahead issues ... this will go away
299 300
\def
\page_layouts_process_element_single_normal
#
content
%
301
{
\doifelsemarking
\m_page_layouts_element_content
302
{
\getmarking
[
\m_page_layouts_element_content
][
\v!first
]
}
303
{
\ignorecrlf
#
content
{}{}{}}}
304 305
\def
\page_layouts_process_element_single_limited
#
content
%
306
{
\doifelsemarking
\m_page_layouts_element_content
307
{
\limitatetext
{
\getmarking
[
\m_page_layouts_element_content
][
\v!first
]
}
\currentlayoutelementwidth
\unknown
}
308
{
\ignorecrlf
\limitatetext
{
#
content
{}{}{}}
\currentlayoutelementwidth
\unknown
}}
309 310
\setvalue
{
\??layouttextspecial\v!pagenumber
}{
\page_layouts_place_page_number
}
311
\setvalue
{
\??layouttextspecial\v!date
}{
\currentdate
}
312 313
%D When specified, the texts are automatically limited in length.
314 315
\appendtoks
\page_layouts_place_text_line
\v!top
\topheight
\to
\toptextcontent
316
\appendtoks
\page_layouts_place_text_line
\v!header
\headerheight
\to
\headertextcontent
317
\appendtoks
\page_layouts_place_text_line
\v!text
\textheight
\to
\texttextcontent
318
\appendtoks
\page_layouts_place_text_line
\v!footer
\footerheight
\to
\footertextcontent
319
\appendtoks
\page_layouts_place_text_line
\v!bottom
\bottomheight
\to
\bottomtextcontent
320 321
%D Texts can be disabled, moved up and ignored, depending in the \type {status}
322
%D variable. This is handled by the next couple of macros.
323 324
\newcount
\c_page_layouts_element_state_n
325 326
\def
\page_layouts_set_element_status
#
vertical
%
327
{
\c_page_layouts_element_state_n
=
0
\namedlayoutelementparameter
#
vertical
\c!n
\relax
328
\ifcase
\c_page_layouts_element_state_n
329
\edef
\textlinestatus
{
\namedlayoutelementparameter
#
vertical
\c!state
}
%
330
\else
331
\setxvalue
{
\namedlayoutelementhash
#
vertical
\c!n
}{
\the\numexpr
\c_page_layouts_element_state_n
+
\minusone
}
%
332
\let
\textlinestatus
\v!stop
333
\fi
}
334 335
\appendtoks
336
\doifinset
\v!header
\floatspecification
{
\setxvalue
{
\namedlayoutelementhash
\v!header\c!n
}{
1
}}
%
337
\doifinset
\v!footer
\floatspecification
{
\setxvalue
{
\namedlayoutelementhash
\v!footer\c!n
}{
1
}}
%
338
\to
\everybeforeflushedpagefloat
339 340
\unexpanded
\def
\page_layouts_place_text_line
#
vertical
%
341
{
\page_layouts_set_element_status
#
vertical
\relax
342
\ifcsname
\??layouttextsline
\textlinestatus
\endcsname
343
\expandafter\lastnamedcs
344
\else
345
\expandafter
\page_layouts_place_text_line_unknown
346
\fi
#
vertical
}
347 348
\unexpanded
\def
\doifelselayouttextline
#
vertical
% shown or not
349
{
\edef
\currentlayoutelementstate
{
\namedlayoutelementparameter
{
#
vertical
}
\c!state
}
%
350
\ifx
\currentlayoutelementstate
\v!normal
351
\expandafter
\firstoftwoarguments
352
\else\ifx
\currentlayoutelementstate
\v!start
353
\doubleexpandafter\firstoftwoarguments
354
\else
355
\doubleexpandafter\secondoftwoarguments
356
\fi\fi
}
357 358
\unexpanded
\def
\doifelselayoutsomeline
#
vertical
% present or not
359
{
\edef
\currentlayoutelementstate
{
\namedlayoutelementparameter
{
#
vertical
}
\c!state
}
%
360
\ifx
\currentlayoutelementstate
\v!none
361
\expandafter
\secondoftwoarguments
362
\else\ifx
\currentlayoutelementstate
\v!high
363
\doubleexpandafter\secondoftwoarguments
364
\else
365
\doubleexpandafter\firstoftwoarguments
366
\fi\fi
}
367 368
\let
\doiflayouttextlineelse\doifelselayouttextline
369
\let
\doiflayoutsomelineelse\doifelselayoutsomeline
370 371
\newconditional
\resyncaftertextline
372 373
\setvalue
{
\??layouttextsline\v!normal
}{
\page_layouts_place_text_line_indeed
}
374
\setvalue
{
\??layouttextsline
\empty
}{
\page_layouts_place_text_line_indeed
}
375 376
\letvalue
{
\??layouttextsline\v!none
}
\gobbletwoarguments
377
\letvalue
{
\??layouttextsline\v!stop
}
\gobbletwoarguments
378 379
\setvalue
{
\??layouttextsline\v!high
}
#
vertical
#
height
%
380
{
\global
\settrue
\resyncaftertextline
381
\page_layouts_reset_element_status
#
vertical
}
382 383
\setvalue
{
\??layouttextsline\v!empty
}
#
vertical
#
height
%
384
{
\page_layouts_reset_element_status
#
vertical
}
385 386
\setvalue
{
\??layouttextsline\v!start
}
#
vertical
#
height
%
387
{
\page_layouts_reset_element_status
#
vertical
%
388
\page_layouts_place_text_line_indeed
#
vertical
#
height
}
389 390
\setvalue
{
\??layouttextsline\v!nomarking
}
#
vertical
#
height
%
391
{
\bgroup
392
\page_layouts_reset_element_status
#
vertical
%
393
\settrue
\inhibitgetmarking
394
\page_layouts_place_text_line_indeed
#
vertical
#
height
%
395
\egroup
}
396 397
% \setupheadertexts [11]
398
% \definetext [title] [header] [aa]
399
% \setupheadertexts [11] [22]
400
% \definetext [title] [header] [aa] [bb]
401
% \setupheadertexts [text] [11] [22]
402
% \definetext [title] [header] [text] [aa] [bb]
403
% \setupheadertexts [11] [22] [33] [44]
404
% \definetext [title] [header] [aa] [bb] [cc] [dd]
405
% \setupheadertexts [text] [11] [22] [33] [44]
406
% \definetext [title] [header] [text] [aa] [bb] [cc] [dd]
407 408
\def
\page_layouts_place_text_line_unknown
#
vertical
#
height
%
409
{
\global
\settrue
\resyncaftertextline
410
\begingroup
% new
411
\page_layouts_reset_element_status
#
vertical
%
412
\begincsname
\namedlayoutelementhash
{
#
vertical
}
\textlinestatus
\endcsname
413
\begincsname
\namedlayoutelementhash
{
#
vertical
:
\v!text
}
\textlinestatus
\endcsname
414
\begincsname
\namedlayoutelementhash
{
#
vertical
:
\v!margin
}
\textlinestatus
\endcsname
415
\begincsname
\namedlayoutelementhash
{
#
vertical
:
\v!edge
}
\textlinestatus
\endcsname
416
\page_layouts_place_text_line_indeed
#
vertical
#
height
%
417
\endgroup
}
418 419
\letvalue
{
\??layouttextsline\s!unknown
}
\page_layouts_place_text_line_unknown
420 421
%D The following macro has to be called after a page is flushed.
422 423
\unexpanded
\def
\resetlayouttextlines
% public
424
{
\begincsname
\??layouttextsreset\v!top
\endcsname
425
\begincsname
\??layouttextsreset\v!header
\endcsname
426
\begincsname
\??layouttextsreset\v!text
\endcsname
427
\begincsname
\??layouttextsreset\v!footer
\endcsname
428
\begincsname
\??layouttextsreset\v!bottom
\endcsname
429
\ifconditional
\resyncaftertextline
430
\calculateglobalvsizes
431
\page_backgrounds_recalculate
432
\global
\setfalse
\resyncaftertextline
433
\fi
}
434 435
\def
\getspecificlayouttext
#
vertical
#
horizontal
#
what
%
436
{
\begincsname
\namedlayoutelementhash
{
#
vertical
:
#
horizontal
}
#
what
\endcsname
}
437 438
% \settext[header][text][middle][xxx][yyy]
439 440
\unexpanded
\def
\settextcontent
441
{
\doquintupleempty
\page_layouts_set_text_content
}
442 443
\def
\page_layouts_set_text_content
[#
vertical
][#
horizontal
][#
one
][#
two
][#
three
]
% header text middle text/text
444
{
\iffifthargument
445
\setvalue
{
\namedlayoutelementhash
{
#
vertical
:
#
horizontal
}
\executeifdefined
{
\??layouttextcontent\v!text
:
#
one
}
\c!middletext
}
%
446
{
\page_layouts_process_element_double
447
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
two
}
%
448
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
three
}}
%
449
\else
\iffourthargument
450
\setvalue
{
\namedlayoutelementhash
{
#
vertical
:
#
horizontal
}
\executeifdefined
{
\??layouttextcontent\v!text
:
#
one
}
\c!middletext
}
%
451
{
\page_layouts_process_element_double
452
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
two
}
%
453
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
two
}}
%
454
\else
\ifthirdargument
455
\setvalue
{
\namedlayoutelementhash
{
#
vertical
:
#
horizontal
}
\c!middletext
}
%
456
{
\page_layouts_process_element_double
457
\c!leftstyle
\c!leftcolor
\c!leftwidth
{
#
one
}
%
458
\c!rightstyle\c!rightcolor\c!rightwidth
{
#
one
}}
%
459
\fi\fi\fi
}
460 461
\let
\currentlayoutelement
\relax
462 463
\unexpanded
\def
\resettextcontent
464
{
\dotripleempty
\page_layouts_reset_text_content
}
465 466
\def
\page_layouts_reset_text_content
[#
vertical
][#
horizontal
][#
tag
]
% header text middle
467
{
\edef
\currentlayoutelement
{
#
vertical
:
#
horizontal
}
%
468
\ifthirdargument
469
\letvalueempty
{
\layoutelementhash
\executeifdefined
{
\??layouttextcontent\v!text
:
#
tag
}
\c!middletext
}
%
470
\else
\ifsecondargument
471
\resetlayoutelementparameter
\c!lefttext
472
\resetlayoutelementparameter
\c!middletext
473
\resetlayoutelementparameter
\c!righttext
474
\fi\fi
}
475 476
\letvalue
{
\??layouttextcontent\v!text
:
\c!middle
}
\c!middletext
477
\letvalue
{
\??layouttextcontent\v!text
:
\c!left
}
\c!lefttext
478
\letvalue
{
\??layouttextcontent\v!text
:
\c!right
}
\c!righttext
479 480
%D The placement of a whole line is handled by the next two macros. These are hooked
481
%D into the general purpose token list registers mentioned before.
482 483
\let
\currentlayouttextline
\relax
484 485
\def
\page_layouts_place_text_line_indeed
#
vertical
#
height
%
486
{
\let
\currentlayouttextline
#
vertical
%
487
\ifdim
#
height
>
\zeropoint
\relax
% prevents pagenumbers when zero height
488
\page_layouts_place_text_line_left_or_right
{
#
height
}
%
489
\fi
}
490 491
\def
\page_layouts_place_text_line_left_or_right
#
height
%
492
{
\goleftonpage
493
\setbox
\b_page_layouts_element
\vbox
to
#
height
494
{
\vsize
#
height
\relax
495
%\hsize\zeropoint % hack so that e.g. after=\hairline gives predictable results
496
\hsize
\totaltextwidth
497
\normalbaselines
498
\let
\\
\ignoredlinebreak
499
\let
\crlf
\ignoredlinebreak
500
\namedlayoutelementparameter
\currentlayouttextline
\c!before
501
\doifbothsidesoverruled
502
\page_layouts_place_text_line_right
503
\page_layouts_place_text_line_right
504
\page_layouts_place_text_line_left
505
\namedlayoutelementparameter
\currentlayouttextline
\c!after
506
\vkern
\zeropoint
}
% keep the \dp, beware of \vtops, never change this!
507
\dp
\b_page_layouts_element
\zeropoint
508
\box
\b_page_layouts_element
509
\vkern
-
#
height
\relax
}
510 511
\let
\page_layouts_extra_at_margin_left
\plusone
512
\let
\page_layouts_extra_at_margin_right
\plustwo
513 514
\let
\page_layouts_place_extra_text_left
\relax
% historic
515
\let
\page_layouts_place_extra_text_right
\relax
% historic
516 517
\def
\page_layouts_place_text_line_right
518
{
\hpack
519
{
\ifdim
\leftedgewidth
>
\zeropoint
520
\page_layouts_left_edge_element
\c!lefttext
521
\fi
522
\ifdim
\leftmarginwidth
>
\zeropoint
523
%\page_layouts_left_margin_element\c!lefttext\page_layouts_extra_at_margin_left
524
\page_layouts_left_margin_element
\c!lefttext
\page_layouts_extra_at_margin_right
525
\fi
526
\ifdim
\makeupwidth
>
\zeropoint
527
\page_layouts_text_body_element
\c!lefttext\c!middletext\c!righttext
\page_layouts_extra_at_margin_left
528
\fi
529
\ifdim
\rightmarginwidth
>
\zeropoint
530
%\page_layouts_right_margin_element\c!righttext\page_layouts_extra_at_margin_left
531
\page_layouts_right_margin_element
\c!righttext
\page_layouts_extra_at_margin_right
532
\fi
533
\ifdim
\rightedgewidth
>
\zeropoint
534
%\page_layouts_right_edge_element\c!lefttext
535
\page_layouts_right_edge_element
\c!righttext
536
\fi
}}
537 538
\def
\page_layouts_place_text_line_left
539
{
\hpack
540
{
\ifdim
\leftedgewidth
>
\zeropoint
541
\page_layouts_left_edge_element
\c!righttext
542
\fi
543
\ifdim
\leftmarginwidth
>
\zeropoint
544
%\page_layouts_left_margin_element\c!righttext\page_layouts_extra_at_margin_right
545
\page_layouts_left_margin_element
\c!righttext
\page_layouts_extra_at_margin_left
546
\fi
547
\ifdim
\makeupwidth
>
\zeropoint
548
\page_layouts_text_body_element
\c!righttext\c!middletext\c!lefttext
\page_layouts_extra_at_margin_right
549
\fi
550
\ifdim
\rightmarginwidth
>
\zeropoint
551
%\page_layouts_right_margin_element\c!lefttext\page_layouts_extra_at_margin_right
552
\page_layouts_right_margin_element
\c!lefttext
\page_layouts_extra_at_margin_left
553
\fi
554
\ifdim
\rightedgewidth
>
\zeropoint
555
%\page_layouts_right_edge_element\c!righttext
556
\page_layouts_right_edge_element
\c!lefttext
557
\fi
}}
558 559
\def
\page_layouts_left_edge_element
#
parameter
%
560
{
\edef
\currentlayoutelement
{
\currentlayouttextline
:
\v!edge
}
%
561
\page_layouts_place_element_indeed
\leftedgewidth
562
{
\hss
\layoutelementparameter
#
parameter
}
%
563
\kern
\leftedgedistance
}
564 565
\def
\page_layouts_left_margin_element
#
parameter
#
extrastate
%
566
{
\edef
\currentlayoutelement
{
\currentlayouttextline
:
\v!margin
}
%
567
\page_layouts_place_element_indeed
\leftmarginwidth
568
{
\hbox
to
\leftmarginwidth
{
\hss
\layoutelementparameter
#
parameter
}
%
569
\ifnum
#
extrastate
=
\page_layouts_extra_at_margin_left
570
\kern
-
\leftmarginwidth
571
\hbox
to
\leftmarginwidth
{
\hss
\layoutelementparameter
\c!margintext
}
%
572
\fi
}
%
573
\kern
\leftmargindistance
}
574 575
\def
\page_layouts_text_body_element
#
left
#
middle
#
right
#
extrastate
%
576
{
\edef
\currentlayoutelement
{
\currentlayouttextline
:
\v!text
}
%
577
\page_layouts_place_element_indeed
\makeupwidth
578
{
\hbox
to
\makeupwidth
{
\ifnum
#
extrastate
=
\page_layouts_extra_at_margin_left
\page_layouts_place_extra_text_left
\fi
\layoutelementparameter
#
left
\hss
}
%
579
\kern
-
\makeupwidth
580
\hbox
to
\makeupwidth
{
\hss
\layoutelementparameter
#
middle
\hss
}
%
581
\kern
-
\makeupwidth
582
\hbox
to
\makeupwidth
{
\hss
\layoutelementparameter
#
right
\ifnum
#
extrastate
=
\page_layouts_extra_at_margin_right
\page_layouts_place_extra_text_right
\fi
}}}
583 584
\def
\page_layouts_right_margin_element
#
parameter
#
extrastate
%
585
{
\edef
\currentlayoutelement
{
\currentlayouttextline
:
\v!margin
}
%
586
\kern
\rightmargindistance
587
\page_layouts_place_element_indeed
\rightmarginwidth
588
{
\hbox
to
\rightmarginwidth
{
\layoutelementparameter
#
parameter
\hss
}
%
589
\ifnum
#
extrastate
=
\page_layouts_extra_at_margin_right
590
\kern
-
\rightmarginwidth
591
\hbox
to
\rightmarginwidth
{
\layoutelementparameter
\c!margintext
\hss
}
%
592
\fi
}}
593 594
\def
\page_layouts_right_edge_element
#
parameter
%
595
{
\edef
\currentlayoutelement
{
\currentlayouttextline
:
\v!edge
}
%
596
\kern
\rightedgedistance
597
\page_layouts_place_element_indeed
\rightedgewidth
598
{
\layoutelementparameter
#
parameter
\hss
}}
599 600
\def
\page_layouts_place_element_indeed
#
width
#
content
%
601
{
\vbox
% to \vsize
602
{
\hsize
#
width
\relax
603
\layoutelementparameter
\c!before
604
\setlayoutcomponentattribute
\currentlayoutelement
605
\hbox
\layoutcomponentboxattribute
to
#
width
{
#
content
}
%
606
\layoutelementparameter
\c!after
}}
607 608
%D Although it is far better to use backgrounds for this purpose, one can add a rule
609
%D in the following way. This method makes the rules disappear in case of an empty
610
%D text line. Consider this a feature.
611
%D
612
%D \starttyping
613
%D \setupheadertexts[left][right]
614
%D
615
%D \setupheader[text][after=\hrule,style=bold]
616
%D
617
%D \starttext
618
%D \input tufte \page
619
%D \setupheader[state=empty]
620
%D \input tufte \page
621
%D \stoptext
622
%D \stoptyping
623 624
%D This code will move to \type {page-flt.tex}.
625 626
\appendtoks
\placerightmarginblock
\kern
-
\rightmarginwidth
\to
\rightmargintextcontent
627
\appendtoks
\placeleftmarginblock
\kern
-
\leftmarginwidth
\to
\leftmargintextcontent
628 629
%D \macros
630
%D {definetext}
631
%D
632
%D Some macros ago, we implemented the \type {status} option \type {unknown}. This
633
%D one is used to take care of symbolic texts handlers.
634
%D
635
%D \showsetup{definetext}
636
%D
637
%D The next example demonstrates how we can use this mechanism to provide page
638
%D (event) dependent text lines.
639
%D
640
%D \starttyping
641
%D \definetext[chapter][footer][pagenumber]
642
%D \setuphead[chapter][header=high,footer=chapter]
643
%D \setupheadertexts[pagenumber]
644
%D \setupfootertexts[left][right]
645
%D \chapter{eerste} \dorecurse{20}{\input tufte \relax}
646
%D \chapter{tweede} \dorecurse{20}{\input tufte \relax}
647
%D \stoptyping
648 649
\unexpanded
\def
\definetext
650
{
\doseventupleempty
\page_layouts_define_text
}
651 652
\def
\page_layouts_define_text
[#
tag
][#
vertical
][#
horizontal
][#
a
][#
b
][#
c
][#
d
]
%
653
{
\ifseventhargument
654
\setvalue
{
\namedlayoutelementhash
{
#
vertical
:
#
horizontal
}
#
tag
}{
\page_layouts_setup_text_six
{
#
vertical
}{
#
horizontal
}{
#
a
}{
#
b
}{
#
c
}{
#
d
}}
%
655
\else
\ifsixthargument
656
\setvalue
{
\namedlayoutelementhash
{
#
vertical
}
#
tag
}{
\page_layouts_setup_text_five
{
#
vertical
}{
#
horizontal
}{
#
a
}{
#
b
}{
#
c
}}
%
657
\else
\iffifthargument
658
\setvalue
{
\namedlayoutelementhash
{
#
vertical
:
#
horizontal
}
#
tag
}{
\page_layouts_setup_text_four
{
#
vertical
}{
#
horizontal
}{
#
a
}{
#
b
}}
%
659
\else
\iffourthargument
660
\setvalue
{
\namedlayoutelementhash
{
#
vertical
}
#
tag
}{
\page_layouts_setup_text_three
{
#
vertical
}{
#
horizontal
}{
#
a
}}
%
661
\else
662
\setvalue
{
\namedlayoutelementhash
{
#
vertical
}
#
tag
}{
\page_layouts_setup_text_two
{
#
vertical
}{
#
horizontal
}}
%
663
\fi\fi\fi\fi
}
664 665
%D A few more page breakers:
666 667
\installpagebreakmethod
\v!empty
668
{
\page_otr_flush_all_floats
669
\page_otr_command_next_page
670
\doifnot
{
\namedlayoutelementparameter
\v!header\c!state
}
\v!stop
{
\setuplayoutelement
[
\v!header
][
\c!state
=
\v!empty
]
}
%
671
\doifnot
{
\namedlayoutelementparameter
\v!footer\c!state
}
\v!stop
{
\setuplayoutelement
[
\v!footer
][
\c!state
=
\v!empty
]
}
%
672
\page_otr_insert_dummy_page
}
673 674
\installpagebreakmethod
\v!header
675
{
\doifnot
{
\namedlayoutelementparameter
\v!header\c!state
}
\v!stop
{
\setuplayoutelement
[
\v!header
][
\c!state
=
\v!empty
]
}}
676 677
\installpagebreakmethod
\v!footer
678
{
\doifnot
{
\namedlayoutelementparameter
\v!footer\c!state
}
\v!stop
{
\setuplayoutelement
[
\v!footer
][
\c!state
=
\v!empty
]
}}
679 680
%D While the header and footer lines are moved away from the main text, the top and
681
%D bottom lines are centered.
682 683
\setuplayoutelement
[
\v!top
][
\c!state
=
\v!normal
,
\c!n
=
0
,
\c!before
=
\vss
,
\c!after
=
\vss
,
\c!strut
=]
684
\setuplayoutelement
[
\v!header
][
\c!state
=
\v!normal
,
\c!n
=
0
,
\c!before
=
,
\c!after
=
\vss
,
\c!strut
=
\v!yes
]
685
\setuplayoutelement
[
\v!text
][
\c!state
=
\v!normal
,
\c!n
=
0
,
\c!before
=
\vss
,
\c!after
=
\vss
,
\c!strut
=]
686
\setuplayoutelement
[
\v!footer
][
\c!state
=
\v!normal
,
\c!n
=
0
,
\c!before
=
\vss
,
\c!after
=
,
\c!strut
=
\v!yes
]
687
\setuplayoutelement
[
\v!bottom
][
\c!state
=
\v!normal
,
\c!n
=
0
,
\c!before
=
\vss
,
\c!after
=
\vss
,
\c!strut
=]
688 689
%D Moved here from strc-pag:
690
%D
691
%D We reset a previous location but only when it has a pagenumber associated. This
692
%D is a rather messy test but better than the MkII way where we use states and keep
693
%D settings.
694 695
\let
\m_page_layouts_page_number_location
\relax
696
\let
\m_page_layouts_page_number_location_v
\relax
697
\let
\m_page_layouts_page_number_location_h
\relax
698
\let
\m_page_layouts_page_number_location_x
\relax
699 700
\def
\page_layouts_place_page_number
% also elsewhere .. beware, not \unexpanded else
701
{
\strc_pagenumbers_place_location
}
% test below fails
702 703
\def
\page_layouts_reset_page_number_location
704
{
\ifx
\m_page_layouts_page_number_location_v
\relax\else
705
\edef
\currentlayoutelement
{
\m_page_layouts_page_number_location_v
:
\m_page_layouts_page_number_location_h
}
%
706
\edef
\page_layouts_previous_page_number_locator
{
\detokenizedlayoutelementparameter
\m_page_layouts_page_number_location_x
}
%
707
\doif
{
\meaning
\page_layouts_previous_page_number_locator
}{
\meaning
\page_layouts_place_page_number
}
708
{
\resetlayoutelementparameter
\m_page_layouts_page_number_location_x
}
%
709
\fi
}
710 711
\def
\page_layouts_set_page_number_location
712
{
\edef
\currentlayoutelement
{
\m_page_layouts_page_number_location_v
:
\m_page_layouts_page_number_location_h
}
%
713
\letlayoutelementparameter
\m_page_layouts_page_number_location_x
\page_layouts_place_page_number
714
\ifx
\m_page_layouts_page_number_location_x
\c!marginedgetext
715
\let
\page_layouts_place_extra_text_left
\page_layouts_place_page_number_left
716
\let
\page_layouts_place_extra_text_right
\page_layouts_place_page_number_right
717
\else
718
\let
\page_layouts_place_extra_text_left
\relax
719
\let
\page_layouts_place_extra_text_right
\relax
720
\fi
}
721 722
\def
\page_layouts_identify_page_number_location
723
{
\let
\m_page_layouts_page_number_location_v
\v!footer
724
\let
\m_page_layouts_page_number_location_h
\v!text
725
\let
\m_page_layouts_page_number_location_x
\c!middletext
726
\processallactionsinset
[
\directpagenumberingparameter
\c!location
]
727
[
\v!header
=>
\let
\m_page_layouts_page_number_location_v
\v!header
,
728
\v!footer
=>
\let
\m_page_layouts_page_number_location_v
\v!footer
,
729
\v!middle
=>
\let
\m_page_layouts_page_number_location_h
\v!text
730
\let
\m_page_layouts_page_number_location_x
\c!middletext
,
731
\v!left
=>
\let
\m_page_layouts_page_number_location_h
\v!text
732
\let
\m_page_layouts_page_number_location_x
\c!lefttext
,
733
\v!right
=>
\let
\m_page_layouts_page_number_location_h
\v!text
734
\let
\m_page_layouts_page_number_location_x
\c!righttext
,
735
\v!inleft
=>
\let
\m_page_layouts_page_number_location_h
\v!margin
736
\let
\m_page_layouts_page_number_location_x
\c!lefttext
,
737
\v!inright
=>
\let
\m_page_layouts_page_number_location_h
\v!margin
738
\let
\m_page_layouts_page_number_location_x
\c!righttext
,
739
\v!inmargin
=>
\let
\m_page_layouts_page_number_location_h
\v!margin
740
\def
\m_page_layouts_page_number_location_x
{
\ifdoublesided
\c!margintext
\else
\c!righttext
\fi
}
,
741
\v!margin
=>
\let
\m_page_layouts_page_number_location_h
\v!margin
742
\def
\m_page_layouts_page_number_location_x
{
\ifdoublesided
\c!margintext
\else
\c!righttext
\fi
}
,
743
\v!atmargin
=>
\let
\m_page_layouts_page_number_location_h
\v!text
744
\let
\m_page_layouts_page_number_location_x
\c!marginedgetext
,
745
\v!marginedge
=>
\let
\m_page_layouts_page_number_location_h
\v!text
746
\let
\m_page_layouts_page_number_location_x
\c!marginedgetext
]
}
747 748
\unexpanded
\def
\strc_pagenumbers_set_location
749
{
\edef
\p_strc_pagenumbers_location
{
\directpagenumberingparameter
\c!location
}
%
750
\ifx
\p_strc_pagenumbers_location
\m_page_layouts_page_number_location
751
% unchanged
752
\else
753
\let
\m_page_layouts_page_number_location
\p_strc_pagenumbers_location
754
\page_layouts_reset_page_number_location
755
\ifx
\p_strc_pagenumbers_location
\empty
756
% set otherwise
757
\else\ifx
\p_strc_pagenumbers_location
\v!none
758
% set otherwise
759
\else
760
\page_layouts_identify_page_number_location
761
\page_layouts_set_page_number_location
762
\fi\fi
763
\fi
}
764 765
\def
\page_layouts_place_page_number_left
% historic
766
{
\begingroup
767
\setbox
\scratchbox
\hbox
{
\ignorespaces
\layoutelementparameter
\c!marginedgetext
\removeunwantedspaces
}
%
768
\ifzeropt
\wd
\scratchbox
\else
769
\edef
\p_strc_pagenumbers_width
{
\directpagenumberingparameter
\c!width
}
%
770
\ifx
\p_strc_pagenumbers_width
\empty
771
\box
\scratchbox
\tfskip
772
\else
773
\hpack
to
\p_strc_pagenumbers_width
{
\box
\scratchbox
\hss
}
%
774
\fi
775
\fi
776
\endgroup
}
777 778
\def
\page_layouts_place_page_number_right
% historic
779
{
\begingroup
780
\setbox
\scratchbox
\hbox
{
\ignorespaces
\layoutelementparameter
\c!marginedgetext
\removeunwantedspaces
}
%
781
\ifzeropt
\wd
\scratchbox
\else
782
\edef
\p_strc_pagenumbers_width
{
\directpagenumberingparameter
\c!width
}
%
783
\ifx
\p_strc_pagenumbers_width
\empty
784
\tfskip
\box
\scratchbox
785
\else
786
\hpack
to
\p_strc_pagenumbers_width
{
\hss\box
\scratchbox
}
%
787
\fi
788
\fi
789
\endgroup
}
790 791
\strc_pagenumbers_set_location
% initializes
792 793
\newbox
\b_page_layouts_element
794 795
\def
\page_layouts_insert_elements
796
{
\ifcase
\pageornamentstate
797
\page_layouts_place_elements_indeed
% we could have a special flag for always ignored
798
\fi
}
799 800
\def
\page_layouts_place_elements_indeed
801
{
\setbox
\b_page_layouts_element
\vpack
802
{
\dontcomplain
803
\calculatereducedvsizes
804
\swapmargins
805
\offinterlineskip
806
\vkern
\dimexpr
-
\topheight
-
\topdistance
\relax
807
\the
\toptextcontent
808
\vkern
\dimexpr
\topheight
+
\topdistance
\relax
809
\the
\headertextcontent
810
\vkern
\dimexpr
\headerheight
+
\headerdistance
+
\textdistance
\relax
811
\anch_positions_place_anchors
812
\vkern
\dimexpr
-
\textdistance
-
\textheight
\relax
813
\the
\texttextcontent
814
\vkern
\textheight
815
\the
\everyendoftextbody
816
\vkern
\footerdistance
817
\the
\footertextcontent
818
\vkern
\dimexpr
\footerheight
+
\bottomdistance
\relax
819
\the
\bottomtextcontent
820
\vkern
\bottomheight
821
\vfilll
}
%
822
\smashbox
\b_page_layouts_element
823
\box
\b_page_layouts_element
}
824 825
% \ifdefined\page_prepare_backgrounds\else
826
% \let\page_prepare_backgrounds\gobbleoneargument
827
% \fi
828 829
% only for very special controlled cases or experiments:
830 831
\let
\page_scale_text_box
\gobbleoneargument
832 833
\def
\page_insert_body
#
1
#
2
%
834
{
\setbox
\b_page_layouts_element
\vpack
835
{
\offinterlineskip
836
\calculatereducedvsizes
837
\calculatehsizes
838
\swapmargins
839
\vkern
\dimexpr
\headerheight
+
\headerdistance
+
\textdistance
\relax
840
\dontleavehmode
841
%\page_prepare_backgrounds{#2}%
842
\hpack
to
\makeupwidth
843
{
\begingroup
844
\swapmargins
845
\goleftonpage
846
\ifdim
\leftedgewidth
>
\zeropoint
847
\the
\leftedgetextcontent
848
\kern\dimexpr
\leftedgewidth
+
\leftedgedistance
\relax
849
\fi
850
\ifdim
\leftmarginwidth
>
\zeropoint
851
\the
\leftmargintextcontent
852
\kern\dimexpr
\leftmarginwidth
+
\leftmargindistance
\relax
853
\fi
854
\endgroup
855
\page_apply_postprocessors_page
{
#
2
}
%
856
\settextpagecontent
\b_page_layouts_element
{
#
1
}{
#
2
}
%
857
\page_backgrounds_add_to_text
\b_page_layouts_element
858
\page_grids_add_to_box
\b_page_layouts_element
859
\page_scale_text_box
\b_page_layouts_element
860
\box
\b_page_layouts_element
861
\begingroup
862
\ifdim
\rightmarginwidth
>
\zeropoint
863
\kern
\rightmargindistance
864
\the
\rightmargintextcontent
865
\kern
\rightmarginwidth
866
\fi
867
\ifdim
\rightedgewidth
>
\zeropoint
868
\kern
\rightedgedistance
869
\the
\rightedgetextcontent
870
\kern
\rightedgewidth
871
\fi
872
\endgroup
873
\hss
}}
%
874
\smashbox
\b_page_layouts_element
875
\box
\b_page_layouts_element
}
876 877
%D The main text area has to be combined with some additional (tracing) information.
878
%D
879
%D This will be stored as normal and overloaded in page-lyr and later in page-spr we
880
%D overload the the stored version .. evenatually i will clear up the experimental
881
%D mess.
882 883
\def
\settextpagecontent
#
1
#
2
#
3
% #2 and #3 will disappear / is overloaded
884
{
\setbox
#
1
\hpack
to
\makeupwidth
885
{
\hss
% so don't change this
886
\setlayoutcomponentattribute
{
\v!page
:
\v!text
}
%
887
\vpack
\layoutcomponentboxattribute
to
\textheight
888
{
\offinterlineskip
889
\freezetextwidth
890
\hsize
\textwidth
% local variant of \sethsize <<< in columns?
891
\boxmaxdepth\maxdepth
892
\noindent
% content can be < \hsize
893
\page_otr_command_package_contents
#
2
#
3
}
% this will vbox
894
\hss
}
%
895
\dp
#
1
\zeropoint
}
896 897
\protect
\endinput
898