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