summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/magazines/mag-1101-mkiv.tex
blob: f56dbfe39155245f0a22ce50a0af875aa8de90e2 (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
% language=uk

% author    : Hans Hagen
% copyright : PRAGMA ADE & ConTeXt Development Team
% license   : Creative Commons Attribution ShareAlike 4.0 International
% reference : pragma-ade.nl | contextgarden.net | texlive (related) distributions
% origin    : the ConTeXt distribution
%
% comment   : Because this manual is distributed with TeX distributions it comes with a rather
%             liberal license. We try to adapt these documents to upgrades in the (sub)systems
%             that they describe. Using parts of the content otherwise can therefore conflict
%             with existing functionality and we cannot be held responsible for that. Many of
%             the manuals contain characteristic graphics and personal notes or examples that
%             make no sense when used out-of-context.
%
% comment   : Some chapters might have been published in TugBoat, the NTG Maps, the ConTeXt
%             Group journal or otherwise. Thanks to the editors for corrections. Also thanks
%             to users for testing, feedback and corrections.

\usemodule[mag-01,abr-02,job-01]

\startbuffer[abstract]
    For a long time already \CONTEXT\ provides a way to organize your document(s)
    in a structure that permits processing of components. This mechanism has been
    upgraded a bit in \MKIV\ and here we will summarize the status quo.
\stopbuffer

\startdocument
  [title={Project Structure},
   author=Hans Hagen,
   affiliation=PRAGMA ADE,
   date=July 2011,
   number=1101 \MKIV]

A regular document has a simple structure. When we talk about structure here, we
only refer to the overall document structure.

\startscite[tex]
% style specification

\starttext
  % the document content
\stoptext
\stopscite

For practical reasons we delay initial font loading till the first \type
{\starttext} so that one can overload the defaults. This means that when no
bodyfont is specified, and {\starttext} is not given, there will be hardly any
visible output.

An example of a more elaborate structure is the following:

% \enabletrackers[context.trace]

\startscite[tex]
\environment environment-1
\environment environment-2

\startproduct product-1

  \component component-1.tex
  \component component-2.mkiv
  \component component-3.cld

  \component component-1
  \component component-2

\stopproduct
\stopscite

Here we have a specific product, made up out of components and using a few
environment files that specify the style. By default we assume tex files, but you
can be specific and use known suffixes. A less abstract example is the following:

\startscite[tex]
\environment my-fonts
\environment my-style
\environment my-abbreviations
\environment my-urls

\startproduct manual

  \component titlepage
  \component contents

  \component chapter-1
  \component chapter-2
  \component chapter-3

  \component index

\stopproduct
\stopscite

You can process components and products independently but be aware that you won't
get cross document (or chapter) references then.

There is one more level: projects.

\startscite[tex]
\environment my-fonts
\environment my-style
\environment my-abbreviations
\environment my-urls

\startproject documentation

  \product manual
  \product faqs

\stopproject
\stopscite

This means that we can also define the manual as follows:

\startscite[tex]
\project documentation

\startproduct manual

  \component titlepage
  \component contents

  \component chapter-1
  \component chapter-2
  \component chapter-3

  \component index

\stopproduct
\stopscite

Environments are only loaded once and when you run a component or product that
refers to environments or when environments are picked up from an encapsulating
structure you need to be aware of the order of loading.

The names given after the start command are not that important but the names
after the simple commands refer to filenames, so in the next case there need to
be a file called \type {index.tex}:

\startscite[tex]
\component index
\stopscite

Equally valid is:

\startscite[tex]
\component[index]
\stopscite

Subpaths are also permitted:

\startscite[tex]
\component manual/index
\stopscite

The meaning of the mentioned commands is not frozen but adapts itself to the
current situation. A file can be processed many times, only once or never. The
following table shows what will happen when:

\ctxlua{moduledata.jobs.showprocessors()}

When you load an environment or component, you can specify it to be a \LUA\ file
by using the \type {lua} or \type {cld} suffix. In that case the file will be
loaded in the right way. From the table you can deduce that the following is also
valid:

\startscite[tex]
\environment mystyle

\starttext
  % the content
\stoptext
\stopscite

combined with:

\startscite[tex]
\startenvironment mystyle
  % the definitions
\stopenvironment
\stopscite

This is about the simplest structure that you can use that still gives a bit of
abstraction.

In addition to files in a project structure, you can load predefined modules.

\startscite[tex]
\usemodule[mathml]
\stopscite

or more specific:

\startscite[tex]
\usemodule[x][mathml]
\stopscite

Which limits the lookup to the \type {x} namespace. The first match quits the
search and the order of lookups is: \type {mkvi}, \type {mkiv}, \type {tex},
\type {cld}, \type {lua}. It follows that modules can be \LUA\ files.

When you use structure in the files you will find an overview in the log file.
This looks as follows:

\starttyping
system          > structure > start used structure

used structure  > text: product-1
used structure  >   environment: environment-1
used structure  >   environment: environment-2
used structure  >   product: product-1
used structure  >     component: component-1
used structure  >     component: component-2
used structure  >     component: component-1
used structure  >     component: component-2

system          > structure > stop used structure
\stoptyping

Some basic logging on the console can be enabled with:

\startscite[tex]
\enabletrackers[system.jobfiles]
\stopscite

A new command pair is the following:

\starttyping
\startdocument[settings]
    structured content
\stopdocument
\stoptyping

The settings are key|/|value pairs and the values can be retrieved using:

\starttyping
\documentvariable{key}
\stoptyping

You can set \type {before} and \type {after} parameters and by default these are
set up as follows:

\starttyping
\setvariables
  [document]
  [before=\directsetup{document:start},
   after=\directsetup{document:stop}]
\stoptyping

You can for instance define these setups to generate a title page (using document
variables) and a colophon page. In the future more functionality might be added.

\stopdocument