summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-tugboat.mkiv
blob: e243dc4879bc2571133691499a780710657a504a (plain)
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
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
%D \module
%D   [      file=t-tugboat
%D        version=$Id: s-tugboat.mkiv 246 2019-09-09 18:22:19Z karl $
%D          title=\CONTEXT\ Style File,
%D       subtitle=\TUGBOAT\ base style,
%D         author=Aditya Mahajan and others,
%D           date=\currentdate,
%D      copyright=Public Domain]

%D \filename {s-tug-02} was originally written by Hans Hagen and Steve Grathwohl,
%D and used grid typesetting. \filename {t-tugboat} was a major revision by Aditya
%D Mahajan, no grid. \filename {s-tugboat.mkiv} was another major revision by Taco
%D Hoekwater and Alan Braslau, now with pagecolumns. The latest version has been
%D adapted by Karl Berry.

%D HH: most articles are not that demanding, otherwise I'd probably redefine some
%D of the code below. So, for now things gets adapted when needed.

%D \section{Variables}
%D
%D We store the information about the article in variables.

\setvariables
  [tugboat]
  [type=article,
   columns=yes,
   grid=no]

\setvariables
  [tugboat] % overridden from ../tugboat.dates if present.
  [year=1900,
   volume=0,
   number=0,
   page=900]

\setvariables
  [tugboat]
  [title=ConTeXt style for TUGboat,
   subtitle=,
   keywords=,
   author=T. Boat,
   address=Pragmatically Advanced tugboats\\314 Pi Ave.\\8061GH Hasselt NL,
   email={pragboat@tug.org}]

%D \section{Font Setup}
%D
%D \TUGBOAT\ uses standard CM interline spacing.

\definebodyfontenvironment    [8pt] [interlinespace=9.5pt, big=9pt,   small=7pt]
\definebodyfontenvironment    [9pt] [interlinespace=11pt,  big=10pt,  small=8pt]
\definebodyfontenvironment   [10pt] [interlinespace=12pt,  big=12pt,  small=9pt]
\definebodyfontenvironment   [12pt] [interlinespace=14pt,  big=14.4pt,small=10pt]
\definebodyfontenvironment [14.4pt] [interlinespace=18pt,  big=14.4pt,small=12pt]

%D \TUGBOAT\ uses Computer Modern fonts, and \CONTEXT\ uses Latin Modern by default,
%D which is fine. So, we just specify the font size.

\setupbodyfont [10pt]

%D \TUGBOAT\ uses italic rather than slanted for emphasis.

\setupbodyfontenvironment
  [default]
  [em=italic]

%D Break after these chars in urls, not before.

\sethyphenatedurlafter /
\sethyphenatedurlafter .
\sethyphenatedurlafter _

%D \section{Layout Setup}
%D
%D The original layout used in the \LATEX\ style for \TUGBOAT\ uses low|-|level
%D \TEX\ syntax.

\setuppapersize
  [letter]
  [letter]

\setuplayout
  [topspace=3.8pc,% was 3.5pc
   header=1pc,
   headerdistance=1.5pc,
   height=middle,
   footerdistance=2pc,
   footer=1pc,
   bottomspace=3pc,
   %
   backspace=6pc,
   width=middle,
   cutspace=6pc,
   %
   margin=4pc,
   margindistance=1pc,
  ]

%D With pagecolumns, seemingly can't get single-column floats. (HH: not sure
%D what is meant but probably that it can't be done in the running text.)

\enablemode [pagecolumns]

%D KB: With columnsets, get unwanted gridsetting and blank last pages. HH: can
%D be solved but columnsets normally get set up beforehand (figures and such).

% \enablemode [columnsets]
% \startmode [columnsets]
%    \usemodule [newcolumnsets]
% \stopmode

\setuppagenumbering
  [location=,
   alternative=doublesided]

%D In \TUGBOAT\ different articles are glued together to form the final journal, so
%D we do not want each article to occupy an even number of pages. (Except this seems
%D to have no effect with pagecolumns.) HH: page columns are actually just single
%D columns but combined, so it supports side floats and such.

\installpagebreakhandler {last} {}

%D \section{Indentation}
%D
%D We use automatic indentation control, that is: no indentation after titles and
%D skips.

\setupindenting[20pt,yes]

%D We do not usually want indentation after lists.

\setupenumerations [indentnext=no]
\setupdescriptions [indentnext=no]

%D \section{Itemize}
%D
%D And these. We typeset itemizations ragged right.

\setupitemgroup
  [itemize]
  [indentnext=no,
   align=right]

%D We align them at the paragraph indentation and
%D pack them by default.

\setupitemgroup
  [itemize]
  [each]
  [margin=1pc,
   width=1em,
   distance=0pt]

\setupitemgroup
  [itemize]
  [1]
  [packed]

%D \section{Section Headings}
%D
%D We follow the \TUGBOAT\ style for sections. I do not know if \type {align=right}
%D also disables hyphenation (HH: no that is independent). Let's wait and see on
%D this. The rest is straightforward. It took me a while to realize that in \LATEX\
%D \type {\@startsection} the absolute value of before skip (fourth argument) is
%D important and not the sign.

\setuphead
  [section,subsection,subsubsection,
   subject,subsubject,subsubsubject]
  [style=bold,
   align=right,
   before={\blank[8pt]},
   after={\blank[4pt]}]

%D \section{Spacing}
%D
%D We define a logical skip. This is equal to the \type {\topsep} in \LATEX, and
%D most environments should have this skip.

\defineblank
  [tugblank]
  [3pt]

%D HH: In fact, \type \setupblank[tugblank] would deal with most of the blanks
%D anyway, but let's not change this now.

\setupblank
  [3pt]

\setupitemize
  [1]
  [before={\blank[tugblank]},
   after={\blank[tugblank]},
   inbetween={\blank[tugblank]}]

\setuplines
  [before={\blank[tugblank]},
   after={\blank[tugblank]},
   inbetween={\blank[tugblank]}]

%D \section Typing %<<<1
%D
%D \TUGBOAT\ uses a smaller font size for verbatim typesetting. Not sure why
%D \type {nowhite} is used here.

\setuptyping
  [option=none,
   bodyfont=9pt,
   before={\blank[nowhite,tugblank]},
   after={\blank[back,nowhite,tugblank]}]

%D Do not colorize code.

\setuptyping[LUA][option=]
\setuptyping[TEX][option=]
\setuptyping[MP] [option=]

%D Tiny line numbers in numbered code (not text size)

\setuplinenumbering[style=\tfxx] % \infofont would be really tiny

%D \section{Figure captions}
%D
%D \TUGBOAT\ uses a smaller font size for captions, too; \type {\small} gives 8pt,
%D and we want 9pt, so we have to manually fix the baselines.

\setupcaptions
  [headstyle=\AcroFontBold,
   style={\AcroFont\advance\baselineskip by -1pt},
   align=right]

%D We like a colon after the caption label.

\let\floatcaptionsuffix=:

% Prefer floats in text.

\setupfloat[figure][align=middle,default=here]
\setupfloat[table] [align=middle,default=here]

%D \section{Footnotes}
%D
%D Not entirely a la \TUGBOAT:

% rule={\hrule width 5pc height .4pt depth 0pt\relax \kern \strutdepth},

\setupfootnotes
  [bodyfont=9pt]

\doif {\getvariable{tugboat}{columns}} {yes} {
    \setupfootnotes
      [location=columns]
}

\setupnotation
  [footnote]
  [location=joinedup,
   width=fit,
   headstyle=normal,
   distance=.5em]

%D \section{List}
%D
%D We define a standard description and enumeration environment.

\definedescription
  [description]
  [location=hanging,
   width=broad,
   before={\blank[tugblank]},
   after={\blank[tugblank]}]

\defineenumeration
  [enumeration]
  [location=hanging,
   width=broad,
   before={\blank[tugblank]},
   after={\blank[tugblank]}]

%D \section{References}
%D
%D More or less like plain BibTeX + ltugboat.

\setupbtx
  [default:list:numbering]
  [left={[},
   right={]}]

\setupbtxlist
  [default]
  [width=2em,
   style={\frenchspacing},
   align={raggedright,verystrict}]

%D Instead of color, we use weighted gray scales:

\setupcolors
  [conversion=always]

%D We define some logical skips

\defineblank [tugbefore]   [big]
\defineblank [tuginbetween][big]
\defineblank [tugafter]    [tugbefore]

%D Some real macros: <<<

\def\StartAbstract
  {\dostartbuffer[abstract][StartAbstract][StopAbstract]}

\startsetups tugboat:abstract:setup

  % \setuptolerance
  %   [horizontal, tolerant]

    \setupnarrower
      [before={\blank[.5\baselineskip]},
     % after={\blank[10pt plus4pt minus4pt]},
       after={\blank[10pt]},
       middle=4.875pc]

    \setupindenting
      [20pt,yes]

\stopsetups

%D Headers and footers.

\startsetups tugboat:banner:text:article

    {\sl TUGboat},\space
    Volume \getvariable{tugboat}{volume}\space
    (\getvariable{tugboat}{year}),\space
    No.\space\getvariable{tugboat}{number}

\stopsetups

\def\postissno{Proceedings of the \tubyear\ Annual Meeting}

\startsetups tugboat:banner:text:proceedings

    \setups{tugboat:banner:text:article}
    \thinspace---\thinspace
    \postissno

\stopsetups

\startsetups tugboat:banner:setup:article

  \setupheadertexts
    [\setups{tugboat:banner:text:article}]
    [\pagenumber]

    % no footer in regular articles

  \setupfootertexts
    [][\getvariable{tugboat}{author}]
    [\getvariable{tugboat}{title}][]

\stopsetups

%D article is default.

\setups{tugboat:banner:setup:article}

%D It all starts here:

\def\StartArticle{\setups{tugboat:\getvariable{tugboat}{type}:start}}
\def\StopArticle {\setups{tugboat:article:stop}}

\startsetups tugboat:grid:setup:settings:yes

    \setupblank
      [line]

    \defineblank [tugbefore]    [halfline]
    \defineblank [tuginbetween] [halfline]

\stopsetups

% \startsetups tugboat:grid:setup:no
%
%   \setupblank
%     [halfline]
%
%   \defineblank [medium]       [halfline]
%   \defineblank [tugbefore]    [halfline]
%   \defineblank [tuginbetween] [halfline]
%
% \stopsetups

\startsetups tugboat:introduction:article

  % \blank[halfline]

    \start
        \def\\{\unskip\space\&\space\ignorespaces}
        \hbox{\indent\getvariable{tugboat}{author}}
        \par
    \stop

\stopsetups

\startsetups tugboat:article:start

    \starttext

    \setups{tugboat:columns:\getvariable{tugboat}{columns}}
    \setups{tugboat:banner:setup:\getvariable{tugboat}{type}}

    \doif {\getvariable{tugboat}{columns}} {yes} {
        \doifmodeelse {columnset}  {
            \startcolumnset
        } {
            \doifmodeelse {pagecolumns} {
                \startpagecolumns
            } {
                \startcolumns
            }
        }
    }

    \setcounter
      [userpage]
      [\getvariable{tugboat}{page}]

    \setups{tugboat:grid:setup:\getvariable{tugboat}{grid}}

    \snaptogrid \vbox \bgroup

        \forgetall
        \hrule height .6pt
        \blank[halfline]
        \start
            \let\\=\par
            {\bf\getvariable{tugboat}{title}}
            \par
            \blank[halfline]
            \hskip20pt\getvariable{tugboat}{author}
        \stop

        \blank[line]

        \doiftext {\getbuffer[abstract]} {
            \let\\=\endgraf
            \setups{tugboat:abstract:setup}
            \subject{Abstract}
            \getbuffer[abstract]
        }

    \egroup

\stopsetups

