summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-10-21 21:08:04 +0000
committerKarl Berry <karl@freefriends.org>2015-10-21 21:08:04 +0000
commitca8b37e0e9b1a89ad33804cfb8404f919c01b1f0 (patch)
tree918f841962543928f9839874400073051be3a82b /Master
parent906cc538429df04e26a1f8bbf54ff6930e1ffb1b (diff)
substances (21oct15)
git-svn-id: svn://tug.org/texlive/trunk@38684 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/substances/README6
-rw-r--r--Master/texmf-dist/doc/latex/substances/substances-examples.sub27
-rw-r--r--Master/texmf-dist/doc/latex/substances/substances_en.pdfbin791771 -> 576775 bytes
-rw-r--r--Master/texmf-dist/doc/latex/substances/substances_en.tex1030
-rw-r--r--Master/texmf-dist/tex/latex/substances/substances-default.def75
-rw-r--r--Master/texmf-dist/tex/latex/substances/substances.sty513
6 files changed, 916 insertions, 735 deletions
diff --git a/Master/texmf-dist/doc/latex/substances/README b/Master/texmf-dist/doc/latex/substances/README
index e0936ece139..a7dbfee3982 100644
--- a/Master/texmf-dist/doc/latex/substances/README
+++ b/Master/texmf-dist/doc/latex/substances/README
@@ -3,13 +3,13 @@ the SUBSTANCES package
A Chemical Database
-2012/07/22 v0.1
+2015/10/21 v0.2
--------------------------------------------------------------------------
Clemens Niederberger
Web: https://bitbucket.org/cgnieder/substances/
E-Mail: contact@mychemistry.eu
--------------------------------------------------------------------------
-Copyright 2012 Clemens Niederberger
+Copyright 2012-2015 Clemens Niederberger
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either version 1.3
@@ -29,4 +29,4 @@ The substances package consists of the files
--------------------------------------------------------------------------
If you have any ideas, questions, suggestions or bugs to report, please
feel free to contact me.
--------------------------------------------------------------------------- \ No newline at end of file
+--------------------------------------------------------------------------
diff --git a/Master/texmf-dist/doc/latex/substances/substances-examples.sub b/Master/texmf-dist/doc/latex/substances/substances-examples.sub
index e7aa9a9fe7d..79a8f6b5434 100644
--- a/Master/texmf-dist/doc/latex/substances/substances-examples.sub
+++ b/Master/texmf-dist/doc/latex/substances/substances-examples.sub
@@ -8,7 +8,7 @@
% Web: https://bitbucket.org/cgnieder/substances/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
-% Copyright 2012 Clemens Niederberger
+% Copyright 2012--2015 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -32,9 +32,11 @@
%
% example database to the package `substances'
%
-\DeclareChemIUPAC\normal{\textit{n}}
+\SubstancesDatabase{substances-example}
+
+\ProvideChemIUPAC\normal{\textit{n}}
\DeclareSubstance{NaCl}{
- name = Sodium\|chloride ,
+ name = Sodium|chloride ,
sort = Sodiumchloride ,
formula = NaCl ,
CAS = 7647-14-5,
@@ -46,7 +48,8 @@
}
\DeclareSubstance{HCl}{
- name = Hydro\|chloric Acid ,
+ name = Hydro|chloric Acid ,
+ sort = Hydrochloric Acid ,
formula = HCl ,
CAS = 7647-01-0 ,
pictograms = {acid,exclam} ,
@@ -147,7 +150,7 @@
\DeclareSubstance{butane}{
name = Butane ,
sort = Butane ,
- alt = \normal\-Butane ,
+ alt = \normal-Butane ,
altsort = n-Butane ,
formula = C4H10 ,
structure = H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-H ,
@@ -166,7 +169,7 @@
\DeclareSubstance{pentane}{
name = Pentane ,
sort = Pentane ,
- alt = \normal\-Pentane ,
+ alt = \normal-Pentane ,
altsort = n-Pentane ,
formula = C5H12 ,
structure = H-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-C(-[2]H)(-[6]H)-H ,
@@ -186,7 +189,7 @@
\DeclareSubstance{hexane}{
name = Hexane ,
sort = Hexane ,
- alt = \normal\-Hexane ,
+ alt = \normal-Hexane ,
altsort = n-Hexane ,
formula = C6H14 ,
structure = -[:30]-[:-30]-[:30]-[:-30]-[:30] ,
@@ -205,7 +208,7 @@
\DeclareSubstance{heptane}{
name = Heptane ,
sort = Heptane ,
- alt = \normal\-Heptane ,
+ alt = \normal-Heptane ,
altsort = n-Heptane ,
formula = C7H16 ,
structure = -[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30] ,
@@ -224,7 +227,7 @@
\DeclareSubstance{octane}{
name = Octane ,
sort = Octane ,
- alt = \normal\-Octane ,
+ alt = \normal-Octane ,
altsort = n-Octane ,
formula = C8H18 ,
structure = -[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30] ,
@@ -243,7 +246,7 @@
\DeclareSubstance{nonane}{
name = Nonane ,
sort = Nonane ,
- alt = \normal\-Nonane ,
+ alt = \normal-Nonane ,
altsort = n-Nonane ,
formula = C9H20 ,
structure = -[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30] ,
@@ -262,7 +265,7 @@
\DeclareSubstance{decane}{
name = Decane ,
sort = Decane ,
- alt = \normal\-Decane ,
+ alt = \normal-Decane ,
altsort = n-Decane ,
formula = C10H22 ,
structure = -[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30] ,
@@ -298,4 +301,4 @@
LD50 = 5800
}
-\endinput \ No newline at end of file
+\endinput
diff --git a/Master/texmf-dist/doc/latex/substances/substances_en.pdf b/Master/texmf-dist/doc/latex/substances/substances_en.pdf
index da9d3aa1764..bfd21bd18de 100644
--- a/Master/texmf-dist/doc/latex/substances/substances_en.pdf
+++ b/Master/texmf-dist/doc/latex/substances/substances_en.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/substances/substances_en.tex b/Master/texmf-dist/doc/latex/substances/substances_en.tex
index 2484e6c1527..b54c70a3303 100644
--- a/Master/texmf-dist/doc/latex/substances/substances_en.tex
+++ b/Master/texmf-dist/doc/latex/substances/substances_en.tex
@@ -10,7 +10,7 @@
% Web: https://bitbucket.org/cgnieder/substances/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
-% Copyright 2012 Clemens Niederberger
+% Copyright 2012--2015 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -37,569 +37,603 @@
% https://bitbucket.org/cgnieder/cnpkgdoc/
% the class is licensed LPPL 1.3 or later
%
-\documentclass[DIV10,toc=index,toc=bib]{cnpkgdoc}
-\docsetup{
- pkg = {[index]substances} ,
- code-box = {
- backgroundcolor = gray!7!white ,
- skipbelow = .6\baselineskip plus .5ex minus .5ex ,
- skipabove = .6\baselineskip plus .5ex minus .5ex ,
- roundcorner = 3pt ,
- } ,
- gobble = 0
-}
+\documentclass[load-preamble+]{cnltx-doc}
+\usepackage[utf8]{inputenc}
+\usepackage[index]{substances}
+
\LoadSubstances{substances-examples}
-\addcmds{
- @CAS,
- @EC,
- ac,
- AllSubstancesClist,
- AllSubstancesSequence,
- arraybackslash,
- bottomrule,
- CAS,
- celsius,
- ch,
- chem,
- chemfig,
- chemsetup,
- cmc,
- DeclareChemIUPAC,
- DeclareSubstance,
- DeclareSubstanceProperty,
- EC,
- endinput,
- ForAllSubstancesDo,
- GetSubstanceProperty,
- gram,
- IfSubstanceExistF,
- IfSubstanceExistT,
- IfSubstanceExistTF,
- IfSubstanceFieldF,
- IfSubstanceFieldT,
- IfSubstanceFieldTF,
- IfSubstancePropertyF,
- IfSubstancePropertyT,
- IfSubstancePropertyTF,
- iupac,
- Lewis,
- LoadSubstances,
- midrule,
- MolMass,
- NewDocumentCommand,
- newindex,
- normal,
- num,
- per,
- printindex,
- RetrieveSubstanceProperty,
- SI,
- sisetup,
- SubstanceIndexAltEntry,
- SubstanceIndexNameAltEntry,
- SubstanceIndexNameEntry,
- toprule
-}
-% Layout:
-\usepackage[osf]{libertine}
-\cnpkgcolors{
- main => cnpkgred ,
- key => yellow!40!brown ,
- module => cnpkgblue ,
- link => black!90
+\usepackage{imakeidx}
+\makeindex[name=\jobname-chem,title=Chemicals]
+
+\setcnltx{
+ package = {substances},
+ url = http://www.mychemistry.eu/forums/forum/substances/ ,
+ authors = Clemens Niederberger ,
+ email = contact@mychemistry.eu ,
+ abstract = {%
+ The \substances\ package allows you to create a database like file that
+ contains data of various chemicals. These data can be retrieved in the
+ document. An index creation of the chemicals used in the document is
+ directly supported.
+ } ,
+ quote-format = \small\biolinumLF ,
+ add-cmds = {
+ @CAS, @EC,
+ ac, AllSubstancesClist, AllSubstancesSequence, arraybackslash,
+ bottomrule,
+ CAS, celsius, centi, ch, chem, chemfig, chemsetup, cmc, cubic,
+ DeclareSubstance, DeclareSubstanceProperty,
+ EC, endinput,
+ ForAllSubstancesDo,
+ GetSubstanceProperty, ghs, ghspic, ghspictograms, ghsstatements, gram,
+ IfSubstanceExistF, IfSubstanceExistT, IfSubstanceExistTF,
+ IfSubstanceFieldF, IfSubstanceFieldT, IfSubstanceFieldTF,
+ IfSubstancePropertyF, IfSubstancePropertyT, IfSubstancePropertyTF,
+ iupac,
+ kilo,
+ Lewis, LoadSubstances,
+ metre, midrule, milli, MolMass,
+ NewDocumentCommand, newindex, normal, num,
+ ProvideChemIUPAC,
+ per, printindex,
+ RetrieveSubstanceProperty,
+ SI, sisetup, SubstanceIndexAltEntry, SubstanceIndexNameAltEntry,
+ SubstanceIndexNameEntry, SubstancesDatabase, SubstancesStyle,
+ toprule
+ } ,
+ index-setup = { level = \section , othercode = \small }
}
+
+\defbibheading{bibliography}{\section{References}}
+
\usepackage{booktabs}
-\renewcommand*\othersectionlevelsformat[3]{%
- \textcolor{main}{#3\autodot}\enskip}
-\renewcommand*\partformat{%
- \textcolor{main}{\partname~\thepart\autodot}}
-\usepackage{fnpct}
-\usepackage{embrac}[2012/06/29]% option biblatex, falls Bibliography dazu kommt
+
+\expandafter\def\csname libertine@figurestyle\endcsname{LF}
+\usepackage[libertine]{newtxmath}
+\expandafter\def\csname libertine@figurestyle\endcsname{OsF}
+
+\usepackage[biblatex]{embrac}
\ChangeEmph{[}[,.02em]{]}[.055em,-.08em]
\ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em]
\usepackage{acro}
-\DeclareAcronym{CAS}{CAS,}{Chemical Abstract Service,}
-\DeclareAcronym{EC}{EC}{European Commission Number}
-\DeclareAcronym{LD50}{LD50,}{Median Lethal Dose}
-\DeclareAcronym{IUPAC}{IUPAC,}{International Union of Pure and Applied Chemistry,}
-\DeclareAcronym{ghs}{GHS,}{Globally Harmonized System of Classification and
- Labelling of Chemicals,}
-
-% bibliography:
-% \usepackage[style=alphabetic,backend=biber]{biblatex}
-
-% index:
-\usepackage{imakeidx,filecontents}
-\begin{filecontents*}{\jobname.ist}
- heading_prefix "{\\bfseries "
- heading_suffix "\\hfil}\\nopagebreak\n"
- headings_flag 1
- delim_0 "\\dotfill "
- delim_1 "\\dotfill "
- delim_2 "\\dotfill "
- delim_r "\\textendash"
- suffix_2p "\\nohyperpage{\\,f.}"
- suffix_3p "\\nohyperpage{\\,ff.}"
-\end{filecontents*}
-
-% \indexsetup{noclearpage}
-\makeindex[options=-sl \jobname.ist,intoc,title=Package Index]
-\makeindex[name=\jobname-chem,title=Index of Chemicals,intoc,columns=3]
-
-% abstract:
-\TitlePicture{\parbox{.7\linewidth}{%
- The \substances package allows you to create a database like file that contains
- data of various chemicals. These data can be retrieved in the document. An index
- creation of the chemicals used in the document is directly supported.}}
+\acsetup{short-format=\scshape}
+\DeclareAcronym{CAS}{
+ short = cas ,
+ long = Chemical Abstract Service
+}
+\DeclareAcronym{EC}{
+ short = ec ,
+ long = European Commission Number
+}
+\DeclareAcronym{LD50}{
+ short = ld50 ,
+ long = Median Lethal Dose
+}
+\DeclareAcronym{IUPAC}{
+ short = iupac ,
+ long = International Union of Pure and Applied Chemistry
+}
+\DeclareAcronym{ghs}{
+ short = ghs ,
+ long = Globally Harmonized System of Classification and Labelling of
+ Chemicals
+}
\ExplSyntaxOn
-\NewDocumentCommand \Default {g}
- {
- \hfill\llap
- {
- \IfNoValueTF { #1 }
- {(initially~empty)}
- {Default:~\code{#1}}
- }
- \newline
- }
-\NewDocumentCommand \required {}
- { \hfill \llap { required } \newline }
-\NewDocumentCommand \optional {}
- { \hfill \llap { optional } \newline }
+\DeclareExpandableDocumentCommand \substancesdatabase {m}
+ { \__substances_database:n {#1} }
+\DeclareExpandableDocumentCommand \substancesstyle {m}
+ { \__substances_style:n {#1} }
\ExplSyntaxOff
+
+\newidxcmd\substyle{\texttt{#1}}[ (\substances\ style)]
+
\begin{document}
+\part{Preliminaries}
+
\section{Licence and Requirements}
-Permission is granted to copy, distribute and/or modify this software under the
-terms of the \LaTeX{} Project Public License, version 1.3 or later
-(\url{http://www.latex-project.org/lppl.txt}). The package has the status
-``maintained.''
+\license
-\substances loads and needs the following packages: \paket{expl3},
-\paket{xparse}, \paket{xtemplate} and \paket{l3keys2e}. It also needs the
-chemistry package \paket{chemmacros}.
+\substances\ loads and needs the following packages:
+\pkg{expl3}~\cite{bnd:l3kernel}, \pkg{xparse}, \pkg{xtemplate} and
+\pkg{l3keys2e}~\cite{bnd:l3packages}. It also needs the chemistry packages
+\pkg{chemmacros}~\cite{pkg:chemmacros}, \pkg{chemfig}~\cite{pkg:chemfig} and
+\pkg{ghsystem}~\cite{pkg:ghsystem}.
\section{About}
-The \substances package allows you to create a database like file that contains
+The \substances\ package allows you to create a database like file that contains
data of various chemicals. These data can be retrieved in the document. An index
creation of the chemicals used in the document is directly supported.
-\section{Options}
-\substances has only a few options:
-\begin{beschreibung}
- \Option{draft}{\default{true}|false}\Default{false}
- If set to true all warnings will be errors.
- \Option{final}{\default{true}|false}\Default{true}
- The opposite of \key{draft}.
- \Option{index}{\default{true}|false}\Default{false}
- Add index entries when \cmd{chem} is called, see section~\ref{sec:index}.
- \Option{style}{<style>}\Default{default}
- Load specific style, see section~\ref{ssec:styles}.
- \Option{strict}{\default{true}|false}\Default{false}
- If set to true all warnings will be errors. This option overwrites any
- \key{draft} or \key{final} option that is passed on by the document class.
-\end{beschreibung}
+\part{Package Description}
+
+\section{Options}\label{sec:options}
+The \substances\ package has a few options:
+\begin{options}
+ \keybool{draft}\Default{false}
+ If set to true all warnings will be errors.
+ \keybool{final}\Default{true}
+ The opposite of \option{draft}.
+ \keybool{index}\Default{false}
+ Add index entries when \cs{chem} is called, see section~\ref{sec:index}.
+ \keyval{style}{style}\Default{default}
+ Load specific style, see sections~\ref{ssec:styles}
+ and~\ref{sec:default-style}.
+ \keybool{strict}\Default{false}
+ If set to true all warnings will be errors. This option overwrites any
+ \option{draft} or \option{final} option that is passed on by the document
+ class.
+\end{options}
+
+The most important option is \option{style}. Details concerning this option
+are explaind in sections~\ref{ssec:styles} and~\ref{sec:default-style}.
\section{The Database}
\subsection{Declaring the Chemicals}
The data about substances are stored via the command
-\begin{beschreibung}
- \Befehl{DeclareSubstance}{<id>}\ma{<list of properties>}
-\end{beschreibung}
+\begin{commands}
+ \command{DeclareSubstance}[\marg{id}\marg{list of properties}]
+ This declares substance \meta{id}.
+\end{commands}
An entry could look like this:
-\begin{beispiel}[code only]
-\DeclareSubstance{NaCl}{
- name = Sodiumchloride ,
- sum = NaCl ,
- CAS = 7647-14-5,
- mass = 58.44 ,
- mp = 801 ,
- bp = 1465 ,
- phase = solid ,
- density = 2.17
-}
-\end{beispiel}
-
-Such entries can either be declared in the document preamble or probably
-more useful in a file with the ending \code{.sub}. Such a file can be input in
-the document via
-\begin{beschreibung}
- \befehl{LoadSubstances}{<filename>} input the file \emph{without} specifying
- the file ending.
-\end{beschreibung}
-Suppose you have the file \code{mysubstances.sub} then you input it in the
-document preamble via \cmd{LoadSubstances}{mysubstances}.
+\begin{sourcecode}
+ \DeclareSubstance{NaCl}{
+ name = Sodiumchloride ,
+ sum = NaCl ,
+ CAS = 7647-14-5,
+ mass = 58.44 ,
+ mp = 801 ,
+ bp = 1465 ,
+ phase = solid ,
+ density = 2.17
+ }
+\end{sourcecode}
+
+Such\changedversion{0.2} entries can either be declared in the document
+preamble or probably more useful in a database file. Such a file can be input
+in the document via
+\begin{commands}
+ \command{LoadSubstances}[\marg{database name}]
+ Input the database \meta{database name}. The name of a database file must
+ follow the structure
+ \code{\substancesdatabase{\meta{database name}}}.
+\end{commands}
+Suppose you have the file \code{\substancesdatabase{mydatabase}} then you
+input it in the document preamble via \cs{LoadSubstances}\Marg{mydatabase}.
\subsection{Available Fields}
\subsubsection{Always Defined Fields}
-Below all fields defined by \substances are listed\footnote{Look in the file
-\code{substances-examples.sub} which is part of this package and
-should be in the same place as this documentation for example uses.}.
-\begin{beschreibung}
- \Option{name}\required The \acs{IUPAC} name of the substance. This is the only
- field that \emph{has} to be used. The field's input is parsed with
- \paket{chemmacros}' command \cmd{iupac}.
- \Option{sort}\optional If you plan to use the \key{index} option you
- should specify this field to get the sorting of the index right. This then
- creates index entries \cmd{index}{<sort field>\@<name field>}.
- \Option{alt}\optional An alternative name. The field's input is parsed with
- \paket{chemmacros}' command \cmd{iupac}.
- \Option{altsort}\optional This is the same as the \key{sort} field but for the
- alternative name.
- \Option{CAS}\optional The \ac{CAS} number. The input needs to be input in the
- form \code{<num>-<num>-<num>}.
- \Option{PubChem}\optional The PubChem number.
-\end{beschreibung}
-
-The \key{CAS} field processes the number using the macro \cmd{CAS}{<number>}
-which is defined like this:
-\begin{beispiel}[code only]
- \def\@CAS#1-#2-#3{\iupac{#1\-#2\-#3}}
- \NewDocumentCommand\CAS{m}{\@CAS#1}
-\end{beispiel}
+Below all fields defined by \substances\ are listed\footnote{Look in the file
+ \code{\substancesdatabase{substances-examples}} which is part of this
+ package and should be in the same place as this documentation for example
+ uses.}.
+\begin{options}
+ \keyval{name}{name}\Default!
+ The \acs{IUPAC} name of the substance. This is the only field that
+ \emph{has} to be used. The field's input is parsed with
+ \pkg{chemmacros}' command \cs{iupac}.
+ \keyval{sort}{sort name}
+ If you plan to use the \option{index} option you should specify this field
+ to get the sorting of the index right. This then creates index entries
+ \cs{index}\Marg{\meta{sort field}@\meta{name field}}.
+ \keyval{alt}{alt name}
+ An alternative name. The field's input is parsed with \pkg{chemmacros}'
+ command \cs{iupac}.
+ \keyval{altsort}{sort alt name}
+ This is the same as the \option{sort} field but for the alternative name.
+ \keyval{CAS}{CAS number}
+ The \ac{CAS} number. The input needs to be input in the form
+ \code{\meta{num}-\meta{num}-\meta{num}}.
+ \keyval{PubChem}{PubChem number}
+ The PubChem number.
+\end{options}
+
+The \option{CAS} field processes the number using the macro
+\cs{CAS}\marg{number} which is defined like this:
+\begin{sourcecode}
+ \def\@CAS#1-#2-#3\relax{\iupac{#1-#2-#3}}
+ \NewDocumentCommand\CAS{m}{\@CAS#1\relax}
+\end{sourcecode}
You're free to redefine it to your needs.
\subsubsection{Style-dependend Fields}
-\substances defines the style `default' which is loaded if no other style has
-been specified. It defines the following additional fields and loads the
-packages \paket{chemfig} and \paket{siunitx}.
-\begin{beschreibung}
- \Option{formula}\optional The molecular formula of the substance. The field's
- input is parsed with \paket{chemmacros}' command
- \cmd{ch}.
- \Option{structure}\optional The structural formula of the substance. The field's
- input is parsed with \paket{chemfig}'s command \cmd{chemfig}.
- \Option{mp}\optional The boiling point. The field's entry is input into
- the \paket{siunitx} command \cmd{SI} in the following way:
- \cmd{SI}{<field>}\ma{\cmd{celsius}}.
- \Option{bp}\optional The melting point. The field's entry is input into
- the \paket{siunitx} command \cmd{SI} in the following way:
- \cmd{SI}{<field>}\ma{\cmd{celsius}}.
- \Option{density}\optional The density. The field's entry is input into
- the \paket{siunitx} command \cmd{SI} in the following way:
- \cmd{SI}{<field>}\ma{\cmd{gram}\cmd{per}\cmd{cmc}}.
- \Option{phase}\optional The state of aggregation.
- \Option{pKa}\optional The \pKa\ value. The field's entry is input into the
- \paket{siunitx} command \cmd{num}.
- \Option{pKa1}\optional The first of several \pKa\ values. The field's entry is
- input into the \paket{siunitx} command \cmd{num}.
- \Option{pKa2}\optional The second of several \pKa\ values. The field's entry is
- input into the \paket{siunitx} command \cmd{num}.
- \Option{pKb}\optional The \pKb\ values. The field's entry is input into the
- \paket{siunitx} command \cmd{num}.
- \Option{pKb1}\optional The first of several \pKb\ values. The field's entry is
- input into the \paket{siunitx} command \cmd{num}.
- \Option{pKb2}\optional The second of several \pKb\ values. The field's entry is
- input into the \paket{siunitx} command \cmd{num}.
- \Option{pictograms}\optional The GHS pictograms. This field takes a list
- of pictogram names as they're input into \paket{chemmacros}' command
- \cmd{ghspic}.
- \Option{H}\optional The H statements. This field takes a list
- of numbers as they're input into \paket{chemmacros}' command
- \cmd{ghs}{h}\ma{<number>}.
- \Option{P}\optional The P statements. This field takes a list
- of pictogram names as they're input into \paket{chemmacros}' command
- \cmd{ghs}{p}\ma{<number>}.
- \Option{EUH}\optional The EUH statements. This field takes a list
- of pictogram names as they're input into \paket{chemmacros}' command
- \cmd{ghs}{h}\ma{<number>}.
- \Option{LD50}\optional The \ac{LD50} in \si{\milli\gram\per\kilo\gram}. The
- field's entry is input into the \paket{siunitx} command \cmd{SI} in the
- following way: \cmd{SI}{<field>}\ma{\cmd{milli}\cmd{gram}\cmd{per}\cmd{kilo}\cmd{gram}}.
-\end{beschreibung}
-
-\subsection{Define Custom Styles}\label{ssec:styles}
-\subsubsection{Background}
-You might have other needs for fields than the ones defined by \substances and
-the `default' style. You can easily define your own style which means that you
-save a file with the name \code{substances-<style>.def}. In it you save the
-commands you need and use the command \cmd{DeclareSubstanceProperty}, which is
-explained in the next section, to declare your own fields.
-
-Please beware that this style file is loaded by the package when the \code{expl3}
-namespace is active. This means that all spaces are ignored and you need to use
-\code{\textasciitilde} if you need a space. It also means that \code{\_} and
-\code{:} are letters (as is \code{{\makeatletter @}}). Should you ever decide to
-call \cmd{ExplSyntaxOff} to turn off the \code{expl3} namespace \emph{don't} forget
-to use \cmd{ExplSyntaxOn} at the end of the file!
-
-\subsubsection{Declare New Fields or Change Existing Fields}
+\substances\ defines the style \substyle{default} (see also
+sections~\ref{sec:options}, \ref{ssec:styles}, and~\ref{sec:default-style})
+which is loaded if no other style has been specified. It defines the following
+additional fields and loads the packages \pkg{chemfig}~\cite{pkg:chemfig} and
+\pkg{siunitx}~\cite{pkg:siunitx}.
+\begin{options}
+ \keyval{formula}{formula}
+ The molecular formula of the substance. The field's input is parsed with
+ \pkg{chemmacros}' command \cs{ch}.
+ \keyval{structure}{structure}
+ The structural formula of the substance. The field's input is parsed with
+ \pkg{chemfig}'s command \cs{chemfig}.
+ \keyval{mp}{melting point}
+ The melting point. The field's entry is input into the \pkg{siunitx}
+ command \cs{SI} in the following way: \\
+ \cs{SI}\marg{field}\Marg{\cs{celsius}}.
+ \keyval{bp}{boiling point}
+ The boiling point. The field's entry is input into the \pkg{siunitx}
+ command \cs{SI} in the following way: \\
+ \cs{SI}\marg{field}\Marg{\cs{celsius}}.
+ \keyval{density}{density}
+ The density. The field's entry is input into the \pkg{siunitx} command
+ \cs{SI} in the following way: \\
+ \cs{SI}\marg{field}\Marg{\cs{gram}\cs{per}\cs{cmc}}.
+ \keyval{phase}{phase}
+ The state of aggregation.
+ \keyval{pKa}{\pKa}
+ The \pKa\ value. The field's entry is input into the \pkg{siunitx} command
+ \cs{num}.
+ \keyval{pKa1}{\pKa[1]}
+ The first of several \pKa\ values. The field's entry is input into the
+ \pkg{siunitx} command \cs{num}.
+ \keyval{pKa2}{\pKa[2]}
+ The second of several \pKa\ values. The field's entry is input into the
+ \pkg{siunitx} command \cs{num}.
+ \keyval{pKb}{\pKb}
+ The \pKb\ value. The field's entry is input into the \pkg{siunitx} command
+ \cs{num}.
+ \keyval{pKb1}{\pKb[1]}
+ The first of several \pKb\ values. The field's entry is input into the
+ \pkg{siunitx} command \cs{num}.
+ \keyval{pKb2}{\pKb[2]}
+ The second of several \pKb\ values. The field's entry is input into the
+ \pkg{siunitx} command \cs{num}.
+ \keyval{pictograms}{csv list of pictograms}
+ The \acs{ghs} pictograms. This field takes a list of pictogram names as
+ they're input into \pkg{ghsystem}'s command
+ \cs{ghspic}~\cite{pkg:ghsystem}.
+ \keyval{H}{csv list of hazard statements}
+ The H statements. This field takes a list of numbers as they're input into
+ \pkg{ghsystem}'s command \cs{ghs}\Marg{h}\marg{number}.
+ \keyval{P}{csv list of precautionary statements}
+ The P statements. This field takes a list of pictogram names as they're
+ input into \pkg{ghsystem}'s command \cs{ghs}\Marg{p}\marg{number}.
+ \keyval{EUH}{csv list of EUH statements}
+ The EUH statements. This field takes a list of pictogram names as they're
+ input into \pkg{ghsystem}'s command \cs{ghs}\Marg{euh}\marg{number}.
+ \keyval{LD50}{\acl{LD50}}
+ The \ac{LD50} in \si{\milli\gram\per\kilo\gram}. The field's entry is
+ input into the \pkg{siunitx} command \cs{SI} in the following way: \\
+ \cs{SI}\marg{field}\Marg{\cs{milli}\cs{gram}\cs{per}\cs{kilo}\cs{gram}}.
+\end{options}
+
+\section{Define Custom Styles}\label{ssec:styles}
+\subsection{Background}
+You might have other needs for fields than the ones defined by \substances\
+and the \substyle{default} style. \emph{All fields except the required
+ \option{name} field whixh are explained in this manual are defined by the
+ \substyle{default} style.}
+
+You can easily define your own style which means that you save a file with the
+name \code{\substancesstyle{\meta{style}}}. In it you both define the commands
+you need and you declare substance properties with the command
+\cs{DeclareSubstanceProperty} (which is explained in
+section~\ref{sec:declare-new-fields}) to declare your own fields.
+
+Such a style file should start with a \cs{SubstancesStyle} declaration:
+\begin{commands}
+ \command{SubstancesStyle}[\sarg\marg{style name}]
+ This\sinceversion{0.2} declares the style \meta{style name}. The starred
+ version also switches to the expl3 programming environment. Either way
+ \code{@} has category code~11 in a style file.
+ \command{LoadSubstancesStyle}[\marg{style name}]
+ This\sinceversion{0.2} loads the style \meta{style name}. It can be used
+ inside of a style file. This can be useful if you want to extend the
+ default style without copy-pasting every definition of the default style.
+ Outside of a style file this command does nothing.
+\end{commands}
+
+The implementation of the \substyle{default} style is shown in
+section~\ref{sec:default-style} as an example.
+
+\subsection{Declare New Fields or Change Existing Fields}\label{sec:declare-new-fields}
You might want other fields or change the definition of the predefined ones.
For this there's
-\begin{beschreibung}
- \Befehl{DeclareSubstanceProperty}*{<field name>}\oa{<pre code>}\oa{<post code>}
-\end{beschreibung}
-This command declares a new property field for a substance. The star makes the
-property a required one which means an error will be issued if a substance is
-declared without it. The optional arguments \code{<pre code>} and \code{<post code>}
-specify any code that should be input directly before or after the field entry,
-respectively. The \code{<pre code>} may end with a command that takes one mandatory
-argument. In this case the field entry will be its argument.
-
-The following example would define a field \key{EC} which uses a custom command
-to parse the field entry. The \ac{EC} is assigned to chemical substances
-for regulatory purposes within the European Union by the regulatory authorities.
-\begin{beispiel}[code only]
- \makeatletter
- \def\@EC#1-#2-#3{#1-#2-#3}
- \newcommand*\EC[1]{\@EC#1}
- \makeatother
- \DeclareSubstanceProperty{EC}[\EC]
-\end{beispiel}
+\begin{commands}
+ \command{DeclareSubstanceProperty}[\sarg\marg{field name}\oarg{pre
+ code}\oarg{post code}]
+ This command declares a new property field for a substance. The star makes
+ the property a required one which means an error will be issued if a
+ substance is declared without it. The optional arguments \meta{pre code}
+ and \meta{post code} specify any code that should be input directly before
+ or after the field entry, respectively. The \meta{pre code} may end with a
+ command that takes one mandatory argument. In this case the field entry
+ will be its argument.
+\end{commands}
+
+The following example would define a field \option*{EC} which uses a custom
+command to parse the field entry. The \ac{EC} is assigned to chemical
+substances for regulatory purposes within the European Union by the regulatory
+authorities.
+\begin{sourcecode}
+ \makeatletter
+ \def\@EC#1-#2-#3\relax{#1-#2-#3}
+ \newcommand*\EC[1]{\@EC#1\relax}
+ \makeatother
+ \DeclareSubstanceProperty{EC}[\EC]
+\end{sourcecode}
For further examples of the usage of pre and post code look at the definition of
-the \key{name} and the \key{mp} field:
-\begin{beispiel}[code only]
- \DeclareSubstanceProperty*{name}[\iupac]
- \DeclareSubstanceProperty{mp}[\SI][{\celsius}]
-\end{beispiel}
-
+the \option{name} and the \option{mp} field:
+\begin{sourcecode}
+ \DeclareSubstanceProperty*{name}[\iupac]
+ \DeclareSubstanceProperty{mp}[\SI][{\celsius}]
+\end{sourcecode}
\section{Retrieving the Data}
-There are two commands defined by \substances that allow the retrieving of the
-data. The command \cmd{chem} is intended as user command, the command
-\cmd{GetSubstanceProperty} can be used to define your own user command (perhaps
+There are two commands defined by \substances\ that allow the retrieving of
+the data. The command \cs{chem} is intended as user command, the command
+\cs{GetSubstanceProperty} can be used to define your own user command (perhaps
in your own style file, see section~\ref{ssec:styles}).
-\begin{beschreibung}
- \Befehl{chem}*[<pre>]\oa{<post>}\ma{<id>}\oa{<property>}
- \Befehl{GetSubstanceProperty}{<id>}\ma{<property>}
-\end{beschreibung}
-If the command \cmd{chem} is called without the \oa{<property>} argument the
-\code{name} entry will be called. The starred version calls the \code{alt} entry
-if it is defined and the \code{name} entry otherwise. The arguments \oa{<pre>}
-and \oa{<post>} add arbitrary input before or after the output, respectively.
-
-All of the next examples use the data defined in the file \code{substances-examples.sub}
-that is part of this package, see section~\ref{sec:examples}.
-\begin{beispiel}
- \chem{H2SO4}[structure] \newline
- \chem{H2SO4} has the boiling point \(\chem[T_b =]{H2SO4}[bp]\) and a
- density of \(\chem[\rho =]{H2SO4}[density]\).
-
- Compare the melting points of methane and ethane,
- \(\chem[T_m=]{methane}[mp]\) and \(\chem[T_m=]{ethane}[mp]\),
- with the boiling points \(\chem[T_b=]{methane}[bp]\) and
- \(\chem[T_b=]{ethane}[bp]\).
-
- \chem{NaCl} has the \ac{CAS} number \chem{NaCl}[CAS].
+\begin{commands}
+ \command{chem}[\sarg\oarg{pre}\oarg{post}\marg{id}\oarg{property}]
+ If the command \cs{chem} is called without the optional \meta{property}
+ argument the \option{name} entry will be called. The starred version calls
+ the \option{alt} entry if it is defined and the \option{name} entry
+ otherwise. The arguments \meta{pre} and \meta{post} add arbitrary input
+ before or after the output, respectively.
+ \command{GetSubstanceProperty}[\marg{id}\marg{property}]
+ Retrieves \meta{property} for substance \meta{id}.
+\end{commands}
+
+All of the next examples use the data defined in the file
+\code{substances-examples.sub} that is part of this package, see
+section~\ref{sec:examples}.
+\begin{example}
+ \chem{H2SO4}[structure] \newline
+ \chem{H2SO4} has the boiling point $\chem[T_b =]{H2SO4}[bp]$ and a
+ density of $\chem[\rho =]{H2SO4}[density]$.
+
+ Compare the melting points of methane and ethane,
+ $\chem[T_m=]{methane}[mp]$ and $\chem[T_m=]{ethane}[mp]$,
+ with the boiling points $\chem[T_b=]{methane}[bp]$ and
+ $\chem[T_b=]{ethane}[bp]$.
- \chem{acetone} (\chem*{acetone}) is the most simple ketone:
+ \chem{NaCl} has the \ac{CAS} number \chem{NaCl}[CAS].
+
+ \chem{acetone} (\chem*{acetone}) is the most simple ketone:
- \chem{acetone}[structure]
-\end{beispiel}
+ \chem{acetone}[structure]
+\end{example}
The following code creates table~\ref{tab:methane}.
-\begin{beispiel}[code and float]
-\begin{table}[htp]
-\centering\chemsetup[ghsystem]{hide}
-\sisetup{scientific-notation=fixed,fixed-exponent=0,per-mode=symbol}
-\begin{tabular}{l>{\raggedright\arraybackslash}p{.6\linewidth}}
- \toprule
- name & \chem{methane} \\
- formula & \chem{methane}[formula] \\
- & \chem{methane}[structure] \\
- \midrule
- CAS & \chem{methane}[CAS] \\
- PubChem & \chem{methane}[PubChem] \\
- \midrule
- boiling point & \chem{methane}[bp] \\
- melting point & \chem{methane}[mp] \\
- density & \chem{methane}[density] \\
- molar mass & \chem{methane}[mass] \\
- \midrule
- & \chem{methane}[pictograms] \\
- H statements & \chem{methane}[H] \\
- P statements & \chem{methane}[P] \\
- \bottomrule
-\end{tabular}
-\caption{\label{tab:methane}All properties of \chem{methane} that have been
-saved in the example database.}
-\end{table}
-\end{beispiel}
+\begin{example}[outside]
+ \begin{table}[htp]
+ \centering
+ \ghssetup{hide}
+ \sisetup{scientific-notation=fixed,fixed-exponent=0,per-mode=symbol}
+ \begin{tabular}{l>{\raggedright\arraybackslash}p{.6\linewidth}}
+ \toprule
+ name & \chem{methane} \\
+ formula & \chem{methane}[formula] \\
+ & \chem{methane}[structure] \\
+ \midrule
+ \ac{CAS} & \chem{methane}[CAS] \\
+ PubChem & \chem{methane}[PubChem] \\
+ \midrule
+ boiling point & \chem{methane}[bp] \\
+ melting point & \chem{methane}[mp] \\
+ density & \chem{methane}[density] \\
+ molar mass & \chem{methane}[mass] \\
+ \midrule
+ & \chem{methane}[pictograms] \\
+ H statements & \chem{methane}[H] \\
+ P statements & \chem{methane}[P] \\
+ \bottomrule
+ \end{tabular}
+ \caption{\label{tab:methane}All properties of \chem{methane} that have
+ been saved in the example database.}
+ \end{table}
+\end{example}
\section{Additional Commands}
-\substances provides a few commands that maybe are useful in building custom
+\substances\ provides a few commands that maybe are useful in building custom
macros for styles. A field exists if it has been defined with
-\cmd{DeclareSubstanceProperty} regardless if it has been used or not. A substance
-exists if it has been defined with \cmd{DeclareSubstance}.
-\begin{beschreibung}
- \Befehl{GetSubstanceProperty}{<id>}\ma{<field>} \cnpkgdocarrow\ You know that
- already: retrieve the property specified in \code{<field>} for a given substance.
- This command is \emph{not} expandable.
- \Befehl{RetrieveSubstanceProperty}{<id>}\ma{<field>} \cnpkgdocarrow\ Same as
- \cmd{GetSubstanceProperty} but expandable.
- \befehl{ForAllSubstancesDo}{<code>} Loops through all existing substances.
- Inside \code{<code>} \code{\#1} may be used to refer to the \code{<id>} of the
- current substance. This command is expandable.
- \befehl{AllSubstancesSequence} A sequence of all substances. This is a sequence
- of balanced groups each containing the \code{<id>} of a substance. This command
- is expandable.
- \befehl{AllSubstancesClist} A comma separated list of all substances. Every
- \code{<id>} is separated from the next with a comma. This command is expandable.
- \Befehl{IfSubstancePropertyTF}{<id>}\ma{<field>}\ma{<true code>}\ma{<false code>}
- \cnpkgdocarrow\ Tests if the property \code{<field>} is defined for the
- substance \code{<id>} and returns either \code{<true code>} or \code{<false code>}.
- This command is expandable.
- \Befehl{IfSubstancePropertyT}{<id>}\ma{<field>}\ma{<true code>} \cnpkgdocarrow\
- Tests if the property \code{<field>} is defined for the substance \code{<id>}
- and returns \code{<true code>} if it is. This command is expandable.
- \Befehl{IfSubstancePropertyF}{<id>}\ma{<field>}\ma{<false code>} \cnpkgdocarrow\
- Tests if the property \code{<field>} is defined for the substance \code{<id>}
- and returns \code{<false code>} if it isn't. This command is expandable.
- \Befehl{IfSubstanceFieldTF}{<field>}\ma{<true code>}\ma{<false code>}
- \cnpkgdocarrow\ Tests if the property \code{<field>} exists and returns either
- \code{<true code>} or \code{<false code>}. This command is expandable.
- \Befehl{IfSubstanceFieldT}{<field>}\ma{<true code>} \cnpkgdocarrow\
- Tests if the property \code{<field>} exists and returns \code{<true code>} if
- it does. This command is expandable.
- \Befehl{IfSubstanceFieldF}{<field>}\ma{<false code>} \cnpkgdocarrow\
- Tests if the property \code{<field>} exists and returns \code{<false code>} if
- it doesn't. This command is expandable.
- \Befehl{IfSubstanceExistTF}{<id>}\ma{<true code>}\ma{<false code>}
- \cnpkgdocarrow\ Tests if the property \code{<field>} exists and returns either
- \code{<true code>} or \code{<false code>}. This command is expandable.
- \Befehl{IfSubstanceExistT}{<id>}\ma{<true code>} \cnpkgdocarrow\
- Tests if the substance \code{<id>} exists and returns \code{<true code>} if
- it does. This command is expandable.
- \Befehl{IfSubstanceExistF}{<id>}\ma{<false code>} \cnpkgdocarrow\
- Tests if the substance \code{<id>} exists and returns \code{<false code>} if
- it doesn't. This command is expandable.
-\end{beschreibung}
-
-\begin{beispiel}
-Just to demonstrate how these commands can be used. And to get
-our demonstration index filled.\par
-\newcounter{substances}
-\ForAllSubstancesDo{%
- \ifnum0=\value{substances}\relax
- \else, \fi
- \stepcounter{substances}%
- \chem{#1}%
- \IfSubstancePropertyT{#1}{alt}{
- (\chem*{#1})}}
-\end{beispiel}
+\cs{DeclareSubstanceProperty} regardless if it has been used or not. A
+substance exists if it has been defined with \cs{DeclareSubstance}.
+
+\begin{commands}
+ \command{GetSubstanceProperty}[\marg{id}\marg{field}]
+ Retrieve the property specified in \meta{field} for substance \meta{id}.
+ This command is \emph{not} expandable.
+ \expandable\command{RetrieveSubstanceProperty}[\marg{id}\marg{field}]
+ The same as \cs{GetSubstanceProperty} but expandable.
+ \expandable\command{ForAllSubstancesDo}[\marg{code}]
+ Loops through all existing substances. Inside \meta{code} \code{\#1} may
+ be used to refer to the \meta{id} of the current substance. This command
+ is expandable.
+ \expandable\command{AllSubstancesSequence}
+ A sequence of all substances. This is a sequence of balanced groups each
+ containing the \meta{id} of a substance. This command is expandable.
+ \expandable\command{AllSubstancesClist}
+ A comma separated list of all substances. Every \meta{id} is separated
+ from the next with a comma. This command is expandable.
+ \expandable\command{IfSubstancePropertyTF}[\marg{id}\marg{field}\marg{true
+ code}\marg{false code}]
+ Tests if the property \meta{field} is defined for the substance \meta{id}
+ and returns either \meta{true code} or \meta{false code}. This command is
+ expandable.
+ \expandable\command{IfSubstancePropertyT}[\marg{id}\marg{field}\marg{true
+ code}]
+ Tests if the property \meta{field} is defined for the substance \meta{id}
+ and returns \meta{true code} if it is. This command is expandable.
+ \expandable\command{IfSubstancePropertyF}[\marg{id}\marg{field}\marg{false
+ code}]
+ Tests if the property \meta{field} is defined for the substance \meta{id}
+ and returns \meta{false code} if it isn't. This command is expandable.
+ \expandable\command{IfSubstanceFieldTF}[\marg{field}\marg{true
+ code}\marg{false code}]
+ Tests if the property \meta{field} exists and returns either
+ \meta{true code} or \meta{false code}. This command is expandable.
+ \expandable\command{IfSubstanceFieldT}[\marg{field}\marg{true code}]
+ Tests if the property \meta{field} exists and returns \meta{true code} if
+ it does. This command is expandable.
+ \expandable\command{IfSubstanceFieldF}[\marg{field}\marg{false code}]
+ Tests if the property \meta{field} exists and returns \meta{false code} if
+ it doesn't. This command is expandable.
+ \expandable\command{IfSubstanceExistTF}[\marg{id}\marg{true code}\marg{false
+ code}]
+ Tests if the substance \meta{id} exists and returns either \meta{true
+ code} or \meta{false code}. This command is expandable.
+ \expandable\command{IfSubstanceExistT}[\marg{id}\marg{true code}]
+ Tests if the substance \meta{id} exists and returns \meta{true code} if
+ it does. This command is expandable.
+ \expandable\command{IfSubstanceExistF}[\marg{id}\marg{false code}]
+ Tests if the substance \meta{id} exists and returns \meta{false code} if
+ it doesn't. This command is expandable.
+\end{commands}
+
+\begin{example}
+ Just to demonstrate how these commands can be used. And to get
+ our demonstration index filled.\par
+ \newcounter{substances}
+ \ForAllSubstancesDo{%
+ \ifnum0=\value{substances}\relax
+ \else,
+ \fi
+ \stepcounter{substances}%
+ \chem{#1}%
+ \IfSubstancePropertyT{#1}{alt}{ (\chem*{#1})}%
+ }
+\end{example}
\section{Create an Index}\label{sec:index}
-When \substances is called with \key{index}{true} the command \cmd{chem} will
-add index entries each time it is used. In this case the entries of the fields
-\key{name}, \key{sort}, \key{alt} and \key{altsort} will be expanded during the
-process. You should keep that in mind if some error arises. It might be due to
-a \cmd{textbf} or similar in your database. In this case you either need to
-replace it with some robust command or put a \cmd{noexpand} in front of it.
-
-Alternative names as specified in the \key{alt} also get an index entry with a
-reference to the one of the corresponding \key{name} field. The entry of the
-\key{name} field in this case gets the \key{alt} name appended in braces.
+When \substances\ is called with \keyis{index}{true} the command \cs{chem}
+will add index entries each time it is used. In this case the entries of the
+fields \option{name}, \option{sort}, \option{alt} and \option{altsort} will be
+expanded during the process. You should keep that in mind if some error
+arises. It might be due to a \cs*{textbf} or similar in your database. In this
+case you either need to replace it with some robust command or put a
+\cs*{noexpand} in front of it.
+
+Alternative names as specified in the \option{alt} also get an index entry
+with a reference to the one of the corresponding \option{name} field. The
+entry of the \option{name} field in this case gets the \option{alt} name
+appended in braces.
This behaviour is not customizable for the time being. It is planned for future
versions of this package, though.
As a demonstration an index for all chemicals used in this documentation is
-created with the help of the package \paket{imakeidx}.
+created with the help of the package \pkg{imakeidx}~\cite{pkg:imakeidx}.
\subsection{Formatting Commands}
The index entries are formatted with the following commands. You can redefine
them to your needs. If you do make sure they have the same number of required
arguments and are expandable!
-\begin{beschreibung}\makeatletter
- \Befehl{SubstanceIndexNameEntry}\code{\#1\#2}\ma{\#1@\#2} \cnpkgdocarrow\
- Formats the name if no \key{alt} field is given. \code{\#1} refers to the
- \key{sort} field entry and \code{\#2} refers to the \key{name} field entry.
- \Befehl{SubstanceIndexNameAltEntry}\code{\#1\#2\#3}\ma{\#1@\#2 (\#3)}
- \cnpkgdocarrow\ Formats the name if also the \key{alt} field is given.
- \code{\#1} refers to the \key{sort} field entry, \code{\#2} refers to the
- \key{name} field entry, and \code{\#3} to the \key{alt} field entry.
- \Befehl{SubstanceIndexAltEntry}\code{\#1\#2\#3}\ma{\#1@\#3|see\#2} \cnpkgdocarrow\
- Formats the entry for the \key{alt} field. \code{\#1} refers to the \key{altsort}
- field entry, \code{\#2} refers to the \key{name} field entry, and \code{\#3}
- to the \key{alt} field entry.
-\end{beschreibung}
+\begin{commands}
+ \expandable\command{SubstanceIndexNameEntry}[\marg{sort}\marg{name}]
+ Formats the name if no \option{alt} field is given. The default definition
+ is \code{\#1@\#2}.
+ \expandable\command{SubstanceIndexNameAltEntry}[\marg{sort}\marg{name}\marg{alt}]
+ Formats the name if the \option{alt} field is given. The default definition is
+ \code{\#1@\#2 (\#3)}.
+ \expandable\command{SubstanceIndexAltEntry}[\marg{alt sort}\marg{name}\marg{alt}]
+ Formats the entry for the \option{alt} field. The default definition is
+ \code{\#1@\#3|see\#2}
+\end{commands}
\subsection{Using makeidx}
-Using the option \key{index}{true} with the standard way to create an index will
-add the entries \cmd{index}{<name>} to the index. This means you would mix them
-with other entries if you have any. Below a sample document is shown that needs
-to be compiled with \code{pdflatex}, \code{makeindex} and again with \code{pdflatex}.
-\begin{beispiel}[code only]
-\documentclass{article}
-\usepackage[T1]{fontenc}
-\usepackage[index]{substances}
-\LoadSubstances{substances-examples}
-
-\usepackage{makeidx}
-\makeindex
-\begin{document}
-
-\newcounter{substances}
-\ForAllSubstancesDo{%
- \ifnum0=\value{substances}\relax
- \else, \fi
- \stepcounter{substances}\chem{#1}}
+Using the option \keyis{index}{true} with the standard way to create an index
+will add the entries \cs{index}\marg{name} to the index. This means you would
+mix them with other entries if you have any. Below a sample document is shown.
+
+\begin{sourcecode}
+ \documentclass{article}
+ \usepackage[T1]{fontenc}
+ \usepackage[index]{substances}
+ \LoadSubstances{substances-examples}
+
+ \usepackage{makeidx}
+ \makeindex
+ \begin{document}
+
+ \newcounter{substances}
+ \ForAllSubstancesDo{%
+ \ifnum0=\value{substances}\relax
+ \else, \fi
+ \stepcounter{substances}\chem{#1}
+ }
-\printindex
-\end{document}
-\end{beispiel}
-
-\subsection{Using splitidx}
-Maybe a seperate index for the chemicals will make more sense. In this case you
-could use the package \paket{splitidx}. \substances will recognize this and
-create \cmd{sindex}[\cmd{jobname}-chem]{<name>} entries each time \cmd{chem} is
-used. The sample document below needs to be compiled with \code{pdflatex},
-\code{splitindex} and again with \code{pdflatex}.
-\begin{beispiel}[code only]
-\documentclass{article}
-\usepackage[T1]{fontenc}
-\usepackage[index]{substances}
-\LoadSubstances{substances-examples}
+ \printindex
+ \end{document}
+\end{sourcecode}
+
+\subsection{Using \pkg*{splitidx}}
+Maybe a seperate index for the chemicals will make more sense. In this case
+you could use the package \pkg{splitidx}~\cite{pkg:splitidx}. \substances\
+will recognize this and create \cs{sindex}\Oarg{\cs*{jobname}-chem}\marg{name}
+entries each time \cs{chem} is used.
+
+\begin{sourcecode}
+ \documentclass{article}
+ \usepackage[T1]{fontenc}
+ \usepackage[index]{substances}
+ \LoadSubstances{substances-examples}
+
+ \usepackage{splitidx}
+ \makeindex
+ \newindex[Chemicals]{\jobname-chem}
+ \begin{document}
+
+ \newcounter{substances}
+ \ForAllSubstancesDo{%
+ \ifnum0=\value{substances}\relax
+ \else, \fi
+ \stepcounter{substances}\chem{#1}
+ }
-\usepackage{splitidx}
-\makeindex
-\newindex[Chemicals]{\jobname-chem}
-\begin{document}
+ \printindex[\jobname-chem]
+ \end{document}
+\end{sourcecode}
+
+\subsection{Using \pkg*{imakeidx}}
+Another way to create multiple indexes is the package
+\pkg{imakeidx}~\cite{pkg:imakeidx}. \substances\ recognizes its usage and
+creates index entries \cs{index}\Oarg{\cs*{jobname}-chem}\marg{name}.
+
+\begin{sourcecode}
+ \documentclass{article}
+ \usepackage[T1]{fontenc}
+ \usepackage[index]{substances}
+ \LoadSubstances{substances-examples}
+
+ \usepackage{imakeidx}
+ \makeindex[name=\jobname-chem,title=Chemicals]
+ \begin{document}
+
+ \newcounter{substances}
+ \ForAllSubstancesDo{%
+ \ifnum0=\value{substances}\relax
+ \else, \fi
+ \stepcounter{substances}\chem{#1}
+ }
-\newcounter{substances}
-\ForAllSubstancesDo{%
- \ifnum0=\value{substances}\relax
- \else, \fi
- \stepcounter{substances}\chem{#1}}
+ \printindex[\jobname-chem]
+ \end{document}
+\end{sourcecode}
-\printindex[\jobname-chem]
-\end{document}
-\end{beispiel}
-
-\subsection{Using imakeidx}
-Another way to create multiple indexes is the package \paket{imakeidx}. \substances
-recognizes its usage and creates index entries \cmd{index}[\cmd{jobname}-chem]{<name>}.
-The sample document below needs to be compiled with \code{pdflatex -{}-shell-escape}.
-\begin{beispiel}[code only]
-\documentclass{article}
-\usepackage[T1]{fontenc}
-\usepackage[index]{substances}
-\LoadSubstances{substances-examples}
-
-\usepackage{imakeidx}
-\makeindex[name=\jobname-chem,title=Chemicals]
-\begin{document}
+\part{Appendix}
+\appendix
-\newcounter{substances}
-\ForAllSubstancesDo{%
- \ifnum0=\value{substances}\relax
- \else, \fi
- \stepcounter{substances}\chem{#1}}
+\section{The Default Style}\label{sec:default-style}
+The following code shows the contents of the file
+\code{\substancesstyle{default}} which defines the \substyle{default} style
+which is part of this package.
-\printindex[\jobname-chem]
-\end{document}
-\end{beispiel}
+\implementation[basicstyle=\ttfamily\footnotesize]{\substancesstyle{default}}
\section{The Example Database}\label{sec:examples}
-The following code shows the example database \code{substances-examples.sub}
-that is part of this package.
+The following code shows the example database
+\code{\substancesdatabase{substances-examples}} that is part of this package.
-\lstinputlisting[basicstyle=\ttfamily\footnotesize]{substances-examples.sub}
+\implementation[basicstyle=\ttfamily\footnotesize]{\substancesdatabase{substances-examples}}
-\appendix
\printindex[\jobname-chem]
-\printindex
-\end{document} \ No newline at end of file
+
+\end{document}
diff --git a/Master/texmf-dist/tex/latex/substances/substances-default.def b/Master/texmf-dist/tex/latex/substances/substances-default.def
index f802dbc00c5..c88c6a98fc3 100644
--- a/Master/texmf-dist/tex/latex/substances/substances-default.def
+++ b/Master/texmf-dist/tex/latex/substances/substances-default.def
@@ -8,7 +8,7 @@
% Web: https://bitbucket.org/cgnieder/substances/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
-% Copyright 2012 Clemens Niederberger
+% Copyright 2012--2015 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -30,51 +30,50 @@
% feel free to contact me.
% --------------------------------------------------------------------------
% substances: default style
-\RequirePackage { chemfig , siunitx }
+\SubstancesStyle*{default}
+\RequirePackage {chemfig,siunitx}
% ----------------------------------------------------------------------------
% helper functions for the GHS properties:
-\cs_new:Npn \substances_get_pics:n #1
+\cs_new_protected:Npn \substances_get_pics:n #1
{
- \int_zero:N \l_tmpa_int
- \clist_map_inline:nn { #1 }
- {
- \int_incr:N \l_tmpa_int
- \int_compare:nF { \l_tmpa_int = 1 } { ~ }
- \ghspic{##1}
- }
+ \seq_set_split:Nnn \l_tmpa_seq {,} {#1}
+ \seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq { \ghspic {##1} }
+ \seq_use:Nn \l_tmpa_seq {~}
}
-\cs_new:Npn \substances_get_ghs:nn #1#2
+\cs_new_protected:Npn \substances_get_ghs:nn #1#2
{
- \int_zero:N \l_tmpa_int
- \clist_map_inline:nn { #2 }
- {
- \int_incr:N \l_tmpa_int
- \int_compare:nF { \l_tmpa_int = 1 }
- { \bool_if:NT \l_ghsystem_hide_statement_bool { , } ~ }
- \ghs{#1}{##1}
- }
+ \seq_set_split:Nnn \l_tmpa_seq {,} {#2}
+ \seq_set_map:NNn \l_tmpa_seq \l_tmpa_seq { \ghs {#1} {##1} }
+ \seq_use:Nn \l_tmpa_seq
+ { \bool_if:NT \l__ghsystem_hide_statement_bool {,} ~ }
}
+\NewDocumentCommand \ghspictograms {m}
+ { \substances_get_pics:n {#1} }
+
+\NewDocumentCommand \ghsstatements {mm}
+ { \substances_get_ghs:nn {#1} {#2} }
+
% ----------------------------------------------------------------------------
-\DeclareSubstanceProperty { formula } [\ch]
-\DeclareSubstanceProperty { structure } [\chemfig]
-\DeclareSubstanceProperty { mass } [\SI][{\MolMass}]
-\DeclareSubstanceProperty { bp } [\SI][{\celsius}]
-\DeclareSubstanceProperty { mp } [\SI][{\celsius}]
-\DeclareSubstanceProperty { density } [\SI][{\gram\per\cmc}]
-\DeclareSubstanceProperty { phase }
-\DeclareSubstanceProperty {pKa} [\num]
-\DeclareSubstanceProperty {pKa1} [\num]
-\DeclareSubstanceProperty {pKa2} [\num]
-\DeclareSubstanceProperty {pKb} [\num]
-\DeclareSubstanceProperty {pKb1} [\num]
-\DeclareSubstanceProperty {pKb2} [\num]
-\DeclareSubstanceProperty { pictograms } [\substances_get_pics:n]
-\DeclareSubstanceProperty { H } [\substances_get_ghs:nn{H}]
-\DeclareSubstanceProperty { P } [\substances_get_ghs:nn{P}]
-\DeclareSubstanceProperty { EUH } [\substances_get_ghs:nn{EUH}]
-\DeclareSubstanceProperty {LD50} [\SI][{\milli\gram\per\kilo\gram}]
+\DeclareSubstanceProperty {formula} [\ch]
+\DeclareSubstanceProperty {structure} [\chemfig]
+\DeclareSubstanceProperty {mass} [\SI][{\MolMass}]
+\DeclareSubstanceProperty {bp} [\SI][{\celsius}]
+\DeclareSubstanceProperty {mp} [\SI][{\celsius}]
+\DeclareSubstanceProperty {density} [\SI][{{\gram\per\cubic\centi\metre}}]
+\DeclareSubstanceProperty {phase}
+\DeclareSubstanceProperty {pKa} [\num]
+\DeclareSubstanceProperty {pKa1} [\num]
+\DeclareSubstanceProperty {pKa2} [\num]
+\DeclareSubstanceProperty {pKb} [\num]
+\DeclareSubstanceProperty {pKb1} [\num]
+\DeclareSubstanceProperty {pKb2} [\num]
+\DeclareSubstanceProperty {pictograms} [\ghspictograms]
+\DeclareSubstanceProperty {H} [\ghsstatements{H}]
+\DeclareSubstanceProperty {P} [\ghsstatements{P}]
+\DeclareSubstanceProperty {EUH} [\ghsstatements{EUH}]
+\DeclareSubstanceProperty {LD50} [\SI][{{\milli\gram\per\kilo\gram}}]
-\tex_endinput:D \ No newline at end of file
+\tex_endinput:D
diff --git a/Master/texmf-dist/tex/latex/substances/substances.sty b/Master/texmf-dist/tex/latex/substances/substances.sty
index e9406055d2b..286c9463218 100644
--- a/Master/texmf-dist/tex/latex/substances/substances.sty
+++ b/Master/texmf-dist/tex/latex/substances/substances.sty
@@ -8,7 +8,7 @@
% Web: https://bitbucket.org/cgnieder/substances/
% E-Mail: contact@mychemistry.eu
% --------------------------------------------------------------------------
-% Copyright 2012 Clemens Niederberger
+% Copyright 2012--2015 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -29,80 +29,99 @@
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
-\RequirePackage{ expl3 , xparse , l3keys2e , xtemplate , chemmacros }
+\RequirePackage{ expl3 , xparse , l3keys2e , xtemplate }
\ProvidesExplPackage
{substances}
- {2012/07/22}
- {0.1}
+ {2015/10/21}
+ {0.2}
{A Chemical Database}
+\RequirePackage{chemmacros,chemfig,ghsystem}
+\usechemmodule{nomenclature,units}
+
% ----------------------------------------------------------------------------
% variables:
-\prop_new:N \l_substances_properties_pre_prop
-\prop_new:N \l_substances_properties_post_prop
+\tl_new:N \l__substances_tmpa_tl
+\tl_new:N \l__substances_tmpb_tl
+
+\prop_new:N \l__substances_properties_pre_prop
+\prop_new:N \l__substances_properties_post_prop
-\seq_new:N \l_substances_required_seq
+\seq_new:N \l__substances_required_seq
\seq_new:N \l_substances_chemicals_seq
\clist_new:N \l_substances_chemicals_clist
-\bool_new:N \l_substances_strict_bool
-\bool_new:N \l_substances_index_entry_bool
-\bool_new:N \l_substances_imakeidx_bool
-\bool_new:N \l_substances_multind_bool
-\bool_new:N \l_substances_splitidx_bool
+\bool_new:N \l__substances_strict_bool
+\bool_new:N \l__substances_index_entry_bool
+\bool_new:N \l__substances_imakeidx_bool
+\bool_new:N \l__substances_multind_bool
+\bool_new:N \l__substances_splitidx_bool
+\bool_new:N \l__substances_single_name_bool
+\bool_new:N \l__substances_single_alt_bool
+\bool_set_true:N \l__substances_single_alt_bool
-\tl_new:N \l_substances_style_tl
-\tl_set:Nn \l_substances_style_tl { default }
+\tl_new:N \l__substances_style_tl
+\tl_set:Nn \l__substances_style_tl {default}
\AtBeginDocument
{
- \@ifpackageloaded { imakeidx }
- { \bool_set_true:N \l_substances_imakeidx_bool } {}
- \@ifpackageloaded { splitidx }
- { \bool_set_true:N \l_substances_splitidx_bool } {}
- \@ifpackageloaded { multind }
- { \bool_set_true:N \l_substances_multind_bool } {}
+ \@ifpackageloaded {imakeidx}
+ { \bool_set_true:N \l__substances_imakeidx_bool } { }
+ \@ifpackageloaded {splitidx}
+ { \bool_set_true:N \l__substances_splitidx_bool } { }
+ \@ifpackageloaded {multind}
+ { \bool_set_true:N \l__substances_multind_bool } { }
}
% ----------------------------------------------------------------------------
% messages:
-\cs_new:Npn \substances_msg:nnn #1#2#3
+\cs_new_protected:Npn \substances_msg:nnn #1#2#3
+ {
+ \bool_if:NTF \l__substances_strict_bool
+ { \msg_error:nnnn {substances} {#1} {#2} {#3} }
+ { \msg_warning:nnnn {substances} {#1} {#2} {#3} }
+ }
+
+\cs_new_protected:Npn \substances_msg:nn #1#2
{
- \bool_if:NTF \l_substances_strict_bool
- { \msg_error:nnxx { substances } { #1 } { #2 } { #3 } }
- { \msg_warning:nnxx { substances } { #1 } { #2 } { #3 } }
+ \bool_if:NTF \l__substances_strict_bool
+ { \msg_error:nnn {substances} {#1} {#2} }
+ { \msg_warning:nnn {substances} {#1} {#2} }
}
-\msg_new:nnnn { substances } { property-missing }
+\msg_new:nnnn {substances} {property-missing}
{ Property~`#2'~not~defined~for~substance~`#1'~\msg_line_context:. }
{
You~called~property~`#2'~for~substance~`#1'.~It~seems~though~that~you~
haven't~defined~it,~yet.
}
-\msg_new:nnnn { substances } { field-missing }
+\msg_new:nnnn {substances} {field-missing}
{ Property~`#2'~is~not~defined~\msg_line_context:. }
{
You~called~property~`#2'~for~substance~`#1'.~This~property~has~not~been~
declared,~though.~Perhaps~you've~mispelled?
}
-\msg_new:nnnn { substances } { dadabase-missing }
- { I~can't~find~the~database~file~`#1'~\msg_line_context:. }
+\msg_new:nnnn {substances} {database-missing}
+ {
+ I~ can't~ find~ the~ database~ file~ `\__substances_database:n{#1}'~
+ \msg_line_context: .
+ }
{
- You~requested~the~database~file~`#1',~but~apparently~it~is~missing.~Maybe~
- you've~mispelled?
+ You~ requested~ the~ database~ file~ `\__substances_database:n{#1}',~ but~
+ apparently~ it~ is~ missing.~ Maybe~ you've~ mispelled?
}
-\msg_new:nnnn { substances } { required-field }
+\msg_new:nnnn {substances} {required-field}
{ The~field~`#1'~is~missing~for~substance~`#2'~\msg_line_context:. }
{
You~declared~the~the~substance~`#2'~but~forgot~to~add~the~required~
property~`#1'.
}
-\msg_new:nnnn { substances } { style-missing }
+\msg_new:nnnn {substances} {style-missing}
{ I~can't~find~the~file~`substances_#1.def'. }
{
You~specified~the~style~`#1'~which~means~you~want~me~to~load~the~file~
@@ -114,165 +133,171 @@
% options
\keys_define:nn { substances / options }
{
- strict .bool_set:N = \l_substances_strict_bool ,
- draft .code:n = \bool_set_true:N \l_substances_strict_bool ,
- final .code:n = \bool_set_false:N \l_substances_strict_bool ,
- index .bool_set:N = \l_substances_index_entry_bool ,
- style .tl_set:N = \l_substances_style_tl
+ strict .bool_set:N = \l__substances_strict_bool ,
+ draft .code:n = \bool_set_true:N \l__substances_strict_bool ,
+ final .code:n = \bool_set_false:N \l__substances_strict_bool ,
+ index .bool_set:N = \l__substances_index_entry_bool ,
+ style .tl_set:N = \l__substances_style_tl
}
\ProcessKeysOptions { substances / options }
% ----------------------------------------------------------------------------
% define new property fields:
-\cs_new:Npn \substances_define_property_field:nnnn #1#2#3#4
- {
- \IfBooleanT { #1 }
- { \seq_put_right:Nn \l_substances_required_seq { #2 } }
- \prop_if_exist:cF { l_substances_#2_prop }
- { \prop_new:c { l_substances_#2_prop } }
- \IfNoValueTF { #3 }
- { \prop_put:Nnn \l_substances_properties_pre_prop { #2 } { } }
- {
- \tl_if_blank:nTF { #3 }
- { \prop_put:Nnn \l_substances_properties_pre_prop { #2 } { } }
- { \prop_put:Nnn \l_substances_properties_pre_prop { #2 } { #3 } }
- }
- \IfNoValueTF { #4 }
- { \prop_put:Nnn \l_substances_properties_post_prop { #2 } { } }
- { \prop_put:Nnn \l_substances_properties_post_prop { #2 } { #4 } }
+\cs_new_protected:Npn \substances_define_property_field:nnnn #1#2#3#4
+ {
+ \bool_if:nT {#1}
+ { \seq_put_right:Nn \l__substances_required_seq {#2} }
+ \prop_if_exist:cF { l__substances_#2_prop }
+ { \prop_new:c { l__substances_#2_prop } }
+ \tl_if_blank:nTF {#3}
+ { \prop_put:Nnn \l__substances_properties_pre_prop {#2} { } }
+ { \prop_put:Nnn \l__substances_properties_pre_prop {#2} {#3} }
+ \tl_if_blank:nTF {#4}
+ { \prop_put:Nnn \l__substances_properties_post_prop {#2} { } }
+ { \prop_put:Nnn \l__substances_properties_post_prop {#2} {#4} }
}
-\NewDocumentCommand \DeclareSubstanceProperty { smoo }
- { \substances_define_property_field:nnnn { #1 } { #2 } { #3 } { #4 } }
+\NewDocumentCommand \DeclareSubstanceProperty { smO{}O{} }
+ { \substances_define_property_field:nnnn {#1} {#2} {#3} {#4} }
\@onlypreamble\DeclareSubstanceProperty
% ----------------------------------------------------------------------------
% declare new substance entry:
-\cs_new:Npn \substances_declare_substance:nn #1#2
+\cs_new_protected:Npn \substances_declare_substance:nn #1#2
{
- \seq_put_right:Nn \l_substances_chemicals_seq { #1 }
- \clist_put_right:Nn \l_substances_chemicals_clist { #1 }
- \prop_map_inline:Nn \l_substances_properties_pre_prop
+ \seq_put_right:Nn \l_substances_chemicals_seq {#1}
+ \clist_put_right:Nn \l_substances_chemicals_clist {#1}
+ \prop_map_inline:Nn \l__substances_properties_pre_prop
{
- \tl_set:Nn \l_tmpa_tl { ##2 }
- \prop_get:NnN \l_substances_properties_post_prop { ##1 } \l_tmpb_tl
- \substances_add_property:nnVV { #1 } { ##1 } \l_tmpa_tl \l_tmpb_tl
+ \tl_set:Nn \l__substances_tmpa_tl {##2}
+ \prop_get:NnN \l__substances_properties_post_prop
+ {##1}
+ \l__substances_tmpb_tl
+ \substances_add_property:nnVV {#1} {##1}
+ \l__substances_tmpa_tl
+ \l__substances_tmpb_tl
}
- \keys_set:nn { substances / #1 } { #2 }
- \seq_map_inline:Nn \l_substances_required_seq
+ \keys_set:nn { substances / #1 } {#2}
+ \seq_map_inline:Nn \l__substances_required_seq
{
\group_begin:
- \bool_set_true:N \l_substances_strict_bool
- \prop_if_in:cnF { l_substances_##1_prop } { #1 }
- { \substances_msg:nnn { required-field } { ##1 } { #1 } }
+ \bool_set_true:N \l__substances_strict_bool
+ \prop_if_in:cnF { l__substances_##1_prop } {#1}
+ { \substances_msg:nnn {required-field} {##1} {#1} }
\group_end:
}
- \prop_if_in:NnTF \l_substances_sort_prop { #1 }
+ \prop_if_in:NnTF \l__substances_sort_prop {#1}
{
- \substances_remove_braces:xN
- { \prop_get:Nn \l_substances_sort_prop { #1 } } \l_tmpa_tl
+ \substances_remove_braces_set:xN
+ { \prop_get:Nn \l__substances_sort_prop {#1} }
+ \l__substances_tmpa_tl
}
{
- \prop_get:NnN \l_substances_properties_pre_prop { name } \l_tmpa_tl
- \substances_remove_str_x:VnnN
- \l_tmpa_tl
- { #1 }
- { name }
- \l_tmpa_tl
+ \prop_get:NnN \l__substances_properties_pre_prop
+ {name}
+ \l__substances_tmpa_tl
+ \substances_remove_str_unbrace_set:VnnN
+ \l__substances_tmpa_tl
+ {#1}
+ {name}
+ \l__substances_tmpa_tl
}
- \prop_put:NnV \l_substances_sort_prop { #1 } \l_tmpa_tl
- \prop_if_in:NnT \l_substances_alt_prop { #1 }
+ \prop_put:NnV \l__substances_sort_prop {#1} \l__substances_tmpa_tl
+ \prop_if_in:NnT \l__substances_alt_prop {#1}
{
- \prop_if_in:NnTF \l_substances_altsort_prop { #1 }
+ \prop_if_in:NnTF \l__substances_altsort_prop {#1}
{
- \substances_remove_braces:xN
- { \prop_get:Nn \l_substances_altsort_prop { #1 } } \l_tmpa_tl
+ \substances_remove_braces_set:xN
+ { \prop_get:Nn \l__substances_altsort_prop {#1} }
+ \l__substances_tmpa_tl
}
{
- \prop_get:NnN \l_substances_properties_pre_prop { alt } \l_tmpa_tl
- \substances_remove_str_x:VnnN
- \l_tmpa_tl
- { #1 }
- { alt }
- \l_tmpa_tl
+ \prop_get:NnN \l__substances_properties_pre_prop {alt}
+ \l__substances_tmpa_tl
+ \substances_remove_str_unbrace_set:VnnN
+ \l__substances_tmpa_tl
+ {#1}
+ {alt}
+ \l__substances_tmpa_tl
}
- \prop_put:NnV \l_substances_altsort_prop { #1 } \l_tmpa_tl
+ \prop_put:NnV \l__substances_altsort_prop {#1} \l__substances_tmpa_tl
}
\bool_new:c { g_substances_#1_alt_index_entry_bool }
+ \bool_new:c { g_substances_#1_name_index_entry_bool }
}
-\cs_new:Npn \substances_add_property:nnnn #1#2#3#4
+\cs_new_protected:Npn \substances_add_property:nnnn #1#2#3#4
{
\keys_define:nn { substances / #1 }
{
#2 .code:n = \prop_put:cnn
- { l_substances_#2_prop } { #1 } { #3{##1}#4 }
+ { l__substances_#2_prop } {#1} { #3{##1}#4 }
}
}
\cs_generate_variant:Nn \substances_add_property:nnnn { nnVV }
\NewDocumentCommand \DeclareSubstance { mm }
- { \substances_declare_substance:nn { #1 } { #2 } }
+ { \substances_declare_substance:nn {#1} {#2} }
\@onlypreamble\DeclareSubstance
% ----------------------------------------------------------------------------
% recover values:
-\cs_new:Npn \substances_get_property:nn #1#2
+\cs_new_protected:Npn \substances_get_property:nn #1#2
{
- \IfSubstanceFieldTF { #2 }
+ \IfSubstanceFieldTF {#2}
{
- \IfSubstancePropertyTF { #1 } { #2 }
- { \prop_get:cn { l_substances_#2_prop } { #1 } }
- { {??} \substances_msg:nnn { property-missing } { #1 } { #2 } }
+ \IfSubstancePropertyTF {#1} {#2}
+ { \prop_get:cn { l__substances_#2_prop } {#1} }
+ { {??} \substances_msg:nnn {property-missing} {#1} {#2} }
}
- { {??} \substances_msg:nnn { field-missing } { #1 } { #2 } }
+ { {??} \substances_msg:nnn {field-missing} {#1} {#2} }
}
% ----------------------------------------------------------------------------
% some commands for creating user macros or whatever:
\NewDocumentCommand \GetSubstanceProperty { mm }
- { \substances_get_property:nn { #1 } { #2 } }
+ { \substances_get_property:nn {#1} {#2} }
\DeclareExpandableDocumentCommand \RetrieveSubstanceProperty { mm }
- { \substances_get_property:nn { #1 } { #2 } }
+ { \substances_get_property:nn {#1} {#2} }
\DeclareExpandableDocumentCommand \IfSubstanceFieldTF { mmm }
- { \cs_if_exist:cTF { l_substances_#1_prop } { #2 } { #3 } }
+ { \cs_if_exist:cTF { l__substances_#1_prop } {#2} {#3} }
\DeclareExpandableDocumentCommand \IfSubstanceFieldT { mm }
- { \cs_if_exist:cT { l_substances_#1_prop } { #2 } }
+ { \cs_if_exist:cT { l__substances_#1_prop } {#2} }
\DeclareExpandableDocumentCommand \IfSubstanceFieldF { mm }
- { \cs_if_exist:cF { l_substances_#1_prop } { #2 } }
+ { \cs_if_exist:cF { l__substances_#1_prop } {#2} }
\DeclareExpandableDocumentCommand \IfSubstanceExistTF { mmm }
- { \seq_if_in:NnTF \l_substances_chemicals_seq { #1 } { #2 } { #3 } }
+ { \seq_if_in:NnTF \l_substances_chemicals_seq {#1} {#2} {#3} }
\DeclareExpandableDocumentCommand \IfSubstanceExistT { mm }
- { \seq_if_in:NnT \l_substances_chemicals_seq { #1 } { #2 } }
+ { \seq_if_in:NnT \l_substances_chemicals_seq {#1} {#2} }
\DeclareExpandableDocumentCommand \IfSubstanceExistF { mm }
- { \seq_if_in:NnF \l_substances_chemicals_seq { #1 } { #2 } }
+ { \seq_if_in:NnF \l_substances_chemicals_seq {#1} {#2} }
\DeclareExpandableDocumentCommand \IfSubstancePropertyTF { mmmm }
{
- \cs_if_exist:cTF { l_substances_#2_prop }
- { \prop_if_in:cnTF { l_substances_#2_prop } { #1 } { #3 } { #4 } }
- { #4 }
+ \cs_if_exist:cTF { l__substances_#2_prop }
+ { \prop_if_in:cnTF { l__substances_#2_prop } {#1} {#3} {#4} }
+ {#4}
}
\DeclareExpandableDocumentCommand \IfSubstancePropertyT { mmm }
{
- \cs_if_exist:cT { l_substances_#2_prop }
- { \prop_if_in:cnT { l_substances_#2_prop } { #1 } { #3 } }
+ \cs_if_exist:cT { l__substances_#2_prop }
+ { \prop_if_in:cnT { l__substances_#2_prop } {#1} {#3} }
}
\DeclareExpandableDocumentCommand \IfSubstancePropertyF { mmm }
{
- \cs_if_exist:cTF { l_substances_#2_prop }
- { \prop_if_in:cnF { l_substances_#2_prop } { #1 } { #3 } }
- { #3 }
+ \cs_if_exist:cTF { l__substances_#2_prop }
+ { \prop_if_in:cnF { l__substances_#2_prop } {#1} {#3} }
+ {#3}
}
\DeclareExpandableDocumentCommand \ForAllSubstancesDo {}
@@ -290,101 +315,115 @@
% user command:
\NewDocumentCommand \chem { soomo }
{
- \IfNoValueF { #2 } { #2 }
- \IfNoValueTF { #5 }
+ \IfNoValueF {#2} {#2}
+ \IfNoValueTF {#5}
{
- \IfBooleanTF { #1 }
+ \IfBooleanTF {#1}
{
- \IfSubstancePropertyTF { #4 } { alt }
- { \RetrieveSubstanceProperty { #4 } { alt } }
- { \RetrieveSubstanceProperty { #4 } { name } }
+ \IfSubstancePropertyTF {#4} {alt}
+ { \RetrieveSubstanceProperty {#4} {alt} }
+ { \RetrieveSubstanceProperty {#4} {name} }
}
- { \RetrieveSubstanceProperty { #4 } { name } }
+ { \RetrieveSubstanceProperty {#4} {name} }
}
- { \substances_get_property:nn { #4 } { #5 } }
- \IfNoValueF { #3 } { #3 }
- \bool_if:NT \l_substances_index_entry_bool
- { \substances_index_entry:n { #4 } }
+ { \RetrieveSubstanceProperty {#4} {#5} }
+ \IfNoValueF {#3} {#3}
+ \SubstanceIndex {#4}
}
% ----------------------------------------------------------------------------
% index command to add an entry to the chemicals list if the option
% `index=true' is used:
-\cs_new:Npn \substances_index:nn #1#2
+\cs_new_protected:Npn \substances_index:nn #1#2
{
- \bool_if:NTF \l_substances_imakeidx_bool
- { \index [ #1 ] { #2 } }
+ \bool_if:NTF \l__substances_imakeidx_bool
+ { \index [ #1 ] {#2} }
{
- \bool_if:NTF \l_substances_splitidx_bool
- { \sindex [ #1 ] { #2 } }
+ \bool_if:NTF \l__substances_splitidx_bool
+ { \sindex [ #1 ] {#2} }
{
- \bool_if:NTF \l_substances_multind_bool
- { \index { #1 } { #2 } }
- { \index { #2 } }
+ \bool_if:NTF \l__substances_multind_bool
+ { \index {#1} {#2} }
+ { \index {#2} }
}
}
}
\cs_generate_variant:Nn \substances_index:nn { no,nx }
-\cs_new:Npn \substances_index_entry:n #1
- { \UseInstance { substances-index } { default } { #1 } }
+\cs_new_protected:Npn \substances_index_entry:nn #1#2
+ { \UseInstance {substances-index} {#1} {#2} }
-\cs_new:Npn \substances_remove_braces:xN #1#2
- { \exp_last_unbraced:NNx \tl_set:Nn #2 { #1 } }
-\cs_generate_variant:Nn \exp_last_unbraced:NNo { NNx }
+\NewDocumentCommand \SubstanceIndex {O{default}m}
+ {
+ \bool_if:NT \l__substances_index_entry_bool
+ { \substances_index_entry:nn {#1} {#2} }
+ }
-\cs_new:Npn \substances_remove_str_x:nnnN #1#2#3#4
+\cs_new_protected:Npn \substances_remove_braces_set:nN #1#2
+ { \tl_set:Nn #2 #1 }
+\cs_generate_variant:Nn \substances_remove_braces_set:nN {x}
+
+\cs_new_protected:Npn \substances_remove_str_unbrace_set:nnnN #1#2#3#4
{
- \tl_set:Nx #4
- { \prop_get:cn { l_substances_#3_prop } { #2 } }
- \tl_remove_all:Nn #4 { #1 }
- \substances_remove_braces:xN { #4 } #4
+ \tl_set:Nx #4 { \prop_get:cn { l__substances_#3_prop } {#2} }
+ \tl_remove_all:Nn #4 {#1}
+ \substances_remove_braces_set:xN {#4} #4
}
-\cs_generate_variant:Nn \substances_remove_str_x:nnnN { V }
+\cs_generate_variant:Nn \substances_remove_str_unbrace_set:nnnN { V }
% let's use xtemplate's features for possible customization later:
-\DeclareObjectType { substances-index } { 1 }
+\DeclareObjectType {substances-index} {1}
-\DeclareTemplateInterface { substances-index } { standard } { 1 }
+\DeclareTemplateInterface {substances-index} {standard} {1}
{
alternative-entry : boolean = true ,
alternative-name : boolean = true
}
-\DeclareTemplateCode { substances-index } { standard } { 1 }
+\DeclareTemplateCode {substances-index} {standard} {1}
{
- alternative-entry = \l_substances_index_alternative_entry_bool ,
- alternative-name = \l_substances_index_alternative_name_bool ,
+ alternative-entry = \l__substances_index_alternative_entry_bool ,
+ alternative-name = \l__substances_index_alternative_name_bool ,
}
{
\AssignTemplateKeys
\bool_if:nTF
{
- \l_substances_index_alternative_name_bool &&
- \prop_if_in_p:Nn \l_substances_alt_prop { #1 }
+ \l__substances_index_alternative_name_bool &&
+ \prop_if_in_p:Nn \l__substances_alt_prop {#1}
}
{
- \substances_index:nx { \c_job_name_tl -chem }
+ \bool_if:cF { g_substances_#1_name_index_entry_bool }
{
- \SubstanceIndexNameAltEntry
- { \prop_get:Nn \l_substances_sort_prop { #1 } }
- { \GetSubstanceProperty { #1 } { name } }
- { \GetSubstanceProperty { #1 } { alt } }
+ \substances_index:nx { \c_job_name_tl -chem }
+ {
+ \SubstanceIndexNameAltEntry
+ { \prop_get:Nn \l__substances_sort_prop {#1} }
+ { \GetSubstanceProperty {#1} {name} }
+ { \GetSubstanceProperty {#1} {alt} }
+ }
}
+ \bool_if:NT \l__substances_single_name_bool
+ { \bool_gset_true:c { g_substances_#1_name_index_entry_bool } }
}
{
- \substances_index:nx { \c_job_name_tl -chem }
+ \bool_if:cF { g_substances_#1_name_index_entry_bool }
{
- \SubstanceIndexNameEntry
- { \prop_get:Nn \l_substances_sort_prop { #1 } }
- { \GetSubstanceProperty { #1 } { name } }
+ \substances_index:nx { \c_job_name_tl -chem }
+ {
+ \SubstanceIndexNameEntry
+ { \prop_get:Nn \l__substances_sort_prop {#1} }
+ { \GetSubstanceProperty {#1} {name} }
+ }
}
+ \bool_if:NT \l__substances_single_name_bool
+ { \bool_gset_true:c { g_substances_#1_name_index_entry_bool } }
}
\bool_if:nT
{
- \l_substances_index_alternative_entry_bool &&
- \l_substances_index_alternative_name_bool &&
- \prop_if_in_p:Nn \l_substances_alt_prop { #1 }
+ \l__substances_index_alternative_entry_bool &&
+ \l__substances_index_alternative_name_bool &&
+ \prop_if_in_p:Nn \l__substances_alt_prop {#1}
}
{
\bool_if:cF { g_substances_#1_alt_index_entry_bool }
@@ -392,51 +431,157 @@
\substances_index:nx { \c_job_name_tl -chem }
{
\SubstanceIndexAltEntry
- { \prop_get:Nn \l_substances_altsort_prop { #1 } }
- { \GetSubstanceProperty { #1 } { name } }
- { \GetSubstanceProperty { #1 } { alt } }
+ { \prop_get:Nn \l__substances_altsort_prop {#1} }
+ { \GetSubstanceProperty {#1} {name} }
+ { \GetSubstanceProperty {#1} {alt} }
}
- \bool_gset_true:c { g_substances_#1_alt_index_entry_bool }
+ \substances_contains_see:NT \SubstanceIndexAltEntry
+ { \bool_gset_true:c { g_substances_#1_alt_index_entry_bool } }
}
}
}
-\DeclareInstance { substances-index } { default } { standard } { }
+\DeclareInstance {substances-index} {default} {standard} { }
\cs_new:Npn \SubstanceIndexNameEntry #1#2 { #1@#2 }
\cs_new:Npn \SubstanceIndexNameAltEntry #1#2#3 { #1@#2~(#3) }
\cs_new:Npn \SubstanceIndexAltEntry #1#2#3 { #1@#3|see{#2} }
+
+\cs_new_protected:Npn \substances_contains_see:NT #1#2
+ {
+ \tl_set_rescan:Nnx \l__substances_tmpa_tl {} {\cs_meaning:N #1 }
+ \tl_if_in:VnT \l__substances_tmpa_tl { |see } {#2}
+ }
+
% ----------------------------------------------------------------------------
% define some default fields:
-\cs_new_nopar:Npn \@CAS #1-#2-#3 { \iupac{#1\-#2\-#3} }
-\NewDocumentCommand \CAS { m } { \@CAS #1 }
+\cs_new_nopar:Npn \@CAS #1-#2-#3\relax { \iupac{#1-#2-#3} }
+\NewDocumentCommand \CAS { m } { \@CAS #1 \relax }
-\DeclareSubstanceProperty* { name } [\iupac]
-\DeclareSubstanceProperty { sort }
-\DeclareSubstanceProperty { alt } [\iupac]
-\DeclareSubstanceProperty { altsort }
-\DeclareSubstanceProperty { CAS } [\CAS]
-\DeclareSubstanceProperty { PubChem }
+\DeclareSubstanceProperty* {name} [\iupac]
+\DeclareSubstanceProperty {sort}
+\DeclareSubstanceProperty {alt} [\iupac]
+\DeclareSubstanceProperty {altsort}
+\DeclareSubstanceProperty {CAS} [\CAS]
+\DeclareSubstanceProperty {PubChem}
% ----------------------------------------------------------------------------
% load style file
-\file_if_exist:nTF { substances- \l_substances_style_tl .def }
- { \file_input:n { substances- \l_substances_style_tl .def } }
+\tl_const:Nn \c__substances_style_extension_tl {def}
+\tl_const:Nn \c__substances_style_prefix_tl {substances-}
+
+\cs_new:Npn \__substances_style:n #1
+ { \c__substances_style_prefix_tl#1.\c__substances_style_extension_tl }
+
+\cs_new_protected:Npn \substances_load_style:n #1
+ {
+ \tl_set:Nx \l__substances_tmpa_tl { \tl_trim_spaces:n {#1} }
+ \__substances_load_style:V \l__substances_tmpa_tl
+ }
+\cs_generate_variant:Nn \substances_load_style:n { V }
+
+\cs_new_protected:Npn \__substances_load_style:n #1
+ {
+ \substances_if_style_exist:nTF {#1}
+ {
+% \msg_log:nnn {substances} {loading-style} {#1}
+ \@onefilewithoptions
+ {\c__substances_style_prefix_tl#1}[][]
+ \c__substances_style_extension_tl
+ }
+ { \substances_msg:nn {style-missing} {#1} }
+ }
+\cs_generate_variant:Nn \__substances_load_style:n { V }
+
+\prg_new_conditional:Npnn \substances_if_style_exist:n #1 {T,F,TF}
+ {
+ \file_if_exist:nTF
+ { \__substances_style:n {#1} }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+
+\cs_new_protected:Npn \__substances_style:nn #1#2
+ {
+ \ProvidesFile { \__substances_style:n {#2} }
+ \bool_if:nT {#1} { \ExplSyntaxOn }
+ }
+
+\bool_new:N \l__substances_inside_style_file_bool
+
+\NewDocumentCommand \SubstancesStyle {sm}
+ {
+ \__substances_style:nn {#1} {#2}
+ \bool_set_true:N \l__substances_inside_style_file_bool
+ \AtEndOfPackage
+ { \bool_set_false:N \l__substances_inside_style_file_bool }
+ }
+
+\NewDocumentCommand \LoadSubstancesStyle {m}
+ {
+ \bool_if:NTF \l__substances_inside_style_file_bool
+ { \substances_load_style:n {#1} }
+ {}
+ }
+
+\substances_load_style:V \l__substances_style_tl
+
+% ----------------------------------------------------------------------------
+% load database file
+\tl_const:Nn \c__substances_database_extension_tl {sub}
+\tl_const:Nn \c__substances_database_prefix_tl {}
+
+\cs_new:Npn \__substances_database:n #1
+ { \c__substances_database_prefix_tl#1.\c__substances_database_extension_tl }
+
+\prg_new_conditional:Npnn \substances_if_database_exist:n #1 {T,F,TF}
{
- \substances_msg:nnn { style-missing } { \l_substances_style_tl } { }
- \file_input:n { substances-default.def }
+ \file_if_exist:nTF
+ { \__substances_database:n {#1} }
+ { \prg_return_true: }
+ { \prg_return_false: }
}
-\NewDocumentCommand \LoadSubstances { m }
+\cs_new_protected:Npn \__substances_load_database:n #1
{
- \file_if_exist:nTF { #1.sub }
- { \file_input:n { #1.sub } }
- { \substances_msg:nnn { database-missing } { #1.sub } { } }
+ \substances_if_database_exist:nTF {#1}
+ {
+ \@onefilewithoptions
+ {\c__substances_database_prefix_tl#1}[][]
+ \c__substances_database_extension_tl
+ }
+ { \substances_msg:nn {database-missing} {#1} }
}
+\cs_generate_variant:Nn \__substances_load_database:n { V }
+
+\cs_new_protected:Npn \substances_load_database:n #1
+ {
+ \tl_set:Nx \l__substances_tmpa_tl { \tl_trim_spaces:n {#1} }
+ \__substances_load_database:V \l__substances_tmpa_tl
+ }
+
+\NewDocumentCommand \LoadSubstances {m}
+ { \substances_load_database:n {#1} }
\@onlypreamble\LoadSubstances
+\cs_new_protected:Npn \__substances_database:nn #1#2
+ {
+ \ProvidesFile { \__substances_database:n {#2} }
+ \bool_if:nF {#1} { }
+ }
+
+\NewDocumentCommand \SubstancesDatabase {sm}
+ { \__substances_database:nn {#1} {#2} }
+
\tex_endinput:D
+% ----------------------------------------------------------------------------
% HISTORY:
-2012/07/22 v0.1 - first release to CTAN \ No newline at end of file
+2012/07/22 v0.1 - first release to CTAN
+2012/09/02 v0.1a - small fix due to updated l3kernel
+2015/10/21 v0.2 - maintenance: minor fixes, adapt to chemmacros v5
+ - change implementation of how style files are loaded
+ - change implementation of how database files are loaded
+
+% TODO: