create context-beginner-vi project
[cuteobr.git] / ma-cb-style.tex
blobc58bcadc9df402b7675c6871bdf352c5b3ce0a8e
1 \startenvironment ma-cb-style
3 \def\GenericDir{../generic}
4 \setupexternalfigures[directory={\GenericDir}]
6 % The strange mix of english and dutch is due to the fact
7 % that much of the core of \CONTEXT\ is still dutch.
9 % Beware, this module looks awful. This is due to the fact
10 % that we use one setup for many interface languages and many
11 % alternative layouts. A single language setup looks much
12 % better and readible.
14 \usemodule[res-trace] % so that we know what graphics are used
16 \usemodule[units]
17 \usemodule[chemic]
18 \usemodule[chart]
20 \unprotect
22 % The layout dimensions are based on the A4 paper dimensions.
23 % That way users can print this manual themselves.
25 \setuplayout
26 [\c!backspace=3cm,
27 \c!margin=2cm,
28 \c!margindistance=.5cm,
29 \c!width=15cm,
30 \c!topspace=2cm,
31 \c!header=2cm,
32 \c!footer=2cm,
33 \c!height=25.7cm]
35 % There will be three versions:
37 % \startopsomming
38 % \som bound: the real paper one
39 % \som print: the user printable one
40 % \som screen: the interactive version
41 % \stopopsomming
43 % This mode mechanism is rather new but painfully simple.
45 \startmode[bound]
47 \setuplayout
48 [%\c!marking=\v!on,
49 %\c!scale=.8,
50 \c!location=\v!doublesided]
52 \stopmode
54 % The lucida fonts look a bit more informal.
56 \startmode[atpragma]
58 \usetypescriptfile[type-buy]
59 \usetypescript[lucida][texnansi]
60 \setupbodyfont[lucida,10pt]
62 \stopmode
64 \startnotmode[atpragma]
66 \usetypescriptfile[type-buy]
67 \usetypescript[palatino][\defaultencoding]
68 \setupbodyfont[palatino,10pt]
70 \stopnotmode
72 % We enable colors and define an aditional color, used in the
73 % chapter headings.
75 \setupcolors
76 [\c!state=\v!start]
78 % \doifmode{bound}
79 % {\setupcolors[\c!conversie=\v!altijd]}
81 \definecolor
82 [headrule][r=0,g=1,b=0]
84 % Let's keep the text compact.
86 \setupwhitespace
87 [\v!medium]
89 \setupblank
90 [\v!medium]
92 % We indent verbatim with the default indenting value.
94 \setuptyping
95 [\c!margin=\v!standard,
96 \c!blank=\v!medium]
98 % Manuals as usual need a bit more tolerance, because a lot
99 % of in||line verbatim is used.
101 \setuptolerance
102 [\v!verytolerant]
104 % This manual makes heavy use of backgrounds. During a run,
105 % about 800 metaclips are generated.
107 \defineoverlay
108 [KopAchtergrond]
109 [\MPclipOne{\overlaywidth}{\overlayheight}{10pt}{gray}{red}]
111 \defineoverlay
112 [MargeAchtergrond]
113 [\MPclipOne{\overlaywidth}{\overlayheight}{7.5pt}{gray}{red}]
115 \defineoverlay
116 [IndexAchtergrond]
117 [\MPclipOne{\overlaywidth}{\overlayheight}{5pt}{gray}{red}]
119 \defineoverlay
120 [StatusAchtergrondL]
121 [\MPclipFourL{\overlaywidth}{\overlayheight}{5pt}]
123 \defineoverlay
124 [StatusAchtergrondR]
125 [\MPclipFourR{\overlaywidth}{\overlayheight}{5pt}]
127 \defineoverlay
128 [TitelAchtergrond]
129 [\MPclipOne{\overlaywidth}{\overlayheight}{20pt}{gray}{red}]
131 \defineoverlay
132 [AuteurAchtergrond]
133 [\MPclipOne{\overlaywidth}{\overlayheight}{15pt}{gray}{red}]
135 \defineoverlay
136 [IntroAchtergrond]
137 [\MPclipOne{\overlaywidth}{\overlayheight}{5pt}{lightgray}{lightred}]
139 \defineoverlay
140 [MenuAchtergrond]
141 [\MPclipTwoA{\overlaywidth}{\overlayheight}{3pt}{3pt}{red}{white}]
143 \defineoverlay
144 [SetupAchtergrond]
145 [\MPclipTwoB{\overlaywidth}{\overlayheight}{5pt}{8pt}{blue}{lightgray}]
147 \defineoverlay
148 [NummerAchtergrond]
149 [\MPclipFive{\overlaywidth}{\overlayheight}{30pt}{5pt}]
151 \defineoverlay
152 [FiguurAchtergrond]
153 [\MPclipSeven{\overlaywidth}{\overlayheight}{2pt}]
155 % We precede footnotes by a nice line. Due to preprocessing
156 % this is a to be a 'use' graphic, not a 'resuse' one! When
157 % I got a more clearer vision of the concept, 'reused'
158 % graphics will be possible too. (The solution is rather
159 % simple, but sort of fuzzy.)
161 \unexpanded\def\VoetnootLijn
162 {\dimen0=.4\makeupwidth
163 \expanded{\MPclipThree{\the\dimen0}{2pt}}}
165 \setupfootnotes
166 [\c!rule=\VoetnootLijn]
168 % This looks ok, but in a manual like this, it is confusing.
170 % \starttypen
171 % \stelplaatsblokin
172 % [\v!figuur]
173 % [\c!background=FiguurAchtergrond,
174 % \c!frame=\v!off,\c!backgroundoffset=3pt]
175 % \stoptypen
177 % So, I decided to comment this one out.
179 % Chapter titles have a fancy shape around them. Because we
180 % have a lot of small chapters, we don't go to a new page.
182 \setuphead
183 [\v!chapter]
184 [\c!command=\HeadCommand,
185 \v!appendix\c!label=none,
186 \c!page=,
187 \c!before=\vskip36pt plus 6pt minus 6pt,
188 \c!after=\vskip24pt]
190 % Titles look the same, but here we go to a new page.
192 \setuphead
193 [\v!title]
194 [\c!command=\HeadCommand,
195 \c!page=\v!right,
196 \c!before=\vskip36pt plus 6pt minus 6pt,
197 \c!after=\vskip24pt]
199 % The next definition is not that complicated, once one knows
200 % a bit of \TEX. Watch the \type{\getpagestatus} and
201 % \type{\ifrightpage}.
203 % \def\HeadCommand#1#2%
204 % {\hbox to \hsize
205 % {\getpagestate
206 % \doifmodeelse{screen}
207 % {\hss}
208 % {\ifrightpage\hss\fi}%
209 % \framed
210 % [\c!background=KopAchtergrond,
211 % \c!width=\v!fit,
212 % \c!height=\v!fit,
213 % \c!frame=\v!off,
214 % \c!strut=\v!no,
215 % \c!offset=24pt,
216 % \c!align=\v!middle]
217 % {\doifmode{*sectionnumber}
218 % {#1\kern.5em% strut niet geset, zou wel moeten
219 % \hbox{\color[headrule]{\vrule\!!width1pt\!!height1.5\ht\strutbox\!!depth1.25\dp\strutbox}}%
220 % \kern.5em}%
221 % #2}%
222 % \doifmodeelse{screen}
223 % {\hss}
224 % {\ifrightpage\else\hss\fi}}}
226 \def\HeadCommand#1#2%
227 {\alignedline{\v!outer}{\v!left}
228 {\framed
229 [\c!background=KopAchtergrond,
230 \c!width=\v!fit,
231 \c!height=\v!fit,
232 \c!frame=\v!off,
233 \c!strut=\v!no,
234 \c!offset=24pt,
235 \c!align=\v!middle]
236 {\doifmode{*sectionnumber}
237 {#1\kern.5em% strut niet geset, zou wel moeten
238 \hbox{\color[headrule]{\vrule\!!width1pt\!!height1.5\ht\strutbox\!!depth1.25\dp\strutbox}}%
239 \kern.5em}%
240 #2}}}
242 % The current chapter number is typeset in the (outer) margin
243 % and slowly moves down. We could have directly put it in the
244 % margin but using the footermargin as starting point works
245 % better.
247 \setupfootertexts
248 [\v!margin]
249 [][\PlaatschapterStatus]
251 \unexpanded\def\PlaatschapterStatus
252 {\determineheadnumber[\v!chapter]%
253 \ifnum\currentheadnumber>0
254 \vbox to \makeupheight
255 {\scratchcounter=\lastpage
256 \advance\scratchcounter by -\realpageno
257 \vskip2cm
258 \vskip0pt plus \realpageno cm
259 \edef\StatusAchtergrond
260 {StatusAchtergrond%
261 % \ifodd\realpageno R\else\ifdubbelzijdig L\else R\fi\fi}%
262 \ifodd\realpageno R\else\ifdoublesided L\else R\fi\fi}%
263 \framed
264 [\c!background=\StatusAchtergrond,
265 \c!width=36pt,
266 \c!height=72pt,
267 \c!frame=\v!off]
268 {\lower.5\dp\strutbox\hbox
269 {\bfb\getmarking[\v!chapter\v!number]}}
270 \vskip0pt plus \scratchcounter cm
271 \vskip2cm}
272 \fi}
274 % The index is put on a double collumned grid. The numbers is
275 % surrounded by a shape.
277 \setupregister
278 [\v!index]
279 [\c!command=\IndexCommando,
280 \c!before={\blank[\v!line]},
281 \c!after=]
283 \unexpanded\def\IndexCommando#1%
284 {\fittoptobaselinegrid
285 \framed
286 [\c!background=IndexAchtergrond,
287 \c!width=36pt,
288 \c!height=\v!fit,
289 \c!align=\v!middle,
290 \c!frame=\v!off,
291 \c!offset=4pt]
292 {#1}}
294 % The very first version used keywords in the margin. The
295 % next settings applied to the level one margin word (we can
296 % stack margin words, you see).
298 % \starttyping
299 % \setupinmargin
300 % [\c!location=\v!left]
302 % \setupinmargin
303 % [1]
304 % [\c!background=MargeAchtergrond,
305 % \c!width=\v!fit,
306 % \c!height=\v!fit,
307 % \c!align=\v!middle,
308 % \c!style=\tfx\setupinterlinespace,
309 % \c!offset=8pt]
310 % \stoptyping
312 % When bound, we use a double sided layout and put the
313 % pagenumber in the margin, enhanced by a fancy background.
315 \startmode[bound]
317 \setuppagenumbering[\c!alternative=\v!doublesided]
319 \stopmode
321 \setuppagenumbering
322 [\c!location={\v!footer,\v!middle},
323 \c!command=\NummerCommando]
325 \unexpanded\def\NummerCommando#1%
326 {\framed
327 [\c!background=NummerAchtergrond,
328 \c!frame=\v!off,
329 \c!offset=6pt]
330 {\lower.5\dp\strutbox\hbox spread 60pt{\hss#1\hss}}}
332 % We put the chapter title in the head. If we wouldn't have
333 % to center, the more simple setting would be:
335 % \starttypen
336 % \setupheadertexts[\v!chapter][]
337 % \stoptypen
339 \setupheadertexts
342 \setupheadertexts
343 [{\hfill\getmarking[\v!chapter]\hfill}]
346 % Guess what the next one does.
348 \setupitemgroup
349 [\v!itemize]
350 [1][\v!autointro]
352 % Indeed, it prevents breaks between one||liners and
353 % following itemizations.
355 % The cover page is a real piece of art. Just watch.
357 \newbox\CoverBackgroundBox
359 \def\CoverBackground
360 {\ifvoid\CoverBackgroundBox
361 \global\setbox\CoverBackgroundBox=\vbox to \paperheight
362 {\hsize\paperwidth
363 \emergencystretch3em
364 \iflocation
365 \switchtobodyfont[5pt]
366 \else
367 \switchtobodyfont[7pt]
369 \parfillskip0pt
370 \setupsetup
371 [\c!command=\test]
372 \def\test##1%
373 {\dontleavehmode
374 \framed
375 [\c!background=IntroAchtergrond,
376 \c!frame=\v!off]
377 {\type{##1}}%\writetexcommand{##1}}%
378 \hskip1.25em plus 1em minus 1em}
379 % beter :
381 % \oninterlineskip
382 % \baselineskip \vsize plus 1fill minus 1fill
383 % \parfillskip0pt
384 % \leftskip3pt
385 % \rightskip3pt
386 % \leavevmode\plaatselkesetup\unskip
388 \beginofshapebox
389 \leftskip3pt
390 \rightskip3pt
391 \plaatselkesetup
392 \endofshapebox
393 \doreshapebox
394 {\box\shapebox}
395 {\penalty\shapepenalty}
396 {\kern\shapekern}
397 {\vfil}
398 \kern3pt
399 \vfilneg
400 \flushshapebox
401 \vfilneg
402 \kern3pt}%
404 \copy\CoverBackgroundBox}
406 \defineoverlay[geintje][\CoverBackground]
408 % In interactive mode we make the text area active. Click and
409 % go to the table of contents.
411 \unexpanded\def\TitleButton% zou iets standaards moeten zijn
412 {\button % nog eens iets achter page
413 [\c!height=\vsize, % moeten kunnen zetten
414 \c!width=\hsize,
415 \c!frame=\v!off]
417 [contents]}
419 \def\TitlePage#1#2#3%
420 {\setupbackgrounds
421 [\v!rightpage]
422 [\c!background=geintje]
423 \setuptexttexts
424 [\TitleButton]
426 \startmakeup
427 [\v!standard]
428 [\c!doublesided=\v!empty,
429 \c!headerstate=\v!none,
430 \c!footerstate=\v!none]
431 \hbox to \hsize
432 {\hss
433 \definedfont[SansBold at 40pt]% \setfont lsb at 40pt % change this into something available
434 \framed
435 [\c!background=TitelAchtergrond,
436 \c!width=\v!fit,
437 \c!height=\v!fit,
438 \c!align=\v!middle,
439 \c!frame=\v!off,
440 \c!offset=40pt]
441 {#1}}
442 \vfill
443 \hbox to \hsize
444 {\definedfont[SansBold at 14pt]% \setfont lsb at 14pt % change this into something available
445 \framed
446 [\c!background=AuteurAchtergrond,
447 \c!frame=\v!off,
448 \c!width=\v!fit,
449 \c!height=\v!fit,
450 \c!align=\v!middle,
451 \c!offset=20pt]
452 {#2}
453 \hss}
454 \hbox to \hsize
455 {\hss
456 \definedfont[SansBold at 20pt]% \setfont lsb at 20pt % change this into something available
457 \framed
458 [\c!background=AuteurAchtergrond,
459 \c!frame=\v!off,
460 \c!width=\v!fit,
461 \c!height=\v!fit,
462 \c!align=\v!middle,
463 \c!offset=35pt]
464 {#3\\PRAGMA ADE}}
465 \stopmakeup
466 %\setuplayout[\c!marking=\v!off]
467 \setuptexttexts
468 \setupbackgrounds
469 [\v!rightpage]
470 [\c!background=]
471 \doifmode{screen}
472 {\setupbackgrounds
473 [\v!page]
474 [\c!background=\v!screen,
475 \c!backgroundscreen=.95]
476 \setupbackgrounds
477 [\v!text][\v!text]
478 [\c!backgroundoffset=.25cm,
479 \c!depth=.125cm,
480 \c!background=\v!color,
481 \c!backgroundcolor=white]}}
483 % The backpage uses the same background and overlays a piece
484 % of text.
486 \def\StartBackPage
487 {\page[\v!yes,\v!blank,\v!left]
488 \setupbackgrounds
489 [\v!leftpage]
490 [\c!background=geintje]
491 \setuptexttexts
492 [\TitleButton][]
493 \startmakeup
494 [\v!standard]
495 [\c!page=,
496 \c!doublesided=\v!no,
497 \c!headerstate=\v!none,
498 \c!footerstate=\v!none]
499 \setuptolerance
500 [\v!verytolerant]
501 \vfill
502 \framed
503 [\c!background=\v!color,
504 \c!backgroundcolor=white,
505 \c!frame=\v!off,
506 \c!offset=10pt,
507 \c!corner=\v!round,
508 \c!width=.4\makeupwidth,
509 \c!height=\textheight,
510 \c!align=\v!middle,
511 \c!strut=\v!no]
512 \bgroup
513 \vfil}
515 \def\StopBackPage
516 {\vfil
517 \egroup
518 \hfill
519 \vfill
520 \stopmakeup}
522 % We draw a nice line between columns. The next command does
523 % the job. Of course a normal line can be set more easily,
524 % but here we hook in a command.
526 \unexpanded\def\KolommenLijn
527 {\vsmash
528 {\hbox to 36pt
529 {\hss
530 \vbox
531 {\vskip-\maxcolumnheight
532 \dimen0=\maxcolumnheight
533 \advance\dimen0 by \maxcolumndepth
534 \expanded{\MPclipSix{\the\dimen0}{2pt}}}%
535 \hss}}}
537 % To save space we don't start chapters on a new page, except
538 % in appendices and the introduction. These settings happen
539 % in dedicated setups sections (see later). We also add some
540 % white space between table of content entries.
542 \setupsectionblock
543 [\v!frontmatter]
544 [\c!page=\v!right,
545 \c!before={\setups{introduction}\writebetweenlist[\v!chapter]{\blank[\v!line]}}]
547 \setupsectionblock
548 [\v!bodymatter]
549 [\c!page=\v!right,
550 \c!before={\setups{bodymatter}\writebetweenlist[\v!chapter]{\blank[\v!line]}}]
552 \setupsectionblock
553 [\v!appendix]
554 [\c!page=\v!right,
555 \c!before={\setups{appendix}\writebetweenlist[\v!chapter]{\blank[\v!line]}}]
557 \setupsectionblock
558 [\v!backmatter]
559 [\c!page=\v!right,
560 \c!before={\setups{backmatter}\writebetweenlist[\v!chapter]{\blank[\v!line]}}]
562 \startsetups introduction
563 \setuphead[\v!chapter][\c!page=\v!right]
564 \stopsetups
566 \startsetups bodymatter
567 \setuphead[\v!chapter][\c!page=]
568 \stopsetups
570 \startsetups appendix
571 \setuphead[\v!chapter][\c!page=\v!right]
572 \stopsetups
574 %\setuplabeltext [\csname s!\currentmainlanguage\endcsname] [\v!appendix=]
576 \startsetups backmatter
577 \setuphead[\v!chapter][\c!page=\v!right]
578 \stopsetups
580 % In normal documents one will never find awful things like
581 % below. Because we want an international setup, we just call
582 % the chapters in an indirect way.
584 \def\Introduction#1% nothing funny yet
585 {\getvalue{\v!title}[intro]{#1}} % == \titel[intro]{#1}
587 % In a previous version I aligned the columns to the middle.
588 % Watch the column postprocessor routine!
590 \def\TableOfContents#1%
591 {\getvalue{\v!title}[contents]{#1}
592 \bgroup
593 %\def\postprocesscolumnline##1%
594 % {\ifodd\currentcolumn
595 % \hss##1\relax
596 % \else
597 % \relax##1\hss
598 % \fi}%
599 \startcolumns[\c!n=2,\c!distance=36pt,\c!rule=\KolommenLijn]
600 \placelist
601 [\v!chapter]
602 [\c!criterium=\v!all,
603 \c!before=,
604 \c!after=\vskip0pt] % makes it breakable
605 \stopcolumns
606 \egroup}
608 \def\NormalIndex#1%
609 {\getvalue{\v!chapter}[subind]{#1}
610 \bgroup
611 \startcolumns[\c!n=2,\c!distance=36pt,\c!rule=\KolommenLijn]
612 \placeregister[\v!index]
613 \stopcolumns
614 \egroup}
616 \def\CommandIndex#1%
617 {\getvalue{\v!chapter}[comind]{#1}
618 \bgroup
619 \startcolumns[\c!n=2,\c!distance=36pt,\c!rule=\KolommenLijn]
620 \placeregister[Command][\c!before={\blank[\v!line]}]
621 \stopcolumns
622 \egroup}
624 \def\CommandList#1%
625 {\getvalue{\v!chapter}[comdefs]{#1}
626 \bgroup
627 \component ma-cb-\currentmainlanguage-commandlist
628 \blank[2*\v!big]
629 \startcolumns[\c!n=2,\c!distance=36pt,\c!rule=\KolommenLijn,
630 tolerance=verytolerant]
631 \switchtobodyfont[7pt]
632 \setupsetup[\c!reference=2]
633 \placesetup
634 \stopcolumns
635 \egroup}
637 \defineregister
638 [Command]
639 [Commands]
641 \setupregister
642 [Command]
643 [bagger=oeps,\c!indicator=\v!off]
645 \def\Copyright{%
646 \doiffileelse{ma-cb-\currentmainlanguage-copyright.tex }
647 {\component ma-cb-\currentmainlanguage-copyright.tex }
648 % {\component \GenericDir/ma-cb-copyright.tex }
649 {\component ma-cb-copyright.tex }
651 \def\Colofon {%
652 \doiffileelse{ma-cb-\currentmainlanguage-colophon.tex }
653 {\component ma-cb-\currentmainlanguage-colophon.tex }
654 % {\component \GenericDir/ma-cb-colophon.tex }
655 {\component ma-cb-colophon.tex }
658 % Oh, how far more easy it would have been if we could put
659 % this in the text directly. But consistency is needed.
661 % Info sources
662 \definedescription[infosource]
663 [location=hanging,align=left,width=broad,margin=2em,headstyle=bold,
664 command=\infosourcehead]
665 \def\infosourcehead#1{#1\crlf}
667 \def\Fr#1{\bgroup\rm\tf(\from[#1])\egroup}
669 \def\redospecialfrom[#1::#2]%
670 {\ifundefined{\v!file:::#1}%
671 \tttf[#1]%
672 \else
673 \doifmodeelse{screen}
674 {\def\doexternaldocument##1##2##3{\goto{##3}[#1::#2]}}%
675 {\def\doexternaldocument##1##2##3{\hyphenatedurl{##1}}}%
676 \csname\v!file:::#1\endcsname
677 \fi}
679 \protect
681 % VZ 2006-11-23 after Hans's advice
682 \appendtoks \obeyMPlines \to \everyMPgraphic
684 \stopenvironment