\startsetups tugboat:affiliation:article

    \blank[line]
    \begingroup
        \leftskip=5.7pc
        \noindent
        \llap{\sym{\diamond}\enspace}
        \getvariable{tugboat}{author}
        \\
        \getvariable{tugboat}{address}
        \\
        {\tt\getvariable{tugboat}{email}}
        \par
    \endgroup

\stopsetups

\startsetups tugboat:article:stop

    \setups{tugboat:affiliation:\getvariable{tugboat}{type}}

    % article joining in the issue.

    \ifx\writelastpage\undefined \else
        \begingroup
        \count0=\count1 % because context uses \count0
        \writelastpage{+1}%
        \endgroup
    \fi

  \stoptext

\stopsetups

%D Normal word spacing, please.

\setuptolerance
  [strict]

%D Hz is fine but hanging can hang quotes out too far.

\setupalign[hz]

%D Let's see boxes overfull by >.5pt

\overfullrule =  2pt % yes, I want to see
\hfuzz        = .5pt

%D One can use the following setups (in the article) to collect settings specific to
%D normal and|/|or multi column typesetting.

\startsetups tugboat:columns:yes

    \doifmodeelse {columnset} {
        \setuplayout
            [grid=no]
        \setupcolumnset
            [distance=1.5pc]
    } {
        \doifmodeelse {pagecolumns} {
            \setuplayout
                [grid=no]
            \setuppagecolumns
                [distance=1.5pc]
         } {
            \setupcolumns
                [distance=1.5pc]
        }
    }

\stopsetups

% \startsetups tugboat:columns:no
%
% \stopsetups

%D Logos, abbreviations: lots could be better here.

\font\mflogo=logo10 % hm, better use \definefont

%D HH: I'm pretty sure that this doesn't really work as it probably assumes some
%D specific math family setup and that's not how \MKIV\ works. The TB definition
%D doesn't scale with font changes and also doesn't adapt itself to style changes.

\newcount\TestCount
\newbox  \TestBox

\def\La
  {\dontleavehmode
   \begingroup
   \TestCount=\the\fam % no meaningful fams in text mode in ConTeXt
   \setbox\TestBox=\hbox{$\fam\TestCount\scriptstyle A$}%
   L\kern-.5\wd\TestBox\raise.42ex\box\TestBox
   \endgroup}

%D Probably this will do a better job:

% \def\La
%   {\dontleavehmode
%    \begingroup
%    \setbox\scratchbox\hbox{\tx A}% % or \txx
%    L\kern-.5\wd\scratchbox\raise.42ex\scratchbox
%    \endgroup}

