ma-cb-style.tex /size: 16 Kb    last modification: 2020-07-01 14:35
1% macros=mkvi
2
3\startenvironment ma-cb-style
4
5\usemodule[chart]
6
7\usemodule[s][abr-03]
8\usemodule[x][set-11]
9
10\unprotect
11
12% Setups are kind of special.
13
14% \loadsetups[cont-\currentmainlanguage.xml]
15
16\loadsetups[i-context]
17
18\setupsetup
19  [\c!criterium=\v!used]
20
21\setupframedtexts
22  [setuptext]
23  [\c!before={\blank[\v!big]},
24   \c!after={\blank[\v!big]},
25   \c!background=setup-shape,
26   \c!backgroundoffset=10pt,
27   \c!rulethickness=5pt,
28   \c!offset=15pt,
29   \c!frame=\v!off]
30
31\setupexternalfigures
32  [\c!directory={../graphics}]
33
34% The layout dimensions are based on the A4 paper dimensions because that way users
35% can print this manual themselves. Let's be economical with paper. We also assume a
36% decent doublesided A4 printer. We use equal margins so that a single sided run or
37% print also comes out all right.
38
39\setuplayout
40  [\c!backspace=22.5mm,
41   \c!width=\v!fit,
42   \c!cutspace=22.5mm,
43   \c!margin=20mm,
44   \c!margindistance=5mm,
45   \c!topspace=15mm,
46   \c!header=10mm,
47   \c!headerdistance=5mm,
48   \c!height=\v!fit,
49   \c!footerdistance=5mm,
50   \c!footer=15mm,
51   \c!bottomspace=15mm]
52
53\setuppagenumbering
54  [\c!alternative=\v!doublesided]
55
56% The lucida fonts look a bit more informal.
57
58\doifmodeelse {atpragma} {
59    \setupbodyfont[lucidaot,10pt]
60} {
61    \setupbodyfont[palatino,10pt]
62}
63
64% All colors will go here.
65
66% todo
67
68% Let's keep the text compact.
69
70\setupwhitespace
71  [\v!medium]
72
73\setupblank
74  [\v!medium]
75
76% We indent verbatim with the default indenting value.
77
78\setuptyping
79  [\c!margin=\v!standard,
80   \c!blank=\v!medium]
81
82% Manuals as usual need a bit more tolerance, because a lot of in||line verbatim is
83% used.
84
85\setuptolerance
86  [\v!verytolerant,\v!stretch]
87
88% This manual makes heavy use of backgrounds. During a run about many metaclips are
89% generated.
90
91\defineoverlay [chapter-state]     [\uniqueMPpagegraphic{chapter-state}]
92\defineoverlay [pagenumber-state]  [\uniqueMPgraphic{pagenumber-state}]
93
94\defineoverlay [basic-shape-light] [\useMPgraphic{basic-shape-light}]
95\defineoverlay [basic-shape-dark]  [\useMPgraphic{basic-shape-dark}]
96
97\defineoverlay [setup-shape]       [\useMPgraphic{setup-shape}]
98\defineoverlay [note-rule]         [\uniqueMPgraphic{note-rule}]
99\defineoverlay [column-rule]       [\uniqueMPgraphic{column-rule}]
100
101% \defineoverlay
102%   [MenuAchtergrond]
103%   [\MPclipTwoA{\overlaywidth}{\overlayheight}{3pt}{3pt}{red}{white}]
104
105\starttexdefinition unexpanded FootnoteRule
106    \blank[2*\v!big]
107    \framed
108        [\c!background=note-rule,
109         \c!width=.4\makeupwidth,
110         \c!height=2pt,
111         \c!offset=\v!overlay,
112         \c!rulethickness=2pt,
113         \c!frame=\v!off]
114        {}
115    \blank[\v!small]
116\stoptexdefinition
117
118\setupfootnotes
119  [\c!rule=off,
120   \c!before=\FootnoteRule]
121
122% Chapter titles have a fancy shape around them. Because we have a lot of small
123% chapters, we don't go to a new page. Titles look the same, but there we go to
124% a new page.
125
126\setuphead
127  [\v!chapter]
128  [\c!command=\HeadCommand,
129   \c!page=,
130   \c!before={\blank[3*\v!big]},
131   \c!after={\blank[2*\v!big,\v!samepage]}]
132
133\setuphead
134  [\v!title]
135  [\c!page=\v!right]
136
137\starttexdefinition unexpanded HeadCommand #number #title
138    \alignedline {\v!outer} {\v!left} {
139        \framed [
140            \c!background=basic-shape-dark,
141            \c!rulethickness=10pt,
142            \c!frame=\v!off,
143            \c!strut=\v!no,
144            \c!offset=24pt,
145            \c!align=\v!middle
146        ] {
147            \doifmode {*\v!sectionnumber} {
148                #number
149                \kern.5em
150                \blackrule [
151                    color=green,
152                    width=1pt,
153                    height=1.5\ht\strutbox,
154                    depth=1.25\dp\strutbox
155                ]
156                \kern.5em
157            }
158            #title
159        }
160    }
161\stoptexdefinition
162
163% The current chapter number is typeset in the (outer) margin and slowly moves
164% down. We could have directly put it in the margin but using the footermargin as
165% starting point works better. This is an old command and there is no reason to
166% change the definition to more fabce MkIV version.
167
168\setupfootertexts
169  [\v!margin]
170  [][\fastsetup{chapterindicator}]
171
172\startsetups chapterindicator
173    \determineheadnumber[\v!chapter]
174    \ifcase\currentheadnumber\else
175        \vbox to \makeupheight {
176            \scratchcounter=\numexpr\lastpage-\realpageno\relax
177            \vskip2cm
178            \vskip0pt plus \realpageno cm
179            \framed [
180                \c!background=chapter-state,
181                \c!width=36pt,
182                \c!height=72pt,
183                \c!backgroundoffset=5pt,
184               %\c!align={\v!lohi,\v!middle},
185                \c!frame=\v!off
186            ] {
187                \lower.5\dp\strutbox\hbox {
188                    \bfb
189                    \getmarking[\v!chapter\v!number]
190                }
191            }
192            \vskip0pt plus \scratchcounter cm
193            \vskip2cm
194        }
195   \fi
196\stopsetups
197
198% The index is put on a double collumned grid. The numbers is surrounded by a
199% shape.
200
201\setupregister
202  [\v!index]
203  [\c!command=\IndexCommand,
204   \c!before={\blank[\v!line]},
205   \c!after=]
206
207\starttexdefinition unexpanded IndexCommand #text
208    \framed [
209        \c!background=basic-shape-dark,
210        \c!width=36pt,
211        \c!frame=\v!off,
212        \c!offset=4pt,
213        \c!align=\v!middle,
214        \c!rulethickness=4pt
215    ] {
216        #text
217    }
218\stoptexdefinition
219
220% When bound, we use a double sided layout and put the pagenumber in the margin,
221% enhanced by a fancy background.
222
223\setuppagenumbering
224  [\c!location={\v!footer,\v!middle},
225   \c!command=\PageNumberCommand]
226
227\starttexdefinition unexpanded PageNumberCommand #pagenumber
228    \framed [
229        \c!background=pagenumber-state,
230        \c!backgroundoffset=5pt,
231        \c!frame=\v!off,
232        \c!offset=6pt
233    ] {
234        \lower.5\dp\strutbox\hbox spread 60pt {
235            \hss
236            #pagenumber
237            \hss
238        }
239    }
240\stoptexdefinition
241
242% We put the chapter title in the head. If we wouldn't have to center, the more
243% simple setting would be:
244
245\setupheadertexts
246  [{\getmarking[\v!chapter]}]
247
248% Guess what the next one does.
249
250\setupitemgroup
251  [\v!itemize]
252  [1]
253  [\v!autointro]
254
255% The coverpage looks more complex than it is. We can reuse it.
256
257\newbox\CoverBackgroundBox % reuse saves .8 sec, could be an object!
258
259\definebodyfontenvironment[1.9pt]
260
261\defineframed
262  [CoverFramed]
263  [%\c!foregroundstyle=\CoverFont,
264   \c!background=basic-shape-dark,
265   \c!backgroundoffset=1pt,
266   \c!rulethickness=2pt,
267   \c!frame=\v!off]
268
269\starttexdefinition unexpanded ShowSetupOnCover #n #tag #xmlroot
270    \dontleavehmode
271    \CoverFramed {
272        \tttf\showsetupnameonly{#1}{#2}{#3}
273    }
274    \kern\zeropoint
275    \hskip1em plus 1em minus .25em\relax
276\stoptexdefinition
277
278\definecolor[CoverTransparency][a=1,t=.5]
279
280\startsetups coverbackground
281
282    \ifvoid\CoverBackgroundBox
283
284        \global\setbox\CoverBackgroundBox
285            \startnicelyfilledbox
286                [\c!width=\paperwidth,
287                 \c!height=\paperheight,
288%                  \c!offset=\exheight,
289%                  \c!offset=\emwidth,
290                 \c!offset=\zeropoint,
291                 \c!strut=\v!no]
292                \switchtobodyfont
293                    [1.9pt]
294                \starttransparent[CoverTransparency]
295                \placelistofsorts
296                    [texcommand]
297                    [\c!command=\ShowSetupOnCover,
298                     \c!criterium=\v!all]% used
299                \stoptransparent
300            \stopnicelyfilledbox
301
302   \fi
303
304   \copy\CoverBackgroundBox
305
306\stopsetups
307
308\defineoverlay[coverbackground][\setups{coverbackground}]
309
310\setupdocument
311  [author={Ton Otten\crlf PRAGMA ADE},
312   translator=,
313   contributer=,
314   before=\setups{coverpage},
315   after=\setups{backpage}]
316
317\defineoverlay[gotocontents][\overlaybutton{contents}]
318
319\startsetups coverpage
320
321    \setupbackgrounds
322        [\v!rightpage]
323        [\c!background=coverbackground]
324
325    \setupbackgrounds
326        [\v!text]
327        [\v!text]
328        [\c!background=gotocontents]
329
330    \startmakeup
331        [\v!standard]
332        [\c!doublesided=\v!empty,
333         \c!headerstate=\v!none,
334         \c!footerstate=\v!none]
335
336        \hbox to \hsize \bgroup
337            \hss
338           %\definedfont[SansBold*default at 40pt]
339            \definedfont[Bold*default at 40pt]
340            \framed
341                [\c!background=basic-shape-dark,
342                 \c!frame=\v!off,
343                 \c!rulethickness=30pt,
344                 \c!align=\v!middle,
345                 \c!offset=40pt]
346                {\dontleavehmode\hbox{\documentvariable{title}}\par
347                 \dontleavehmode\hbox{\documentvariable{subtitle}}}
348        \egroup
349
350        \vfill
351
352        \doifsomething {\documentvariable{subtitle}} {
353
354            \hbox to \hsize \bgroup
355               %\definedfont[SansBold*default at 20pt]
356                \definedfont[Bold*default at 20pt]
357                \framed
358                    [\c!background=basic-shape-dark,
359                     \c!frame=\v!off,
360                     \c!rulethickness=15pt,
361                     \c!align=\v!middle,
362                     \c!offset=20pt]
363                    {\documentvariable{version}}
364                \hss
365            \egroup
366
367        }
368
369        \hbox to \hsize \bgroup
370            \hss
371           %\definedfont[SansBold*default at 24pt]
372            \definedfont[Bold*default at 24pt]
373            \framed
374                [\c!background=basic-shape-dark,
375                 \c!frame=\v!off,
376                 \c!rulethickness=18pt,
377                 \c!align=\v!middle,
378                 \c!offset=35pt]
379                {\documentvariable{author}}
380        \egroup
381
382    \stopmakeup
383
384    \setupbackgrounds
385        [\v!text]
386        [\v!text]
387        [\c!background=]
388
389    \setupbackgrounds
390        [\v!rightpage]
391        [\c!background=]
392
393    \doifmode {screen} {
394
395        \setupbackgrounds
396            [\v!page]
397            [\c!background=\v!screen,
398             \c!backgroundscreen=.95]
399
400        \setupbackgrounds
401            [\v!text]
402            [\v!text]
403            [\c!backgroundoffset=.25cm,
404             \c!depth=.125cm,
405             \c!background=\v!color,
406             \c!backgroundcolor=white]
407
408    }
409
410    \component[ma-cb-copyright]
411
412\stopsetups
413
414% The backpage uses the same background and overlays a piece of text.
415
416\startsetups backpage
417
418    \page
419      [\v!yes,\v!blank,\v!right]
420
421    \component[ma-cb-colofon]
422
423    \page
424        [\v!yes,\v!blank,\v!left]
425
426    \setupbackgrounds
427        [\v!leftpage]
428        [\c!background=coverbackground]
429
430    \startmakeup
431        [\v!standard]
432        [\c!page=,
433         \c!doublesided=\v!no,
434         \c!headerstate=\v!none,
435         \c!footerstate=\v!none]
436
437        \setuptolerance
438            [\v!verytolerant]
439
440        \vfill
441
442        \hbox to \hsize \bgroup
443
444            \framed
445                [\c!background=\v!color,
446                 \c!backgroundcolor=white,
447                 \c!frame=\v!off,
448                 \c!offset=10pt,
449                 \c!corner=\v!round,
450                 \c!width=.4\makeupwidth,
451                 \c!height=\textheight,
452                 \c!align=\v!middle,
453                 \c!strut=\v!no]
454            {
455                \vfil
456                \component[ma-cb-en-backpage]
457                \vfil
458            }
459
460            \hss
461
462        \egroup
463
464        \vfill
465
466    \stopmakeup
467
468\stopsetups
469
470% To save space we don't start chapters on a new page, except in appendices and the
471% introduction. These settings happen in dedicated setups sections (see later). We
472% also add some white space between table of content entries.
473
474\setupsectionblock [\v!frontpart] [\c!page=\v!right,\c!before=\setups{frontpart}]
475\setupsectionblock [\v!bodypart]  [\c!page=\v!right,\c!before=\setups{bodypart}]
476\setupsectionblock [\v!appendix]  [\c!page=\v!right,\c!before=\setups{appendix}]
477\setupsectionblock [\v!backpart]  [\c!page=\v!right,\c!before=\setups{backpart}]
478
479\setuplist
480  [\v!chapter]
481  [\c!criterium=\v!all,
482   \c!before=,
483   \c!after=]
484
485\startsetups frontpart
486
487    \setuphead[\v!chapter][\c!page=\v!right]
488
489    \writebetweenlist[\v!chapter]{\blank}
490
491    \startnamedsection[\v!chapter][\c!title=\labeltext{document:contents}]
492
493        \startmixedcolumns[documentcolumns]
494            \placelist[\v!chapter]
495        \stopmixedcolumns
496
497    \stopnamedsection
498
499    \page[\v!right]
500
501\stopsetups
502
503\startsetups bodypart
504
505    \setuphead[\v!chapter][\c!page=]
506
507    \writebetweenlist[\v!chapter]{\blank}
508
509\stopsetups
510
511\startsetups appendix
512
513    \setuphead[\v!chapter][\c!page=\v!right]
514
515    \writebetweenlist[\v!chapter]{\blank}
516
517    \startnamedsection[\v!chapter][\c!title=\labeltext{document:commanddefinitions},\c!reference=commandsetups]
518
519        \component[ma-cb-\currentmainlanguage-commandlist]
520
521        \blank[2*\v!big]
522
523        \start
524
525            \switchtobodyfont[8pt]
526
527            % somehow \blank doesn't work here
528
529            \setupframedtexts
530              [setuptext]
531              [\c!before={\vskip6pt},
532               \c!after={\vskip6pt}]
533
534          % \startmixedcolumns[documentcolumns]
535                \placelistofsorts[texcommand]
536          % \stopmixedcolumns
537
538        \stop
539
540    \stopnamedsection
541
542    \startnamedsection[\v!chapter][\c!title=\labeltext{document:commandindex}]
543
544        \startmixedcolumns[documentcolumns]
545            \placeregister[Command]
546        \stopmixedcolumns
547
548    \stopnamedsection
549
550    \startnamedsection[\v!chapter][\c!title=\labeltext{document:subjectindex}]
551
552        \startmixedcolumns[documentcolumns]
553            \placeregister[\v!index]
554        \stopmixedcolumns
555
556    \stopnamedsection
557
558    \startnamedsection[\v!chapter][\c!title=\labeltext{document:supportandreading}]
559
560        \index{support}
561
562        \startnamedsection[\v!section][\c!title=\labeltext{document:support}]
563
564            \component[ma-cb-\currentmainlanguage-support]
565
566        \stopnamedsection
567
568        \startnamedsection[\v!section][\c!title=\labeltext{document:manuals}]
569
570            % this will be done from a bib file
571
572            \startlines
573               \goto {Chemical Formulas in \CONTEXT} [ url (manual:chemic-ex)   ]
574               \goto {Color Separation}              [ url (manual:color)       ]
575               \goto {Columns}                       [ url (manual:columns)     ]
576               \goto {\CONTEXT, the manual}          [ url (manual:context)     ]
577               \goto {Dealing with \XML}             [ url (manual:xml)         ]
578               \goto {Extreme Tables}                [ url (manual:extab)       ]
579               \goto {Figures}                       [ url (manual:figures)     ]
580               \goto {Fonts in \CONTEXT}             [ url (manual:fonts)       ]
581               \goto {luatools, mtxrun, context}     [ url (manual:tools)       ]
582               \goto {\METAFUN\ manual}              [ url (manual:metafun)     ]
583               \goto {Natural Tables}                [ url (manual:nattab)      ]
584               \goto {\PPCHTEX\ Manual}              [ url (manual:chemic)      ]
585               \goto {Quick Reference (dutch)}       [ url (manual:qr-nl)       ]
586               \goto {Quick Reference (english)}     [ url (manual:qr-en)       ]
587               \goto {\SCITE\ in \CONTEXT}           [ url (manual:scite)       ]
588               \goto {Units}                         [ url (manual:units)       ]
589               \goto {Widgets}                       [ url (manual:widgets)     ]
590            \stoplines
591
592        \stopnamedsection
593
594        \startnamedsection[\v!section][\c!title=\labeltext{document:magazines}]
595
596            % this will be done from a bib file
597
598            \startlines
599                \goto {\CONTEXT\ Magazine 1103}      [ url (thisway:crossrefs)  ]
600                \goto {Project structure}            [ url (thisway:proj-struc) ]
601            \stoplines
602
603        \stopnamedsection
604
605    \stopnamedsection
606
607\stopsetups
608
609\startsetups backpart
610
611    \setuphead[\v!chapter][\c!page=\v!right]
612
613    \writebetweenlist[\v!chapter]{\blank}
614
615\stopsetups
616
617% In normal documents one will never find awful things like below. Because we want
618% an international setup, we just call the chapters in an indirect way.
619
620% We draw a nice line between columns. The next command does the job. Of course a
621% normal line can be set more easily, but here we hook in a command.
622
623\installmixedcolumnseparator{ColumnRule}%
624  {\framed
625     [\c!background=column-rule,
626      \c!height=\mixedcolumnseparatorheight,
627      \c!depth=\mixedcolumnseparatordepth,
628      \c!width=\mixedcolumnseparatorwidth,
629      \c!offset=\v!overlay,
630      \c!rulethickness=2pt,
631      \c!frame=\v!off]
632     {}}
633
634% alternative implemenation
635%
636% \installmixedcolumnseparator{ColumnRule}%
637%   {\lower\mixedcolumnseparatordepth\hbox{\uniqueMPgraphic
638%      {column-rule}%
639%      {height=\the\dimexpr\mixedcolumnseparatorheight+\mixedcolumnseparatordepth,linewidth=2pt}}}
640
641\setupmixedcolumns
642  [\c!n=2,
643   \c!distance=36pt,
644   \c!separator=ColumnRule]
645
646\definemixedcolumns
647  [documentcolumns]
648  [\c!n=2,
649   \c!distance=36pt,
650   \c!separator=ColumnRule]
651
652\defineregister
653  [Command]
654
655\setupregister
656  [Command]
657  [\c!indicator=\v!off,
658   \c!before={\blank[\v!line]}]
659
660\protect
661
662\stopenvironment
663