s-tugboat.mkiv /size: 16 Kb    last modification: 2023-12-21 09:45
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
128  [20pt,yes]
129
130%D We do not usually want indentation after lists.
131
132\setupenumerations [indentnext=no]
133\setupdescriptions [indentnext=no]
134
135%D \section{Itemize}
136%D
137%D And these. We typeset itemizations ragged right.
138
139\setupitemgroup
140  [itemize]
141  [indentnext=no,
142   align=right]
143
144%D We align them at the paragraph indentation and 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    \doif {\getvariable{tugboat}{columns}} {yes} {
485        \doifmodeelse {columnset}  {
486            \stopcolumnset
487        } {
488            \doifmodeelse {pagecolumns} {
489                \stoppagecolumns
490            } {
491                \stopcolumns
492            }
493        }
494    }
495
496  \stoptext
497
498\stopsetups
499
500%D Normal word spacing, please.
501
502\setuptolerance
503  [strict]
504
505%D Hz is fine but hanging can hang quotes out too far.
506
507\setupalign[hz]
508
509%D Let's see boxes overfull by >.5pt
510
511\overfullrule =  2pt % yes, I want to see
512\hfuzz        = .5pt
513
514%D One can use the following setups (in the article) to collect settings specific to
515%D normal and|/|or multi column typesetting.
516
517\startsetups tugboat:columns:yes
518
519    \doifmodeelse {columnset} {
520        \setuplayout
521            [grid=no]
522        \setupcolumnset
523            [distance=1.5pc]
524    } {
525        \doifmodeelse {pagecolumns} {
526            \setuplayout
527                [grid=no]
528            \setuppagecolumns
529                [distance=1.5pc]
530         } {
531            \setupcolumns
532                [distance=1.5pc]
533        }
534    }
535
536\stopsetups
537
538% \startsetups tugboat:columns:no
539%
540% \stopsetups
541
542%D Logos, abbreviations: lots could be better here.
543
544\font\mflogo=logo10 % hm, better use \definefont
545
546%D HH: I'm pretty sure that this doesn't really work as it probably assumes some
547%D specific math family setup and that's not how \MKIV\ works. The TB definition
548%D doesn't scale with font changes and also doesn't adapt itself to style changes.
549
550\newcount\TestCount
551\newbox  \TestBox
552
553\def\La
554  {\dontleavehmode
555   \begingroup
556   \TestCount=\the\fam % no meaningful fams in text mode in ConTeXt
557   \setbox\TestBox=\hbox{$\fam\TestCount\scriptstyle A$}%
558   L\kern-.5\wd\TestBox\raise.42ex\box\TestBox
559   \endgroup}
560
561%D Probably this will do a better job:
562
563% \def\La
564%   {\dontleavehmode
565%    \begingroup
566%    \setbox\scratchbox\hbox{\tx A}% % or \txx
567%    L\kern-.5\wd\scratchbox\raise.42ex\scratchbox
568%    \endgroup}
569
570\def\ALEPH     {Aleph}
571\def\API       {\acro{API}}
572\def\CCODE     {C}
573\def\CD        {\acro{CD}}
574\def\CMYK      {\acro{CMYK}}
575\def\CONTEXT   {C\kern-.0333emon\-\kern-.0667em\TeX\kern-.0333emt}
576\def\Cplusplus {C\plusplus}
577\def\CPU       {\acro{CPU}}
578\def\DVI       {\acro{DVI}}
579\def\DVIPDFMX  {dvipdfmx}
580\def\DVIPS     {dvips}
581\def\ETEX      {$\varepsilon$-\kern-.125em\TeX}
582\def\FTP       {\acro{FTP}}
583\def\HTTP      {\acro{HTTP}}
584\def\IO        {\acro{I/O}}
585\def\ISO       {\acro{ISO}}
586\def\KPSE      {\acro{KPSE}}
587\def\KPSEWHICH {kpsewhich}
588\def\LATEX     {\La\kern-.15em\TeX}
589\def\LATEXE    {\LaTeX{}\kern.05em2$_{\textstyle\varepsilon}$}
590\def\LINUX     {Linux}
591\def\LPEG      {Lpeg}
592\def\LUA       {Lua}
593\def\LUAJIT    {Lua\acro{JIT}}
594\def\LUATEX    {Lua\-\TeX}
595\def\LUATOOLS  {lua\-tools}
596\def\MATHML    {Math\acro{ML}}
597\def\METAFUN   {Metafun}
598\def\METAPOST  {MetaPost}
599\def\METATEX   {Meta\TeX{}}
600\def\MF        {{\mflogo META\-FONT}}
601\def\MKII      {Mk\acro{II}}
602\def\MKIV      {Mk\acro{IV}}
603\def\MPLIB     {\acro{MP}lib}
604\def\MPTOPDF   {mp\-to\-pdf}
605\def\MSWINDOWS {Windows}
606\def\MTXTOOLS  {mtx\-tools}
607\def\NFSS      {\acro{NFSS}}
608\def\OPENMATH  {Open\-Math}
609\def\OPENTYPE  {Open\-Type}
610\def\PASCAL    {Pascal}
611\def\PDF       {\acro{PDF}}
612\def\PDFTEX    {pdf\/\-\TeX}
613\def\plusplus  {\lower.45ex\hbox{$^{++}$}}
614\def\POSIX     {\acro{POSIX}}
615\def\POSTSCRIPT{Post\-Script}
616\def\PRAGMA    {Pragma \acro{ADE}}
617\def\RGB       {\acro{RGB}}
618\def\RUBY      {Ruby}
619\def\SCITE     {Sci\acro{TE}}
620\def\TDS       {\acro{TDS}}
621\def\TEX       {\TeX}
622\def\TEXBOOK   {{\sl The \TeX book}}
623\def\TEXEXEC   {\TeX exec}
624\def\TFM       {\acro{TFM}}
625\def\TRUETYPE  {True\-Type}
626\def\TYPEONE   {Type~1}
627\def\UTF       {\acro{UTF}}
628\def\WEBC      {Web2C}
629\def\XETEX     {X\lower.5ex\hbox{\kern-.15em\mirror{E}}\kern-.1667em\TeX}
630\def\XML       {\acro{XML}}
631\def\XPATH     {\acro{XP}ath}
632\def\XSLT      {\acro{XSLT}}
633\def\XSLTPROC  {\acro{XSLTPROC}}
634\def\ZIP       {zip}
635
636\def\Dash      {\unskip\nobreak\thinspace---\thinspace\ignorespaces}
637\def\slash     {/\penalty0 \hskip0pt \relax}
638
639% \acro for one point size smaller. Don't know how to do this for real.
640
641\definefont[AcroFont]     [Serif*default     sa .91]
642\definefont[AcroFontBold] [SerifBold*default sa .91]
643\definefont[AcroFontSmall][Serif*default     sa .80]
644
645\unexpanded\def\acro     #1{{\AcroFont      #1}} % could be a style definition
646\unexpanded\def\acrobf   #1{{\AcroFontBold  #1}} % could be a style definition
647\unexpanded\def\acrosmall#1{{\AcroFontSmall #1}} % could be a style definition
648
649%D This is English; disallow x- or -xx breaks. (These are already the defaults
650%D but let's keep this anyway.)
651
652\setuplanguage
653  [en]
654  [lefthyphenmin=2,
655   righthyphenmin=3]
656
657% \lefthyphenmin  = 2
658% \righthyphenmin = 3
659
660\mainlanguage
661  [en]
662
663\hyphenation {
664    Post-Script
665    data-base
666    data-bases
667}
668
669%D A hack to read \type {tugboat.dates} settings.
670
671\doifelsefileexists {../tugboat.dates} {
672
673    \newif   \ifPrelimDraft
674    \newcount\issueseqno
675
676    \def\vol    #1, #2.{\gdef\tubvol {#1}%
677                        \gdef\tubnum {#2}}
678    \def\issyear    #1.{\gdef\tubyear{#1}}
679
680    \input ../tugboat.dates
681
682    \setevariables
683      [tugboat]
684      [year=\tubyear,
685       volume=\tubvol,
686       number=\tubnum,
687       page=\the\count0]
688
689} {
690    % nothing
691}
692
693%D Good bye.
694
695\continueifinputfile{s-tugboat.mkiv}
696
697% \showgrid
698
699\starttext
700
701\StartArticle
702
703\StartAbstract
704    \samplefile{bryson}
705\StopAbstract
706
707\dorecurse{30}{\input ward \endgraf} \page
708
709\startitemize
710    \startitem \samplefile{ward} \stopitem
711    \startitem \samplefile{ward} \stopitem
712\stopitemize
713
714\StopArticle
715
716\setvariables[tugboat][columns=yes]
717
718\StartArticle
719
720\StartAbstract
721    \samplefile{bryson}
722\StopAbstract
723
724\dorecurse {30} {
725    \samplefile{ward}\endgraf
726} \page
727
728\StopArticle
729
730\stoptext
731
732% >>>
733