\def\ALEPH     {Aleph}
\def\API       {\acro{API}}
\def\CCODE     {C}
\def\CD        {\acro{CD}}
\def\CMYK      {\acro{CMYK}}
\def\CONTEXT   {C\kern-.0333emon\-\kern-.0667em\TeX\kern-.0333emt}
\def\Cplusplus {C\plusplus}
\def\CPU       {\acro{CPU}}
\def\DVI       {\acro{DVI}}
\def\DVIPDFMX  {dvipdfmx}
\def\DVIPS     {dvips}
\def\ETEX      {$\varepsilon$-\kern-.125em\TeX}
\def\FTP       {\acro{FTP}}
\def\HTTP      {\acro{HTTP}}
\def\IO        {\acro{I/O}}
\def\ISO       {\acro{ISO}}
\def\KPSE      {\acro{KPSE}}
\def\KPSEWHICH {kpsewhich}
\def\LATEX     {\La\kern-.15em\TeX}
\def\LATEXE    {\LaTeX{}\kern.05em2$_{\textstyle\varepsilon}$}
\def\LINUX     {Linux}
\def\LPEG      {Lpeg}
\def\LUA       {Lua}
\def\LUAJIT    {Lua\acro{JIT}}
\def\LUATEX    {Lua\-\TeX}
\def\LUATOOLS  {lua\-tools}
\def\MATHML    {Math\acro{ML}}
\def\METAFUN   {Metafun}
\def\METAPOST  {MetaPost}
\def\METATEX   {Meta\TeX{}}
\def\MF        {{\mflogo META\-FONT}}
\def\MKII      {Mk\acro{II}}
\def\MKIV      {Mk\acro{IV}}
\def\MPLIB     {\acro{MP}lib}
\def\MPTOPDF   {mp\-to\-pdf}
\def\MSWINDOWS {Windows}
\def\MTXTOOLS  {mtx\-tools}
\def\NFSS      {\acro{NFSS}}
\def\OPENMATH  {Open\-Math}
\def\OPENTYPE  {Open\-Type}
\def\PASCAL    {Pascal}
\def\PDF       {\acro{PDF}}
\def\PDFTEX    {pdf\/\-\TeX}
\def\plusplus  {\lower.45ex\hbox{$^{++}$}}
\def\POSIX     {\acro{POSIX}}
\def\POSTSCRIPT{Post\-Script}
\def\PRAGMA    {Pragma \acro{ADE}}
\def\RGB       {\acro{RGB}}
\def\RUBY      {Ruby}
\def\SCITE     {Sci\acro{TE}}
\def\TDS       {\acro{TDS}}
\def\TEX       {\TeX}
\def\TEXBOOK   {{\sl The \TeX book}}
\def\TEXEXEC   {\TeX exec}
\def\TFM       {\acro{TFM}}
\def\TRUETYPE  {True\-Type}
\def\TYPEONE   {Type~1}
\def\UTF       {\acro{UTF}}
\def\WEBC      {Web2C}
\def\XETEX     {X\lower.5ex\hbox{\kern-.15em\mirror{E}}\kern-.1667em\TeX}
\def\XML       {\acro{XML}}
\def\XPATH     {\acro{XP}ath}
\def\XSLT      {\acro{XSLT}}
\def\XSLTPROC  {\acro{XSLTPROC}}
\def\ZIP       {zip}

\def\Dash      {\unskip\nobreak\thinspace---\thinspace\ignorespaces}
\def\slash     {/\penalty0 \hskip0pt \relax}

% \acro for one point size smaller. Don't know how to do this for real.

\definefont[AcroFont]     [Serif*default     sa .91]
\definefont[AcroFontBold] [SerifBold*default sa .91]
\definefont[AcroFontSmall][Serif*default     sa .80]

\unexpanded\def\acro     #1{{\AcroFont      #1}} % could be a style definition
\unexpanded\def\acrobf   #1{{\AcroFontBold  #1}} % could be a style definition
\unexpanded\def\acrosmall#1{{\AcroFontSmall #1}} % could be a style definition

%D This is English; disallow x- or -xx breaks. (These are already the defaults
%D but let's keep this anyway.)

\setuplanguage
  [en]
  [lefthyphenmin=2,
   righthyphenmin=3]

% \lefthyphenmin  = 2
% \righthyphenmin = 3

\mainlanguage
  [en]

\hyphenation {
    Post-Script
    data-base
    data-bases
}

%D A hack to read \type {tugboat.dates} settings.

\doifelsefileexists {../tugboat.dates} {

    \newif   \ifPrelimDraft
    \newcount\issueseqno

    \def\vol    #1, #2.{\gdef\tubvol {#1}%
                        \gdef\tubnum {#2}}
    \def\issyear    #1.{\gdef\tubyear{#1}}

    \input ../tugboat.dates

    \setevariables
      [tugboat]
      [year=\tubyear,
       volume=\tubvol,
       number=\tubnum,
       page=\the\count0]

} {
    % nothing
}

%D Good bye.

\continueifinputfile{s-tugboat.mkiv}

% \showgrid

\starttext

\StartArticle

\StartAbstract
    \samplefile{bryson}
\StopAbstract

\dorecurse{30}{\input ward \endgraf} \page

\startitemize
    \startitem \samplefile{ward} \stopitem
    \startitem \samplefile{ward} \stopitem
\stopitemize

\StopArticle

\setvariables[tugboat][columns=yes]

\StartArticle

\StartAbstract
    \samplefile{bryson}
\StopAbstract

\dorecurse {30} {
    \samplefile{ward}\endgraf
} \page

\StopArticle

\stoptext

% >>>