summaryrefslogtreecommitdiff
path: root/tex/context/modules/mkiv/s-magazine-basic.mkiv
blob: 267bf50d898fbaab786ab0b5ea1659348cb94f4b (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
%D \module
%D   [      file=s-magazine-basic, % was: s-mag-01
%D        version=2016.09.12, % mkiv version of 2002.12.14,
%D          title=\CONTEXT\ Style File,
%D       subtitle=\CONTEXT\ Magazine Base Style,
%D         author=Hans Hagen,
%D           date=\currentdate,
%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.

%D This style is used for producing explanationary documents. Don't misuse it for
%D other purposes, since it may confuse users. Don't change the title either, since
%D it provides a way to categorize documents. Numbers are disabled in instances
%D produced outside PRAGMA ADE.
%D
%D The layout setup is such that one has several text areas available: headers and
%D footers, margins and edges as well as the main text area. The surrounding (gray)
%D makes the main page stand out and is suitable for viewing in spread mode.
%D
%D Since this style is under constant construction, messing around with settings
%D will produce unwanted side effects. So, if some feature or settings is needed,
%D let me know.

% These are reserved for PRAGMA-ADE, don't use them yourself!

% \setupdocument[main=Tricky]
% \setupdocument[main=Update]
% \setupdocument[main=HOWTO]

% \setupdocument[main=This Way]      % preludes to a/the manual
% \setupdocument[main=A Better Way]  % dirty versus clean
% \setupdocument[main=No Way]        % how users should not do it
% \setupdocument[main=Your Way]      % how users do it
% \setupdocument[main=My Way]        % how users do it
% \setupdocument[main=Our Way]       % how we do things at pragma
% \setupdocument[main=Their Way]     % how to do latex things in context

\usemodule[narrowtt,scite]

\definepapersize
  [magazine]
  [width=\dimexpr\paperwidth-.1\paperwidth\relax,
   height=\dimexpr\paperheight-.1\paperheight\relax]

\setuppapersize
  [magazine]
  [A4]

\setupinteractionscreen
  [option=doublesided]

\setupexternalfigures
  [location={local,default}]

\definecolor[OuterColor][s=.3]
\definecolor[InnerColor][s=.8]
\definecolor[MainColor] [s=.2]
\definecolor[TitleColor][s=.9]

\definecolor[MyRed]  [r=.6]
\definecolor[MyGreen][g=.6]
\definecolor[MyBlue] [b=.6]

\startreusableMPgraphic{middlepaper}
    fill OverlayBox
        withshademethod "circular"
        withshadecenter center (0.5,0.5)
        withshadecolors ("InnerColor","OuterColor") ;
\stopreusableMPgraphic

\startreusableMPgraphic{rightpaper}
    fill OverlayBox
        withshademethod "circular"
        withshadecenter center (0,0.5)
        withshadecolors ("InnerColor","OuterColor") ;
\stopreusableMPgraphic

\startreusableMPgraphic{leftpaper}
    fill OverlayBox
        withshademethod "circular"
        withshadecenter center (1,0.5)
        withshadecolors ("InnerColor","OuterColor") ;
\stopreusableMPgraphic

\startreusableMPgraphic{page}
    fill OverlayBox withcolor white ;
\stopreusableMPgraphic

\startusableMPgraphic{text}
    StartPage ;
        for i = Header,Text,Footer :
            for j = LeftEdge, LeftMargin, Text, RightMargin, RightEdge :
                draw Field[i][j] withpen pencircle scaled .5pt ;
            endfor ;
        endfor ;
    StopPage ;
    setbounds currentpicture to Field[Text][Text] ;
\stopusableMPgraphic

\startsetups[paper]

    \doifmodeelse{*makeup} {
        \reuseMPgraphic{middlepaper}
    } {
        \doifoddpageelse {
            \reuseMPgraphic{rightpaper}
        } {
            \reuseMPgraphic{leftpaper}}
        }

\stopsetups

\defineoverlay[paper] [\setups{paper}]
\defineoverlay[page]  [\reuseMPgraphic{page}]
\defineoverlay[text]  [\doifmode{frame}{\useMPgraphic{text}}]

\setupbackgrounds [paper] [background=paper]
\setupbackgrounds [page]  [background={page,title}]
\setupbackgrounds [text]  [background=text]

\definelayer
  [title]
  [state=repeat,
   hoffset=-1cm,
   voffset=1cm,
   width=\paperwidth,
   height=\paperheight]

\setuplayout
  [width=middle,
   topspace=1.5cm,
   height=middle,
   header=1.5cm,
   footer=1cm,
  %grid=yes,
   headerdistance=.25cm,
   footerdistance=.5cm,
   backspace=3cm,
   margin=1.5cm,
   margindistance=.25cm,
   edge=.75cm,
   edgedistance=.25cm,
   bottomdistance=1.5cm,
   bottom=.1\printpaperheight]

\definelayout
  [listing]
  [backspace=15mm,
   curspace=15mm]

\definelayout
  [makeup]
  [topspace=1cm,
   backspace=1cm,
   header=0pt,
   footer=0pt,
   bottom=0pt]

\setuppagenumbering
  [alternative=doublesided]

\setupbodyfont
  [pagella,10pt]

\setuptolerance
  [verytolerant,stretch]

\appendtoks
    \setups[papershift]%
\to \beforeeverypage

\startsetups[papershift]

    \setuppapersize[top=\vskip.5cm,bottom=\vss]

    \doifmodeelse{*makeup} {
        \setuppapersize[left=\hfill,right=\hfill]
    } {
        \doifoddpageelse {
            \setuppapersize[right=\hfill]
        } {
            \setuppapersize[left=\hfill]
        }
    }

\stopsetups

\setupbottomtexts
  [\setups{rightbanner}] []
  [] [\setups{leftbanner}]

\startsetups [leftbanner]

    \definedfont[Regular*default at \the\bottomheight]

    \TitleColor

    \setbox\scratchbox\hbox {
        \documentvariable{main}
    }
    \ht\scratchbox\exheight
    \dp\scratchbox\zeropoint

    \definedfont[Regular*default sa 2]
    \doifsomething {\documentvariable{number}} {
        \doifnot {\documentvariable{number}} {0} {
            \#\documentvariable{number}
        }
    }
    \quad
    \currentdate
    \quad
    \scale
        [height=.25\bottomheight]
        {\box\scratchbox}
    \quad
    \hbox to 1.5em{\hss\pagenumber\hss}
    \quad
    \hskip-\backspace

\stopsetups

\startsetups [rightbanner]

    \definedfont[Regular*default at \the\bottomheight]

    \TitleColor

    \setbox\scratchbox\hbox {
        \documentvariable{main}
    }
    \ht\scratchbox\exheight
    \dp\scratchbox\zeropoint

    \hskip-\backspace
    \definedfont[Regular*default sa 2]
    \quad
    \hbox to 1.5em{\hss\pagenumber\hss}
    \quad
    \scale
        [height=.25\bottomheight]
        {\box\scratchbox}
    \quad
    \currentdate
    \quad
    \doifmode {atpragma} {
        \#\documentvariable{number}
    }

\stopsetups

\startsetups[titlepage]

    \disablemode[frame]

    \doifmode {atpragma} {
        \definecolor[pragmacolor] [r=1,g=.62,b=.06] % (Pantone 138 CV)
        \definecolor[OuterColor][.3(\documentvariable{color})]
    }

    \setuplayout[makeup]

    \startstandardmakeup[doublesided=no]

        \dontcomplain

        \definelayer
          [makeup]
          [width=\textwidth,
           height=\textheight]

        \setlayerframed [
                makeup
            ] [
                corner={left,top},
                location={right,bottom}
            ] [
                frame=off,
                foregroundcolor=MainColor
            ] {
                \scale
                    [width=\makeupwidth]
                    {
                        \definedfont[Regular*default sa 10]
                        \documentvariable{main}
                    }
            }

        \setlayerframed [
                makeup
            ] [
                corner={right,top},
                location={left},
                y=.4\textheight
            ] [
                frame=off,
                foregroundcolor=MainColor,
                width=\textwidth,
                align=left
            ] {
                \definedfont[Regular*default sa 2.5]
                \setupinterlinespace
                \startmode[atpragma]
                    \strut \ConTeXt\ magazine \#\documentvariable{number}\endgraf
                \stopmode
                \strut \documentvariable{date} \endgraf
                \blank
                \strut \documentvariable{title}\endgraf
                \doifsomething {\documentvariable{author}} {
                    \strut \documentvariable{author}\endgraf
                }
                \doifsomething {\documentvariable{affiliation}} {
                    \strut \documentvariable{affiliation}\endgraf
                }
            }

        \setlayerframed [
            makeup
        ] [
            corner={right,bottom},
            location={left,top}
        ] [
            frame=off,
            align=normal,
            width=.8\textwidth,
            foregroundcolor=MainColor
        ] {
            \getbuffer[abstract]
        }

        \flushlayer[makeup]

    \stopstandardmakeup

    \setuplayout[reset]

\stopsetups

\startsetups[cleanup]

    \page

    \setuptexttexts
      [margin]
      [] []

\stopsetups

\startsetups[listing]

    \page \disablemode[frame]

    \setuptexttexts  [][] \setuptexttexts  []
    \setupheadertexts[][] \setupheadertexts[source code of this document]
    \setupfootertexts[][] \setupfootertexts[]

    \setuplayout[listing]

    \start

        \dontcomplain

        \switchtobodyfont[8pt]

        \scitefile[\jobfilefullname]

        \page

    \stop

    \setuplayout

\stopsetups

\startsetups[lastpage]

    \page \disablemode[frame] \page[even]

    \doifoddpageelse {
    } {
        \setuplayout[makeup]
        \startstandardmakeup[doublesided=no,page=]
        \stopstandardmakeup
        \setuplayout[reset]
    }

\stopsetups

\startsetups[title]

    \disablemode[frame]

    \setlayerframed [
            title
        ] [
            corner={left,top},
            location={left,bottom},
            rotation=90
        ] [
            frame=off,
            foregroundcolor=TitleColor
        ] {
            \definedfont[RegularBold*default sa 2]
            \strut\documentvariable{title}
        }

    \setlayerframed [
            title
        ] [
            corner={right,top},
            rotation=270
        ] [
            frame=off,
            foregroundcolor=TitleColor
        ] {
            \definedfont[RegularBold*default sa 2]
            \strut\documentvariable{title}
        }

    \doifsomething {\documentvariable{subtitle}} {
        \setupheadertexts[\documentvariable{subtitle}]
    }

\stopsetups

\startbuffer[abstract]
    % no abstract
\stopbuffer

\setuphead
  [chapter]
  [page=yes,
   after={\blank[2*big]},
   color=MainColor,
   style=\bfc]

\setuphead
  [section]
  [before={\blank[2*big]},
   after=\blank,
   color=MainColor,
   style=\bfb]

\setuphead
  [subsection]
  [before=\blank,
   after=,
   color=MainColor,
   style=\bf]

\setupwhitespace
  [big]

\definetyping[xtyping] [style=\ttx]
\definetyping[xxtyping][style=\ttxx]

\definetyping[ntyping] \setuptyping[ntyping][style=\narrowtt]
\definetype  [ntype]   \setuptype  [ntype]  [style=\narrowtt]

\setupdocument
  [main={\doifelsemode{atpragma}{This Way}{My Way}},
  %color=pragmacolor,
   title={No Title},
   subtitle=,
   author={No Author},
   affiliation=,
   date={No Date},
   number=0,
   before={\setups[titlepage,title]},
   after={\setups[cleanup,listing,lastpage]}]

\continueifinputfile {s-mag-01.mkiv}

\startbuffer[abstract]
    This is the zero issue of a semi periodical. The associated style can be used
    by \CONTEXT\ users to typeset and publish their own issues.
\stopbuffer

\startdocument
  [title={Introduction},
   subtitle={Welcome},
   author={Hans Hagen},
   affiliation=PRAGMA ADE,
   date=Januari 2003,
   number=0 \MKIV]

This is the zero issue of a range of \CONTEXT\ related publications, in most
cases short introductions to new functionality. The style may be used by users
for providing similar documents, but preferably not for other purposes, since it
may confuse readers in their expectations.

We've chosen a layout which is more functional than beautiful. This layout
provides several text areas: headers and footers, margins and edges as well as a
main text area. The surrounding (gray or color) makes the main page (which is
slightly smaller than A4) stand out and is suitable for viewing in spread mode.

The documents produced at \PRAGMA\ are called {\bf This Way}, user documents gets
the title {\bf My Way}. The \PRAGMA\ issues are numbered. We strongly advise you
not to use the \type {mag-} prefix for your issues, since this may lead to
clashes with files distributed by \PRAGMA.

\stopdocument