summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/s-ptj-01.tex
blob: 188af73bd7e485a2195e9ee2a4e870b21ec2c1ad (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
%D \module
%D   [      file=s-ptj-01,
%D        version=2006.11.28,
%D          title=\CONTEXT\ Style File,
%D       subtitle=PracTeX Journal Style,
%D         author=Aditya Mahajan,
%D          email=adityam at umich dot edu,
%D           date=\currentdate,
%D      copyright=2006 Aditya Mahajan]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%M % These macros are needed to compile the documentation.
%M \def\PracTeX{Prac\kern-0.07em\TeX}
%M \def\PRACTEX{\PracTeX}
%M \def\TPJ    {The \PRACTEX\ Journal}
%M \useurl[TPJ][http://www.tug.org/pracjourn/][][\TPJ]
%M \useurl[texgyre][http://www.gust.org.pl/projects/e-foundry/tex-gyre/]

\writestatus  {loading}   {Context Module for the PracTeX Journal}

%D This module is for producing acticles for \from[TPJ]. It merely copies the
%D layout of the the \LATEX\ class \filename{pracjourn.cls} available from
%D \TPJ\ website (\url[TPJ]).  This module has a filename synonym
%D \filename{pracjourn}. So to use this module, you can write:
%D \starttyping
%D \usemodule[pracjourn]
%D \stoptyping
%D A sample document is given at the end of this file. The typeset sample can
%D be obtained by
%D \starttyping
%D texmfstart texexec --mode=demo s-ptj-01.tex
%D \stoptyping
%D The documentation is written as comments. If you want to see a \PDF\ copy
%D \starttyping
%D texmfstart texexec --module s-ptj-01.tex
%D \stoptyping

\startmodule[pracjourn]

\unprotect

%D First let's setup the paper size and layout for \TPJ. I am actually not
%D sure about the \quote{official} layout requirement for \TPJ\ and have
%D reverse engineered the layout from the typeset \LATEX\ examples. If you
%D feel that anything is wrong here, please let me know.

\setuppapersize
  [letter][letter]

\setuplayout
  [              width=middle,
                height=middle,
              location=middle,
              topspace=1.25in,
           bottomspace=1in,
             backspace=1in,
              cutspace=1in,
            leftmargin=0.25in,
           rightmargin=0.25in,
    leftmargindistance=0in,
   rightmargindistance=0in,
                header=1in,
                footer=.5in,
         headerdistace=0in,
        footerdistance=.25in,
  ]

%D Next we do the font setup. \TPJ\ uses mathpazo for roman and math faces and
%D uses latin modern for sans serif and monotype. For the main face, 12pt is
%D used with a 15.5pt baseline skip. Font protrusion is enabled, but font
%D expansion is not. We follow these conventions, but use Pagella fonts from
%D \TEX{gyre} project, and scale latin modern fonts by 1.1 for better
%D matching. Right now, the \TEX{gyre} fonts are not distributed with
%D \CONTEXT. They can be downloaded from \url[texgyre]. Most of the numbers
%D (page numbers, figure numbers, section numbers) are set in oldstyle.

\usetypescript  [serif,sans,mono] [hanging] [pure]
\setupalign     [hanging]

\usetypescriptfile
  [type-gyr]

\definetypeface
  [mainface] [rm] [serif] [palatino] [default] [encoding=texnansi]
\definetypeface
  [mainface] [ss] [sans]  [modern]   [default]  [encoding=texnansi, rscale=1.1]
\definetypeface
  [mainface] [tt] [mono]  [modern]   [default]  [encoding=texnansi, rscale=1.1]
\definetypeface
  [mainface] [mm] [math]  [palatino] [default]  [encoding=texnansi]

\setupbodyfont
  [mainface,12pt]

\definefont [titlefont]  [Regular at 20pt]
\definefont [authorfont] [Regular at 14pt]

\setupbodyfontenvironment
  [12pt]
  [interlinespace=15.5pt,em=italic]

\setupbodyfontenvironment
  [11pt]
  [interlinespace=13.6pt,em=italic]

%D The variables for the article are stored in the \mono{pracjourn} namespace.
%D To initialize these variables use
%D \starttyping
%D \setvariables
%D  [pracjourn]
%D  [    title=Tile of the Article,
%D      author=Name of Author,
%D     address=Write your Address,
%D    revision={d=14,m=11,y=2006},
%D   copyright=Whatever you want,
%D  ]
%D \stoptyping
%D \mono{title} and \mono{author} should always be entered (even though this
%D module does not make them mandatory, it makes little sense to have an
%D article without a title or author. Other variables are optional. If a
%D revision is not written, current date will be used to show the revision.
%D Other variables for the article are the author's email address and website
%D url. Due to catcode problems, it is not always possible to reliably enter
%D these using the variable mechanism. To enter these use \type|\useURL|
%D \starttyping
%D \useURL[email][mailto:address@whatever.com][][address@whatever.com]
%D \useURL[website][link to your homepage]
%D \stoptyping
%D If either of these \URL's are not present, they will be silently ignored
%D while generating the title.

\setvariables [pracjourn] [    title=]
\setvariables [pracjourn] [   author=]
\setvariables [pracjourn] [  address=]
\setvariables [pracjourn] [copyright=]
\setvariables [pracjourn] [ revision=]

%D We use the buffer \filename{abstract} for the abstract. So to enter the
%D abstract, write
%D \starttyping
%D \startbuffer[abstract]
%D Write your abstract
%D \stopbuffer
%D \stoptyping
%D Right now, there is no mechanism to inhibt abstracts. In case someone
%D requires it, such a mechanism is easy to implement.

\startbuffer[abstract]
\stopbuffer

%D The actual title with the additional information is typset by calling
%D \starttyping
%D \setups{title}
%D \stoptyping
%D Remember that the \type|\setvariables[pracjourn][...]| step must be done
%D before \type|\setups{title}|.

\setuphead
  [title]
  [style=\titlefont,
   after={\blank[big]}]

%D Next we define internal frames to take care of the layout of the extra
%D material in the title. These start with \type|do...| to prevent clash with
%D user macros. (I do not like writing @ in macro names).

\defineframed
  [doinfotitle]
  [   frame=off,
      strut=yes,
      width=0.1\textwidth,
     height=fit,
      align=left,
   location=hanging,
  ]

\defineframed
  [doinfodetails]
  [   frame=off,
      strut=yes,
      width=0.85\textwidth,
     height=fit,
      align=normal,
   location=hanging,
  ]

\newif\iftitleskipdone

\def\doadditionalinfo#1#2
  {\titleskipdonetrue
    \hbox to \textwidth
   \bgroup
    \hfill \doinfotitle{#1}
    \hfill \doinfodetails{#2}
   \egroup\endgraf}

%D Now we take care of the actual layout of the title. Most of this is
%D heuristic, as I was trying to get the same visual effect as the
%D \filename{pracjourn.cls} class. If something does not match, please let me
%D know. The additional information is typeset as
%D \starttyping
%D \hfill <box of .1\textwidth> \hfill <box of .85\textwidth>
%D \stoptyping
%D at 11pt size. We also add the title and author information in the \PDF\
%D metadata.

\startrawsetups [title]
% Place the tile and the author
  \title{\getvariable{pracjourn}{title}}
  \blank[medium]
  \bgroup\authorfont\setupinterlinespace
  \getvariable{pracjourn}{author} \endgraf\egroup
  \blank[2*big]
% Place the additional information
  \bgroup\switchtobodyfont[11pt]
  \setupindenting[no]
  \doifdefined{\v!file:::email}
    {\doadditionalinfo{Email}{\tttf\from[email]\relax}}
  \doifdefined{\v!file:::website}
    {\doadditionalinfo{Website}{\from[website]\relax}}
  \doifsomething{\getvariable{pracjourn}{address}}
    {\doadditionalinfo{Address}{\getvariable{pracjourn}{address}}}
  \iftitleskipdone  \blank[big] \fi
  \doadditionalinfo{Abstract}%
    {\setupindenting[yes]%
     \setupinterlinespace%
     \getbuffer[abstract]
     \endgraf}
  \egroup
  \blank[big]
% If revision number is present, write it to \filename{_rev.tex}
% FIXME: Do we need to ensure that the dates and month are two digits?
  \doifsomething{\getvariable{pracjourn}{revision}}
  {\expanded{\setvariables[pracjourn:date][y=,m=,d=,\getvariable{pracjourn}{revision}]}
   \immediate\openout \scratchwrite _rev.tex
   \immediate\write   \scratchwrite
   {\getvariable{pracjourn:date}{y}/\getvariable{pracjourn:date}{m}/\getvariable{pracjourn:date}{d}}
   \immediate\closeout\scratchwrite}
% Add information to pdfmetadata
  \setupinteraction
    [title={\getvariable{pracjourn}{title}},
    author={\getvariable{pracjourn}{author}},
    subtitle={The PracTeX Journal Article}]
\stoprawsetups

%D Next we setup the header and footer for the first page. \TPJ\ formats the
%D header as
%D \startlines
%D The PracTeX Journal, year, No. number
%D Article revision year/mm/dd
%D \stoplines
%D If a copyright notice is present, it is printed right aligned on the bottom
%D of first page. Otherwise the footer on the first page is empty.

\startlocalsetups [titleheader]
  \framed[frame=off,width=\textwidth,align=normal,location=low]
  {\small\setupinterlinespace
   \doifelsenothing{\TPJissue}{For submission to \TPJ}{\TPJissue}\endgraf
   \doifelsenothing{\getvariable{pracjourn}{revision}}
   {Draft of \currentdate[year,/,mm,/,dd]}
   {Article revision\space
     \expanded{\date[\getvariable{pracjourn}{revision}][year,/,mm,/,dd]}}
    \endgraf}
\stoplocalsetups

\startlocalsetups [titlefooter]
  \framed[frame=off,width=\textwidth,align=flushright,location=low]
  {\small\setupinterlinespace
  \getvariable{pracjourn}{copyright}\endgraf}
\stoplocalsetups

\definetext [titleheader] [header]  [\setups{titleheader}][]
\definetext [titlefooter] [footer]  [\setups{titlefooter}]
\setuphead  [title]       [header=titleheader,footer=titlefooter]

%D For rest of the pages, page number is printed on the middle of the footer.

\setuppagenumbering [location={footer,middle}, style=mediaeval]

%D Next we setup the formating for the sections.  \TPJ\ wants font sizes of
%D 17pt, 14pt, and 12pt respectively for section, subsection, and
%D subsubsection. By default, \tex{tfa} is 1.2, \tex{tfb} is 1.4, so the sizes
%D come out close to what is required. The section number is typset in
%D oldstyle fonts.

\setuphead
  [section,subject]
  [      style=\tfb,
   numberstyle=mediaeval,
        before={\blank[2*big]},
         after={\blank[big]},
  ]

\setuphead
  [subsection,subsubject]
  [      style=\tfa,
   numberstyle=mediaeval,
        before={\blank[big]},
         after={\blank[medium]},
  ]

\setuphead
  [subsubsection,subsubsubject]
  [      style=\tf,
   numberstyle=mediaeval,
        before={\blank[medium]},
         after={\blank},
  ]

%D Now we setup the captions. The captions head are set in normal font, and
%D the caption number is set in oldstlyle.

\setupcaptions  [headstyle=normal,stopper=:,conversion=mediaeval]

%D Footnotes are placed in a box with a width of 1.5em. The footnote numeral
%D are set in oldstyle font.

\setupnote
  [footnote]
  [margindistance=0em,
       conversion=mediaeval,
          command=\pracjournfootnote,
  ]

\setupnotedefinition  [footnote]  [location=left,hang=1]

\def\pracjournfootnote#1{\hbox to 1.5em{#1.}}

%D \TPJ\ uses dash as the first level of itemize and text period as the second
%D level. The third level is left unspecified.

\definesymbol [1]     [{\symbol[dash]}]
\definesymbol [2]     [\periodcentered]

\setupitemize [each]  [packed]
\setupitemize [1]     [packed,autointro]  [margin=1em]

%D We change \type|\type| so that the argument inside \type|\type| is pretty
%D printed using \TEX's patterns. Another command \type|\normaltype| can be
%D used if you do not want the original \type|\type|.

\setuptype    [option=TEX]
\definetype   [normaltype]  [option=none]

%D We enable colors, interaction and bookmarks.

\setupinteraction [state=start,color=darkred,style=normal]
\setupurl         [color=darkred]
\setupcolors      [state=start]
\placebookmarks   [section,subsection]  [section]

%D We setup medium indenting, whitespace and blanks.

\setupindenting   [medium,yes]
\setupwhitespace  [medium]
\setupblank       [medium]

%D We define logos for \PRACTEX\ and \TPJ. These definitions are copied from
%D \filename{pracjourn.cls} and can be accessed by \type|\PracTeX|,
%D \type|\PRACTEX| and \type|\TPJ|.

\def\PracTeX{Prac\kern-0.07em\TeX}
\def\PRACTEX{\PracTeX}
\def\TPJ    {The \PRACTEX\ Journal}

%D \filename{pracjourn.cls} provides two macros \type|\ctanfile| and
%D \type|\ctanloc|. I am not sure what is the advantage of these macors. If
%D you want to use these macros, you can use the \type|\useURL| mechanism of
%D \CONTEXT. For example
%D \starttyping
%D \useURL[pracjourn][http://ctan.org/get?fn=/macros/contrib/latex/pracjourn][][\mono{CTAN:macros/contrib/latex/pracjourn}]
%D The \LATEX\ style files for \TPJ\ is localed at \from[pracjourn]
%D \stoptyping

%D For the final version of the paper, the string \quotation{The PracTeX
%D Journal year, No x} is written on the header. This only happens when the
%D current directory contains a file \filename{_iss.tex} which contains string
%D like \quotation{TPJ 2006 No 04, 2006-11-15}. This step is usually taken in
%D the final production of the article. If this file is absent, \quotation{For
%D submission to the PracTeX Journal} is written instead. The next macros are
%D used to parse this file.

\let\TPJissue\empty

\def\parse@iss TPJ #1 No #2, #3-#4-#5\@nil%
  {\!!counta#2\relax
  \edef\TPJissue{\TPJ, #1, No.\,\the\!!counta}}

%D Read the \filename{_iss.tex} file, if present to determine the current
%D issue.

\immediate\openin\scratchread _iss.tex
\ifeof\scratchread\else
  \read \scratchread to \!!stringa
  \expandafter\parse@iss\!!stringa\@nil
\fi
\immediate\closein\scratchread

\protect

\stopmodule

\doifnotmode{demo}{\endinput}

\usemodule[pracjourn]

\setvariables
  [pracjourn]
  [    title=\PRACTEX\ Article in \CONTEXT,
      author=Aditya Mahajan,
     address={Ann Arbor,\\ Michigan, USA.},
    revision={y=2006,m=11,d=14},
   copyright={Copyright \copyright\ 2006 Aditya Mahajan.}
  ]

\useURL[website][http://www.eecs.umich.edu/~adityam]
\useURL[email][mailto:adityam@umich.edu][][adityam@umich.edu]

%D If any of the above information is not provided, the corresponding entry
%D will not apprear in the title.

\startbuffer[abstract]
Write abstract here
\stopbuffer

\starttext  \setups[title]

\section{Introduction}

Write your article \unknown

\stoptext

\endinput