Debian Codegraph @

texmf-dist/doc/latex/concepts/concepts.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 % %
3 % Copyright (C) 2012 by Michiel Helvensteijn - www.mhelvens.net %
4 % %
5 % http://latex-concepts.googlecode.com %
6 % %
7 % This work may be distributed and/or modified under the %
8 % conditions of the LaTeX Project Public License, either %
9 % version 1.3 of this license or (at your option) any later %
10 % version. The latest version of this license is in %
11 % http://www.latex-project.org/lppl.txt %
12 % and version 1.3 or later is part of all distributions of %
13 % LaTeX version 2005/12/01 or later. %
14 % %
15 % This work has the LPPL maintenance status `author-maintained'. %
16 % %
17 % The Current Maintainer of this work is Michiel Helvensteijn. %
18 % %
19 % This work consists of the files concepts.tex and concepts.sty. %
20 % %
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23 \documentclass[a4paper]{packagedoc}
24
25 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 % Setup %
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28
29 \moretexcs{%
30 NewConcept,ConceptOption,ConceptName,ConceptSymbol,%
31 ConceptSymbols,ConceptNameAndSymbols,delta,d,product,p,%
32 prd%
33 }
34
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Global Changes %
37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38
39 \changes{0.0.1}{2012/11/16}{initial version}
40 \changes{0.0.2}{2012/11/25}{put the package into a .dtx file}
41 \changes{0.0.3}{2012/12/01}{separated the .dtx file from the .sty file}
42 \changes{0.0.4}{2012/12/08}{finished the documentation and made a few fixes}
43 \changes{0.0.5}{2012/12/18}{implemented symbol-list commands and improved documentation}
44 \changes{0.0.6}{2013/1/1}{made concept `options' mandatory + fixed some spacing bugs}
45
46 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 \begin{document} %
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49
50 \maketitle
51
52 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 \section{Introduction and Motivation} %
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55
56 Documents with a lot of formal notation (such as papers about mathematics or
57 theoretical computer science) can introduce a number of concepts that need
58 to be managed. They'll have \emph{names}, \emph{descriptions} and associated
59 \emph{symbols} that need to be typeset, as well as \emph{relations} between them.
60
61 I'm now writing my PhD thesis in the field of Theoretical Computer Science.
62 It will be especially heavy with definitions. I need to make sure that every
63 symbol is associated with no more than one concept and that all names and
64 symbols are consistently used. I'll also need to generate a glossary with
65 this information. But I don't want to manually keep track
66 of all that. It's error-prone and it takes time. I'd rather focus on the theory.
67
68 There are already techniques and packages that help lighten the load:
69 %
70 \begin{itemize}
71 \item Rather than use any names or symbols directly in the text, declare
72 a macro for each one. If you ever need to change one, you'll only
73 have to do it in one place. You'll also be far less likely to
74 introduce any typos.
75 \item There are packages out there to keep track of and output a glossary%
76 \footnote{It is sometimes called a nomenclature.
77 The distinction is subtle.}.
78 \end{itemize}
79
80 But I'm not aware of any technique or package to ensure I'm not
81 using a name or symbol inconsistently, thereby potentially
82 confusing the reader. And even if there was, using all these techniques at the
83 same time is still a lot of overhead.
84
85 I wrote the \textsf{concepts} package to automate all this stuff for me. Every
86 time I introduce a new concept in my thesis I `declare' it once. The package
87 then defines all necessary macros for me and checks that I'm using them
88 properly.
89
90 In \textsf{concepts}~\fileversion{}, most of the above already works but it
91 cannot generate a glossary yet. In future versions, it will interface with
92 the \textsf{glossaries} package to accomplish this, and more.
93
94 I'm also planning to implement a rudimentary typesystem, to catch even more
95 kinds of mistakes in symbol usage. Also, I may want to integrate the
96 |ligature| option from the \textsf{semantic} package, which allows you to
97 choose arbitrary characters to typeset your symbols in math mode (with some
98 restrictions).
99
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
101 \section{Usage} %
102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
103
104 Every concept first has to be declared using the |\NewConcept| macro.
105 Afterwards, its name and associated symbols can by typeset using other macros.
106
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108
109 \describemacro{\NewConcept}{
110 \marg{concept key} \marg{options}
111 }
112
113 Every concept needs a unique \meta{concept key}, by which it will be identified
114 for the rest of the document. This key can also be used to automatically
115 derive the name of the concept as well as the macro used to typeset the name.
116
117 Then you'll want to add \meta{options}. This argument takes
118 a comma-separated list of |key=value| pairs. The following is a list of available
119 options. Note that the option names are case-sensitive:
120 %
121 \begin{description}
122 \item[name] the name of the concept\\
123 --- default: \meta{concept key}
124 \item[Name] the capitalized name of the concept, for use in the beginning of
125 a sentence\\
126 --- default: \meta{name} with the first letter capitalized
127 \item[plural] the plural form of the name\\
128 --- default: \meta{name}|s|
129 \item[Plural] the capitalized, pluralized name of the concept\\
130 --- default: \meta{plural} with the first letter capitalized
131 \item[namecmd] the `short' command that may be used to typeset the name of
132 this concept; this option *has* to be specified for
133 any command to be defined, but the |=value| part may
134 be omitted to get the default\\
135 --- default: |\|\meta{concept key}
136 \item[symbols] a comma-separated list of symbols that may represent instances
137 of this concept, delimited by curly brackets\\
138 --- default: |{}| (the empty list)
139 \item[symbolcmd] the `short' command that may be used to typeset a
140 specific symbol
141 \end{description}
142
143 Here are a few examples which will also be used to illustrate the other commands:
144
145 \begin{latex-example}
146 \NewConcept{swproduct}{
147 name = software product, % options 'plural', 'Plural'
148 Name = Software Product, % are implicitly defined
149 namecmd = \product, % defines \product
150 symbols = {p}, % p represents a product
151 symbolcmd = \p % defines \p
152 }
153 \end{latex-example}
154 %
155 \begin{latex-example}
156 \let\delta\relax \let\d\relax % I won't be using these
157 \NewConcept{delta}{
158 namecmd, % defines \delta
159 symbols = {x, y, z}, % x, y and z represent deltas
160 symbolcmd = \d % defines \d
161 }
162 \end{latex-example}
163
164 There are certain restrictions on new concept declarations. You may
165 not use the same \meta{concept key} more than once. You may not use the same
166 symbol for more than one concept (this is a feature; the package will
167 report an error if you do). Also, both \meta{namecmd} and \meta{symbolcmd} are
168 subject to the rules governing |\newcommand|. They may not be reused, or you
169 will see a standard \LaTeX{} error. Finally, any value you supply must behave
170 properly in an expansion-only context, e.g. be robust.
171
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173
174 \describemacro{\ConceptOption}{
175 \marg{concept key} \marg{option key}
176 }
177
178 This command can be used to get back any option value given a
179 specific \meta{concept~key} and \meta{option key}. For example:
180
181 \begin{latex-example-show}
182 \ConceptOption{delta}{Plural}
183 \end{latex-example-show}
184 %
185 \begin{latex-example-show}
186 \edef\prd{\ConceptOption{swproduct}{namecmd}}%
187 {\ttfamily\expandafter\detokenize\expandafter{\prd}}%
188 expands to ``\prd''.
189 \end{latex-example-show}
190
191 |\ConceptOption| is `fully expandable', meaning that it can expand at
192 least down to the value that was given to the option. (This is not (yet)
193 guaranteed for the other commands.)
194
195 As you can observe from the |\product| example above, options that expect a
196 command sequence are stored with an accompanying |\noexpand|. That means that
197 in an |\edef| context, |\ConceptOption| expands down to the stored command but
198 no further. After that you can expand it further if you wish.
199
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
201
202 \describemacro{\ConceptName}{
203 \movarg{\textasciicircum} \movarg{*} \marg{concept key}
204 }
205
206 With this command you can typeset the name of the concept with \meta{concept key}
207 in any of four forms. The |^| modifier gives you the capitalized version. The |*|
208 modifier gives you the plural version. The combination gives you both. The order
209 between |^| and |*| doesn't matter.
210
211 \begin{latex-example-show}
212 \ConceptName^*{delta} can transform a \ConceptName{swproduct}.
213 \end{latex-example-show}
214
215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
216
217 \describemetamacro{namecmd}{
218 \movarg{\textasciicircum} \movarg{*}
219 }
220
221 This is the `short' version of |\ConceptName|, specific for each concept that
222 was declared with the |namecmd| option. It supports the same modifiers.
223
224 \begin{latex-example-show}
225 \delta^* can easily transform a \product.
226 \end{latex-example-show}
227
228 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229
230 \describemacro{\ConceptSymbol}{
231 \marg{concept key} \oarg{symbol index}
232 }
233
234 This command typesets a specific symbol associated with a a given concept. It is
235 always typeset in math mode. Specify the concept with the \meta{concept key}
236 and the symbol with the \meta{symbol index}.
237
238 The index is 1-based and points to a place in the symbol list provided with the
239 concept options. If a concept has only one allocated symbol the index may be
240 omitted. If there is more than one symbol, the index is mandatory.
241
242 \begin{latex-example-show}
243 \product^* have symbols like \ConceptSymbol{swproduct}.
244 \end{latex-example-show}
245 %
246 \begin{latex-example-show}
247 $\ConceptSymbol{delta}[2] \cdot \ConceptSymbol{delta}[1] =
248 \ConceptSymbol{delta}[1] \cdot \ConceptSymbol{delta}[2]$
249 \end{latex-example-show}
250
251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
252
253 \describemetamacro{symbolcmd}{
254 \momarg{symbol index}
255 }
256
257 This is the `short' version of |\ConceptSymbol|, specific for each concept that
258 was declared with the |symbolcmd| option. The optional index is given directly
259 following the command itself. It doesn't need any delimiters. However, you are
260 allowed to use square brackets. See the list-variation of this short command
261 below.
262
263 \begin{latex-example-show}
264 $(\d2 \cdot \d1)(\p) = \d2(\d1(\p)) = \d2(\p') = \p''$
265 \end{latex-example-show}
266
267 As you can see, this short construct requires a lot less space than the
268 full |\ConceptSymbol| command, so its use is recommended for readability.
269
270 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271
272 \describemacro{\ConceptSymbols}{
273 \marg{concept key} \oarg{separator}
274 \oarg{last separator} \marg{symbol indices}
275 }
276
277 This command typesets a \meta{separator} separated list of symbols associated
278 with the given concept, optionally with a different \meta{last separator}. Specify
279 the concept with the \meta{concept key} and the symbol-list with the
280 \meta{symbol indices}. \meta{separator} defaults to |,| and \meta{last separator}
281 defaults to \meta{separator}. The whole list is typeset in math mode, so if
282 you'd like a non-math delimiter, you need to use \verb|$| tokens.
283
284 The indices are 1-based and point to a place in the symbol list provided with the
285 concept options. The index-list is mandatory, but can be empty.
286
287 \begin{latex-example-show}
288 The symbols \ConceptSymbols{delta}{1,2,3} represent \delta*.
289 \end{latex-example-show}
290 %
291 \begin{latex-example-show}
292 $\{\ConceptSymbols{delta}[;]{1,1,1}\}$ contains only \d1.
293 \end{latex-example-show}
294 %
295 \begin{latex-example-show}
296 What about \ConceptSymbols{delta}[,][$ and $]{3, 2, 1}?
297 \end{latex-example-show}
298 %
299 \begin{latex-example-show}
300 xx\ConceptSymbols{delta}{}xx
301 \end{latex-example-show}
302
303 If you need any symbol in the resulting list to have some decoration (like a
304 prime, subscript or superscript) you can decorate the corresponding index
305 accordingly. This currently only works for decorations that would be specified
306 \emph{after} the symbol. Each element of \meta{symbol indices} still needs to
307 start with the index itself:
308
309 \begin{latex-example-show}
310 \ldots such as the symbols in
311 $(\ConceptSymbols{delta}{1_1, 2'', 3^{\d1(\p)}})$.
312 \end{latex-example-show}
313
314 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315
316 \describemetamacro{symbolcmd}{
317 \oarg{symbol indices}
318 }
319
320 This is the `short' version of |\ConceptSymbols|, specific for each concept that
321 was declared with the |symbolcmd| option. The \meta{symbol indices} list needs
322 to be delimited by square brackets as shown below.
323
324 \begin{latex-example-show}
325 $\forall \d[1,2] \in D:\ \d1 \| \d2\ \Rightarrow\ {}
326 \exists \d[3'] \in D:\ \d1 \prec \d3' \land \d2 \prec \d3'$
327 \end{latex-example-show}
328 %
329 \begin{latex-example-show}
330 xx\d[]xx\p[]xx
331 \end{latex-example-show}
332
333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
334
335 \describemacro{\ConceptNameAndSymbols}{
336 \movarg{\textasciicircum} \marg{concept key}
337 \oarg{separator} \oarg{last separator}
338 \marg{symbol indices}
339 }
340
341 This command is the `hybrid' version of |\ConceptName| and |\ConceptSymbols|.
342 It typesets the name of the concept followed by a \meta{separator} separated list
343 of symbols associated with the given concept, optionally with a different
344 \meta{last separator}. Specify the concept with the \meta{concept key} and the
345 symbol-list with \meta{symbol~indices}. \meta{separator} defaults to |,| and
346 \meta{last separator} defaults to |$ and $|. The name is typeset in text mode and
347 the list is typeset in math mode.
348
349 The indices are 1-based and point to a place in the symbol list provided with the
350 concept options. The index-list is mandatory and cannot be empty.
351
352 You can still supply the |^| modifier to capitalize the name but the choice
353 between singular and plural form is determined by the number of \meta{symbol indices}.
354
355 \begin{latex-example-show}
356 We use \ConceptNameAndSymbols{delta}[,][$ and also $]{1,2,3}.
357 \end{latex-example-show}
358
359 For some other neat tricks, read the documentation of |\ConceptSymbols| above.
360
361 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362
363 \describemetamacro{namecmd}{
364 \movarg{\textasciicircum} \oarg{symbol indices}
365 }
366
367 This is a `short' version of |\ConceptNameAndSymbols|,
368 specific for each concept that was declared with the |namecmd| option.
369 The \meta{symbol indices} list needs to be delimited by square brackets
370 as shown below. The list is comma-delimited and the last (or only) delimiter is
371 the word `and'.
372
373 \begin{latex-example-show}
374 \delta^[1,2] come before \delta[3].
375 \end{latex-example-show}
376
377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
378 \section{Future Work} %
379 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
380
381 Everything up to this version of the package has been a bit of an experiment
382 for me. A way to get me started. I may still fix one or two issues for the
383 0.0.x series, but I will soon start from scratch with all I've learned.
384
385 There will be two major changes starting from version 0.1.0. First of all, the
386 package will be built on top of the |glossaries| package, which already does
387 much of the work I'm now doing manually. This was always the plan, as we'll
388 want to typeset a glossary with our concepts, and I don't want to reinvent
389 the wheel. The |glossaries| package is actively developed and has a great
390 amount of features we can take advantage of. Secondly, I will program the
391 0.1.0 series using \LaTeX3.
392
393 Here is an incomplete list of the features I am planning to implement:
394 \begin{itemize}
395 \item full integration with the \textsf{glossaries} package
396 \item typesetting a \emph{summary} of the concepts introduced in each chapter / section
397 \item management of \emph{tuples} and \emph{sets} of concept instances
398 \item management of \emph{subconcepts} plus a rudimentary \emph{typesystem} that
399 ensures concept instances are not used where a different concept is expected
400 \end{itemize}
401
402 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
403 \end{document} %
404 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%