s-tugboat.mkiv /size: 16 Kb    last modification: 2021-10-28 13:51
1%D \module
2%D   [      file=t-tugboat
3%D        version=$Id: s-tugboat.mkiv 246 2019-09-09 18:22:19Z karl $
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=\TUGBOAT\ base style,
6%D         author=Aditya Mahajan and others,
7%D           date=\currentdate,
8%D      copyright=Public Domain]
9
10%D \filename {s-tug-02} was originally written by Hans Hagen and Steve Grathwohl,
11%D and used grid typesetting. \filename {t-tugboat} was a major revision by Aditya
12%D Mahajan, no grid. \filename {s-tugboat.mkiv} was another major revision by Taco
13%D Hoekwater and Alan Braslau, now with pagecolumns. The latest version has been
14%D adapted by Karl Berry.
15
16%D HH: most articles are not that demanding, otherwise I'd probably redefine some
17%D of the code below. So, for now things gets adapted when needed.
18
19%D \section{Variables}
20%D
21%D We store the information about the article in variables.
22
23\setvariables
24  [tugboat]
25  [type=article,
26   columns=yes,
27   grid=no]
28
29\setvariables
30  [tugboat] % overridden from ../tugboat.dates if present.
31  [year=1900,
32   volume=0,
33   number=0,
34   page=900]
35
36\setvariables
37  [tugboat]
38  [title=ConTeXt style for TUGboat,
39   subtitle=,
40   keywords=,
41   author=T. Boat,
42   address=Pragmatically Advanced tugboats\\314 Pi Ave.\\8061GH Hasselt NL,
43   email={pragboat@tug.org}]
44
45%D \section{Font Setup}
46%D
47%D \TUGBOAT\ uses standard CM interline spacing.
48
49\definebodyfontenvironment    [8pt] [interlinespace=9.5pt, big=9pt,   small=7pt]
50\definebodyfontenvironment    [9pt] [interlinespace=11pt,  big=10pt,  small=8pt]
51\definebodyfontenvironment   [10pt] [interlinespace=12pt,  big=12pt,  small=9pt]
52\definebodyfontenvironment   [12pt] [interlinespace=14pt,  big=14.4pt,small=10pt]
53\definebodyfontenvironment [14.4pt] [interlinespace=18pt,  big=14.4pt,small=12pt]
54
55%D \TUGBOAT\ uses Computer Modern fonts, and \CONTEXT\ uses Latin Modern by default,
56%D which is fine. So, we just specify the font size.
57
58\setupbodyfont [10pt]
59
60%D \TUGBOAT\ uses italic rather than slanted for emphasis.
61
62\setupbodyfontenvironment
63  [default]
64  [em=italic]
65
66%D Break after these chars in urls, not before.
67
68\sethyphenatedurlafter /
69\sethyphenatedurlafter .
70\sethyphenatedurlafter _
71
72%D \section{Layout Setup}
73%D
74%D The original layout used in the \LATEX\ style for \TUGBOAT\ uses low|-|level
75%D \TEX\ syntax.
76
77\setuppapersize
78  [letter]
79  [letter]
80
81\setuplayout
82  [topspace=3.8pc,% was 3.5pc
83   header=1pc,
84   headerdistance=1.5pc,
85   height=middle,
86   footerdistance=2pc,
87   footer=1pc,
88   bottomspace=3pc,
89   %
90   backspace=6pc,
91   width=middle,
92   cutspace=6pc,
93   %
94   margin=4pc,
95   margindistance=1pc,
96  ]
97
98%D With pagecolumns, seemingly can't get single-column floats. (HH: not sure
99%D what is meant but probably that it can't be done in the running text.)
100
101\enablemode [pagecolumns]
102
103%D KB: With columnsets, get unwanted gridsetting and blank last pages. HH: can
104%D be solved but columnsets normally get set up beforehand (figures and such).
105
106% \enablemode [columnsets]
107% \startmode [columnsets]
108%    \usemodule [newcolumnsets]
109% \stopmode
110
111\setuppagenumbering
112  [location=,
113   alternative=doublesided]
114
115%D In \TUGBOAT\ different articles are glued together to form the final journal, so
116%D we do not want each article to occupy an even number of pages. (Except this seems
117%D to have no effect with pagecolumns.) HH: page columns are actually just single
118%D columns but combined, so it supports side floats and such.
119
120\installpagebreakhandler {last} {}
121
122%D \section{Indentation}
123%D
124%D We use automatic indentation control, that is: no indentation after titles and
125%D skips.
126
127\setupindenting[20pt,yes]
128
129%D We do not usually want indentation after lists.
130
131\setupenumerations [indentnext=no]
132\setupdescriptions [indentnext=no]
133
134%D \section{Itemize}
135%D
136%D And these. We typeset itemizations ragged right.
137
138\setupitemgroup
139  [itemize]
140  [indentnext=no,
141   align=right]
142
143%D We align them at the paragraph indentation and
144%D pack them by default.
145
146\setupitemgroup
147  [itemize]
148  [each]
149  [margin=1pc,
150   width=1em,
151   distance=0pt]
152
153\setupitemgroup
154  [itemize]
155  [1]
156  [packed]
157
158%D \section{Section Headings}
159%D
160%D We follow the \TUGBOAT\ style for sections. I do not know if \type {align=right}
161%D also disables hyphenation (HH: no that is independent). Let's wait and see on
162%D this. The rest is straightforward. It took me a while to realize that in \LATEX\
163%D \type {\@startsection} the absolute value of before skip (fourth argument) is
164%D important and not the sign.
165
166\setuphead
167  [section,subsection,subsubsection,
168   subject,subsubject,subsubsubject]
169  [style=bold,
170   align=right,
171   before={\blank[8pt]},
172   after={\blank[4pt]}]
173
174%D \section{Spacing}
175%D
176%D We define a logical skip. This is equal to the \type {\topsep} in \LATEX, and
177%D most environments should have this skip.
178
179\defineblank
180  [tugblank]
181  [3pt]
182
183%D HH: In fact, \type \setupblank[tugblank] would deal with most of the blanks
184%D anyway, but let's not change this now.
185
186\setupblank
187  [3pt]
188
189\setupitemize
190  [1]
191  [before={\blank[tugblank]},
192   after={\blank[tugblank]},
193   inbetween={\blank[tugblank]}]
194
195\setuplines
196  [before={\blank[tugblank]},
197   after={\blank[tugblank]},
198   inbetween={\blank[tugblank]}]
199
200%D \section Typing %<<<1
201%D
202%D \TUGBOAT\ uses a smaller font size for verbatim typesetting. Not sure why
203%D \type {nowhite} is used here.
204
205\setuptyping
206  [option=none,
207   bodyfont=9pt,
208   before={\blank[nowhite,tugblank]},
209   after={\blank[back,nowhite,tugblank]}]
210
211%D Do not colorize code.
212
213\setuptyping[LUA][option=]
214\setuptyping[TEX][option=]
215\setuptyping[MP] [option=]
216
217%D Tiny line numbers in numbered code (not text size)
218
219\setuplinenumbering[style=\tfxx] % \infofont would be really tiny
220
221%D \section{Figure captions}
222%D
223%D \TUGBOAT\ uses a smaller font size for captions, too; \type {\small} gives 8pt,
224%D and we want 9pt, so we have to manually fix the baselines.
225
226\setupcaptions
227  [headstyle=\AcroFontBold,
228   style={\AcroFont\advance\baselineskip by -1pt},
229   align=right]
230
231%D We like a colon after the caption label.
232
233\let\floatcaptionsuffix=:
234
235% Prefer floats in text.
236
237\setupfloat[figure][align=middle,default=here]
238\setupfloat[table] [align=middle,default=here]
239
240%D \section{Footnotes}
241%D
242%D Not entirely a la \TUGBOAT:
243
244% rule={\hrule width 5pc height .4pt depth 0pt\relax \kern \strutdepth},
245
246\setupfootnotes
247  [bodyfont=9pt]
248
249\doif {\getvariable{tugboat}{columns}} {yes} {
250    \setupfootnotes
251      [location=columns]
252}
253
254\setupnotation
255  [footnote]
256  [location=joinedup,
257   width=fit,
258   headstyle=normal,
259   distance=.5em]
260
261%D \section{List}
262%D
263%D We define a standard description and enumeration environment.
264
265\definedescription
266  [description]
267  [location=hanging,
268   width=broad,
269   before={\blank[tugblank]},
270   after={\blank[tugblank]}]
271
272\defineenumeration
273  [enumeration]
274  [location=hanging,
275   width=broad,
276   before={\blank[tugblank]},
277   after={\blank[tugblank]}]
278
279%D \section{References}
280%D
281%D More or less like plain BibTeX + ltugboat.
282
283\setupbtx
284  [default:list:numbering]
285  [left={[},
286   right={]}]
287
288\setupbtxlist
289  [default]
290  [width=2em,
291   style={\frenchspacing},
292   align={raggedright,verystrict}]
293
294%D Instead of color, we use weighted gray scales:
295
296\setupcolors
297  [conversion=always]
298
299%D We define some logical skips
300
301\defineblank [tugbefore]   [big]
302\defineblank [tuginbetween][big]
303\defineblank [tugafter]    [tugbefore]
304
305%D Some real macros: <<<
306
307\def\StartAbstract
308  {\dostartbuffer[abstract][StartAbstract][StopAbstract]}
309
310\startsetups tugboat:abstract:setup
311
312  % \setuptolerance
313  %   [horizontal, tolerant]
314
315    \setupnarrower
316      [before={\blank[.5\baselineskip]},
317     % after={\blank[10pt plus4pt minus4pt]},
318       after={\blank[10pt]},
319       middle=4.875pc]
320
321    \setupindenting
322      [20pt,yes]
323
324\stopsetups
325
326%D Headers and footers.
327
328\startsetups tugboat:banner:text:article
329
330    {\sl TUGboat},\space
331    Volume \getvariable{tugboat}{volume}\space
332    (\getvariable{tugboat}{year}),\space
333    No.\space\getvariable{tugboat}{number}
334
335\stopsetups
336
337\def\postissno{Proceedings of the \tubyear\ Annual Meeting}
338
339\startsetups tugboat:banner:text:proceedings
340
341    \setups{tugboat:banner:text:article}
342    \thinspace---\thinspace
343    \postissno
344
345\stopsetups
346
347\startsetups tugboat:banner:setup:article
348
349  \setupheadertexts
350    [\setups{tugboat:banner:text:article}]
351    [\pagenumber]
352
353    % no footer in regular articles
354
355  \setupfootertexts
356    [][\getvariable{tugboat}{author}]
357    [\getvariable{tugboat}{title}][]
358
359\stopsetups
360
361%D article is default.
362
363\setups{tugboat:banner:setup:article}
364
365%D It all starts here:
366
367\def\StartArticle{\setups{tugboat:\getvariable{tugboat}{type}:start}}
368\def\StopArticle {\setups{tugboat:article:stop}}
369
370\startsetups tugboat:grid:setup:settings:yes
371
372    \setupblank
373      [line]
374
375    \defineblank [tugbefore]    [halfline]
376    \defineblank [tuginbetween] [halfline]
377
378\stopsetups
379
380% \startsetups tugboat:grid:setup:no
381%
382%   \setupblank
383%     [halfline]
384%
385%   \defineblank [medium]       [halfline]
386%   \defineblank [tugbefore]    [halfline]
387%   \defineblank [tuginbetween] [halfline]
388%
389% \stopsetups
390
391\startsetups tugboat:introduction:article
392
393  % \blank[halfline]
394
395    \start
396        \enforced\protected\def\\{\unskip\space\&\space\ignorespaces}
397        \hbox{\indent\getvariable{tugboat}{author}}
398        \par
399    \stop
400
401\stopsetups
402
403\startsetups tugboat:article:start
404
405    \starttext
406
407    \setups{tugboat:columns:\getvariable{tugboat}{columns}}
408    \setups{tugboat:banner:setup:\getvariable{tugboat}{type}}
409
410    \doif {\getvariable{tugboat}{columns}} {yes} {
411        \doifmodeelse {columnset}  {
412            \startcolumnset
413        } {
414            \doifmodeelse {pagecolumns} {
415                \startpagecolumns
416            } {
417                \startcolumns
418            }
419        }
420    }
421
422    \setcounter
423      [userpage]
424      [\getvariable{tugboat}{page}]
425
426    \setups{tugboat:grid:setup:\getvariable{tugboat}{grid}}
427
428    \snaptogrid \vbox \bgroup
429
430        \forgetall
431        \hrule height .6pt
432        \blank[halfline]
433        \start
434            \enforced\let\\\par
435            {\bf\getvariable{tugboat}{title}}
436            \par
437            \blank[halfline]
438            \hskip20pt\getvariable{tugboat}{author}
439        \stop
440
441        \blank[line]
442
443        \doiftext {\getbuffer[abstract]} {
444            \enforced\let\\\endgraf
445            \setups{tugboat:abstract:setup}
446            \subject{Abstract}
447            \getbuffer[abstract]
448        }
449
450    \egroup
451
452\stopsetups
453
454\startsetups tugboat:affiliation:article
455
456    \blank[line]
457    \begingroup
458        \leftskip=5.7pc
459        \noindent
460        \llap{\sym{\diamond}\enspace}
461        \getvariable{tugboat}{author}
462        \\
463        \getvariable{tugboat}{address}
464        \\
465        {\tt\getvariable{tugboat}{email}}
466        \par
467    \endgroup
468
469\stopsetups
470
471\startsetups tugboat:article:stop
472
473    \setups{tugboat:affiliation:\getvariable{tugboat}{type}}
474
475    % article joining in the issue.
476
477    \ifx\writelastpage\undefined \else
478        \begingroup
479        \count0=\count1 % because context uses \count0
480        \writelastpage{+1}%
481        \endgroup
482    \fi
483
484  \stoptext
485
486\stopsetups
487
488%D Normal word spacing, please.
489
490\setuptolerance
491  [strict]
492
493%D Hz is fine but hanging can hang quotes out too far.
494
495\setupalign[hz]
496
497%D Let's see boxes overfull by >.5pt
498
499\overfullrule =  2pt % yes, I want to see
500\hfuzz        = .5pt
501
502%D One can use the following setups (in the article) to collect settings specific to
503%D normal and|/|or multi column typesetting.
504
505\startsetups tugboat:columns:yes
506
507    \doifmodeelse {columnset} {
508        \setuplayout
509            [grid=no]
510        \setupcolumnset
511            [distance=1.5pc]
512    } {
513        \doifmodeelse {pagecolumns} {
514            \setuplayout
515                [grid=no]
516            \setuppagecolumns
517                [distance=1.5pc]
518         } {
519            \setupcolumns
520                [distance=1.5pc]
521        }
522    }
523
524\stopsetups
525
526% \startsetups tugboat:columns:no
527%
528% \stopsetups
529
530%D Logos, abbreviations: lots could be better here.
531
532\font\mflogo=logo10 % hm, better use \definefont
533
534%D HH: I'm pretty sure that this doesn't really work as it probably assumes some
535%D specific math family setup and that's not how \MKIV\ works. The TB definition
536%D doesn't scale with font changes and also doesn't adapt itself to style changes.
537
538\newcount\TestCount
539\newbox  \TestBox
540
541\def\La
542  {\dontleavehmode
543   \begingroup
544   \TestCount=\the\fam % no meaningful fams in text mode in ConTeXt
545   \setbox\TestBox=\hbox{$\fam\TestCount\scriptstyle A$}%
546   L\kern-.5\wd\TestBox\raise.42ex\box\TestBox
547   \endgroup}
548
549%D Probably this will do a better job:
550
551% \def\La
552%   {\dontleavehmode
553%    \begingroup
554%    \setbox\scratchbox\hbox{\tx A}% % or \txx
555%    L\kern-.5\wd\scratchbox\raise.42ex\scratchbox
556%    \endgroup}
557
558\def\ALEPH     {Aleph}
559\def\API       {\acro{API}}
560\def\CCODE     {C}
561\def\CD        {\acro{CD}}
562\def\CMYK      {\acro{CMYK}}
563\def\CONTEXT   {C\kern-.0333emon\-\kern-.0667em\TeX\kern-.0333emt}
564\def\Cplusplus {C\plusplus}
565\def\CPU       {\acro{CPU}}
566\def\DVI       {\acro{DVI}}
567\def\DVIPDFMX  {dvipdfmx}
568\def\DVIPS     {dvips}
569\def\ETEX      {$\varepsilon$-\kern-.125em\TeX}
570\def\FTP       {\acro{FTP}}
571\def\HTTP      {\acro{HTTP}}
572\def\IO        {\acro{I/O}}
573\def\ISO       {\acro{ISO}}
574\def\KPSE      {\acro{KPSE}}
575\def\KPSEWHICH {kpsewhich}
576\def\LATEX     {\La\kern-.15em\TeX}
577\def\LATEXE    {\LaTeX{}\kern.05em2$_{\textstyle\varepsilon}$}
578\def\LINUX     {Linux}
579\def\LPEG      {Lpeg}
580\def\LUA       {Lua}
581\def\LUAJIT    {Lua\acro{JIT}}
582\def\LUATEX    {Lua\-\TeX}
583\def\LUATOOLS  {lua\-tools}
584\def\MATHML    {Math\acro{ML}}
585\def\METAFUN   {Metafun}
586\def\METAPOST  {MetaPost}
587\def\METATEX   {Meta\TeX{}}
588\def\MF        {{\mflogo META\-FONT}}
589\def\MKII      {Mk\acro{II}}
590\def\MKIV      {Mk\acro{IV}}
591\def\MPLIB     {\acro{MP}lib}
592\def\MPTOPDF   {mp\-to\-pdf}
593\def\MSWINDOWS {Windows}
594\def\MTXTOOLS  {mtx\-tools}
595\def\NFSS      {\acro{NFSS}}
596\def\OPENMATH  {Open\-Math}
597\def\OPENTYPE  {Open\-Type}
598\def\PASCAL    {Pascal}
599\def\PDF       {\acro{PDF}}
600\def\PDFTEX    {pdf\/\-\TeX}
601\def\plusplus  {\lower.45ex\hbox{$^{++}$}}
602\def\POSIX     {\acro{POSIX}}
603\def\POSTSCRIPT{Post\-Script}
604\def\PRAGMA    {Pragma \acro{ADE}}
605\def\RGB       {\acro{RGB}}
606\def\RUBY      {Ruby}
607\def\SCITE     {Sci\acro{TE}}
608\def\TDS       {\acro{TDS}}
609\def\TEX       {\TeX}
610\def\TEXBOOK   {{\sl The \TeX book}}
611\def\TEXEXEC   {\TeX exec}
612\def\TFM       {\acro{TFM}}
613\def\TRUETYPE  {True\-Type}
614\def\TYPEONE   {Type~1}
615\def\UTF       {\acro{UTF}}
616\def\WEBC      {Web2C}
617\def\XETEX     {X\lower.5ex\hbox{\kern-.15em\mirror{E}}\kern-.1667em\TeX}
618\def\XML       {\acro{XML}}
619\def\XPATH     {\acro{XP}ath}
620\def\XSLT      {\acro{XSLT}}
621\def\XSLTPROC  {\acro{XSLTPROC}}
622\def\ZIP       {zip}
623
624\def\Dash      {\unskip\nobreak\thinspace---\thinspace\ignorespaces}
625\def\slash     {/\penalty0 \hskip0pt \relax}
626
627% \acro for one point size smaller. Don't know how to do this for real.
628
629\definefont[AcroFont]     [Serif*default     sa .91]
630\definefont[AcroFontBold] [SerifBold*default sa .91]
631\definefont[AcroFontSmall][Serif*default     sa .80]
632
633\unexpanded\def\acro     #1{{\AcroFont      #1}} % could be a style definition
634\unexpanded\def\acrobf   #1{{\AcroFontBold  #1}} % could be a style definition
635\unexpanded\def\acrosmall#1{{\AcroFontSmall #1}} % could be a style definition
636
637%D This is English; disallow x- or -xx breaks. (These are already the defaults
638%D but let's keep this anyway.)
639
640\setuplanguage
641  [en]
642  [lefthyphenmin=2,
643   righthyphenmin=3]
644
645% \lefthyphenmin  = 2
646% \righthyphenmin = 3
647
648\mainlanguage
649  [en]
650
651\hyphenation {
652    Post-Script
653    data-base
654    data-bases
655}
656
657%D A hack to read \type {tugboat.dates} settings.
658
659\doifelsefileexists {../tugboat.dates} {
660
661    \newif   \ifPrelimDraft
662    \newcount\issueseqno
663
664    \def\vol    #1, #2.{\gdef\tubvol {#1}%
665                        \gdef\tubnum {#2}}
666    \def\issyear    #1.{\gdef\tubyear{#1}}
667
668    \input ../tugboat.dates
669
670    \setevariables
671      [tugboat]
672      [year=\tubyear,
673       volume=\tubvol,
674       number=\tubnum,
675       page=\the\count0]
676
677} {
678    % nothing
679}
680
681%D Good bye.
682
683\continueifinputfile{s-tugboat.mkiv}
684
685% \showgrid
686
687\starttext
688
689\StartArticle
690
691\StartAbstract
692    \samplefile{bryson}
693\StopAbstract
694
695\dorecurse{30}{\input ward \endgraf} \page
696
697\startitemize
698    \startitem \samplefile{ward} \stopitem
699    \startitem \samplefile{ward} \stopitem
700\stopitemize
701
702\StopArticle
703
704\setvariables[tugboat][columns=yes]
705
706\StartArticle
707
708\StartAbstract
709    \samplefile{bryson}
710\StopAbstract
711
712\dorecurse {30} {
713    \samplefile{ward}\endgraf
714} \page
715
716\StopArticle
717
718\stoptext
719
720% >>>
721