Debian Codegraph @

texmf-dist/doc/latex/substances/substances_en.tex

raw
1 % arara: pdflatex: { shell: on }
2 % arara: pdflatex: { shell: on }
3 % --------------------------------------------------------------------------
4 % the SUBSTANCES package
5 %
6 % A Chemical Database
7 %
8 % --------------------------------------------------------------------------
9 % Clemens Niederberger
10 % Web: https://bitbucket.org/cgnieder/substances/
11 % E-Mail: [email protected]
12 % --------------------------------------------------------------------------
13 % Copyright 2012--2016 Clemens Niederberger
14 %
15 % This work may be distributed and/or modified under the
16 % conditions of the LaTeX Project Public License, either version 1.3
17 % of this license or (at your option) any later version.
18 % The latest version of this license is in
19 % http://www.latex-project.org/lppl.txt
20 % and version 1.3 or later is part of all distributions of LaTeX
21 % version 2005/12/01 or later.
22 %
23 % This work has the LPPL maintenance status `maintained'.
24 %
25 % The Current Maintainer of this work is Clemens Niederberger.
26 % --------------------------------------------------------------------------
27 % The substances package consists of the files
28 % - substances.sty, substances-default.def, substances-examples.sub,
29 % substances_en.tex, substances_en.pdf, README
30 % --------------------------------------------------------------------------
31 % If you have any ideas, questions, suggestions or bugs to report, please
32 % feel free to contact me.
33 % --------------------------------------------------------------------------
34 %
35 % if you want to compile this documentation you'll need the document class
36 % `cnpkgdoc' which you can get here:
37 % https://bitbucket.org/cgnieder/cnpkgdoc/
38 % the class is licensed LPPL 1.3 or later
39 %
40 \documentclass[load-preamble+]{cnltx-doc}
41 \usepackage[utf8]{inputenc}
42 \usepackage[index]{substances}
43
44 \LoadSubstances{substances-examples}
45
46 \usepackage{imakeidx}
47 \makeindex[name=\jobname-chem,title=Chemicals]
48
49 \setcnltx{
50 package = {substances},
51 url = http://www.mychemistry.eu/forums/forum/substances/ ,
52 authors = Clemens Niederberger ,
53 email = [email protected] ,
54 abstract = {%
55 The \substances\ package allows you to create a database like file that
56 contains data of various chemicals. These data can be retrieved in the
57 document. An index creation of the chemicals used in the document is
58 directly supported.
59 } ,
60 quote-format = \small\biolinumLF ,
61 add-cmds = {
62 @CAS, @EC,
63 ac, AllSubstancesClist, AllSubstancesSequence, arraybackslash,
64 bottomrule,
65 CAS, celsius, centi, ch, chem, chemfig, chemsetup, cmc, cubic,
66 DeclareSubstance, DeclareSubstanceProperty,
67 EC, endinput,
68 ForAllSubstancesDo,
69 GetSubstanceProperty, ghs, ghspic, ghspictograms, ghsstatements, gram,
70 IfSubstanceExistF, IfSubstanceExistT, IfSubstanceExistTF,
71 IfSubstanceFieldF, IfSubstanceFieldT, IfSubstanceFieldTF,
72 IfSubstancePropertyF, IfSubstancePropertyT, IfSubstancePropertyTF,
73 iupac,
74 kilo,
75 Lewis, LoadSubstances,
76 metre, midrule, milli, MolMass,
77 NewDocumentCommand, newindex, normal, num,
78 ProvideChemIUPAC,
79 per, printindex,
80 RetrieveSubstanceProperty,
81 SI, sisetup, SubstanceIndexAltEntry, SubstanceIndexNameAltEntry,
82 SubstanceIndexNameEntry, SubstancesDatabase, SubstancesStyle,
83 toprule
84 } ,
85 index-setup = { level = \section , othercode = \small }
86 }
87
88 \defbibheading{bibliography}{\section{References}}
89
90 \usepackage{booktabs}
91
92 \expandafter\def\csname libertine@figurestyle\endcsname{LF}
93 \usepackage[libertine]{newtxmath}
94 \expandafter\def\csname libertine@figurestyle\endcsname{OsF}
95
96 \usepackage[biblatex]{embrac}
97 \ChangeEmph{[}[,.02em]{]}[.055em,-.08em]
98 \ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em]
99
100 \usepackage{acro}
101 \acsetup{short-format=\scshape}
102 \DeclareAcronym{CAS}{
103 short = cas ,
104 long = Chemical Abstract Service
105 }
106 \DeclareAcronym{EC}{
107 short = ec ,
108 long = European Commission Number
109 }
110 \DeclareAcronym{LD50}{
111 short = ld50 ,
112 long = Median Lethal Dose
113 }
114 \DeclareAcronym{IUPAC}{
115 short = iupac ,
116 long = International Union of Pure and Applied Chemistry
117 }
118 \DeclareAcronym{ghs}{
119 short = ghs ,
120 long = Globally Harmonized System of Classification and Labelling of
121 Chemicals
122 }
123
124 \ExplSyntaxOn
125 \DeclareExpandableDocumentCommand \substancesdatabase {m}
126 { \__substances_database:n {#1} }
127 \DeclareExpandableDocumentCommand \substancesstyle {m}
128 { \__substances_style:n {#1} }
129 \ExplSyntaxOff
130
131 \newidxcmd\substyle{\texttt{#1}}[ (\substances\ style)]
132
133 \begin{document}
134
135 \part{Preliminaries}
136
137 \section{Licence and Requirements}
138 \license
139
140 \substances\ loads and needs the following packages:
141 \pkg{expl3}~\cite{bnd:l3kernel}, \pkg{xparse}, \pkg{xtemplate} and
142 \pkg{l3keys2e}~\cite{bnd:l3packages}. It also needs the chemistry packages
143 \pkg{chemmacros}~\cite{pkg:chemmacros}, \pkg{chemfig}~\cite{pkg:chemfig} and
144 \pkg{ghsystem}~\cite{pkg:ghsystem}.
145
146 \section{About}
147 The \substances\ package allows you to create a database like file that contains
148 data of various chemicals. These data can be retrieved in the document. An index
149 creation of the chemicals used in the document is directly supported.
150
151 \part{Package Description}
152
153 \section{Options}\label{sec:options}
154 The \substances\ package has a few options:
155 \begin{options}
156 \keybool{draft}\Default{false}
157 If set to true all warnings will be errors.
158 \keybool{final}\Default{true}
159 The opposite of \option{draft}.
160 \keybool{index}\Default{false}
161 Add index entries when \cs{chem} is called, see section~\ref{sec:index}.
162 \keyval{style}{style}\Default{default}
163 Load specific style, see sections~\ref{ssec:styles}
164 and~\ref{sec:default-style}.
165 \keybool{strict}\Default{false}
166 If set to true all warnings will be errors. This option overwrites any
167 \option{draft} or \option{final} option that is passed on by the document
168 class.
169 \end{options}
170
171 The most important option is \option{style}. Details concerning this option
172 are explaind in sections~\ref{ssec:styles} and~\ref{sec:default-style}.
173
174 \section{The Database}
175 \subsection{Declaring the Chemicals}
176 The data about substances are stored via the command
177 \begin{commands}
178 \command{DeclareSubstance}[\marg{id}\marg{list of properties}]
179 This declares substance \meta{id}.
180 \end{commands}
181 An entry could look like this:
182 \begin{sourcecode}
183 \DeclareSubstance{NaCl}{
184 name = Sodiumchloride ,
185 sum = NaCl ,
186 CAS = 7647-14-5,
187 mass = 58.44 ,
188 mp = 801 ,
189 bp = 1465 ,
190 phase = solid ,
191 density = 2.17
192 }
193 \end{sourcecode}
194
195 Such\changedversion{0.2} entries can either be declared in the document
196 preamble or probably more useful in a database file. Such a file can be input
197 in the document via
198 \begin{commands}
199 \command{LoadSubstances}[\marg{database name}]
200 Input the database \meta{database name}. The name of a database file must
201 follow the structure
202 \code{\substancesdatabase{\meta{database name}}}.
203 \end{commands}
204 Suppose you have the file \code{\substancesdatabase{mydatabase}} then you
205 input it in the document preamble via \cs{LoadSubstances}\Marg{mydatabase}. A
206 database file should typically start with the following declaration:
207 \begin{commands}
208 \command{SubstancesDatabase}[\marg{database name}]
209 Declare\sinceversion{0.2} the database \meta{database name}
210 \end{commands}
211
212 \subsection{Available Fields}
213 \subsubsection{Always Defined Fields}
214 Below all fields defined by \substances\ are listed\footnote{Look in the file
215 \code{\substancesdatabase{substances-examples}} which is part of this
216 package and should be in the same place as this documentation for example
217 uses.}.
218 \begin{options}
219 \keyval{name}{name}\Default!
220 The \acs{IUPAC} name of the substance. This is the only field that
221 \emph{has} to be used. The field's input is parsed with
222 \pkg{chemmacros}' command \cs{iupac}.
223 \keyval{sort}{sort name}
224 If you plan to use the \option{index} option you should specify this field
225 to get the sorting of the index right. This then creates index entries
226 \cs{index}\Marg{\meta{sort field}@\meta{name field}}.
227 \keyval{alt}{alt name}
228 An alternative name. The field's input is parsed with \pkg{chemmacros}'
229 command \cs{iupac}.
230 \keyval{altsort}{sort alt name}
231 This is the same as the \option{sort} field but for the alternative name.
232 \keyval{CAS}{CAS number}
233 The \ac{CAS} number. The input needs to be input in the form
234 \code{\meta{num}-\meta{num}-\meta{num}}.
235 \keyval{PubChem}{PubChem number}
236 The PubChem number.
237 \end{options}
238
239 The \option{CAS} field processes the number using the macro
240 \cs{CAS}\marg{number} which is defined like this:
241 \begin{sourcecode}
242 \def\@CAS#1-#2-#3\relax{\iupac{#1-#2-#3}}
243 \NewDocumentCommand\CAS{m}{\@CAS#1\relax}
244 \end{sourcecode}
245 You're free to redefine it to your needs.
246
247 \subsubsection{Style-dependend Fields}
248 \substances\ defines the style \substyle{default} (see also
249 sections~\ref{sec:options}, \ref{ssec:styles}, and~\ref{sec:default-style})
250 which is loaded if no other style has been specified. It defines the following
251 additional fields and loads the packages \pkg{chemfig}~\cite{pkg:chemfig} and
252 \pkg{siunitx}~\cite{pkg:siunitx}.
253 \begin{options}
254 \keyval{formula}{formula}
255 The molecular formula of the substance. The field's input is parsed with
256 \pkg{chemmacros}' command \cs{ch}.
257 \keyval{structure}{structure}
258 The structural formula of the substance. The field's input is parsed with
259 \pkg{chemfig}'s command \cs{chemfig}.
260 \keyval{mp}{melting point}
261 The melting point. The field's entry is input into the \pkg{siunitx}
262 command \cs{SI} in the following way: \\
263 \cs{SI}\marg{field}\Marg{\cs{celsius}}.
264 \keyval{bp}{boiling point}
265 The boiling point. The field's entry is input into the \pkg{siunitx}
266 command \cs{SI} in the following way: \\
267 \cs{SI}\marg{field}\Marg{\cs{celsius}}.
268 \keyval{density}{density}
269 The density. The field's entry is input into the \pkg{siunitx} command
270 \cs{SI} in the following way: \\
271 \cs{SI}\marg{field}\Marg{\cs{gram}\cs{per}\cs{cmc}}.
272 \keyval{phase}{phase}
273 The state of aggregation.
274 \keyval{pKa}{\pKa}
275 The \pKa\ value. The field's entry is input into the \pkg{siunitx} command
276 \cs{num}.
277 \keyval{pKa1}{\pKa[1]}
278 The first of several \pKa\ values. The field's entry is input into the
279 \pkg{siunitx} command \cs{num}.
280 \keyval{pKa2}{\pKa[2]}
281 The second of several \pKa\ values. The field's entry is input into the
282 \pkg{siunitx} command \cs{num}.
283 \keyval{pKb}{\pKb}
284 The \pKb\ value. The field's entry is input into the \pkg{siunitx} command
285 \cs{num}.
286 \keyval{pKb1}{\pKb[1]}
287 The first of several \pKb\ values. The field's entry is input into the
288 \pkg{siunitx} command \cs{num}.
289 \keyval{pKb2}{\pKb[2]}
290 The second of several \pKb\ values. The field's entry is input into the
291 \pkg{siunitx} command \cs{num}.
292 \keyval{pictograms}{csv list of pictograms}
293 The \acs{ghs} pictograms. This field takes a list of pictogram names as
294 they're input into \pkg{ghsystem}'s command
295 \cs{ghspic}~\cite{pkg:ghsystem}.
296 \keyval{H}{csv list of hazard statements}
297 The H statements. This field takes a list of numbers as they're input into
298 \pkg{ghsystem}'s command \cs{ghs}\Marg{h}\marg{number}.
299 \keyval{P}{csv list of precautionary statements}
300 The P statements. This field takes a list of pictogram names as they're
301 input into \pkg{ghsystem}'s command \cs{ghs}\Marg{p}\marg{number}.
302 \keyval{EUH}{csv list of EUH statements}
303 The EUH statements. This field takes a list of pictogram names as they're
304 input into \pkg{ghsystem}'s command \cs{ghs}\Marg{euh}\marg{number}.
305 \keyval{LD50}{\acl{LD50}}
306 The \ac{LD50} in \si{\milli\gram\per\kilo\gram}. The field's entry is
307 input into the \pkg{siunitx} command \cs{SI} in the following way: \\
308 \cs{SI}\marg{field}\Marg{\cs{milli}\cs{gram}\cs{per}\cs{kilo}\cs{gram}}.
309 \end{options}
310
311 \section{Define Custom Styles}\label{ssec:styles}
312 \subsection{Background}
313 You might have other needs for fields than the ones defined by \substances\
314 and the \substyle{default} style. \emph{All fields except the required
315 \option{name} field whixh are explained in this manual are defined by the
316 \substyle{default} style.}
317
318 You can easily define your own style which means that you save a file with the
319 name \code{\substancesstyle{\meta{style}}}. In it you both define the commands
320 you need and you declare substance properties with the command
321 \cs{DeclareSubstanceProperty} (which is explained in
322 section~\ref{sec:declare-new-fields}) to declare your own fields.
323
324 Such a style file should start with a \cs{SubstancesStyle} declaration:
325 \begin{commands}
326 \command{SubstancesStyle}[\sarg\marg{style name}]
327 This\sinceversion{0.2} declares the style \meta{style name}. The starred
328 version also switches to the expl3 programming environment. Either way
329 \code{@} has category code~11 in a style file.
330 \command{LoadSubstancesStyle}[\marg{style name}]
331 This\sinceversion{0.2} loads the style \meta{style name}. It can be used
332 inside of a style file. This can be useful if you want to extend the
333 default style without copy-pasting every definition of the default style.
334 Outside of a style file this command does nothing.
335 \end{commands}
336
337 The implementation of the \substyle{default} style is shown in
338 section~\ref{sec:default-style} as an example.
339
340 \subsection{Declare New Fields or Change Existing Fields}\label{sec:declare-new-fields}
341 You might want other fields or change the definition of the predefined ones.
342 For this there's
343 \begin{commands}
344 \command{DeclareSubstanceProperty}[\sarg\marg{field name}\oarg{pre
345 code}\oarg{post code}]
346 This command declares a new property field for a substance. The star makes
347 the property a required one which means an error will be issued if a
348 substance is declared without it. The optional arguments \meta{pre code}
349 and \meta{post code} specify any code that should be input directly before
350 or after the field entry, respectively. The \meta{pre code} may end with a
351 command that takes one mandatory argument. In this case the field entry
352 will be its argument.
353 \end{commands}
354
355 The following example would define a field \option*{EC} which uses a custom
356 command to parse the field entry. The \ac{EC} is assigned to chemical
357 substances for regulatory purposes within the European Union by the regulatory
358 authorities.
359 \begin{sourcecode}
360 \makeatletter
361 \def\@EC#1-#2-#3\relax{#1-#2-#3}
362 \newcommand*\EC[1]{\@EC#1\relax}
363 \makeatother
364 \DeclareSubstanceProperty{EC}[\EC]
365 \end{sourcecode}
366 For further examples of the usage of pre and post code look at the definition of
367 the \option{name} and the \option{mp} field:
368 \begin{sourcecode}
369 \DeclareSubstanceProperty*{name}[\iupac]
370 \DeclareSubstanceProperty{mp}[\SI][{\celsius}]
371 \end{sourcecode}
372
373 \section{Retrieving the Data}
374 There are two commands defined by \substances\ that allow the retrieving of
375 the data. The command \cs{chem} is intended as user command, the command
376 \cs{GetSubstanceProperty} can be used to define your own user command (perhaps
377 in your own style file, see section~\ref{ssec:styles}).
378 \begin{commands}
379 \command{chem}[\sarg\oarg{pre}\oarg{post}\marg{id}\oarg{property}]
380 If the command \cs{chem} is called without the optional \meta{property}
381 argument the \option{name} entry will be called. The starred version calls
382 the \option{alt} entry if it is defined and the \option{name} entry
383 otherwise. The arguments \meta{pre} and \meta{post} add arbitrary input
384 before or after the output, respectively.
385 \command{GetSubstanceProperty}[\marg{id}\marg{property}]
386 Retrieves \meta{property} for substance \meta{id}.
387 \end{commands}
388
389 All of the next examples use the data defined in the file
390 \code{substances-examples.sub} that is part of this package, see
391 section~\ref{sec:examples}.
392 \begin{example}
393 \chem{H2SO4}[structure] \newline
394 \chem{H2SO4} has the boiling point $\chem[T_b =]{H2SO4}[bp]$ and a
395 density of $\chem[\rho =]{H2SO4}[density]$.
396
397 Compare the melting points of methane and ethane,
398 $\chem[T_m=]{methane}[mp]$ and $\chem[T_m=]{ethane}[mp]$,
399 with the boiling points $\chem[T_b=]{methane}[bp]$ and
400 $\chem[T_b=]{ethane}[bp]$.
401
402 \chem{NaCl} has the \ac{CAS} number \chem{NaCl}[CAS].
403
404 \chem{acetone} (\chem*{acetone}) is the most simple ketone:
405
406 \chem{acetone}[structure]
407 \end{example}
408
409 The following code creates table~\ref{tab:methane}.
410 \begin{example}[outside]
411 \begin{table}[htp]
412 \centering
413 \ghssetup{hide}
414 \sisetup{scientific-notation=fixed,fixed-exponent=0,per-mode=symbol}
415 \begin{tabular}{l>{\raggedright\arraybackslash}p{.6\linewidth}}
416 \toprule
417 name & \chem{methane} \\
418 formula & \chem{methane}[formula] \\
419 & \chem{methane}[structure] \\
420 \midrule
421 \ac{CAS} & \chem{methane}[CAS] \\
422 PubChem & \chem{methane}[PubChem] \\
423 \midrule
424 boiling point & \chem{methane}[bp] \\
425 melting point & \chem{methane}[mp] \\
426 density & \chem{methane}[density] \\
427 molar mass & \chem{methane}[mass] \\
428 \midrule
429 & \chem{methane}[pictograms] \\
430 H statements & \chem{methane}[H] \\
431 P statements & \chem{methane}[P] \\
432 \bottomrule
433 \end{tabular}
434 \caption{\label{tab:methane}All properties of \chem{methane} that have
435 been saved in the example database.}
436 \end{table}
437 \end{example}
438
439 \section{Additional Commands}
440 \substances\ provides a few commands that maybe are useful in building custom
441 macros for styles. A field exists if it has been defined with
442 \cs{DeclareSubstanceProperty} regardless if it has been used or not. A
443 substance exists if it has been defined with \cs{DeclareSubstance}.
444
445 \begin{commands}
446 \command{GetSubstanceProperty}[\marg{id}\marg{field}]
447 Retrieve the property specified in \meta{field} for substance \meta{id}.
448 This command is \emph{not} expandable.
449 \expandable\command{RetrieveSubstanceProperty}[\marg{id}\marg{field}]
450 The same as \cs{GetSubstanceProperty} but expandable.
451 \expandable\command{ForAllSubstancesDo}[\marg{code}]
452 Loops through all existing substances. Inside \meta{code} \code{\#1} may
453 be used to refer to the \meta{id} of the current substance. This command
454 is expandable.
455 \expandable\command{AllSubstancesSequence}
456 A sequence of all substances. This is a sequence of balanced groups each
457 containing the \meta{id} of a substance. This command is expandable.
458 \expandable\command{AllSubstancesClist}
459 A comma separated list of all substances. Every \meta{id} is separated
460 from the next with a comma. This command is expandable.
461 \expandable\command{IfSubstancePropertyTF}[\marg{id}\marg{field}\marg{true
462 code}\marg{false code}]
463 Tests if the property \meta{field} is defined for the substance \meta{id}
464 and returns either \meta{true code} or \meta{false code}. This command is
465 expandable.
466 \expandable\command{IfSubstancePropertyT}[\marg{id}\marg{field}\marg{true
467 code}]
468 Tests if the property \meta{field} is defined for the substance \meta{id}
469 and returns \meta{true code} if it is. This command is expandable.
470 \expandable\command{IfSubstancePropertyF}[\marg{id}\marg{field}\marg{false
471 code}]
472 Tests if the property \meta{field} is defined for the substance \meta{id}
473 and returns \meta{false code} if it isn't. This command is expandable.
474 \expandable\command{IfSubstanceFieldTF}[\marg{field}\marg{true
475 code}\marg{false code}]
476 Tests if the property \meta{field} exists and returns either
477 \meta{true code} or \meta{false code}. This command is expandable.
478 \expandable\command{IfSubstanceFieldT}[\marg{field}\marg{true code}]
479 Tests if the property \meta{field} exists and returns \meta{true code} if
480 it does. This command is expandable.
481 \expandable\command{IfSubstanceFieldF}[\marg{field}\marg{false code}]
482 Tests if the property \meta{field} exists and returns \meta{false code} if
483 it doesn't. This command is expandable.
484 \expandable\command{IfSubstanceExistTF}[\marg{id}\marg{true code}\marg{false
485 code}]
486 Tests if the substance \meta{id} exists and returns either \meta{true
487 code} or \meta{false code}. This command is expandable.
488 \expandable\command{IfSubstanceExistT}[\marg{id}\marg{true code}]
489 Tests if the substance \meta{id} exists and returns \meta{true code} if
490 it does. This command is expandable.
491 \expandable\command{IfSubstanceExistF}[\marg{id}\marg{false code}]
492 Tests if the substance \meta{id} exists and returns \meta{false code} if
493 it doesn't. This command is expandable.
494 \end{commands}
495
496 \begin{example}
497 Just to demonstrate how these commands can be used. And to get
498 our demonstration index filled.\par
499 \newcounter{substances}
500 \ForAllSubstancesDo{%
501 \ifnum0=\value{substances}\relax
502 \else,
503 \fi
504 \stepcounter{substances}%
505 \chem{#1}%
506 \IfSubstancePropertyT{#1}{alt}{ (\chem*{#1})}%
507 }
508 \end{example}
509
510 \section{Create an Index}\label{sec:index}
511 When \substances\ is called with \keyis{index}{true} the command \cs{chem}
512 will add index entries each time it is used. In this case the entries of the
513 fields \option{name}, \option{sort}, \option{alt} and \option{altsort} will be
514 expanded during the process. You should keep that in mind if some error
515 arises. It might be due to a \cs*{textbf} or similar in your database. In this
516 case you either need to replace it with some robust command or put a
517 \cs*{noexpand} in front of it.
518
519 Alternative names as specified in the \option{alt} also get an index entry
520 with a reference to the one of the corresponding \option{name} field. The
521 entry of the \option{name} field in this case gets the \option{alt} name
522 appended in braces.
523
524 This behaviour is not customizable for the time being. It is planned for future
525 versions of this package, though.
526
527 As a demonstration an index for all chemicals used in this documentation is
528 created with the help of the package \pkg{imakeidx}~\cite{pkg:imakeidx}.
529
530 \subsection{Formatting Commands}
531 The index entries are formatted with the following commands. You can redefine
532 them to your needs. If you do make sure they have the same number of required
533 arguments and are expandable!
534 \begin{commands}
535 \expandable\command{SubstanceIndexNameEntry}[\marg{sort}\marg{name}]
536 Formats the name if no \option{alt} field is given. The default definition
537 is \code{\#1@\#2}.
538 \expandable\command{SubstanceIndexNameAltEntry}[\marg{sort}\marg{name}\marg{alt}]
539 Formats the name if the \option{alt} field is given. The default definition is
540 \code{\#1@\#2 (\#3)}.
541 \expandable\command{SubstanceIndexAltEntry}[\marg{alt sort}\marg{name}\marg{alt}]
542 Formats the entry for the \option{alt} field. The default definition is
543 \code{\#1@\#3|see\#2}
544 \end{commands}
545
546 \subsection{Using makeidx}
547 Using the option \keyis{index}{true} with the standard way to create an index
548 will add the entries \cs{index}\marg{name} to the index. This means you would
549 mix them with other entries if you have any. Below a sample document is shown.
550
551 \begin{sourcecode}
552 \documentclass{article}
553 \usepackage[T1]{fontenc}
554 \usepackage[index]{substances}
555 \LoadSubstances{substances-examples}
556
557 \usepackage{makeidx}
558 \makeindex
559 \begin{document}
560
561 \newcounter{substances}
562 \ForAllSubstancesDo{%
563 \ifnum0=\value{substances}\relax
564 \else, \fi
565 \stepcounter{substances}\chem{#1}
566 }
567
568 \printindex
569 \end{document}
570 \end{sourcecode}
571
572 \subsection{Using \pkg*{splitidx}}
573 Maybe a seperate index for the chemicals will make more sense. In this case
574 you could use the package \pkg{splitidx}~\cite{pkg:splitidx}. \substances\
575 will recognize this and create \cs{sindex}\Oarg{\cs*{jobname}-chem}\marg{name}
576 entries each time \cs{chem} is used.
577
578 \begin{sourcecode}
579 \documentclass{article}
580 \usepackage[T1]{fontenc}
581 \usepackage[index]{substances}
582 \LoadSubstances{substances-examples}
583
584 \usepackage{splitidx}
585 \makeindex
586 \newindex[Chemicals]{\jobname-chem}
587 \begin{document}
588
589 \newcounter{substances}
590 \ForAllSubstancesDo{%
591 \ifnum0=\value{substances}\relax
592 \else, \fi
593 \stepcounter{substances}\chem{#1}
594 }
595
596 \printindex[\jobname-chem]
597 \end{document}
598 \end{sourcecode}
599
600 \subsection{Using \pkg*{imakeidx}}
601 Another way to create multiple indexes is the package
602 \pkg{imakeidx}~\cite{pkg:imakeidx}. \substances\ recognizes its usage and
603 creates index entries \cs{index}\Oarg{\cs*{jobname}-chem}\marg{name}.
604
605 \begin{sourcecode}
606 \documentclass{article}
607 \usepackage[T1]{fontenc}
608 \usepackage[index]{substances}
609 \LoadSubstances{substances-examples}
610
611 \usepackage{imakeidx}
612 \makeindex[name=\jobname-chem,title=Chemicals]
613 \begin{document}
614
615 \newcounter{substances}
616 \ForAllSubstancesDo{%
617 \ifnum0=\value{substances}\relax
618 \else, \fi
619 \stepcounter{substances}\chem{#1}
620 }
621
622 \printindex[\jobname-chem]
623 \end{document}
624 \end{sourcecode}
625
626 \part{Appendix}
627 \appendix
628
629 \section{The Default Style}\label{sec:default-style}
630 The following code shows the contents of the file
631 \code{\substancesstyle{default}} which defines the \substyle{default} style
632 which is part of this package.
633
634 \implementation[basicstyle=\ttfamily\footnotesize]{\substancesstyle{default}}
635
636 \section{The Example Database}\label{sec:examples}
637 The following code shows the example database
638 \code{\substancesdatabase{substances-examples}} that is part of this package.
639
640 \implementation[basicstyle=\ttfamily\footnotesize]{\substancesdatabase{substances-examples}}
641
642 \printindex[\jobname-chem]
643
644 \end{document}