1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
%D \module
%D [ file=page-one,
%D version=2000.10.20,
%D title=\CONTEXT\ Page Macros,
%D subtitle=Default Routine,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\writestatus{loading}{ConTeXt Page Macros / Default Routine}
%D This is just the good old \CONTEXT\ output routine, which
%D has been there right from the start.
\unprotect
% OTRONE: basic single column
\activateotr{ONE}{} % the default one
\newtoks\OTRONEoutput
\def\OTRONEgotonextpage
{\ejectpage}
\def\OTRONEgotonextpageX % will become obsolete
{\superejectpage}
\def\OTRONEsethsize
{\global\hsize\textwidth}
% keep (original one)
%
% \def\OTRONEsetvsize
% {\ifdim\vsize=\teksthoogte \else
% \bgroup
% \scratchdimen-\vsize
% \advance\scratchdimen \teksthoogte
% \global\advance\vsize \scratchdimen
% \relax \ifdim\pagegoal<\maxdimen
% \advance\scratchdimen \pagegoal
% \global\pagegoal\scratchdimen
% \fi
% \egroup
% \fi}
%
% no (keep)
%
% \def\OTRONEsetvsize
% {\ifdim\vsize=\teksthoogte \else
% \bgroup
% \scratchdimen-\vsize
% \advance\scratchdimen \teksthoogte
% \ifgridsnapping
% \getrawnoflines\scratchdimen
% \scratchdimen\noflines\openlineheight
% \ifdim\scratchdimen>\noflinesheight % available afterwards
% \advance\scratchdimen-\openlineheight
% \fi
% \ifdim\scratchdimen<\zeropoint
% \scratchdimen\zeropoint
% \fi
% \fi
% \global\advance\vsize \scratchdimen
% \relax \ifdim\pagegoal<\maxdimen
% \advance\scratchdimen \pagegoal
% \global\pagegoal\scratchdimen
% \fi
% \egroup
% \fi}
% \def\OTRONEsetvsize
% {\ifgridsnapping
% \ifcase\layoutlines
% \getrawnoflines\teksthoogte
% \else
% \noflines\layoutlines
% \fi
% \global\vsize\noflines\openlineheight
% \else
% \global\vsize\teksthoogte
% \fi
% \ifdim\pagegoal<\maxdimen
% \global\pagegoal\vsize
% \fi}
\newdimen\oldvsize
\def\OTRONEsetvsize
{\ifgridsnapping
\ifcase\layoutlines
\getrawnoflines\textheight
\else
\noflines\layoutlines
\fi
\global\vsize\noflines\openlineheight
\else
\global\vsize\textheight
\fi
\ifdim\pagegoal<\maxdimen
\ifdim\oldvsize=\vsize
% let's assume that the layout didn't change
\else
\bgroup
\global\oldvsize\vsize
\advance\vsize-\topinserted
\advance\vsize-\botinserted
\global\pagegoal\vsize
\egroup
\fi
\fi}
\chardef\kindofpagetextareas=2 % whole page (public variable! never change)
\def\OTRONEregisteredtextarea#1%
{\ifregistertextareas
\setbox0\vbox{#1}%
\wd0\makeupwidth % somehow a space creeps in
\vbox{\registeredtextarea000}%
\else
#1%
\fi}
% \chardef\kindofpagetextareas\plusone
\def\doOTRONEregisteredtextareaA#1%
{\ifregistertextareas
\xypos{pbd:\realfolio:b}% we could save bytes by only saving the y
\endgraf
\begingroup
\scratchdimen\MPy{pbd:\realfolio:b}%
\advance\scratchdimen-\MPy{pbd:\realfolio:e}%
\setbox\scratchbox\null
\wd\scratchbox\makeupwidth
\ht\scratchbox\scratchdimen
\vsmash{\registeredtextarea00\scratchbox}%
\endgroup
#1%
\endgraf
\xypos{pbd:\realfolio:e}%
\else
#1%
\fi}
\def\doOTRONEregisteredtextareaB#1%
{\ifregistertextareas
\setbox0\vbox{#1}%
\wd0\makeupwidth % somehow a space creeps in
\vbox{\registeredtextarea000}%
\else
#1%
\fi}
\let\OTRONEregisteredtextareaA\firstofoneargument
\let\OTRONEregisteredtextareaB\firstofoneargument
\def\OTRONEdopagecontents#1#2% \box<n> \unvbox<n>
{\bgroup % niet breedte zetten, kan fractie zijn!
\ifcase\kindofpagetextareas
\or % partial page (experimental)
\let\OTRONEregisteredtextareaA\doOTRONEregisteredtextareaA
\or % whole page (default)
\let\OTRONEregisteredtextareaB\doOTRONEregisteredtextareaB
\or % partial page (only works well with no stretch!)
\let\OTRONEregisteredtextareaA\doOTRONEregisteredtextareaB
\fi
\setbox0\vbox \ifbottomnotes to \textheight \fi
{\edef\currentpagedepth{\the\dp#2}% still to be derived from #1
\dotopinsertions
\ifgridsnapping
\OTRONEregisteredtextareaA{#1#2}%
\vskip-\currentpagedepth\vskip\openstrutdepth
\pushproperties % moved from just after #1#2
\prevdepth\openstrutdepth
\dobotinsertions
\vfil
\else\ifr@ggedbottom
\OTRONEregisteredtextareaA{#1#2}%
\vskip-\currentpagedepth\vskip\openstrutdepth
\pushproperties % moved from just after #1#2
\prevdepth\openstrutdepth
\dobotinsertions
\vfil
\else\ifb@selinebottom
\OTRONEregisteredtextareaA{#1#2}%
\kern-\currentpagedepth\kern\maxdepth
\pushproperties % moved from just after #1#2
\dobotinsertions
\else
\OTRONEregisteredtextareaA{#1#2}%
\pushproperties % moved from just after #1#2
\dobotinsertions % added
\fi\fi\fi
\fakepagenotes}% was \fakenotes, but wrong! (check with \setupalign[height])
\ifbottomnotes
\ifgridsnapping
\ifcase\layoutlines % todo: make macro of this
\getrawnoflines\textheight
\else
\noflines\layoutlines
\fi
% \getnoflines\textheight
\advance\noflines \minusone
\scratchdimen\noflines\lineheight
\advance\scratchdimen \topskip
\else
\scratchdimen\ht0
\fi
\else
\scratchdimen\zeropoint
\fi
\setbox2\hbox
{\checksinglecolumnfootnotes
\lower\scratchdimen\vbox{\placebottomnotes}}%
\smashbox2% % needed here
\ifbottomnotes
\ht0\zeropoint
\fi
\OTRONEregisteredtextareaB
{\vbox to \textheight
{\box0\box2\ifbottomnotes\else\vfill\fi}}%
\egroup}
\def\OTRONEfinalsidefloatoutput
{\finaloutput\unvbox\normalpagebox}
\OTRONEoutput
{\sidefloatoutput}
%D Insertions
\newif\iftopofinsert
% \def\OTRONEdosettopinserts
% {\bgroup
% \ifsomefloatwaiting
% \noffloatinserts\zerocount
% \let\totaltopinserted\!!zeropoint
% \OTRONEdodosettopinserts
% \ifnum\@@bknbottom=\zerocount
% \ifnum\@@bknlines>\zerocount
% \ifdim\totaltopinserted>\zeropoint\relax
% \dimen0=\lineheight
% \dimen0=\@@bknlines\dimen0
% \advance\dimen0 \totaltopinserted\relax
% \ifdim\dimen0>\textheight
% \showmessage\m!floatblocks8\@@bknlines
% \vfilll\eject
% \fi
% \fi
% \fi
% \fi
% \fi
% \egroup}
\def\OTRONEdosettopinserts
{\bgroup
\ifsomefloatwaiting
\noffloatinserts\zerocount
\let\totaltopinserted\!!zeropoint
\OTRONEdodosettopinserts
\ifnum\@@bknbottom=\zerocount
\ifnum\@@bknlines>\zerocount
\ifdim\totaltopinserted>\zeropoint\relax
\ifdim\dimexpr\@@bknlines\lineheight+\totaltopinserted\relax>\textheight
\showmessage\m!floatblocks8\@@bknlines
\vfilll\eject
\fi
\fi
\fi
\fi
\fi
\egroup}
\def\OTRONEdodosettopinserts
{\ifnum\noffloatinserts<\noftopfloats
\dogetfloat
\ifdim\topinserted=\zeropoint
\topofinserttrue
\else
\topofinsertfalse
\fi
\global\advance\topinserted\dimexpr\ht\floatbox+\dp\floatbox+\floatbottomskip\relax
\ifdim\topinserted<\textheight\relax
\xdef\totaltopinserted{\the\topinserted}%
\insert\topins
{\forgetall
\iftopofinsert
\topskipcorrection % [xx] new: see icare topbleed
\kern-\lineskip\par
\prevdepth\maxdimen
\else
%\blank[-\@@bkspaceafter,\@@bkspacebefore]% inserts can't look back
\betweenfloatblanko
\fi
\flushfloatbox
\blank[\@@bkspaceafter]}%
\ifsomefloatwaiting
\advance\noffloatinserts \plusone
\else
\noffloatinserts\noftopfloats\relax
\fi
\dofloatflushedinfo
\else
\doresavefloat
\noffloatinserts\noftopfloats\relax
\fi
\else
\ifsomefloatwaiting
\showmessage\m!floatblocks6{\the\noftopfloats}%
\fi
\let\OTRONEdodosettopinserts\relax
\fi
\OTRONEdodosettopinserts}
\def\OTRONEdosetbotinserts
{\bgroup
\ifsomefloatwaiting
\noffloatinserts\zerocount
\OTRONEdodosetbotinserts
\fi
\egroup}
\def\OTRONEdodosetbotinserts
{\ifnum\noffloatinserts<\nofbotfloats\relax
\dogetfloat
\global\advance\botinserted \ht\floatbox\relax
\global\advance\botinserted \dp\floatbox\relax
\global\advance\botinserted \floattopskip\relax
\ifdim\botinserted<\pagegoal\relax
\insert\botins
{\forgetall
\blank[\@@bkspacebefore]%
\flushfloatbox}%
\ifsomefloatwaiting
\advance\noffloatinserts \plusone
\else
\noffloatinserts\nofbotfloats
\fi
\dofloatflushedinfo
\else
\doresavefloat
\noffloatinserts\nofbotfloats\relax
\fi
\global\nofloatpermittedtrue % vgl topfloats s!
\else
\ifsomefloatwaiting
\showmessage\m!floatblocks7{\the\nofbotfloats}%
\fi
\let\OTRONEdodosetbotinserts\relax
\fi
\OTRONEdodosetbotinserts}
\def\OTRONEdosetbothinserts
{\global\topinserted\zeropoint
\global\botinserted\zeropoint
\ifflushingfloats \else
\OTRONEdosettopinserts
\OTRONEdosetbotinserts
\ifsomefloatwaiting
\doif\@@bkcache\v!no\doflushfloats
\fi
\fi}
% \def\OTRONEdotopinsertions
% {\ifvoid\topins\else
% \ifgridsnapping
% \box\topins
% \vskip-\topskip \vskip\strutheight % [xx] new: see icare topbleed
% \else
% \unvbox\topins
% \fi
% \fi
% \global\topinserted\zeropoint}
\chardef\topinserttopskipmode=0 % 1 no topskip
\def\OTRONEdotopinsertions
{\ifvoid\topins\else
\ifgridsnapping
\box\topins
\vskip-\topskip
\vskip\strutheight % [xx] new: see icare topbleed
\else
\ifcase\topinserttopskipmode
% 0: default, do nothing
\or
% 1: no topskip (crossed fingers)
\vskip-\topskip
\vskip\strutheight
\fi
\unvbox\topins
\fi
\fi
\global\topinserted\zeropoint}
\def\OTRONEdobotinsertions
{\ifvoid\botins\else
\ifgridsnapping
\snaptogrid\hbox{\box\botins}%
\else
\unvbox\botins
\fi
\fi
\global\botinserted\zeropoint
\global\nofloatpermittedfalse}
\def\OTRONEdoflushfloats
{\global\flushingfloatstrue
\ifsomefloatwaiting
\par
% if kept, then option and definitely off in gridmode ! ! ! !
% \ifvmode \prevdepth\maxdimen \fi % prevents whitespace; problematic in icare tests
\OTRONEdodoflushfloats
\fi
\global\savednoffloats\zerocount
\global\somefloatwaitingfalse
\global\flushingfloatsfalse}
\def\OTRONEflushfloatbox % nog verder doorvoeren en meer info in marge
{\ifcenterfloatbox \ifdim\wd\floatbox<\hsize
\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
\fi \fi
\snaptogrid\hbox{\iftestfloatbox\ruledhbox\fi{\copy\floatbox}}}
\def\OTRONEdodoflushfloats % much in common with OTRSET
{\ifsomefloatwaiting
\ifpackflushedfloats
\centerfloatboxfalse
\dogetfloat
\ifdim\wd\floatbox>\makeupwidth
\global\setbox\floatbox\hbox to \makeupwidth{\hss\box\floatbox\hss}%
\fi
\OTRONEsetvsize
\!!widtha\wd\floatbox
\dofloatflushedinfo
\doloop
{\ifsomefloatwaiting
\dosavefloatstatus
\dogetfloat
\advance\!!widtha 1em % variable
\advance\!!widtha \wd\floatbox\relax
\ifdim\!!widtha>\hsize
\dorestorefloatstatus
\global\somefloatwaitingtrue
\exitloop
\else
\global\setbox\floatbox\hbox
{\ifcase\columndirection % nog document wide
\ifvoid\savedfloatbox\else
\ifhbox\savedfloatbox\unhbox\else\box\fi\savedfloatbox\hfil
\fi
\ifhbox\floatbox\unhbox\else\box\fi\floatbox
\else
\ifhbox\floatbox\unhbox\else\box\fi\floatbox
\ifvoid\savedfloatbox\else
\hfil\ifhbox\savedfloatbox\unhbox\else\box\fi\savedfloatbox
\fi
\fi}%
\dofloatflushedinfo
\fi
\else
\exitloop
\fi}%
\global\setbox\floatbox\hbox to \hsize
{\hfil\ifhbox\floatbox\unhbox\else\box\fi\floatbox\hfil}%
\else
%\bgroup % \box\floatbox can be in use!? messy
\dogetfloat
%\doplacefloatbox
%\egroup
\dofloatflushedinfo
\fi
% there is a chance that due to rounding errors, the float
% fits on a page where it was first rejected, in which case
% the prevdepth is -maxdimen and we cannot obey the grid
\doplacefloatbox
\expandafter\OTRONEdodoflushfloats
\fi}
\def\OTRONEdocheckiffloatfits % vervangen ivm downward comp
{\ifnofloatpermitted
\global\roomforfloatfalse
\else
% new per 31/5/2004, should be an option, only one column mode
\begingroup
\scratchdimen\dimexpr\pagetotal+\lineheight\relax
\ifdim\scratchdimen>\pagegoal
\goodbreak % hack ? needed in icare-az
\fi
% should be an option
\endgroup
\dimen0\dimexpr\pagetotal+\ht\floatbox+\dp\floatbox+\floattopskip-\pageshrink\relax
%\message{c:\the\mofcolumns,t:\the\pagetotal,g:\the\pagegoal}%\wait
\dimen2\pagegoal
\relax % needed
\ifcase\textfloatmethod
% method 0 : raw
\or
% method 1 : safe
\dimen2 .99\pagegoal
\or
% method 2 : tight
\advance\dimen0 -\onepoint
\fi
\relax % really needed ! ! ! !
\ifdim\dimen0>\dimen2
\global\roomforfloatfalse
\else
\global\roomforfloattrue
\fi
\fi}
\def\OTRONEflushsavedfloats
{\dosetbothinserts}
% TODO: TEST FIRST, NO CORRECTION NEEDED IN GRID MODE, EVT OPTION
\def\OTRONEsomeherefloat[#1]% spacing between two successive must be better
{\baselinecorrection % not really needed in grid mode:
%\ifgridsnapping \else \baselinecorrection \fi % ! ! ! test test test ! ! ! !
\doplacefloatbox
\doinsertfloatinfo
\dochecknextindentation\??bk
\dorechecknextindentation}
% \def\OTRONEsomefixdfloat % [#1]
% {\docheckiffloatfits
% \ifroomforfloat\else
% \goodbreak
% \fi
% \showmessage\m!floatblocks9\empty
% \someherefloat} % [#1]
%
% better:
%
% \dorecurse{50}
% {[before normal] \input thuan
% \placefigure{normal}{\framed[height=1cm,width=8cm]{}}
% \placefigure{normal}{\framed[height=2cm,width=8cm]{}}
% [before force] \input thuan
% \placefigure[force]{force}{\framed[height=8cm,width=8cm]{}}}
\chardef\fixedfloatmethod=3
% \def\OTRONEsomefixdfloat % [#1]
% {\docheckiffloatfits
% \ifroomforfloat\else
% \ifzeropt\pagetotal
% % let's assume that there is room
% \else
% \ifcase\fixedfloatmethod
% % disabled
% \or % 1 (old method)
% \goodbreak
% \or % 2 (safe method)
% \page
% \or % 3 (keeps in stream)
% \vskip\textheight
% \vskip-\textheight
% \or % 4 (also keeps in place)
% \dosomebreak\nobreak
% \fi
% \fi
% \fi
% \showmessage\m!floatblocks9\empty
% \someherefloat} % [#1]
\def\OTRONEsomefixdfloat % [#1]
{% there is (in mkii) no good way to prevent a break
% so better fail than mess, we can get loose from
% heads, so be it
\showmessage\m!floatblocks9\empty
\OTRONEsomeherefloat} % [#1]
\def\OTRONEsomesidefloat[#1]% links, rechts NOG TESTEN EN AANPASSEN
{\ifinsidecolumns
\someelsefloat[\v!here]%
\else
%\checkwaitingfloats{#1}%
\def\logsidefloat
{\doinsertfloatinfo}%
\setbox\floatbox\vbox{\box\floatbox}%
\wd\floatbox\floatwidth
\processfirstactioninset
[#1]
[ \v!left=>\leftfloat {\box\floatbox},
\v!right=>\rightfloat {\box\floatbox},
\v!inleft=>\leftmarginfloat {\box\floatbox},
\v!inright=>\rightmarginfloat{\box\floatbox},
\v!leftmargin=>\leftmarginfloat {\box\floatbox},
\v!rightmargin=>\rightmarginfloat{\box\floatbox},
\v!leftedge=>\leftedgefloat {\box\floatbox},
\v!rightedge=>\rightedgefloat {\box\floatbox},
\v!backspace=>\backspacefloat {\box\floatbox},
\v!cutspace=>\cutspacefloat {\box\floatbox},
\v!inmargin=>\cutspacefloat {\box\floatbox}]%
\doifinset\v!tall{#1}\flushsidefloatsafterpar
\fi}
\def\OTRONEdosomepagefloat#1[#2]%
{%\checkwaitingfloats{#1}%
\global\setbox#1\vbox
{\unvbox#1%
\vbox to \textheight
{\doifnotinset\v!high{#2}\vfill
\box\floatbox
\doifnotinset\v!low{#2}\vfill}%
\goodbreak}%
\doinsertfloatinfo}
\def\OTRONEsomepagefloat {\OTRONEdosomepagefloat\collectedpagefloats}
\def\OTRONEsomeleftpagefloat {\OTRONEdosomepagefloat\collectedleftpagefloats}
\def\OTRONEsomerightpagefloat{\OTRONEdosomepagefloat\collectedrightpagefloats}
\def\OTRONEsometopsfloat[#1]%
{\ifdim\topinserted=\zeropoint
\topofinserttrue
\else
\topofinsertfalse
\fi
\global\advance\topinserted \ht\floatbox
\global\advance\topinserted \dp\floatbox
\global\advance\topinserted \floatbottomskip
\insert\topins
{\forgetall
\iftopofinsert
\topskipcorrection % [xx] new: see icare topbleed
\kern-\lineskip\par\prevdepth\maxdimen
\else
%\blank[-\@@bkspaceafter,\@@bkspacebefore]% inserts can't look back
\betweenfloatblanko
\fi
\flushfloatbox
\blank[\@@bkspaceafter]}%
\doinsertfloatinfo}
\def\OTRONEsomebotsfloat[#1]%
{\global\advance\botinserted \ht\floatbox
\global\advance\botinserted \dp\floatbox
\global\advance\botinserted \floattopskip
\insert\botins
{\forgetall
\blank[\@@bkspacebefore]%
\flushfloatbox}%
%\global\nofloatpermittedtrue
\doinsertfloatinfo}
\def\OTRONEsomefacefloat[#1]% untested
{\startopposite\flushfloatbox\stopopposite}
\def\OTRONEnextcolumn[#1]%
{}
\protect \endinput
|