diff options
author | Karl Berry <karl@freefriends.org> | 2014-01-25 22:33:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-01-25 22:33:11 +0000 |
commit | 00162491a0a38dd40e88a84e63192f10868f0df4 (patch) | |
tree | e42dd812872b36f33a7d245b206e65d0d79f4b5a | |
parent | ca3052a995aa72637d7cc9132e4ba1d2f6f3b8a5 (diff) |
chemmacros (25jan14)
git-svn-id: svn://tug.org/texlive/trunk@32786 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/README | 7 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/chemformula_en.pdf | bin | 935935 -> 941017 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/chemformula_en.tex | 122 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.pdf | bin | 528917 -> 538802 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.tex | 144 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf | bin | 897435 -> 903376 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex | 546 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/chemmacros/ghsystem_en.pdf | bin | 788320 -> 788318 bytes | |||
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemformula.sty | 188 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty | 494 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros-version1.cfg | 331 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | 1044 |
12 files changed, 1546 insertions, 1330 deletions
diff --git a/Master/texmf-dist/doc/latex/chemmacros/README b/Master/texmf-dist/doc/latex/chemmacros/README index 239ccb17fc5..2987f1262a7 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/README +++ b/Master/texmf-dist/doc/latex/chemmacros/README @@ -1,10 +1,10 @@ -------------------------------------------------------------------------- the CHEMMACROS bundle 2014/01/09 - - chemmacros package v4.2e -> macros and commands for chemists - - chemformula package v4.2a -> typeset chemical compounds and reactions + - chemmacros package v4.3 -> macros and commands for chemists + - chemformula package v4.3 -> typeset chemical compounds and reactions - ghsystem package v4.2e -> typeset H & P statements and pictograms from the globally harmonised system (GHS) - - chemgreek package v0.2a -> handle mapping of upright greek letters to + - chemgreek package v0.3 -> handle mapping of upright greek letters to the \chemalpha ... commands -------------------------------------------------------------------------- This bundle succeeds the chemmacros package which is now part of the @@ -34,7 +34,6 @@ package files: - chemformula.sty, - ghsystem.sty, - chemgreek.sty, - - chemmacros-version1.cfg image files: - eps-, png-, pdf- and jpg-files for the GHS pictograms (4x31 pictures) language-definition files: diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.pdf b/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.pdf Binary files differindex f747027f451..dd6454d7889 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.pdf +++ b/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.pdf diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.tex b/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.tex index 69254ccb2a1..1266b358f6c 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.tex +++ b/Master/texmf-dist/doc/latex/chemmacros/chemformula_en.tex @@ -50,32 +50,37 @@ \par } , add-cmds = { - abinitio, AddRxnDesc, anti, aq, aqi, + abinitio, activatechemgreekmapping, AddRxnDesc, anti, aq, aqi, ba, bond, bridge, - cd, ch, charrow, chcpd, chemabove, Chemalpha, Chembeta, Chemgamma, - Chemdelta, ChemDelta, chemformula@bondlength, Chemomega, chemsetup, - chlewis, chname , cip, cis, ch, CNMR, + cd, ce, ch, changechemgreeksymbol, charrow, chcpd, chemabove, chemalpha, + chembeta, chemgamma, chemdelta, chemDelta, chemformula@bondlength, + chemomega, chemphi, chemPhi, chemsetup, chlewis, chname , cip, cis, ch, + CNMR, data, DeclareChemArrow, DeclareChemBond, DeclareChemBondAlias, - DeclareChemIUPAC, DeclareChemLatin, DeclareChemNMR, DeclareChemParticle, - DeclareChemPhase, DeclareChemReaction, DeclareChemState, - delm, delp, Delta, Dfi, + declarechemgreekmapping, DeclareChemIUPAC, DeclareChemLatin, + DeclareChemNMR, DeclareChemParticle, DeclareChemPhase, + DeclareChemReaction, DeclareChemState, delm, delp, Delta, Dfi, el, ElPot, endo, Enthalpy, enthalpy, Entropy, fmch, fpch, fscrm, fscrp, gas, ghs, ghslistall, ghspic, Gibbs, gram, - hapto, HNMR, Helmholtz, + hapto, HNMR, Helmholtz, hydrogen, insitu, invacuo, iupac, Ka, Kb, Kw, - Lfi, listofreactions, lqd, ltn, + Lfi, listofreactions, lqd, mch, mega, meta, mhName, - newman, NMR, Nu, Nuc, - orbital, ortho, ox, OX, - para, pch, per, pH, phase, photon, pKa, pKb, pOH, pos, positron, - Pot, prt, - Rad, redox, RenewChemArrow, RenewChemBond, RenewChemIUPAC, - RenewChemLatin, RenewChemNMR, RenewChemParticle, RenewChemPhase, - RenewChemState, - Sf, scrm, scrp, second, setchemformula, ShowChemArrow, ShowChemBond, - sld, Sod, State, + NewChemArrow, NewChemBond, NewChemBondAlias, + newchemgreekmapping, NewChemIUPAC, NewChemLatin, + NewChemNMR, NewChemParticle, NewChemPhase, + NewChemReaction, NewChemState, + newman, nitrogen, NMR, Nu, Nuc, + orbital, ortho, ox, OX, oxygen, + para, pch, per, pH, phase, phosphorus, photon, pKa, pKb, pOH, pos, + positron, Pot, prt, + Rad, redox, RenewChemArrow, RenewChemBond, renewchemgreekmapping, + RenewChemIUPAC, RenewChemLatin, RenewChemNMR, RenewChemParticle, + RenewChemPhase, RenewChemState, + Sf, scrm, scrp, second, selectchemgreekmapping, setchemformula, + ShowChemArrow, ShowChemBond, sld, Sod, State, sulfur, trans, val } , @@ -92,7 +97,7 @@ includegraphics, intertext, IUPAC, joule, kilo, - latin, lewis, Lewis, + latin, lewis, Lewis, liquid, ltn, metre, midrule, milli, mmHg, mole, nano, nicefrac, num, numrange, ominus, oplus, @@ -103,7 +108,8 @@ textcolor, textendash, textsuperscript, tiny, toprule, upbeta, upeta, upgamma, usetikzlibrary, volt, vphantom, vspave, - xspace + xspace, + z@, z@skip } } @@ -294,6 +300,17 @@ then \chemmacros\ will not be loaded. The \chemmacros\ package, however, atom, see section~\ref{sec:lewis-formulae}. \end{itemize} +\subsection{Version 4.3} +\begin{itemize} + \item New option \option{stoich-print}. + \item New command \cs{chstoich}. + \item The commands \cs*{DeclareChem\meta{...}} now don't give an error any + more if the command already exists. This is more consistent with \LaTeX's + \cs*{DeclareRobustCommand}. For all those commands a version + \cs*{NewChem\meta{...}} is introduced that \emph{does} give an error if + the new command is already defined. +\end{itemize} + \section{Licence and Requirements} \license @@ -449,6 +466,12 @@ There are a few possibilities to customize the output. \keybool{stoich-paren-parse}\Default{false} If set to true stoichiometric factors enclosed by parentheses also are parsed. + \keyval{stoich-print}{cs}\Default{\cs{chstoich}} + This option allows to redefine the macro that prints the stoichiometric + factors. \meta{cs} should be a macro that takes one mandatory argument. + \emph{Please note that using this option will disable \chemformula's + stoichiometric parsing as that is done by the default command + \cs{chstoich}.} \end{options} \begin{example} @@ -672,10 +695,19 @@ The predefined bond types are shown in table~\vref{tab:bond_types}. \paragraph{Own Bonds} \chemformula\ offers commands to define own bond types: \begin{commands} + \command{NewChemBond}[\marg{name}\marg{code}] + \sinceversion{4.3}Define the new bond type \meta{name}. Issue an error if + a bond \meta{name} already exists. \command{DeclareChemBond}[\marg{name}\marg{code}] - Define the new bond type \meta{name}. + Define the new bond type \meta{name} or overwrite it if it already + exists. \command{RenewChemBond}[\marg{name}\marg{code}] - Redefine the existing bond type \meta{name}. + Redefine the existing bond type \meta{name}. Issue an error if a bond + \meta{name} doesn't exist. + \command{NewChemBondAlias}[\marg{new name}\marg{old name}] + \sinceversion{4.3}Declare the bond type \meta{new name} to be an alias of + \meta{old name}. Issue an error if a bond \meta{new name} already + exists. \command{DeclareChemBondAlias}[\marg{new name}\marg{old name}] Declare the bond type \meta{new name} to be an alias of \meta{old name}. \command{ShowChemBond}[\marg{name}] @@ -684,14 +716,14 @@ The predefined bond types are shown in table~\vref{tab:bond_types}. The usage is best described with an example. So let's see how the \code{single} bond and the \code{co>} bond are defined: \begin{sourcecode} - \DeclareChemBond{single} + \NewChemBond{single} { \draw[chembond] (chemformula-bond-start) -- (chemformula-bond-end) ; } - \DeclareChemBond{coordright} + \NewChemBond{coordright} { \draw[chembond,butt cap->] (chemformula-bond-start) -- (chemformula-bond-end) ; } - \DeclareChemBondAlias{co>}{coordright} + \NewChemBondAlias{co>}{coordright} \end{sourcecode} Two points are important: the names of the starting and the ending coordinates, \code{chemformula-bond-start} and \code{chemformula-bond-end}, @@ -702,7 +734,7 @@ this: \begin{example} \usetikzlibrary{decorations.pathreplacing} \makeatletter - \DeclareChemBond{dashed} + \NewChemBond{dashed} { \draw[ chembond, @@ -1016,10 +1048,11 @@ brackets as seperated input types. The arrow reads its arguments \emph{afterwards}. As you can see the arrows \enquote{grow} with the length of the labels. What stays constant is the part that protrudes the labels. As you also can see in the last example square brackets inside the arrow -arguments should be produced using \cs*{[} and \cs*{]}. They keep their usual -meaning outside \cs{ch}. These commands are necessary since the usual -grouping (\ie, hiding the brackets inside curly brackets) doesn't work due to -the way \cs{ch} reads its argument. +arguments can be produced using \cs*{[} and \cs*{]}. They keep their usual +meaning outside \cs{ch}. These commands were necessary since the usual +grouping (\ie, hiding the brackets inside curly brackets) didn't work due to +the way \cs{ch} read its argument. This is no longer true but meanwhile +\cs*{[} and \cs*{]} are kept for backwards compatibility. \begin{example} \ch{A ->[a] B} \par \ch{A ->[ab] B} \par @@ -1072,15 +1105,24 @@ arrow: \end{example} \subsection{Modify Arrow Types}\label{sec:arrows_modify} -The arrows are defined with the command +The arrows are defined with the commands \begin{commands} + \command{NewChemArrow}[\marg{type}\marg{\TikZ}] + Define the new arrow type \meta{type}. Issue an error if an arrow type + \meta{type} already exists. \command{DeclareChemArrow}[\marg{type}\marg{\TikZ}] - Define a new arrow type \meta{type}. + Define the new arrow type \meta{type} or overwrite it if it already + exists. + \command{RenewChemArrow}[\marg{type}\marg{\TikZ}] + Redefine the arrow type \meta{type}. Issue an error if an arrow type + \meta{type} doesn't exist. + \command{ShowChemArrow}[\marg{type}] + Print out the current definition of the arrow type \meta{type}. \end{commands} \meta{type} is the sequence of tokens that is replaced with the actual arrow code. For example the basic arrow is defined via \begin{sourcecode} - \DeclareChemArrow{->}{ + \NewChemArrow{->}{ \draw[chemarrow,-cf] (cf_arrow_start) -- (cf_arrow_end) ; } \end{sourcecode} @@ -1115,10 +1157,10 @@ completeness' sake the arrow tips and the \TikZ-style are also listed: \option{arrow-style} \end{codedesc} \begin{example} - \DeclareChemArrow{.>}{ + \NewChemArrow{.>}{ \draw[chemarrow,-cf,dotted,red] (cf_arrow_start) -- (cf_arrow_end); } - \DeclareChemArrow{n>}{ + \NewChemArrow{n>}{ \draw[chemarrow,-cf] (cf_arrow_start) .. controls ([yshift=3ex]cf_arrow_mid) .. @@ -1126,15 +1168,7 @@ completeness' sake the arrow tips and the \TikZ-style are also listed: } \ch{A .> B} \ch{A .>[a][b] B} \ch{A n> B} \end{example} -If you want to redefine an existing arrow there are two commands you can use: -\begin{commands} - \command{RenewChemArrow}[\marg{type}\marg{\TikZ}] - Redefine the arrow type \meta{type}. - \command{ShowChemArrow}[\marg{type}] - Print out the current definition of the arrow type \meta{type}. -\end{commands} -The second one gives the current definition, the first one redefines an existing -arrow. + \begin{example} \texttt{\ShowChemArrow{->}} \par \RenewChemArrow{->}{\draw[chemarrow,->,red] (cf_arrow_start) -- (cf_arrow_end) ;} diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.pdf b/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.pdf Binary files differindex a3e19f1abe2..44bbb921461 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.pdf +++ b/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.pdf diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.tex b/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.tex index d7a12d09514..6cc4e45adb1 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.tex +++ b/Master/texmf-dist/doc/latex/chemmacros/chemgreek_en.tex @@ -1,5 +1,5 @@ -% arara: pdflatex -% !arara: biber +% !arara: pdflatex +% arara: biber % !arara: pdflatex % arara: pdflatex % -------------------------------------------------------------------------- @@ -52,9 +52,9 @@ add-cmds = { abinitio, activatechemgreekmapping, AddRxnDesc, anti, aq, aqi, ba, bond, bridge, - cd, ch, changechemgreeksymbol, charrow, chcpd, chemabove, Chemalpha, - Chembeta, Chemgamma, Chemdelta, ChemDelta, chemformula@bondlength, - Chemomega, Chemphi, ChemPhi, chemsetup, chlewis, chname , cip, cis, ch, + cd, ch, changechemgreeksymbol, charrow, chcpd, chemabove, chemalpha, + chembeta, chemgamma, chemdelta, chemDelta, chemformula@bondlength, + chemomega, chemphi, chemPhi, chemsetup, chlewis, chname , cip, cis, ch, CNMR, data, DeclareChemArrow, DeclareChemBond, DeclareChemBondAlias, declarechemgreekmapping, DeclareChemIUPAC, DeclareChemLatin, @@ -63,21 +63,24 @@ el, ElPot, endo, Enthalpy, enthalpy, Entropy, fmch, fpch, fscrm, fscrp, gas, ghs, ghslistall, ghspic, Gibbs, gram, - hapto, HNMR, Helmholtz, + hapto, HNMR, Helmholtz, hydrogen, insitu, invacuo, iupac, Ka, Kb, Kw, - Lfi, listofreactions, lqd, ltn, + Lfi, listofreactions, lqd, mch, mega, meta, mhName, - newchemgreekmapping, - newman, NMR, Nu, Nuc, - orbital, ortho, ox, OX, - para, pch, per, pH, phase, photon, pKa, pKb, pOH, pos, positron, - Pot, prt, + NewChemArrow, NewChemBond, NewChemBondAlias, + newchemgreekmapping, NewChemIUPAC, NewChemLatin, + NewChemNMR, NewChemParticle, NewChemPhase, + NewChemReaction, NewChemState, + newman, nitrogen, NMR, Nu, Nuc, + orbital, ortho, ox, OX, oxygen, + para, pch, per, pH, phase, phosphorus, photon, pKa, pKb, pOH, pos, + positron, Pot, prt, Rad, redox, RenewChemArrow, RenewChemBond, renewchemgreekmapping, RenewChemIUPAC, RenewChemLatin, RenewChemNMR, RenewChemParticle, RenewChemPhase, RenewChemState, Sf, scrm, scrp, second, selectchemgreekmapping, setchemformula, - ShowChemArrow, ShowChemBond, sld, Sod, State, + ShowChemArrow, ShowChemBond, sld, Sod, State, sulfur, trans, val } , @@ -94,7 +97,7 @@ includegraphics, intertext, IUPAC, joule, kilo, - latin, lewis, Lewis, + latin, lewis, Lewis, liquid, ltn, metre, midrule, milli, mmHg, mole, nano, nicefrac, num, numrange, ominus, oplus, @@ -103,9 +106,10 @@ sample, scriptscriptstyle, setatomsep, setbondoffset, sfrac, shorthandoff, si, SI, sisetup, square, subsection, textcolor, textendash, textsuperscript, tiny, toprule, - upbeta, upeta, upgamma, usetikzlibrary, + upbeta, upeta, upgamma, upPhi, upphi, usetikzlibrary, volt, vphantom, vspave, - xspace + xspace, + z@, z@skip } } @@ -283,18 +287,53 @@ used by \chemmacros\ and its \acs{iupac} naming commands. \pkg{expl3}\footnote{\CTANurl{l3kernel}}~\cite{bnd:l3kernel} and \pkg{xparse}\footnote{\CTANurl{l3packages}}~\cite{bnd:l3packages}. +\section{News} +\subsection{Version~0.2} +\begin{itemize} + \item The mapping ``mathdesign'' has been added. In order to use it you + need the \pkg{mathdesign} package~\cite{pkg:mathdesign} loaded. + \item The mapping ``fourier'' has been added. In order to use it you + need the \pkg{fourier} package~\cite{pkg:fourier} loaded. +\end{itemize} + +\subsection{Version~0.3} +\begin{itemize} + \item The provided macros have been renamed from \cs*{Chem\meta{\ldots}} + into \cs*{chem\meta{\ldots}}. The uppercase version still are provided + for backwards compatibility but issue a warning message and will be + removed some time in the future. + \item The commands for defining mappings have gotten an optional argument + which allows to specify the name of the package a mapping needs. The + command \cs{selectchemgreekmapping} now checks for this package and gives + a warning if it doesn't find it loaded. + \item The mapping ``textalpha'' has been added. In order to use it you + need the \pkg{textalpha} package (part of + \bnd{greek-fontenc}~\cite{bnd:greek-fontenc}) loaded. + \item If the package \pkg{hyperref}~\cite{pkg:hyperref} is loaded with the + \code{unicode} option \emph{and} the \pkg{textalpha} package has been + loaded at begin document all the \cs*{chem\meta{\ldots}} commands are let + to \pkg{textalpha}'s \cs*{text\meta{\ldots}} commands for the \acs{pdf} + bookmarks. This allows Greek letters in the bookmarks without worrying + about \cs*{texorpdfstring}. +\end{itemize} + \section{Define Mappings} \selectchemgreekmapping{default} \chemgreek's main commands are: \begin{commands} - \command{newchemgreekmapping}[\marg{name}\marg{mapping list}] - Add a new mapping to \chemgreek. Issue an error if it already exists. - \command{renewchemgreekmapping}[\marg{name}\marg{mapping list}] - Renew a \chemgreek\ mapping. Issue an error if it doesn't exist yet. - \command{declarechemgreekmapping}[\marg{name}\marg{mapping list}] - Declare a new mapping to \chemgreek. If the mapping already exists it - will be overwritten. + \command{newchemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}] + \changedversion{0.3}Add a new mapping to \chemgreek. Issue an error if it + already exists. With the optional argument the package that is needed for + this mapping can (and should) be specified. + \command{renewchemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}] + \changedversion{0.3}Renew a \chemgreek\ mapping. Issue an error if it + doesn't exist yet. With the optional argument the package that is needed + for this mapping can (and should) be specified. + \command{declarechemgreekmapping}[\oarg{package}\marg{name}\marg{mapping list}] + \changedversion{0.3}Declare a new mapping to \chemgreek. If the mapping + already exists it will be overwritten. With the optional argument the + package that is needed for this mapping can (and should) be specified. \end{commands} The command \cs{newchemgreekmapping} needs to get a comma separated list of @@ -335,9 +374,9 @@ mapping is defined: There \emph{must} be 24 pairs of entries, \ie, a complete mapping! Those entries are the ones that will be used by the interface macros. For each -letter a pair \cs{Chemalpha}/\cs{ChemAlpha} is defined that uses the entries +letter a pair \cs{chemalpha}/\cs{chemAlpha} is defined that uses the entries of the currently active mapping. That means there are 48 (robust) macros -defined each beginning with \cs*{Chem...} followed by the lowercase or +defined each beginning with \cs*{chem...} followed by the lowercase or uppercase name of the Greek letter. The default mapping is -- as you can probably see -- \emph{not an upright @@ -347,7 +386,7 @@ package for example provides a package option that selects one of the available mappings. \begin{example} - Default mapping: \Chemphi\ and \ChemPhi, $\phi$ and $\Phi$ + Default mapping: \chemphi\ and \chemPhi, $\phi$ and $\Phi$ \end{example} \section{Predefined Mappings and Selection of a Mapping} @@ -355,7 +394,7 @@ available mappings. packages to be loaded. The mapping names and the required packages are listed in table~\ref{tab:mappings}. -\begin{table}[hbp] +\begin{table} \centering \begin{tabular}{>{\ttfamily}ll} \toprule @@ -365,10 +404,11 @@ in table~\ref{tab:mappings}. var-default & --- \\ textgreek & \pkg{textgreek} \cite{pkg:textgreek} \\ upgreek & \pkg{upgreek} \cite{pkg:upgreek} \\ - newtx & \pkg{newtxmath} \cite{pkg:newtx} \\ + newtx & \pkg*{newtxmath} \cite{pkg:newtx} \\ kpfonts & \pkg{kpfonts} \cite{pkg:kpfonts} \\ mathdesign & \pkg{mathdesign} \cite{pkg:mathdesign} \\ fourier & \pkg{fourier} \cite{pkg:fourier} \\ + textalpha & \pkg{textalpha} \cite{bnd:greek-fontenc} \\ \bottomrule \end{tabular} \caption{Predefined mappings.} @@ -377,27 +417,28 @@ in table~\ref{tab:mappings}. A mapping is selected and activated with one of the following commands: \begin{commands} - \command{activatechemgreekmapping}[\sarg\oarg{options}\marg{name}] - This commands selects and activates the mapping \meta{name}. If the star - variant is used also the package \meta{name} is loaded with options - \meta{options}. This obviously only makes sense if the package name is the - same as the mapping name. The command can only be used in the document - preamble. + \command{activatechemgreekmapping}[\sarg\marg{name}] + \changedversion{0.3}This commands selects and activates the mapping + \meta{name}. If the star variant is used also the package of mapping + \meta{name} (as defined with \cs{newchemgreekmapping} is loaded. The + command can only be used in the document preamble. \command{selectchemgreekmapping}[\marg{name}] - This commands selects and activates the mapping \meta{name}. A required - package has to be loaded additionally the usual way via \cs*{usepackage} - or \cs*{RequirePackage}. The command can be used throughout the document. + \changedversion{0.3}This commands selects and activates the mapping + \meta{name}. A required package has to be loaded additionally the usual + way via \cs*{usepackage} or \cs*{RequirePackage}. If the package hasn't + been loaded a warning will be written to the log. The command can be used + throughout the document. \end{commands} \begin{example} % requires the `newtxmath' package to be loaded: - \Chemphi\ and \ChemPhi, $\phi$ and $\Phi$\par + \chemphi\ and \chemPhi, $\phi$ and $\Phi$\par \selectchemgreekmapping{newtx} - \Chemphi\ and \ChemPhi, $\upphi$ and $\upPhi$ + \chemphi\ and \chemPhi, $\upphi$ and $\upPhi$ \end{example} \section{Changing a Specific Symbol in an Existing Mapping} -If you should want to change a specifig entry of a specific mapping it would +If you should want to change a specific entry of a specific mapping it would be rather tedious to redefine the whole mapping. That is why \chemgreek\ provides a command for that purpose: \begin{commands} @@ -410,25 +451,32 @@ provides a command for that purpose: In order to activate the change you need the (re-) activate the affected mapping afterwards: \begin{example} - \changechemgreeksymbol{default}{lower}{alpha}{xxx} + \chemalpha + \changechemgreeksymbol{default}{lower}{alpha}{xxx}% \selectchemgreekmapping{default} - \Chemalpha + \chemalpha \end{example} \section{Inspecting a Mapping} If you want to check if a mapping has been correctly set you can use the -following command: +following commands: \begin{commands} + \command{printchemgreekmapping}[\marg{mapping}] + \sinceversion{0.3}This will typeset a table (using a simple \code{tabular} + environment) with all~48 characters like the one shown in + table~\ref{tab:showmapping}. \command{showchemgreekmapping}[\marg{mapping}] - This will typeset a table (using a simple \code{tabular} environment) with - all 48 characters like the one shown in table~\ref{tab:showmapping}. + \changedversion{0.3}This command will write information about the + definition of all 48~macros for a mapping to the log file. \end{commands} -\begin{table}[htbp] +\begin{table} \centering - \showchemgreekmapping{newtx} - \caption{A demonstration of the \cs*{showchemgreekmapping} command.} + \printchemgreekmapping{newtx} + \caption{A demonstration of the \cs*{printchemgreekmapping} command.} \label{tab:showmapping} \end{table} +\clearpage + \end{document} diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf Binary files differindex 08ff636b1d7..db6381cf1ba 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf +++ b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.pdf diff --git a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex index 68720c0a1ec..33552b27838 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex +++ b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex @@ -52,9 +52,9 @@ add-cmds = { abinitio, activatechemgreekmapping, AddRxnDesc, anti, aq, aqi, ba, bond, bridge, - cd, ch, changechemgreeksymbol, charrow, chcpd, chemabove, Chemalpha, - Chembeta, Chemgamma, Chemdelta, ChemDelta, chemformula@bondlength, - Chemomega, Chemphi, ChemPhi, chemsetup, chlewis, chname , cip, cis, ch, + cd, ch, changechemgreeksymbol, charrow, chcpd, chemabove, chemalpha, + chembeta, chemgamma, chemdelta, chemDelta, chemformula@bondlength, + chemomega, chemphi, chemPhi, chemsetup, chlewis, chname , cip, cis, ch, CNMR, data, DeclareChemArrow, DeclareChemBond, DeclareChemBondAlias, declarechemgreekmapping, DeclareChemIUPAC, DeclareChemLatin, @@ -63,21 +63,24 @@ el, ElPot, endo, Enthalpy, enthalpy, Entropy, fmch, fpch, fscrm, fscrp, gas, ghs, ghslistall, ghspic, Gibbs, gram, - hapto, HNMR, Helmholtz, + hapto, HNMR, Helmholtz, hydrogen, insitu, invacuo, iupac, Ka, Kb, Kw, Lfi, listofreactions, lqd, mch, mega, meta, mhName, - newchemgreekmapping, - newman, NMR, Nu, Nuc, - orbital, ortho, ox, OX, - para, pch, per, pH, phase, photon, pKa, pKb, pOH, pos, positron, - Pot, prt, + NewChemArrow, NewChemBond, NewChemBondAlias, + newchemgreekmapping, NewChemIUPAC, NewChemLatin, + NewChemNMR, NewChemParticle, NewChemPhase, + NewChemReaction, NewChemState, + newman, nitrogen, NMR, Nu, Nuc, + orbital, ortho, ox, OX, oxygen, + para, pch, per, pH, phase, phosphorus, photon, pKa, pKb, pOH, pos, + positron, Pot, prt, Rad, redox, RenewChemArrow, RenewChemBond, renewchemgreekmapping, RenewChemIUPAC, RenewChemLatin, RenewChemNMR, RenewChemParticle, RenewChemPhase, RenewChemState, Sf, scrm, scrp, second, selectchemgreekmapping, setchemformula, - ShowChemArrow, ShowChemBond, sld, Sod, State, + ShowChemArrow, ShowChemBond, sld, Sod, State, sulfur, trans, val } , @@ -111,7 +114,6 @@ } \usepackage{chemfig,booktabs,cancel,varioref,csquotes} -\usepackage[version=3]{mhchem} \expandafter\def\csname libertine@figurestyle\endcsname{LF} \usepackage[libertine]{newtxmath} @@ -274,9 +276,9 @@ \newcommand*\tablehead[1]{\textrm{\bfseries#1}} -\DeclareChemPhase{\aqi}{aq,$\infty$}% aqueous solution at infinite dilution -\DeclareChemPhase{\cd}{cd}% condensed phase -\DeclareChemPhase{\lc}{lc}% liquid crystal +\NewChemPhase{\aqi}{aq,$\infty$}% aqueous solution at infinite dilution +\NewChemPhase{\cd}{cd}% condensed phase +\NewChemPhase{\lc}{lc}% liquid crystal \newname\hensel{Martin}{Hensel} \newname\pedersen{Bjørn}{Pedersen} @@ -392,6 +394,31 @@ With version~4.0 some changes have been made: \cs{RenewChemState}. The old syntax is still supported but discouraged. \end{itemize} +\subsection{Version 4.3} +\begin{itemize} + \item All one-letter \acs{iupac} macros have been exchanged in favour of + more meaningful macro names. The one-letter commands still exist for + backward compatibility (and to some users no doubt also for convenience). + They are no longer recommended though. One-letter commands seldomly have + meaningful names and often they've also been defined by other packages. + This means they make collaboration more difficult than it needs to be and + are a source for package conflicts. \chemmacros\ used to solved the + latter problem by only providing them inside the argument of + \cs{iupac}\label{desc:one-letter-commands}. The one exception + \chemmacros\ makes is the command \cs{p} (for things like \pH) which is + and will remain an official command. + \item The environment \env{experimental} has got a number of new options, + see section~\ref{sec:experimental-customization}. + \item The commands \cs*{DeclareChem\meta{...}} now don't give an error any + more if the command already exists. This is more consistent with \LaTeX's + \cs*{DeclareRobustCommand}. For all those commands a version + \cs*{NewChem\meta{...}} is introduced that \emph{does} give an error if + the new command is already defined. + \item The package option \option{strict} has been deprecated. + \item The package option \option{cmversion} has been deprecated. + \item The command \cs{mhName} has been dropped. +\end{itemize} + \section{Package Options}\label{sec:options} \chemmacros\ has several package options. They all are used as key/value pairs like @@ -416,30 +443,26 @@ then only be set using the setup command. \keychoice{circletype}{\default{chem},math}\Module{option}\Default{chem} This option switches between two kinds of circled charge symbols: \cs{fplus} \fplus\ and \verbcode+$\oplus$+ $\oplus$. - % cmversion - \keychoice{cmversion}{1,2,3,4,newest}\Module{option}\Default{newest} - This option restores the old definitions of some commands and tries to - ensure backwards compatibility as much as possible (default = \code{4}). - Actually \code{2} and \code{3} are aliases, as are -- for now -- \code{4} - and \code{newest}. \emph{This option can only be chosen in the preamble}. % ghsystem \keybool{ghsystem}\Module{option}\Default{true} \keyis{ghsystem}{false} disables the automatic loading of the \ghsystem\ package. % greek - \keychoice{greek}{\default{auto},kpfonts,math,newtx,textgreek,upgreek}% - \Module{option}\Default{auto} - This option determines how the letters \cs{Chemalpha} and friends are - typeset. See page~\pageref{desc:upgreek} for more information. Please - note that this option \emph{does not load either \pkg{upgreek}, - \pkg{kpfonts}, \pkg{newtxmath} nor \pkg{textgreek}!} It only + \keychoice{greek}{\default{auto},upgreek,textgreek,mathdesign,kpfonts,newtx,% + fourier,textalpha}\Module{option}{}% empty group pushes default value to + % next line + \Default{auto} + This option determines how the letters \cs{chemalpha} and friends are + typeset. See pages~\pageref{desc:greek} and~\pageref{par:greek_letters} + for more information. Please note that this option \emph{does not load + either \pkg{upgreek}, \pkg{kpfonts} or any other package!} It only determines which one to choose if available. The option \code{auto} will - detect if either (in order of priority) \pkg{upgreek}, \pkg{textgreek}, - \pkg{kpfonts} or \pkg{newtxmath} have been loaded and use them if - available. If you explicitly choose \code{upgreek}, \code{textgreek}, - \pkg{kpfonts} or \pkg{newtxmath} you also have to load the - corresponding package. \emph{This option can only be chosen in the - preamble}. + detect if any of the packages needed for one of the options has been + loaded and use it if available. If more than one of the packages has been + loaded the option will choose the one listed first in the above choice + list. If you explicitly choose an option other than \code{auto} or + \code{math} you also have to load the corresponding package. \emph{This + option can only be chosen in the preamble}. % iupac \keychoice{iupac}{auto,restricted,strict}\Module{option}\Default{auto} Take care of how \ac{iupac} naming commands are defined, see @@ -454,10 +477,6 @@ then only be set using the setup command. The package \pkg{mathspec} also defines a macro \cs{Nu}. This option chooses which definition holds, see page~\pageref{Nu}. \emph{This option can only be chosen in the preamble}. - % strict - \keybool{strict}\Module{option}\Default{false} - Setting \key{strict}{true} will turn all warning messages into erros - messages. % synchronize \keybool{synchronize}\Module{option}\Default{false} The setting \code{true} will tell \chemmacros\ to adapt the font settings @@ -593,7 +612,7 @@ If you choose \code{german/ngerman} the phase commands \cs{sld} and \cs{lqd} and the command \cs{pKa} are translated. \subsubsection{Italian} -\DeclareChemIUPAC{\ter}{\textit{ter}}\DeclareChemIUPAC{\sin}{\textit{sin}}% +\NewChemIUPAC{\ter}{\textit{ter}}\NewChemIUPAC{\sin}{\textit{sin}}% Choosing the language \code{italian} defines two additional \ac{iupac} commands: \begin{commands} \command{ter} \iupac{\ter} @@ -636,7 +655,7 @@ in \chemformula's \cs{ch}. A math operator symbol for denoting the change in an extensive thermodynamic quantity for a process such as \State{H}. This symbol is used in the definitions presented in section~\ref{sec:stand-state-therm}. - \command{Chemalpha}[ \Chemalpha, \cs{ChemAlpha} \ChemAlpha] + \command{chemalpha}[ \chemalpha, \cs{chemAlpha} \chemAlpha] For each of the 24 greek letters a lowercase and uppercase \cs*{Chem...} command is defined that maps to the upright greek letter as set with the option \option{greek}. More details on this can be found in the manual of @@ -656,15 +675,37 @@ the option \ba\ \Nu \end{example} -\label{desc:upgreek}The greek letters aren't newly defined symbols but are +\label{desc:greek}The greek letters aren't newly defined symbols but are defined differently depending on the packages you've loaded. The default definition is the corresponding math letter. If you have loaded the \pkg{textgreek} package the letters are taken from there, and if you have loaded the package \pkg{upgreek} the macros of that package are used. This is also described in the description of the package option \option{greek}, other -details can be found in the documentation of the \chemgreek\ package. This -documentation uses \pkg{newtxmath} and the setting \keyis{greek}{newtx} for -instance. +details can be found in the documentation of the \chemgreek\ package. Which +package you have to load for a specific choice for the package option +\option{greek} is listed in table~\ref{tab:option:greek}. This documentation +uses \pkg{newtxmath} and the setting \keyis{greek}{newtx} for instance. + +\begin{table} + \centering + \caption{Packages needed for the \option*{greek} package option..} + \label{tab:option:greek} + \begin{tabular}{>{\ttfamily}ll} + \toprule + \tablehead{option} & \tablehead{needed package} \\ + \midrule + auto & --- \\ + math & --- \\ + textgreek & \pkg{textgreek} \cite{pkg:textgreek} \\ + upgreek & \pkg{upgreek} \cite{pkg:upgreek} \\ + newtx & \pkg{newtxmath} \cite{pkg:newtx} \\ + kpfonts & \pkg{kpfonts} \cite{pkg:kpfonts} \\ + mathdesign & \pkg{mathdesign} \cite{pkg:mathdesign} \\ + fourier & \pkg{fourier} \cite{pkg:fourier} \\ + textalpha & \pkg{textalpha} \cite{bnd:greek-fontenc} \\ + \bottomrule + \end{tabular} +\end{table} The reason why \chemmacros\ uses these macros in the first place is \ac{iupac} compliance. \ac{iupac} recommends to use upright greek letters in @@ -684,8 +725,11 @@ page~\pageref{par:greek_letters}. Surely sometimes it can be handy to have other particle macros defined such as \cs*{positron} or \cs*{photon}. This can easily be done with this command: \begin{commands} + \command{NewChemParticle}[\marg{cs}\marg{definition}] + \sinceversion{4.3}Define a new particle command. Gives an error if + \meta{cs} already exists. \command{DeclareChemParticle}[\marg{cs}\marg{definition}] - Define a new particle command. + \changedversion{4.3}Define a new particle command. \command{RenewChemParticle}[\marg{cs}\marg{definition}] Renew the definition of a particle command. \end{commands} @@ -694,16 +738,11 @@ the particle which means that the \meta{definition} should be a vaild \chemformula\ compound. Please have a look at the \chemformula\ manual for details. The particle will obey the \option{circled} option. \begin{example} - \DeclareChemParticle\positron{\Chembeta+} - \DeclareChemParticle\photon{\Chemgamma} - \RenewChemParticle\el{\Chembeta-} + \NewChemParticle\positron{\chembeta+} + \NewChemParticle\photon{\chemgamma} + \RenewChemParticle\el{\chembeta-} \positron\ \photon\ \el \end{example} -\cs{DeclareChemParticle} only defines a particle if \meta{cs} is not already -used by any other command. If it \emph{is} already used \chemmacros\ will -either give a warning or an error, depending on the option \option{strict}. -\cs{RenewChemParticle} \emph{only} defines a particle if \meta{cs} \emph{is} -already used and issues a warning/error otherwise. \section{Nomenclature, Stereo Descriptors, Latin Phrases}\label{sec:stereo} \subsection{\acs{iupac} Names} @@ -754,15 +793,16 @@ The spaces inserted by these commands can be customized. \end{options} The command \cs{iupac} serves another purpose, too, however. Regardless of -the setting of the \option{iupac} option all the commands presented in -this section are always defined \emph{inside} \cs{iupac}. Quite a number of -the naming commands have very general names: \cs{meta}, \cs{D}, \cs{E}, -\cs{L}, \cs{R}, \cs{S}, \cs{trans} and so forth. This means they either -are predefined already (\cs{L} \L) or are easily defined by another package -or class (the \pkg{cool} package defines both \cs{D} and \cs{E}, for -example). In order to give you control which commands are defined in which -way, there is the package option \option{iupac}\label{desc:iupac}. It -has three modes: +the setting of the \option{iupac} option all the commands presented in this +section are always defined \emph{inside} \cs{iupac}. Quite a number of the +naming commands have very general names: \cs{meta}, \cs{D}, \cs{E}, \cs{L}, +\cs{R}, \cs{S}, \cs{trans} and so forth\footnote{Please read + page~\pageref{desc:one-letter-commands} before you consider using the + one-letter commands}. This means they either are predefined already (\cs{L} +\L) or are easily defined by another package or class (the \pkg{cool} package +defines both \cs{D} and \cs{E}, for example). In order to give you control +which commands are defined in which way, there is the package option +\option{iupac}\label{desc:iupac}. It has three modes: \begin{itemize} \item \keyis{iupac}{auto}: if the commands are \emph{not} defined by any package or class you're using they are available generally, otherwise only @@ -777,8 +817,9 @@ has three modes: \end{itemize} Table~\ref{tab:iupac_modes} demonstrates the different modes. -\begin{table}[ht] +\begin{table} \centering + \caption{Demonstration of \option*{iupac}'s modes.}\label{tab:iupac_modes} \begin{tabular}{lccc} \toprule & auto & restricted & strict \\ @@ -789,7 +830,6 @@ Table~\ref{tab:iupac_modes} demonstrates the different modes. \cs{iupac}\Marg{\cs{D}} & \iupac{\D} & \iupac{\D} & \iupac{\D} \\ \bottomrule \end{tabular} - \caption{Demonstration of \option*{iupac}'s modes.}\label{tab:iupac_modes} \end{table} \subsubsection{Predefined Commands} @@ -799,57 +839,103 @@ names more convenient. \paragraph{Greek Letters}\label{par:greek_letters} -Greek letters in compound names are typeset upright. For this there are for -example the packages \pkg{upgreek} and \pkg{textgreek}. If you have -loaded one of them\footnote{There are other options, see the description of - the \option{greek} option.} the following commands typeset upright Greek -letters: -\begin{itemize} - \item[] - \cs{a} \iupac{\a} \quad - \cs{b} \iupac{\b} \quad - \cs{g} \iupac{\g} \quad - \cs{d} \iupac{\d} \quad - \cs{k} \iupac{\k} \quad - \cs{m} \iupac{\m} \quad - \cs{n} \iupac{\n} \quad - \cs{w} \iupac{\w} -\end{itemize} +Greek\changedversion{4.3} letters in compound names are typeset upright. For +this there are for example the packages \pkg{upgreek} and \pkg{textgreek}. If +you have loaded one of them\footnote{There are other options, see the + description of the \option{greek} option.} the following commands typeset +upright Greek letters: +\begin{commands} + \command{chemalpha}[\quad\chemalpha] + Upright lowercase alpha + \command{chembeta}[\quad\chembeta] + Upright lowercase alpha + \command{chemgamma}[\quad\chemgamma] + Upright lowercase alpha + \command{chemdelta}[\quad\chemdelta] + Upright lowercase alpha +\end{commands} +The exist two commands for each of the twenty-four Greek letters: a lowercase +and an uppercase version (\cs{chemalpha} and \cs{chemAlpha}). Those commands +are actually provided by the \chemgreek\ package. For more details refer to +its documentation. + +There are a number of one-letter commands that some people may find convenient +to use which use above mentioned commands to pint Greek letters inside +\cs{iupac}. They're listed in table~\ref{tab:iupac-greek-shortcuts}. But +please read page~\pageref{desc:one-letter-commands} first before you use them. + +\begin{table} + \centering + \caption{\acs*{iupac} shortcuts for Greek letters.} + \label{tab:iupac-greek-shortcuts} + \begin{tabular}{*9l} + \toprule + macro & + \cs{a} & \cs{b} & \cs{g} & \cs{d} & + \cs{k} & \cs{m} & \cs{n} & \cs{w} \\ + \midrule + letter & + \iupac{\a} & \iupac{\b} & \iupac{\g} & \iupac{\d} & + \iupac{\k} & \iupac{\m} & \iupac{\n} & \iupac{\w} \\ + \bottomrule + \end{tabular} +\end{table} + + \begin{example} - \iupac{5\a\-androstan\-3\b\-ol} \par - \iupac{\a\-(tri\|chloro\|methyl)\-\w\-chloro\|poly(1,4\-phenylene\|methylene)} + \iupac{5\chemalpha\-androstan\-3\chembeta\-ol} \par + \iupac{\chemalpha\-(tri\|chloro\|methyl)\-\chemomega + \-chloro\|poly(1,4\-phenylene\|methylene)} \end{example} \paragraph{Hetero Atoms and added Hydrogen} -Attachments to hetero atoms and added hydrogen atoms are indicated by italic -letters~\cite{iupac:greenbook}. \chemmacros\ defines a few shortcuts for the -most common ones. -\begin{itemize} - \item[] - \cs{H} \iupac{\H} \quad - \cs{O} \iupac{\O} \quad - \cs{N} \iupac{\N} \quad - \cs{Sf} \iupac{\Sf} \quad - \cs{P} \iupac{\P} -\end{itemize} +Attachments to hetero atoms\changedversion{4.3} and added hydrogen atoms are +indicated by italic letters~\cite{iupac:greenbook}. \chemmacros\ defines a +few macros for the most common ones. +\begin{commands} + \command{hydrogen}[\quad\iupac{\hydrogen}] + The italic H for hydrogen. (An alias for this command is \cs{H}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) + \command{oxygen}[\quad\iupac{\oxygen}] + The italic O for oxygen. (An alias for this command is \cs{O}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) + \command{nitrogen}[\quad\iupac{\nitrogen}] + The italic N for nitrogen. (An alias for this command is \cs{N}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) + \command{sulfur}[\quad\iupac{\sulfur}] + The italic S for sulfur. (An alias for this command is \cs{Sf}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) + \command{phosphorus}[\quad\iupac{\phosphorus}] + The italic P for phosphorus. (An alias for this command is \cs{P}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) +\end{commands} \begin{example}[side-by-side] - \iupac{\N\-methyl\|benz\|amide} \par - \iupac{3\H\-pyrrole} \par - \iupac{\O\-ethyl hexanethioate} + \iupac{\nitrogen\-methyl\|benz\|amide} + + \iupac{3\hydrogen\-pyrrole} + + \iupac{\oxygen\-ethyl hexanethioate} \end{example} \paragraph{Cahn-Ingold-Prelog}\label{par:cip} \begin{commands} \command{cip}[\marg{conf}] Typeset Cahn-Ingol-Prelog descriptors, \eg: \cs{cip}\Marg{R,S} \cip{R,S} - \command{R}[ \iupac{\R}] - Typeset recto descriptor. - \command{S}[ \iupac{\S}] - Typeset sinister descriptor. + \command{rectus}[\quad\iupac{\rectus}] + Typeset rectus descriptor. (An alias for this command is \cs{R}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) + \command{sinister}[\quad\iupac{\sinister}] + Typeset sinister descriptor. (An alias for this command is \cs{S}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) \end{commands} -Since the command \cs{S} has another meaning already (\S) it is only -available inside \cs{iupac} in the default setting. Both these commands and the entgegen/zusammen descriptors get a small additional amount of kerning after the closing parenthesis. This amount can @@ -860,13 +946,16 @@ be changed through the following option: \end{options} \paragraph{Fischer} -\begin{itemize} - \item[] - \cs{D} \iupac{\D} \quad - \cs{L} \iupac{\L} -\end{itemize} -Since the command \cs{L} has another meaning already (\L) it is only -available inside \cs{iupac} in the default setting. +\begin{commands} + \command{dexter}[\quad\iupac{\dexter}] + Typeset dexter descriptor. (An alias for this command is \cs{D}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) + \command{laevus}[\quad\iupac{\laevus}] + Typeset laevus descriptor. (An alias for this command is \cs{L}. But + please read page~\pageref{desc:one-letter-commands} first before you use + it.) +\end{commands} \paragraph{cis/trans, zusammen/entgegen, syn/anti \& tert} \begin{itemize} @@ -875,15 +964,15 @@ available inside \cs{iupac} in the default setting. \cs{trans} \iupac{\trans} \quad \cs{fac} \iupac{\fac} \quad \cs{mer} \iupac{\mer} \quad - \cs{Z} \iupac{\Z} \quad - \cs{E} \iupac{\E} \quad + \cs{zusammen} \iupac{\zusammen} \quad + \cs{entgegen} \iupac{\entgegen} \quad \cs{syn} \iupac{\syn} \quad \cs{anti} \iupac{\anti} \quad \cs{tert} \iupac{\tert} \end{itemize} -The package \pkg{cool} defines the commands \cs{E} and \cs{D}, too. If you -load it, the \chemmacros\ version will only be available inside \cs{iupac} in -the default setting. +An alias for \cs{entgegen} is \cs{E} and an alias for \cs{zusammen} is +\cs{Z}. But please read page~\pageref{desc:one-letter-commands} first before +you use them. \paragraph{ortho/meta/para} \begin{itemize} @@ -898,8 +987,8 @@ Although these commands are provided I like to cite~\cite{iupac:bluebook}: \begin{cnltxquote}[{\acs{iupac} Blue Book {\cite[][p.\,90]{iupac:bluebook}}}] The letters \iupac{\ortho}, \iupac{\meta}, and \iupac{\para} have been used in place of \textit{ortho}, \textit{meta}, and \textit{para}, respectively, - to designate the 1,2- 1,3-, and 1,4- isomers of disubstituted benzene. This - usage is strongly discouraged and is not used in preferred \acs{iupac} + to designate the 1,2-, 1,3-, and 1,4- isomers of disubstituted benzene. + This usage is strongly discouraged and is not used in preferred \acs{iupac} names. \end{cnltxquote} @@ -911,14 +1000,14 @@ Although these commands are provided I like to cite~\cite{iupac:bluebook}: \cs{Sconf}: \Sconf \quad \cs{Sconf}\oarg{}: \Sconf[] \end{commands} -Examples: +Examples:\nopagebreak \begin{example} - \iupac{\D\-Wein\|s\"aure} = + \iupac{\dexter\-Wein\|s\"aure} = \iupac{\cip{2S,3S}\-Wein\|s\"aure} \par - \iupac{\D\-($-$)\-Threose} = + \iupac{\dexter\-($-$)\-Threose} = \iupac{\cip{2S,3R}\-($-$)\-2,3,4\-Tri\|hydroxy\|butanal} \par \iupac{\cis\-2\-Butene} = - \iupac{\Z\-2\-Butene}, \par + \iupac{\zusammen\-2\-Butene}, \par \iupac{\cip{2E,4Z}\-Hexa\|diene} \par \iupac{\meta\-Xylol} = \iupac{1,3\-Di\|methyl\|benzene} @@ -926,12 +1015,15 @@ Examples: \paragraph{Coordination Chemistry} -\chemmacros\ provides two commands useful with coordination chemistry: -\begin{itemize} - \item[] - \cs{bridge}\marg{num} \bridge{3} \quad - \cs{hapto}\marg{num} \hapto{5} -\end{itemize} +\chemmacros\ provides a few commands useful with coordination chemistry: +\begin{commands} + \command{bridge}[\marg{num}\quad\bridge{3}] + Denote bridging ligand connection. + \command{hapto}[\marg{num}\quad\hapto{5}] + Denote hapticity. + \command{dento}[\marg{num}\quad\dento{2}] + \sinceversion{4.3}Denote denticity. +\end{commands} \begin{example} Ferrocene = \iupac{bis(\hapto{5}cyclo\|penta\|dienyl)iron} \par \iupac{tetra\-\bridge{3}iodido\-tetrakis[tri\|methyl\|platinum(IV)]} @@ -943,28 +1035,33 @@ Two options allow customization: Appends the number as a subscript or superscript. \ac{iupac} recommendation is the subscript~\cite{iupac:redbook}. \keybool{coord-use-hyphen}\Module{iupac}\Default{true} - Append a hyphen to \cs{hapto} and \cs{bridge} or don't. + Append a hyphen to \cs{hapto}, \cs{dent} and \cs{bridge} or don't. \end{options} \subsubsection{Own Naming Commands} If you find any commands missing you can define them using \begin{commands} - \command{DeclareChemIUPAC}[\marg{cs}\marg{declaration}] - Define a new \ac{iupac} command that is in any case defined inside of - \cs{iupac} regardless if \meta{cs} is defined elsewhere already. + \command{NewChemIUPAC}[\marg{cs}\marg{declaration}] + \sinceversion{4.3}Define a new \ac{iupac} command that is in any case + defined inside of \cs{iupac} regardless if \meta{cs} is defined elsewhere + already. \command{RenewChemIUPAC}[\marg{cs}\marg{declaration}] Redefine an existing \ac{iupac} command that is in any case defined inside of \cs{iupac} regardless if \meta{cs} is defined elsewhere already. + \command{DeclareChemIUPAC}[\marg{cs}\marg{declaration}] + \changedversion{4.3}Define a new \ac{iupac} command that is in any case + defined inside of \cs{iupac} regardless if \meta{cs} is defined elsewhere + already. This silently overwrites an existing \ac{iupac} definition. \end{commands} A command defined in this way will obey the setting of the option \option{iupac}. This means any existing command is only overwritten with -\keyis{iupac}{strict}. However, \cs{DeclareChemIUPAC} will \emph{not} change -the definition of an existing \ac{iupac} naming command but issue a warning/an -error (depending on the package option \option{strict}) if the \ac{iupac} -naming command already exists. +\keyis{iupac}{strict}. However, \cs{NewChemIUPAC} will \emph{not} change the +definition of an existing \ac{iupac} naming command but issue an error if the +\ac{iupac} naming command already exists. \cs{DeclareChemIUPAC} \emph{will} +overwrite an existing \ac{iupac} command. \begin{example} - \DeclareChemIUPAC\endo{\textit{endo}} + \NewChemIUPAC\endo{\textit{endo}} \RenewChemIUPAC\anti{\textit{anti}} \iupac{(2\-\endo,7\-\anti)\-2\-bromo\-7\-fluoro\|bicyclo[2.2.1]heptane} \end{example} @@ -996,13 +1093,16 @@ depends on \pkg{chemstyle}'s option \code{abbremph}. The commands are defined through \begin{commands} + \command{NewChemLatin}[\marg{cs}\marg{phrase}] + \sinceversion{4.3}Define a new latin phrase. Gives an error if \meta{cs} + already exists. \command{DeclareChemLatin}[\marg{cs}\marg{phrase}] - Define a new latin phrase. + \changedversion{4.3}Define a new latin phrase. \command{RenewChemLatin}[\marg{cs}\marg{phrase}] Redefine an existing latin phrase. \end{commands} \begin{example}[side-by-side] - \DeclareChemLatin\ltn{latin text}\ltn + \NewChemLatin\ltn{latin text}\ltn \end{example} If you have \emph{not} loaded \pkg{chemstyle} you can change the appearance with this option: @@ -1066,11 +1166,11 @@ There is one option which changes the style the \p{} is typeset: \begin{options} \keychoice{p-style}{italics,slanted,upright}\Module{acid-base}\Default{upright} Set the style of the \p{} operator. - \keyval{K-acid}{text}\Module{acid-base} + \keyval{K-acid}{text}\Module{acid-base}\Default{A} The subscript to \cs{Ka} and \cs{pKa}. - \keyval{K-base}{text}\Module{acid-base} + \keyval{K-base}{text}\Module{acid-base}\Default{B} The subscript to \cs{Kb} and \cs{pKb}. - \keyval{K-water}{text}\Module{acid-base} + \keyval{K-water}{text}\Module{acid-base}\Default{W} The subscript to \cs{Kw}. \end{options} \begin{example} @@ -1348,7 +1448,7 @@ The default length of the vertical lines can be customized with the option \OX{a,Na} $\rightarrow$ \OX{b,Na}\pch\redox(a,b)[->,red]{ox} \end{example} -Examples:% TODO: watch pagebreaks! +Examples:\nopagebreak% TODO: watch pagebreaks! \begin{example} \vspace{7mm} \ch{ @@ -1454,14 +1554,15 @@ its settings: \subsubsection{Create New Variables or Redefine Existing Ones}\label{sec:create-new-variables} \begin{commands} - \command{DeclareChemState}[\marg{name}\oarg{options}\marg{symbol}\marg{unit}] - Define new corresponding commands. \meta{name} may either be a control - sequence token or a control sequence name without leading backslash. - \changedversion{4.2}This means that \cs{DeclareChemState}\Marg{name} and + \command{NewChemState}[\marg{name}\oarg{options}\marg{symbol}\marg{unit}] + \sinceversion{4.3}Define new corresponding commands. \meta{name} may + either be a control sequence token or a control sequence name without + leading backslash. This means that \cs{DeclareChemState}\Marg{name} and \cs{DeclareChemState}\Marg{\cs*{name}} are equivalent. The reason for this rather strange definition is a syntax change in \cs{DeclareChemState} while retaining backwards compaitibility. The latter version is recommended though and the former version may deprecate in the future. + Gives an error if \meta{name} already exists \command{RenewChemState}[\marg{name}\oarg{options}\marg{symbol}\marg{unit}] Redefine existing state commands. \meta{name} may either be a control sequence token or a control sequence name without leading backslash. @@ -1470,11 +1571,14 @@ its settings: this rather strange definition is a syntax change in \cs{RenewChemState} while retaining backwards compaitibility. The latter version is recommended though and the former version may deprecate in the future. + \command{DeclareChemState}[\marg{name}\oarg{options}\marg{symbol}\marg{unit}] + \changedversion{4.3}Like \cs{NewChemState} but gives now error if + \meta{name} already exists. \end{commands} \begin{example} - \DeclareChemState\Helmholtz{A}{\kilo\joule\per\mole} - \DeclareChemState\ElPot[subscript-left=false,exponent=]{E}{\volt} + \NewChemState\Helmholtz{A}{\kilo\joule\per\mole} + \NewChemState\ElPot[subscript-left=false,exponent=]{E}{\volt} \Helmholtz{123.4} \par \ElPot{-1.1} \par \ElPot[exponent=0]($\ch{Sn}|\ch{Sn^2+}||\ch{Pb^2+}|\ch{Pb}$){0.01} @@ -1501,16 +1605,16 @@ can be set. The existing commands have been defined like this: \begin{sourcecode} - \DeclareChemState\Enthalpy{H}{\kilo\joule\per\mole} - \DeclareChemState\Entropy[delta=false,subscript-left=false]{S} + \NewChemState\Enthalpy{H}{\kilo\joule\per\mole} + \NewChemState\Entropy[delta=false,subscript-left=false]{S} {\joule\per\kelvin\per\mole} - \DeclareChemState\Gibbs{G}{\kilo\joule\per\mole} + \NewChemState\Gibbs{G}{\kilo\joule\per\mole} \end{sourcecode} So -- for following thermodynamic conventions -- one could define a molar and an absolute variable: \begin{example} - \DeclareChemState\enthalpy[exponent=]{h}{\kilo\joule\per\mole}% molar + \NewChemState\enthalpy[exponent=]{h}{\kilo\joule\per\mole}% molar \RenewChemState\Enthalpy[exponent=]{H}{\kilo\joule}% absolute \enthalpy{-12.3} \Enthalpy{-12.3} \end{example} @@ -1596,9 +1700,13 @@ The third argument specifies the solvent: It is possible to define short cut commands for specific nuclei. \begin{commands} + \command{NewChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] + \sinceversion{4.3}Define a new shortcut macro for typesetting a certain + type of magnetic resonence data. Gives an error if \meta{cs} already + exists. \command{DeclareChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] - Define a new shortcut macro for typesetting a certain type of magnetic - resonence data. + \changedversion{4.3}Define a new shortcut macro for typesetting a certain + type of magnetic resonence data. \command{RenewChemNMR}[\marg{cs}\Marg{\meta{num},\meta{atom}}] Redefine an existing shortcut macro for typesetting a certain type of magnetic resonence data. @@ -1607,8 +1715,8 @@ It is possible to define short cut commands for specific nuclei. This defines a command with the same arguments as \cs{NMR} \emph{except} for \Marg{\meta{num},\meta{atom}}: \begin{example}[side-by-side] - \DeclareChemNMR\HNMR{1,H}% - \DeclareChemNMR\CNMR{13,C}% + \NewChemNMR\HNMR{1,H}% + \NewChemNMR\CNMR{13,C}% \CNMR*(100) \par \HNMR*(400) \end{example} @@ -1634,8 +1742,8 @@ This defines a command with the same arguments as \cs{NMR} \emph{except} for \cs{NMR}\Marg{13,C[\textasciicircum 1H]} \NMR{13,C[^1H]} \command{J}[\Darg{\meta{bonds};\meta{nuclei}}\oarg{unit}\marg{list of nums}] Coupling constant, values are input separated by \code{;} (NMR). The - argument \Darg{\meta{bonds};\meta{nuclei}} is optional and enables further - specifications of the coupling. + argument \Darg{\meta{bonds};\meta{nuclei}} and \oarg{unit} are optional + and enable further specifications of the coupling. \command{\#}[\marg{num}] Number of nuclei (NMR). \command{pos}[\marg{num}] @@ -1654,7 +1762,7 @@ This defines a command with the same arguments as \cs{NMR} \emph{except} for \end{experimental} \end{example} -\subsection{Customization} +\subsection{Customization}\label{sec:experimental-customization} The output of the environment and of the NMR commands can be customized be a number of options. For historical reasons they all belong to the module @@ -1666,10 +1774,26 @@ number of options. For historical reasons they all belong to the module The used default nucleus. \keyval{format}{commands}\Module{nmr}\Default For example \cs*{bfseries}. - \keychoice{pos-number}{side,sub}\Module{nmr}\Default{side} - Position of the number next to the atom. + \keychoice{pos-number}{side,sub,super}\Module{nmr}\Default{side} + \changedversion{4.3}Position of the number next to the atom. + \keyval{coupling-symbol}{code}\Module{nmr}\Default{J} + \sinceversion{4.3}The symbol used for the coupling constant. \keyval{coupling-unit}{unit}\Module{nmr}\Default{\cs*{hertz}} A \pkg{siunitx} unit. + \keychoice{coupling-pos}{side,sub}\Module{nmr}\Default{side} + \sinceversion{4.3}Placement of the coupling nuclei next to the symbol + $J$ (or rather the symbol specified with option + \option{coupling-symbol}). + \keyval{coupling-nuclei-pre}{code}\Module{nmr}\Default{(} + \sinceversion{4.3}Code inserted before the coupling nuclei when + \keyis{coupling-pos}{side}. + \keyval{coupling-nuclei-post}{code}\Module{nmr}\Default{)} + \sinceversion{4.3}Code inserted after the coupling nuclei when + \keyis{coupling-pos}{side}. + \keyval{coupling-bonds-pre}{code}\Module{nmr}\Default + \sinceversion{4.3}Code inserted before the coupling bonds. + \keyval{coupling-bonds-post}{code}\Module{nmr}\Default{\cs*{!}} + \sinceversion{4.3}Code inserted after the coupling bonds. \keybool{parse}\Module{nmr}\Default{true} Treat the solvent as \chemformula\ formula or not. \keyval{delta}{tokens}\Module{nmr}\Default @@ -1697,7 +1821,7 @@ The default setup of the list: \end{experimental} \end{example} -The command \cs{NMR} and all commands defined through \cs{DeclareChemNMR} +The command \cs{NMR} and all commands defined through \cs{NewChemNMR} can be used like \cs{data} for the NMR data. \begin{example} @@ -1907,61 +2031,6 @@ Output for these options: \data*{quantum yield} $\Phi = \val{0.74+-0.1}$\,. \end{experimental} -\section{Commands for \pkg*{mhchem}}\label{sec:mhchem} - -\pkg{mhchem} is not officially supported by \chemmacros\ as it used -\chemformula\ instead. However, for historical reasons the following command -is still provided. - -\begin{commands} - \command{mhName}[\oarg{options}\marg{formula}\marg{text}] - Writes \meta{text} below \meta{formula} -\end{commands} - -For example: -\begin{example} - \ce{ - 4 C2H5Cl + Pb{/}Na - -> - \mhName{Pb(C2H5)4}{former antiknock additive} + NaCl - } -\end{example} - -There are several keys to customize \cs{mhName}. -\begin{options} - \keyval{align}{alignment command}\Module{mhName}\Default{\cs*{centering}} - The alignment of the text in the box it is placed in. - \keyval{format}{anything}\Module{mhName}\Default - The format of the text. - \keyval{fontsize}{font size command}\Module{mhName}\Default{\cs*{tiny}} - The fontsize of the text. - \keychoice{width}{\meta{dim},auto}\Module{mhName}\Default{auto} - The width of the box the text is placed in. -\end{options} - -Since version~3.13 of \pkg{mhchem} you need to hide the command in braces if -you want to use the optional argument, - -\begin{example} - \ce{ - 4 C2H5Cl + Pb / Na - -> - {\mhName[fontsize=\footnotesize]{Pb(C2H5)4}{former antiknock additive}} - + NaCl - }\par - \chemsetup[mhName]{ - align=\raggedright, - fontsize=\small, - format=\bfseries\color{red}, - width=3cm - } - \ce{ - 4 C2H5Cl + Pb / Na - -> - \mhName{Pb(C2H5)4}{former antiknock additive} + NaCl - } -\end{example} - \section{Reaction Environments}\label{sec:reactions} \subsection{Defined by \chemmacros} @@ -2049,9 +2118,15 @@ function properly: \subsection{Own Reactions} You can create new types of reactions with the command: \begin{commands} + \command{NewChemReaction}[\oarg{options}\marg{name}\marg{math name}] + \sinceversion{4.3}\meta{name} will be the name of the new environment. + \meta{math name} is the underlying math environment. Gives an error if + \meta{name} already exists. \command{DeclareChemReaction}[\oarg{options}\marg{name}\marg{math name}] - \meta{name} will be the name of the new environment. \meta{math name} - is the underlying math environment. + \changedversion{4.3}\meta{name} will be the name of the new environment. + \meta{math name} is the underlying math environment. + \command{RenewChemReaction}[\oarg{options}\marg{name}\marg{math name}] + \sinceversion{4.3}Renew an existing definition. \end{commands} The command has two options. @@ -2071,20 +2146,20 @@ has a mandatory argument. The predefined environments are defined via \begin{sourcecode} - \DeclareChemReaction[star]{reaction}{equation} - \DeclareChemReaction[star]{reactions}{align}. + \NewChemReaction[star]{reaction}{equation} + \NewChemReaction[star]{reactions}{align}. \end{sourcecode} Let's suppose, you'd like to have the alignment behaviour of the \env{alignat} environment for \chemformula\ reactions. You could do the following: \begin{sourcecode} - \DeclareChemReaction[star,arg]{reactionsat}{alignat} + \NewChemReaction[star,arg]{reactionsat}{alignat} \end{sourcecode} With this the \env{reactionsat} environment is defined. \begin{example} - \DeclareChemReaction[star,arg]{reactionsat}{alignat} + \NewChemReaction[star,arg]{reactionsat}{alignat} \begin{reactionsat}{3} A &-> B &&-> C &&-> D \\ aaaaa &-> bbbbb &&-> ccccc &&-> ddddd @@ -2195,6 +2270,12 @@ There are two options to customize the output: Depending on the subject of your document you might need to indicate other states of aggregation. You can easily define them. \begin{commands} + \command{NewChemPhase}[\marg{cs}\oarg{german}\marg{english}] + \sinceversion{4.3}Define a new phase command. Actually the optional + argument is an artefact of an earlier implementation of the command. It + has no effect at all. See section~\ref{sec:lang-depend} for a way to + define language dependent settings. Gives an error if \meta{cs} already + exists. \command{DeclareChemPhase}[\marg{cs}\oarg{german}\marg{english}] Define a new phase command. Actually the optional argument is an artefact of an earlier implementation of the command. It has no effect at all. @@ -2209,19 +2290,20 @@ states of aggregation. You can easily define them. If you need a phase indicator just once or twice. \end{commands} -\cs{DeclareChemPhase} only defines a phase if \meta{cs} is not already used by -any other command. If it \emph{is} already used \chemmacros\ will either give -a warning or an error, depending on the option \option{strict}. -\cs{RenewChemPhase} \emph{only} defines a phase if \meta{cs} \emph{is} already -used and issues a warning/error otherwise. Unlike the other declaration -commands of \chemmacros\ \cs{DeclareChemPhase} and \cs{RenewChemPhase} -\emph{can only be used in the preamble.} +\cs{NewChemPhase} only defines a phase if \meta{cs} is not already used by any +other command. If it \emph{is} already used \chemmacros\ will either give an +error \cs{RenewChemPhase} \emph{only} defines a phase if \meta{cs} \emph{is} +already used and issues an error otherwise. \cs{DeclareChemPhase} does not +check if the phase command already exists but simply defines it with the new +meaning. Unlike the other declaration commands of \chemmacros\ +\cs{NewChemPhase}, \cs{RenewChemPhase} and \cs{DeclareChemPhase} \emph{can + only be used in the preamble.} \begin{example} % preamble: - % \DeclareChemPhase{\aqi}{aq,$\infty$}% aqueous solution at infinite dilution - % \DeclareChemPhase{\cd}{cd}% condensed phase - % \DeclareChemPhase{\lc}{lc}% liquid crystal + % \NewChemPhase{\aqi}{aq,$\infty$}% aqueous solution at infinite dilution + % \NewChemPhase{\cd}{cd}% condensed phase + % \NewChemPhase{\lc}{lc}% liquid crystal NaOH\aqi\ \ch{H2O\cd} U\phase{cr} A\lc \par \chemsetup[phases]{pos=sub} NaOH\aqi\ \ch{H2O\cd} U\phase{cr} A\lc @@ -2229,11 +2311,11 @@ commands of \chemmacros\ \cs{DeclareChemPhase} and \cs{RenewChemPhase} \subsection{Language Dependencies}\label{sec:lang-depend} For each pahse command a translation into the custom language can be defined. -If a phase is declared with \cs{DeclareChemPhase} no translation exists and +If a phase is declared with \cs{NewChemPhase} no translation exists and for every \pkg{babel} languuage the literal string is used that was provided as a definition. Let's say you define the phase \begin{sourcecode} - \DeclareChemPhase\liquid{l} + \NewChemPhase\liquid{l} \end{sourcecode} and want to add the German translation ``f{}l''. Then you could do \begin{sourcecode} diff --git a/Master/texmf-dist/doc/latex/chemmacros/ghsystem_en.pdf b/Master/texmf-dist/doc/latex/chemmacros/ghsystem_en.pdf Binary files differindex 45ec00a0839..c0a3ea31a47 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/ghsystem_en.pdf +++ b/Master/texmf-dist/doc/latex/chemmacros/ghsystem_en.pdf diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty index 05e7dbce85e..cbf29837ede 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty @@ -27,8 +27,8 @@ % -------------------------------------------------------------------------- \RequirePackage{ expl3 , xparse , l3keys2e , tikz , amsmath , xfrac , nicefrac , scrlfile } \usetikzlibrary{arrows} -\def\chemformula@version{4.2a} -\def\chemformula@date{2013/11/04} +\def\chemformula@version{4.3} +\def\chemformula@date{2014/01/24} \ProvidesExplPackage {chemformula} @@ -51,39 +51,9 @@ } % -------------------------------------------------------------------------- -% warning and erroe messages: -\cs_new_protected:Npn \chemformula_error:nnxx #1#2#3#4 - { - \bool_if:NTF \l__chemformula_strict_bool - { \msg_error:nnxx { #1 } { #2 } { #3 } { #4 } } - { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } } - } - -\cs_new_protected:Npn \chemformula_error:nn #1#2 - { - \bool_if:NTF \l__chemformula_strict_bool - { \msg_error:nnxx { #1 } { #2 } } - { \msg_warning:nnxx { #1 } { #2 } } - } - -\cs_new_protected:Npn \chemformula_warning:nnxx #1#2#3#4 - { - \bool_if:NTF \l__chemformula_strict_bool - { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } } - { \msg_info:nnxx { #1 } { #2 } { #3 } { #4 } } - } - -\cs_new_protected:Npn \chemformula_warning:nn #1#2 - { - \bool_if:NTF \l__chemformula_strict_bool - { \msg_warning:nn { #1 } { #2 } } - { \msg_info:nn { #1 } { #2 } } - } - +% warning and error messages: \msg_new:nnnn { chemformula } { missing-argument } - { - Wrong~name~input~ \msg_line_context: . - } + { Wrong~name~input~ \msg_line_context: . } { Maybe~you've~forgotten~to~add~the~second~argument~to~name~syntax?~ "!(<name>)(<chemformula>)".\\ @@ -92,13 +62,11 @@ Either~way~-~I~don't~know~what~to~do~ \msg_line_context: . } -\msg_new:nnnn { chemformula } { declare-arrow } - { - The~arrow~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined. - } +\msg_new:nnnn { chemformula } { new-arrow } + { The~arrow~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined. } { You've~tried~to~define~the~arrow~type~\tl_to_str:n { #1 } \c_space_tl with - ~\token_to_str:N \DeclareChemArrow \c_space_tl but~it~already~exists. + ~\token_to_str:N \NewChemArrow \c_space_tl but~it~already~exists. ~Choose~another~name. } @@ -109,13 +77,11 @@ exist. } -\msg_new:nnnn { chemformula } { declare-bond } - { - The~bond~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined. - } +\msg_new:nnnn { chemformula } { new-bond } + { The~bond~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined. } { You've~tried~to~define~the~bond~type~\tl_to_str:n { #1 } \c_space_tl with - ~\token_to_str:N \DeclareChemBond \c_space_tl but~it~already~exists. + ~\token_to_str:N \NewChemBond \c_space_tl but~it~already~exists. ~Choose~another~name. } @@ -154,7 +120,7 @@ { \cs_new_protected:Npn #1 { - \chemformula_error:nnxx { chemformula } { command-deprecated } + \msg_warning:nnnn { chemformula } { command-deprecated } { #1 } { #2 } #3 } @@ -812,10 +778,10 @@ % commands to declare arrows (can also be used by users): % #1: symbol, #2: code -\NewDocumentCommand \DeclareChemArrow { mm } +\NewDocumentCommand \NewChemArrow { mm } { \prop_if_in:NnTF \l__chemformula_arrows_code_prop { #1 } - { \chemformula_error:nnxx { chemformula } { declare-arrow } { #1 } {} } + { \msg_error:nnn { chemformula } { new-arrow } { #1 } } { % store type in the sequence and code in the property list \seq_put_right:Nn \l__chemformula_arrows_type_seq { #1 } @@ -823,11 +789,19 @@ } } +\NewDocumentCommand \DeclareChemArrow { mm } + { + \prop_if_in:NnF \l__chemformula_arrows_code_prop { #1 } + { \seq_put_right:Nn \l__chemformula_arrows_type_seq { #1 } } + % store type in the sequence and code in the property list + \prop_put:Nnn \l__chemformula_arrows_code_prop { #1 } { #2 } + } + \NewDocumentCommand \RenewChemArrow { mm } { \prop_if_in:NnTF \l__chemformula_arrows_code_prop { #1 } { \prop_put:Nnn \l__chemformula_arrows_code_prop { #1 } { #2 } } - { \chemformula_error:nnxx { chemformula } { renew-arrow } { #1 } {} } + { \msg_error:nnn { chemformula } { renew-arrow } { #1 } } } \NewDocumentCommand \ShowChemArrow { m } @@ -839,13 +813,13 @@ % declare arrows in the right order % e.g. <-> must be declared before -> in order to search & replace it first % resonance arrow: -\DeclareChemArrow { <-> } +\NewChemArrow { <-> } { \draw[chemarrow,cf-cf] (cf_arrow_start) -- (cf_arrow_end) ; } -\DeclareChemArrow { -> } +\NewChemArrow { -> } { \draw[chemarrow,-cf] (cf_arrow_start) -- (cf_arrow_end) ; } -\DeclareChemArrow { <- } +\NewChemArrow { <- } { \draw[chemarrow,cf-] (cf_arrow_start) -- (cf_arrow_end) ; } -\DeclareChemArrow { <> } +\NewChemArrow { <> } { \draw[chemarrow,-cf] ([yshift=.2ex]cf_arrow_start) -- ([yshift=.2ex]cf_arrow_end) ; @@ -853,48 +827,48 @@ ([yshift=-.2ex]cf_arrow_start) -- ([yshift=-.2ex]cf_arrow_end) ; } % isolobal arrow: -\DeclareChemArrow { <o> } +\NewChemArrow { <o> } { \draw[chemarrow,cf-cf] (cf_arrow_start) -- (cf_arrow_end) ; \draw[chemarrow] (cf_arrow_mid) .. controls ++(-.9ex,-1.5ex) and ++(.9ex,-1.5ex) .. (cf_arrow_mid) ; } -\DeclareChemArrow { <=>> } +\NewChemArrow { <=>> } { \draw[chemarrow,-left~cf] ([yshift=.15ex]cf_arrow_start) -- ([yshift=.15ex]cf_arrow_end) ; \draw[chemarrow,left~cf-] ([yshift=-.15ex]cf_arrow_mid_start) -- ([yshift=-.15ex]cf_arrow_mid_end) ; } -\DeclareChemArrow {<<=>} +\NewChemArrow {<<=>} { \draw[chemarrow,-left~cf] ([yshift=.15ex]cf_arrow_mid_start) -- ([yshift=.15ex]cf_arrow_mid_end) ; \draw[chemarrow,left~cf-] ([yshift=-.15ex]cf_arrow_start) -- ([yshift=-.15ex]cf_arrow_end) ; } -\DeclareChemArrow { <=> } +\NewChemArrow { <=> } { \draw[chemarrow,-left~cf] ([yshift=.15ex]cf_arrow_start) -- ([yshift=.15ex]cf_arrow_end) ; \draw[chemarrow,left~cf-] ([yshift=-.15ex]cf_arrow_start) -- ([yshift=-.15ex]cf_arrow_end) ; } -\DeclareChemArrow { -/> } +\NewChemArrow { -/> } { \draw[chemarrow,-cf] (cf_arrow_start) -- (cf_arrow_end) ; \draw[chemarrow] (cf_arrow_mid) ++ (.2ex,.4ex) -- ++(-.4ex,-.8ex) ; \draw[chemarrow] (cf_arrow_mid) ++ (-.2ex,.4ex) -- ++(-.4ex,-.8ex) ; } -\DeclareChemArrow { </- } +\NewChemArrow { </- } { \draw[chemarrow,cf-] (cf_arrow_start) -- (cf_arrow_end) ; \draw[chemarrow] (cf_arrow_mid) ++ (.2ex,.4ex) -- ++(-.4ex,-.8ex) ; \draw[chemarrow] (cf_arrow_mid) ++ (.6ex,.4ex) -- ++(-.4ex,-.8ex) ; } % net reaction: -\DeclareChemArrow { == } { \node at ([yshift=-.2ex]cf_arrow_mid) { = } ; } +\NewChemArrow { == } { \node at ([yshift=-.2ex]cf_arrow_mid) { = } ; } % -------------------------------------------------------------------------- % arrow customization @@ -1249,32 +1223,53 @@ \l__chemformula_tmpa_tl } -\NewDocumentCommand \DeclareChemBond { mm } +\NewDocumentCommand \NewChemBond { mm } { - \cs_if_exist:cTF { chemformula_bond_type_#1 } - { \chemformula_error:nnxx { chemformula } { declare-bond } { #1 } {} } + \cs_if_exist:cTF { chemformula_bond_type_#1: } + { \msg_error:nnn { chemformula } { new-bond } { #1 } } { - \cs_new:cpn { chemformula_bond_type_#1 } {} + \cs_new:cpn { chemformula_bond_type_#1: } {} \prop_put:Nnn \l__chemformula_bonds_prop { #1 } { #2 } } } +\NewDocumentCommand \DeclareChemBond { mm } + { + \cs_if_exist:cF { chemformula_bond_type_#1: } + { \cs_new:cpn { chemformula_bond_type_#1: } {} } + \prop_put:Nnn \l__chemformula_bonds_prop { #1 } { #2 } + } + +\NewDocumentCommand \NewChemBondAlias { mm } + { + \cs_if_exist:cTF { chemformula_bond_type_#2: } + { + \cs_if_exist:cTF { chemformula_bond_type_#1: } + { \msg_error:nnn { chemformula } { new-bond } { #1 } } + { \cs_new:cpn { chemformula_bond_type_#1: } {} } + \prop_get:NnN \l__chemformula_bonds_prop { #2 } \l__chemformula_tmpa_tl + \prop_put:Nno \l__chemformula_bonds_prop { #1 } { \l__chemformula_tmpa_tl } + } + { \msg_error:nnnn { chemformula } { bond-alias } { #1 } { #2 } } + } + \NewDocumentCommand \DeclareChemBondAlias { mm } { - \cs_if_exist:cTF { chemformula_bond_type_#1 } - { \chemformula_error:nnxx { chemformula } { declare-bond } { #1 } {} } + \cs_if_exist:cTF { chemformula_bond_type_#2: } { - \cs_new:cpn { chemformula_bond_type_#1 } {} + \cs_if_exist:cF { chemformula_bond_type_#1: } + { \cs_new:cpn { chemformula_bond_type_#1: } {} } \prop_get:NnN \l__chemformula_bonds_prop { #2 } \l__chemformula_tmpa_tl \prop_put:Nno \l__chemformula_bonds_prop { #1 } { \l__chemformula_tmpa_tl } } + { \msg_error:nnnn { chemformula } { bond-alias } { #1 } { #2 } } } \NewDocumentCommand \RenewChemBond { mm } { - \cs_if_exist:cTF { chemformula_bond_type_#1 } + \cs_if_exist:cTF { chemformula_bond_type_#1: } { \prop_put:Nnn \l__chemformula_bonds_prop { #1 } { #2 } } - { \chemformula_error:nnxx { chemformula } { renew-bond } { #1 } {} } + { \msg_error:nnn { chemformula } { renew-bond } { #1 } } } \NewDocumentCommand \ShowChemBond { m } @@ -1287,16 +1282,16 @@ { \chemformula_bond:n { #1 } } % now let's declare some default bonds: -\DeclareChemBond{single} +\NewChemBond{single} { \draw[chembond] (chemformula-bond-start) -- (chemformula-bond-end) ; } -\DeclareChemBondAlias{normal}{single} -\DeclareChemBondAlias{sb}{single} +\NewChemBondAlias{normal}{single} +\NewChemBondAlias{sb}{single} -\DeclareChemBond{semisingle} +\NewChemBond{semisingle} { \draw[chembond,densely~dotted] (chemformula-bond-start) -- (chemformula-bond-end) ; } -\DeclareChemBondAlias{dotted}{semisingle} +\NewChemBondAlias{dotted}{semisingle} -\DeclareChemBond{double} +\NewChemBond{double} { \draw (chemformula-bond-start) ++ (0pt,.0858em) coordinate (double-start-up) ; \draw (chemformula-bond-end) ++ (0pt,.0858em) coordinate (double-end-up) ; @@ -1306,9 +1301,9 @@ (double-start-down) -- (double-end-down) (double-start-up) -- (double-end-up) ; } -\DeclareChemBondAlias{db}{double} +\NewChemBondAlias{db}{double} -\DeclareChemBond{semidouble} +\NewChemBond{semidouble} { \draw (chemformula-bond-start) ++ (0pt,.0858em) coordinate (double-start-up) ; \draw (chemformula-bond-end) ++ (0pt,.0858em) coordinate (double-end-up) ; @@ -1318,10 +1313,10 @@ \draw[chembond,densely~dotted] (double-start-up) -- (double-end-up) ; } -\DeclareChemBondAlias{deloc}{semidouble} +\NewChemBondAlias{deloc}{semidouble} % \DeclareChemBondAlias{deloc2}{semidouble} -\DeclareChemBond{triple} +\NewChemBond{triple} { \draw (chemformula-bond-start) ++ (0pt,.1287em) coordinate (triple-start-up) ; \draw (chemformula-bond-end) ++ (0pt,.1287em) coordinate (triple-end-up) ; @@ -1332,9 +1327,9 @@ (chemformula-bond-start) -- (chemformula-bond-end) (triple-start-up) -- (triple-end-up) ; } -\DeclareChemBondAlias{tp}{triple} +\NewChemBondAlias{tp}{triple} -\DeclareChemBond{semitriple} +\NewChemBond{semitriple} { \draw (chemformula-bond-start) ++ (0pt,.1287em) coordinate (triple-start-up) ; \draw (chemformula-bond-end) ++ (0pt,.1287em) coordinate (triple-end-up) ; @@ -1345,15 +1340,15 @@ (chemformula-bond-start) -- (chemformula-bond-end) ; \draw[chembond,densely~dotted] (triple-start-up) -- (triple-end-up) ; } -\DeclareChemBondAlias{tdeloc}{semitriple} +\NewChemBondAlias{tdeloc}{semitriple} -\DeclareChemBond{coordright} +\NewChemBond{coordright} { \draw[chembond,butt~cap->] (chemformula-bond-start) -- (chemformula-bond-end) ; } -\DeclareChemBondAlias{co>}{coordright} +\NewChemBondAlias{co>}{coordright} -\DeclareChemBond{coordleft} +\NewChemBond{coordleft} { \draw[chembond,<-butt~cap] (chemformula-bond-start) -- (chemformula-bond-end) ; } -\DeclareChemBondAlias{<co}{coordleft} +\NewChemBondAlias{<co}{coordleft} % -------------------------------------------------------------------------- % sub- and superscripts @@ -1730,7 +1725,7 @@ \__chemformula_sanitize:NV \l__chemformula_stoich_tl \l__chemformula_stoich_tl - \__chemformula_parse_stoich:V + \__chemformula_print_stoich:V \l__chemformula_stoich_tl } } @@ -1739,9 +1734,15 @@ \cs_new:Npn \chemformula_bm:n #1 { #1 } -\cs_new_protected:Npn \__chemformula_parse_stoich:n #1 +\cs_new:Npn \__chemformula_print_stoich:n #1 + { \chemformula_parse_stoich:n { #1 } } +\cs_generate_variant:Nn \__chemformula_print_stoich:n { V } + +\cs_new_protected:Npn \chemformula_parse_stoich:n #1 { \__chemformula_parse_stoich:w #1 \q_nil } -\cs_generate_variant:Nn \__chemformula_parse_stoich:n { V } + +\NewDocumentCommand \chstoich { m } + { \chemformula_parse_stoich:n { #1 } } \cs_new:Npn \__chemformula_parse_stoich:w \q_mark #1 \q_nil { @@ -2318,6 +2319,8 @@ { \cs_set_eq:NN \chemformula_math_frac:nn #1 } , stoich-paren-parse .bool_set:N = \l__chemformula_stoich_parse_iupac_bool , stoich-space .skip_set:N = \l__chemformula_stoich_space_skip , + stoich-print .code:n = + \cs_set_eq:NN \chemformula_print_stoich:n #1 , adduct-space .dim_set:N = \l__chemformula_adduct_space_dim , plus-space .skip_set:N = \l__chemformula_plus_space_skip , plus-penalty .tl_set:N = \l__chemformula_plus_penalty_tl , @@ -2730,12 +2733,17 @@ VERSION HISTORY - new command \chlewis 2013/11/04 - version 4.2a - bug fix in \chcpd, - change sanitizing/restoring of category codes +2014/01/24 - version 4.3 - changed behaviour of \DeclareChem to match + \DeclareRobustCommand, i.e., no check if command + is defined; added a \NewChem variant to each that + /does/ check; use \NewChem instead of \DeclareChem + for definitions + - new option stoich-print + - new command \chstoich % -------------------------------------------------------------------------- % TODO -- https://bitbucket.org/cgnieder/chemmacros/issue/23/ - Addukte: Zahlen nach * und . automatisch erkennen? - optionale Argumente von \\ nach außen - make escaped text/math /truely/ escaped, i.e., behave as if it's been input /outside/ of \ch -- add possibility to use `siunitx' \num for stoichiometric factors diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty b/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty index 0a90ba4809f..7471dc7f8a8 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty @@ -26,8 +26,8 @@ % - The Current Maintainer of this work is Clemens Niederberger. % ---------------------------------------------------------------------------- \RequirePackage{expl3,xparse} -\def\chemgreek@version{0.2a} -\def\chemgreek@date{2013/11/20} +\def\chemgreek@version{0.3} +\def\chemgreek@date{2014/01/24} \ProvidesExplPackage{chemgreek}{\chemgreek@date}{\chemgreek@version} {interface for upright greek letters for use in chemistry (CN)} @@ -47,30 +47,99 @@ \prg_new_conditional:Npnn \chemgreek_latex_if:n #1 {p,T,F,TF} { \use:c { if #1 } \prg_return_true: \else: \prg_return_false: \fi: } +% let's see if we can test if a package has been loaded after begin document: +\prg_new_conditional:Npnn \chemgreek_if_package_loaded:n #1 {p,T,F,TF} + { + \cs_if_exist:cTF { ver@#1.sty } + { \prg_return_true: } + { \prg_return_false: } + } +\cs_generate_variant:Nn \chemgreek_if_package_loaded:nF { V } + +\prg_new_protected_conditional:Npnn \chemgreek_if_package_with:nn #1#2 {T,F,TF} + { + \cs_if_exist:cTF {opt@#1.sty} + { + \clist_if_in:cnTF {opt@#1.sty} {#2} + { \prg_return_true: } + { \prg_return_false: } + } + { \prg_return_false: } + } + % ---------------------------------------------------------------------------- % messages \msg_new:nnnn { chemgreek } { mapping-not-defined } { The~ mapping~ `#1'~ does~ not~ exist~ \msg_line_context: } { - You~ chose~ the~ mapping~ `#1'~ which~ has~ apparently~ not~ been~ - defined,~ yet.~ If~ this~ is~ due~ to~ a~ miss-spelling~ you~ need~ to~ - declare~ it~ first~ via~ \token_to_str:N \newchemgreekmapping \c_space_tl - or~ \token_to_str:N \declarechemgreekmapping . + You~ chose~ the~ mapping~ `#1'~ \msg_line_context: \c_space_tl which~ has~ + apparently~ not~ been~ defined,~ yet.~ If~ this~ is~ due~ to~ a~ + miss-spelling~ you~ need~ to~ declare~ it~ first~ via~ \token_to_str:N + \newchemgreekmapping \c_space_tl or~ \token_to_str:N + \declarechemgreekmapping . } -\msg_new:nnnn { chemgreek } { mapping-defined } +\msg_new:nnnn { chemgreek } { mapping-already-defined } { The~ mapping~ `#1'~ does~ already~ exist~ \msg_line_context: } { - It~ seems~ you're~ trying~ to~ define~ the~ mapping~ `#1'.~ However,~ - this~ mapping~ does~ already~ exist.~ If~ this~ is~ not~ due~ to~ a~ - miss-spelling~ you~ need~ to~ redefine~ it~ via~ \token_to_str:N - \renewchemgreekmapping . + It~ seems~ you're~ trying~ to~ define~ the~ mapping~ `#1'~ + \msg_line_context: .~ However,~ this~ mapping~ does~ already~ exist.~ If~ + this~ is~ not~ due~ to~ a~ miss-spelling~ you~ need~ to~ redefine~ it~ + via~ \token_to_str:N \renewchemgreekmapping . + } + +\msg_new:nnnn { chemgreek } { mapping-active } + { + The~ mapping~ `#1'~ already~ is~ active~ \msg_line_context: .~ I'm~ doing~ + nothing. + } + { + The~ mapping~ `#1'~ already~ is~ active~ \msg_line_context: .~ I'm~ doing~ + nothing. + } + +\msg_new:nnnn { chemgreek } { package-missing } + { + You've~ activated~ mapping~ `#1'~ which~ needs~ package~ `#2'~ loaded.~ + However, package~ `#2'~ does~ not~ seem~ to~ be~ loaded~ + \msg_line_context: .~ If~ I'm~ mistaken~ then~ ignore~ this~ warning. + } + { + You've~ activated~ mapping~ `#1'~ which~ needs~ package~ `#2'~ loaded.~ + However,~ package~ `#2'~ does~ not~ seem~ to~ be~ loaded~ + \msg_line_context: .~ Using~ the~ letter~ macros~ will~ probably~ not~ + work.~ If~ I'm~ mistaken~ then~ ignore~ this~ warning. + } + +\msg_new:nnnn { chemgreek } { command-deprecated } + { + The~ command~ \token_to_str:N #1 is~ deprecated.~ Use~ \token_to_str:N #2 + instead~ \msg_line_context: .~ \token_to_str:N #1 may~ be~ dropped~ in~ + the~ future~ without~ further~ warning. + } + { + The~ command~ \token_to_str:N #1 is~ deprecated.~ Use~ \token_to_str:N #2 + instead~ \msg_line_context: .~ \token_to_str:N #1 may~ be~ dropped~ in~ + the~ future~ without~ further~ warning. + } + +% ---------------------------------------------------------------------------- +% define a deprecated command with hints to the corresponding new one: +\cs_new_protected:Npn \chemgreek_define_deprecated:NN #1#2 + { + \cs_new_protected:Npn #1 + { + \msg_warning:nnnn { chemgreek } { command-deprecated } + { #1 } { #2 } + #2 + } } +\cs_generate_variant:Nn \chemgreek_define_deprecated:NN { cc } % ---------------------------------------------------------------------------- % a tokenlist constant that will be used to build the mapping property lists % both for uppercase and lowercase and also for setting the output macros -\tl_const:Nn \c__chemgreek_order_tl +\tl_const:Nn \c__chemgreek_alphabet_tl { { alpha } % 1 { beta } % 2 @@ -101,18 +170,19 @@ % ---------------------------------------------------------------------------- % variants of kernel functions: \cs_generate_variant:Nn \prop_put:Nnn { cxV } +\cs_generate_variant:Nn \tl_if_eq:nnTF { V } % ---------------------------------------------------------------------------- % helper function to retrieve upper- and lowercase entries while the mapping % happens: -\cs_new:Npn \__chemgreek_get_upper_lower:w #1 / #2 \q_stop +\cs_new_protected:Npn \__chemgreek_get_upper_lower:w #1 / #2 \q_stop { \tl_set:Nn \l__chemgreek_tmpa_tl { #1 } \tl_set:Nn \l__chemgreek_tmpb_tl { #2 } } % ---------------------------------------------------------------------------- -% a conditional to test if a mapping exists: +% a conditional for testing if a mapping exists: \prg_new_conditional:Npnn \chemgreek_if_mapping_exists:n #1 {p,T,F,TF} { \bool_if:nTF @@ -124,36 +194,59 @@ { \prg_return_false: } } +% a conditional for testing if a mapping is active: +\tl_new:N \l__chemgreek_active_mapping_tl +\prg_new_conditional:Npnn \chemgreek_if_mapping_active:n #1 {p,T,F,TF} + { + \tl_if_eq:NcTF + \l__chemgreek_active_mapping_tl + { c__chemgreek_mapping_#1_tl } + { \prg_return_true: } + { \prg_return_false: } + } + +% ---------------------------------------------------------------------------- +% a property lists that holds the needed package names for a mapping +\prop_new:N \l__chemgreek_packages_prop + % ---------------------------------------------------------------------------- % the main mapping function: % #1: mapping-name -% #2: mapping-entries -\cs_new_protected:Npn \chemgreek_new_mapping:nn #1#2 +% #2: package name +% #3: mapping-entries +\cs_new_protected:Npn \chemgreek_new_mapping:nnn #1#2#3 { \chemgreek_if_mapping_exists:nTF { #1 } - { \msg_error:nnn { chemgreek } { mapping-defined } { #1 } } + { \msg_error:nnn { chemgreek } { mapping-already-defined } { #1 } } { \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop } \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop } - \__chemgreek_set_mapping:nn { #1 } { #2 } + \tl_const:cn { c__chemgreek_mapping_#1_tl } { #1 } + \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 } + \__chemgreek_set_mapping:nn { #1 } { #3 } } } -\cs_new_protected:Npn \chemgreek_renew_mapping:nn #1#2 +\cs_new_protected:Npn \chemgreek_renew_mapping:nnn #1#2#3 { \chemgreek_if_mapping_exists:nTF { #1 } - { \__chemgreek_set_mapping:nn { #1 } { #2 } } + { + \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 } + \__chemgreek_set_mapping:nn { #1 } { #3 } + } { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } } } -\cs_new_protected:Npn \chemgreek_declare_mapping:nn #1#2 +\cs_new_protected:Npn \chemgreek_declare_mapping:nnn #1#2#3 { \chemgreek_if_mapping_exists:nF { #1 } { \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop } \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop } + \tl_const:cn { c__chemgreek_mapping_#1_tl } { #1 } } - \__chemgreek_set_mapping:nn { #1 } { #2 } + \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 } + \__chemgreek_set_mapping:nn { #1 } { #3 } } \cs_new_protected:Npn \__chemgreek_set_mapping:nn #1#2 @@ -166,26 +259,32 @@ \int_incr:N \l__chemgreek_tmpa_int \__chemgreek_get_upper_lower:w ##1 \q_stop \prop_put:cxV { l__chemgreek_lowercase_mapping_#1_prop } - { \tl_item:Nn \c__chemgreek_order_tl { \l__chemgreek_tmpa_int } } + { \tl_item:Nn \c__chemgreek_alphabet_tl { \l__chemgreek_tmpa_int } } \l__chemgreek_tmpa_tl \prop_put:cxV { l__chemgreek_uppercase_mapping_#1_prop } - { \tl_item:Nn \c__chemgreek_order_tl { \l__chemgreek_tmpa_int } } + { \tl_item:Nn \c__chemgreek_alphabet_tl { \l__chemgreek_tmpa_int } } \l__chemgreek_tmpb_tl } } -% the user command: -\NewDocumentCommand \newchemgreekmapping { mm } - { \chemgreek_new_mapping:nn { #1 } { #2 } } +% the user commands: +\NewDocumentCommand \newchemgreekmapping { O{}mm } + { \chemgreek_new_mapping:nn { #2 } { #1 } { #3 } } -\NewDocumentCommand \renewchemgreekmapping { mm } - { \chemgreek_renew_mapping:nn { #1 } { #2 } } +\NewDocumentCommand \renewchemgreekmapping { O{}mm } + { \chemgreek_renew_mapping:nnn { #2 } { #1 } { #3 } } -\NewDocumentCommand \declarechemgreekmapping { mm } - { \chemgreek_declare_mapping:nn { #1 } { #2 } } +\NewDocumentCommand \declarechemgreekmapping { O{}mm } + { \chemgreek_declare_mapping:nnn { #2 } { #1 } { #3 } } % ---------------------------------------------------------------------------- % a function to selectively change specific entries in a mapping: + +% this will hold all changed mappings until they've been (re-)activated +% logically a sequence or clist would make more sense; however, +% \prop_if_in:Nn(TF) is expandable +\prop_new:N \l__chemgreek_changed_mappings_prop + % #1: mapping-name % #2: upper / lower % #3: entry-name @@ -197,6 +296,9 @@ \prop_put:cnn { l__chemgreek_#2 case_mapping_#1_prop } { #3 } { #4 } + \prop_put:Nnn \l__chemgreek_changed_mappings_prop + { #1 } + { #1 } } { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } } } @@ -208,16 +310,42 @@ % ---------------------------------------------------------------------------- % a function to activate a mapping: % #1: mapping-name +% TODO: error if needed package has not been loaded \cs_new_protected:Npn \chemgreek_activate_mapping:n #1 { \chemgreek_if_mapping_exists:nTF { #1 } { - \tl_map_inline:Nn \c__chemgreek_order_tl + \bool_if:nTF + { + ( \chemgreek_if_mapping_active_p:n { #1 } ) + && + !( \prop_if_in_p:Nn \l__chemgreek_changed_mappings_prop { #1 } ) + } + { \msg_info:nnn { chemgreek } { mapping-active } { #1 } } { - \cs_set_protected:cpx { Chem \tl_expandable_uppercase:n ##1 } - { \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } } - \cs_set_protected:cpx { Chem ##1 } - { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } } + \tl_set:Nn \l__chemgreek_active_mapping_tl { #1 } + \prop_get:NnN \l__chemgreek_packages_prop { #1 } + \l__chemgreek_tmpa_tl + \tl_if_blank:VF \l__chemgreek_tmpa_tl + { + \chemgreek_if_package_loaded:VF \l__chemgreek_tmpa_tl + { + \msg_warning:nnxx { chemgreek } { package-missing } + { #1 } + { \l__chemgreek_tmpa_tl } + } + } + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \cs_set_protected:cpx { chem \tl_expandable_uppercase:n ##1 } + { \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } } + \cs_set_protected:cpx { chem ##1 } + { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } } + } + \prop_get:NnNT \l__chemgreek_changed_mappings_prop + { #1 } + \l__chemgreek_tmpa_tl + { \prop_remove:Nn \l__chemgreek_changed_mappings_prop { #1 } } } } { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } } @@ -225,17 +353,18 @@ % user command that also loads the needed package: % #1: load package -% #2: option -% #3: mapping-name -\NewDocumentCommand \activatechemgreekmapping { som } +% #2: mapping-name +\NewDocumentCommand \activatechemgreekmapping { sm } { \IfBooleanT { #1 } { - \IfNoValueTF { #2 } - { \RequirePackage { #3 } } - { \RequirePackage [ #2 ] { #3 } } + \prop_get:NnN \l__chemgreek_packages_prop + { #2 } + \l__chemgreek_tmpa_tl + \tl_if_blank:VF \l__chemgreek_tmpa_tl + { \exp_args:No \RequirePackage { \l__chemgreek_tmpa_tl } } } - \chemgreek_activate_mapping:n { #3 } + \chemgreek_activate_mapping:n { #2 } } \@onlypreamble\activatechemgreekmapping @@ -245,56 +374,99 @@ % ---------------------------------------------------------------------------- % a debugging command: -\cs_new_protected:Npn \chemgreek_show_mapping:n #1 +\cs_new_protected:Npn \chemgreek_print_mapping:n #1 { - \chemgreek_activate_mapping:n { #1 } \int_gzero:N \g__chemgreek_tmpa_int - \begin { tabular } { llll } + \begin { tabular } { llcc } pos & name & lower & upper \\ - \tl_map_inline:Nn \c__chemgreek_order_tl + \tl_map_inline:Nn \c__chemgreek_alphabet_tl { \int_gincr:N \g__chemgreek_tmpa_int \int_use:N \g__chemgreek_tmpa_int . & ##1 & - \use:c { Chem ##1 } & - \use:c { Chem \tl_expandable_uppercase:n ##1 } \\ + \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } & + \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } \\ } \end{tabular} } +\cs_new_eq:NN \printchemgreekmapping \chemgreek_print_mapping:n + +\cs_new_protected:Npn \chemgreek_show_mapping:n #1 + { + \int_gzero:N \g__chemgreek_tmpa_int + \iow_log:n { ................................................. } + \iow_log:n { . ~ chemgreek~ mapping~ `#1': } + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \int_gincr:N \g__chemgreek_tmpa_int + \iow_log:x + { . ~ \int_use:N \g__chemgreek_tmpa_int . } + \iow_log:x + { + . \c_space_tl \c_space_tl \c_space_tl \c_space_tl \c_space_tl + ##1 ~ => ~ + \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } + } + \iow_log:x + { + . \c_space_tl \c_space_tl \c_space_tl \c_space_tl \c_space_tl + \tl_expandable_uppercase:n ##1 ~ => ~ + \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } + } + } + \iow_log:n { ................................................. } + } + \cs_new_eq:NN \showchemgreekmapping \chemgreek_show_mapping:n % ---------------------------------------------------------------------------- +% deprecate old macro names that started with an uppercase C: +\cs_new_protected:Npn \chemgreek_deprecate_symbol:n #1 + { \chemgreek_define_deprecated:cc { Chem#1 } { chem#1 } } + +\cs_new_protected:Npn \chemgreek_deprecate_symbols: + { + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \chemgreek_deprecate_symbol:n { ##1 } + \chemgreek_deprecate_symbol:n { \tl_expandable_uppercase:n ##1 } + } + } + +\chemgreek_deprecate_symbols: + +% ---------------------------------------------------------------------------- % functions to format integers with greek letters; these are basically copies % of \int_to_alph:n \cs_new:Npn \chemgreek_int_to_greek:n #1 { \int_to_symbols:nnn { #1 } { 24 } { - { 1 } { \Chemalpha } - { 2 } { \Chembeta } - { 3 } { \Chemgamma } - { 4 } { \Chemdelta } - { 5 } { \Chemepsilon } - { 6 } { \Chemzeta } - { 7 } { \Chemeta } - { 8 } { \Chemiota } - { 9 } { \Chemtheta } - { 10 } { \Chemkappa } - { 11 } { \Chemlambda } - { 12 } { \Chemmu } - { 13 } { \Chemnu } - { 14 } { \Chemxi } - { 15 } { \Chemomikron } - { 16 } { \Chempi } - { 17 } { \Chemrho } - { 18 } { \Chemsigma } - { 19 } { \Chemtau } - { 20 } { \Chemupsilon } - { 21 } { \Chemphi } - { 22 } { \Chempsi } - { 23 } { \Chemchi } - { 24 } { \Chemomega } + { 1 } { \chemalpha } + { 2 } { \chembeta } + { 3 } { \chemgamma } + { 4 } { \chemdelta } + { 5 } { \chemepsilon } + { 6 } { \chemzeta } + { 7 } { \chemeta } + { 8 } { \chemiota } + { 9 } { \chemtheta } + { 10 } { \chemkappa } + { 11 } { \chemlambda } + { 12 } { \chemmu } + { 13 } { \chemnu } + { 14 } { \chemxi } + { 15 } { \chemomikron } + { 16 } { \chempi } + { 17 } { \chemrho } + { 18 } { \chemsigma } + { 19 } { \chemtau } + { 20 } { \chemupsilon } + { 21 } { \chemphi } + { 22 } { \chempsi } + { 23 } { \chemchi } + { 24 } { \chemomega } } } @@ -302,37 +474,37 @@ { \int_to_symbols:nnn { #1 } { 24 } { - { 1 } { \ChemAlpha } - { 2 } { \ChemBeta } - { 3 } { \ChemGamma } - { 4 } { \ChemDelta } - { 5 } { \ChemEpsilon } - { 6 } { \ChemZeta } - { 7 } { \ChemEta } - { 8 } { \ChemIota } - { 9 } { \ChemTheta } - { 10 } { \ChemKappa } - { 11 } { \ChemLambda } - { 12 } { \ChemMu } - { 13 } { \ChemNu } - { 14 } { \ChemXi } - { 15 } { \ChemOmikron } - { 16 } { \ChemPi } - { 17 } { \ChemRho } - { 18 } { \ChemSigma } - { 19 } { \ChemTau } - { 20 } { \ChemUpsilon } - { 21 } { \ChemPhi } - { 22 } { \ChemPsi } - { 23 } { \ChemChi } - { 24 } { \ChemOmega } + { 1 } { \chemAlpha } + { 2 } { \chemBeta } + { 3 } { \chemGamma } + { 4 } { \chemDelta } + { 5 } { \chemEpsilon } + { 6 } { \chemZeta } + { 7 } { \chemEta } + { 8 } { \chemIota } + { 9 } { \chemTheta } + { 10 } { \chemKappa } + { 11 } { \chemLambda } + { 12 } { \chemMu } + { 13 } { \chemNu } + { 14 } { \chemXi } + { 15 } { \chemOmikron } + { 16 } { \chemPi } + { 17 } { \chemRho } + { 18 } { \chemSigma } + { 19 } { \chemTau } + { 20 } { \chemUpsilon } + { 21 } { \chemPhi } + { 22 } { \chemPsi } + { 23 } { \chemChi } + { 24 } { \chemOmega } } } % ---------------------------------------------------------------------------- % predefine some mappings % default: -\chemgreek_new_mapping:nn { default } +\chemgreek_new_mapping:nnn { default } { } { \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2 @@ -361,7 +533,7 @@ } % default-variant: -\chemgreek_new_mapping:nn { var-default } +\chemgreek_new_mapping:nnn { var-default } { } { \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2 @@ -390,7 +562,7 @@ } % mathdesign: -\chemgreek_new_mapping:nn { mathdesign } +\chemgreek_new_mapping:nnn { mathdesign } { mathdesign } { \ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2 @@ -419,36 +591,36 @@ } % textgreek: -\chemgreek_new_mapping:nn { textgreek } - { - \textalpha / \textAlpha , % 1 - \textbeta / \textBeta , % 2 - \textgamma / \textGamma , % 3 - \textdelta / \textDelta , % 4 - \textepsilon / \textEpsilon , % 5 - \textzeta / \textZeta , % 6 - \texteta / \textEta , % 7 - \texttheta / \textTheta , % 8 - \textiota / \textIota , % 9 - \textkappa / \textKappa , % 10 - \textlambda / \textLambda , % 11 - \textmugreek / \textMu , % 12 - \textnu / \textNu , % 13 - \textxi / \textXi , % 14 - \textomikron / \textOmikron , % 15 - \textpi / \textPi , % 16 - \textrho / \textRho , % 17 - \textsigma / \textSigma , % 18 - \texttau / \textTau , % 19 - \textupsilon / \textUpsilon , % 20 - \textphi / \textPhi , % 21 - \textpsi / \textPsi , % 22 - \textchi / \textChi , % 23 - \textomega / \textOmega % 24 +\chemgreek_new_mapping:nnn { textgreek } { textgreek } + { + \mbox{\textalpha} / \mbox{\textAlpha} , % 1 + \mbox{\textbeta} / \mbox{\textBeta} , % 2 + \mbox{\textgamma} / \mbox{\textGamma} , % 3 + \mbox{\textdelta} / \mbox{\textDelta} , % 4 + \mbox{\textepsilon} / \mbox{\textEpsilon} , % 5 + \mbox{\textzeta} / \mbox{\textZeta} , % 6 + \mbox{\texteta} / \mbox{\textEta} , % 7 + \mbox{\texttheta} / \mbox{\textTheta} , % 8 + \mbox{\textiota} / \mbox{\textIota} , % 9 + \mbox{\textkappa} / \mbox{\textKappa} , % 10 + \mbox{\textlambda} / \mbox{\textLambda} , % 11 + \mbox{\textmugreek} / \mbox{\textMu} , % 12 + \mbox{\textnu} / \mbox{\textNu} , % 13 + \mbox{\textxi} / \mbox{\textXi} , % 14 + \mbox{\textomikron} / \mbox{\textOmikron} , % 15 + \mbox{\textpi} / \mbox{\textPi} , % 16 + \mbox{\textrho} / \mbox{\textRho} , % 17 + \mbox{\textsigma} / \mbox{\textSigma} , % 18 + \mbox{\texttau} / \mbox{\textTau} , % 19 + \mbox{\textupsilon} / \mbox{\textUpsilon} , % 20 + \mbox{\textphi} / \mbox{\textPhi} , % 21 + \mbox{\textpsi} / \mbox{\textPsi} , % 22 + \mbox{\textchi} / \mbox{\textChi} , % 23 + \mbox{\textomega} / \mbox{\textOmega} % 24 } % upgreek: -\chemgreek_new_mapping:nn { upgreek } +\chemgreek_new_mapping:nnn { upgreek } { upgreek } { \ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2 @@ -477,7 +649,7 @@ } % kpfonts: -\chemgreek_new_mapping:nn { kpfonts } +\chemgreek_new_mapping:nnn { kpfonts } { kpfonts } { \ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2 @@ -506,7 +678,7 @@ } % newtx: -\chemgreek_new_mapping:nn { newtx } +\chemgreek_new_mapping:nnn { newtx } { newtxmath } { \ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2 @@ -549,7 +721,7 @@ { \ensuremath { \use:c { other #1 } } } } -\chemgreek_new_mapping:nn { fourier } +\chemgreek_new_mapping:nnn { fourier } { fourier } { \__chemgreek_lfourier:n {alpha} / \ensuremath{\mathrm{A}} , % 1 \__chemgreek_lfourier:n {beta} / \ensuremath{\mathrm{B}} , % 2 @@ -577,9 +749,58 @@ \__chemgreek_lfourier:n {omega} / \__chemgreek_ufourier:n {Omega} % 24 } +% textalpha: +\chemgreek_new_mapping:nnn { textalpha } { textalpha } + { + \mbox{\textalpha} / \mbox{\textAlpha} , % 1 + \mbox{\textbeta} / \mbox{\textBeta} , % 2 + \mbox{\textgamma} / \mbox{\textGamma} , % 3 + \mbox{\textdelta} / \mbox{\textDelta} , % 4 + \mbox{\textepsilon} / \mbox{\textEpsilon} , % 5 + \mbox{\textzeta} / \mbox{\textZeta} , % 6 + \mbox{\texteta} / \mbox{\textEta} , % 7 + \mbox{\texttheta} / \mbox{\textTheta} , % 8 + \mbox{\textiota} / \mbox{\textIota} , % 9 + \mbox{\textkappa} / \mbox{\textKappa} , % 10 + \mbox{\textlambda} / \mbox{\textLambda} , % 11 + \mbox{\textmu} / \mbox{\textMu} , % 12 + \mbox{\textnu} / \mbox{\textNu} , % 13 + \mbox{\textxi} / \mbox{\textXi} , % 14 + \mbox{\textomicron} / \mbox{\textOmicron} , % 15 + \mbox{\textpi} / \mbox{\textPi} , % 16 + \mbox{\textrho} / \mbox{\textRho} , % 17 + \mbox{\textsigma} / \mbox{\textSigma} , % 18 + \mbox{\texttau} / \mbox{\textTau} , % 19 + \mbox{\textupsilon} / \mbox{\textUpsilon} , % 20 + \mbox{\textphi} / \mbox{\textPhi} , % 21 + \mbox{\textpsi} / \mbox{\textPsi} , % 22 + \mbox{\textchi} / \mbox{\textChi} , % 23 + \mbox{\textomega} / \mbox{\textOmega} % 24 + } + % activate default mapping \chemgreek_activate_mapping:n { default } +\AtBeginDocument + { + \chemgreek_if_package_with:nnT {hyperref} {unicode} + { + \chemgreek_if_package_loaded:nT {textalpha} + { + \pdfstringdefDisableCommands + { + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \cs_set_eq:cc + { chem \tl_expandable_uppercase:n #1 } + { text \tl_expandable_uppercase:n #1 } + \cs_set_eq:cc { chem #1 } { text #1 } + } + } + } + } + } + \tex_endinput:D HISTORY: @@ -593,6 +814,19 @@ HISTORY: 2013/11/20 - v0.2a - fixed typos in `fourier' mapping - added missing \prop_clear: to \__chemgreek_set_mapping:nn - added missing argument to message calls +2014/01/24 - v0.3 - rename \Chem<name => \chem<name>, the old names will + issue warnings but still work + - new mappings `textalpha' (cf the package with the same + name, part of `greek-fontenc') + - \chemgreek_new_mapping:nnn redefined so that package name + must be given if needed; \chemgreek_activate_mapping:n + now issues a warning if the needed package hasn't been + loaded + - if hyperref has been loaded with package option `unicode' + and the active mapping is `textalpha' we can use greek + letters in PDF bookmarks + - new command \printchemgreekmapping + - \showchemgreekmapping now writes information to the log TODO: diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros-version1.cfg b/Master/texmf-dist/tex/latex/chemmacros/chemmacros-version1.cfg deleted file mode 100644 index ae8adb9f968..00000000000 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros-version1.cfg +++ /dev/null @@ -1,331 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% --------------------------------------------------------------------------- % -% - the CHEMMACROS bundle - % -% - chemmacros-version1.cfg - % -% - macros and commands for chemists - % -% --------------------------------------------------------------------------- % -% - Clemens Niederberger - % -% - 2012/01/28 - % -% --------------------------------------------------------------------------- % -% - http://www.mychemistry.eu/ - % -% - contact@mychemistry.eu - % -% --------------------------------------------------------------------------- % -% - If you have any ideas, questions, suggestions or bugs to report, please - % -% - feel free to contact me. - % -% --------------------------------------------------------------------------- % -% - Copyright 2011-2012 Clemens Niederberger - % -% - - % -% - This work may be distributed and/or modified under the - % -% - conditions of the LaTeX Project Public License, either version 1.3 - % -% - of this license or (at your option) any later version. - % -% - The latest version of this license is in - % -% - http://www.latex-project.org/lppl.txt - % -% - and version 1.3 or later is part of all distributions of LaTeX - % -% - version 2005/12/01 or later. - % -% - - % -% - This work has the LPPL maintenance status `maintained'. - % -% - - % -% - The Current Maintainer of this work is Clemens Niederberger. - % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% old definitions of some commands, deprecated commands -\RequirePackage { ifthen } -% first copy old tools: -% --------------------------------------------------------------------------- % -\ExplSyntaxOff -% Test if #2 is part of #1 -% (the macro is a copy of chemfig's \CF@if@instr by Christian Tellechea) -\newcommand*\CM@ifinstr[2]{% - \def\CM@ifinstr@i##1#2##2\@nil{\ifx\@empty##2\@empty\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}% - \CM@ifinstr@i#1#2\@nil% -} - -% split at comma, save part before in #3, save part after in \CM@RemainStr -% (the macro is a copy of chemfig's \CF@analyze@movearg by Christian Tellechea) -\def\CM@split#1,#2\@nil#3{% - \def#3{#1}\def\CM@RemainStr{#2}% -} -% --------------------------------------------------------------------------- % -% Optional Argument Analysis -\newcounter{CM@tmp@cnt} -\setcounter{CM@tmp@cnt}{0} -\newcounter{CM@splitting@cnt} -% empty \CM@arg@<num> -\newcommand*\CM@ClearArgs[1]{% - \whiledo{\value{CM@tmp@cnt}<#1}{% - \stepcounter{CM@tmp@cnt}% - \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\@empty% - }% - \setcounter{CM@tmp@cnt}{0}% -} -% split a list separated by commas into \CM@arg@<num>, number of arguments chosen by #2 -\newcommand*\CM@splitting[2]{% - \CM@ClearArgs{#2}% - \setcounter{CM@splitting@cnt}{#2-1}% - \def\CM@RemainStr{#1}% - \whiledo{\value{CM@tmp@cnt}<\value{CM@splitting@cnt}}{% - \expandafter\CM@ifinstr\expandafter{\CM@RemainStr}{,}{% - \stepcounter{CM@tmp@cnt}% - \expandafter\CM@split\CM@RemainStr\@nil\CM@tmp@name% - \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\CM@tmp@name% - }{% - \stepcounter{CM@tmp@cnt}% - \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\CM@RemainStr% - \let\CM@RemainStr\@empty% - \setcounter{CM@tmp@cnt}{\value{CM@splitting@cnt}}% - }% - }% - \stepcounter{CM@tmp@cnt}% - \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\CM@RemainStr% - \setcounter{CM@tmp@cnt}{0}% -} -% --------------------------------------------------------------------------- % -% check commands for equality -\newcommand*\CM@compareCs[2]{% - \expandafter\let\expandafter\CM@cs@one\csname#1\endcsname% - \expandafter\let\expandafter\CM@cs@two\csname#2\endcsname% - \ifx\CM@cs@one\CM@cs@two\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi -} -% check strings for equality ---------------------------------------------------------- % -\newcommand*\CM@compareStr[2]{% - \edef\CM@cs@one{#1}% - \edef\CM@cs@two{#2}% - \ifx\CM@cs@one\CM@cs@two\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi -} - -% --------------------------------------------------------------------------- % -% \setnewstate, \renewstate \State -% copy of definitions in v1.1 -% \setstatesubscript{right/left} -\newcommand*\CM@State@subscript{left} -\newcommand*\setstatesubscript[1]{% - \renewcommand*\CM@State@subscript{\ifx\relax#1\relax left\else#1\fi} -} -% \State[<exp>,<Delta>,<subscript pos>]{<Symbol>}{<Index>} -% {<Index>} is an optional argument! -\NewDocumentCommand\State{omG{}}{% - \IfNoValueTF{#1}{\CM@splitting{}{3}}{\CM@splitting{#1}{3}}% - \ensuremath{% - \CM@compareCs{CM@arg@iii}{@empty}{% - \CM@compareStr{\CM@State@subscript}{right}{\let\CM@State@sub@left\@empty\def\CM@State@sub@right{_\mathrm{#3}}}{\let\CM@State@sub@right\@empty\def\CM@State@sub@left{_\mathrm{#3}}}% - }{ - \CM@compareStr{\CM@arg@iii}{right}{\let\CM@State@sub@left\@empty\def\CM@State@sub@right{_\mathrm{#3}}}{% - \CM@compareStr{\CM@arg@iii}{left}{\let\CM@State@sub@right\@empty\def\CM@State@sub@left{_\mathrm{#3}}}{% - \PackageWarning{chemmacros}{\string\State: <subscript pos> can only have the values 'left' or 'right'}{}% - } - }% - }% - \CM@compareCs{CM@arg@ii}{@empty}{\Delta}{\CM@arg@ii}\CM@State@sub@left#2\CM@State@sub@right% - \CM@compareCs{CM@arg@i}{@empty}{^{\standardstate}}{^{\CM@arg@i}}}% -} - -% \setnewstate[<exp>,<Delta>,<subscript pos>]{<command>}{<letter>}{<unit>} -% \renewstate[<exp>,<Delta>,<subscript pos>]{<command>}{<letter>}{<unit>} -\newcommand*\CM@setnewstate[4][]{% - \CM@splitting{#1}{3}% [<exp>,<Delta>,<subscript pos>] - \CM@compareCs{CM@arg@i}{@empty}{\expandafter\let\csname CM@#2@supscript\endcsname\standardstate}{\expandafter\let\csname CM@#2@supscript\endcsname\CM@arg@i}% - \CM@compareCs{CM@arg@ii}{@empty}{\expandafter\let\csname CM@#2@delta\endcsname\Delta}{\expandafter\let\csname CM@#2@delta\endcsname\CM@arg@ii} - \CM@compareCs{CM@arg@iii}{@empty}{\@namedef{CM@#2@right}{left}}{\expandafter\let\csname CM@#2@right\endcsname\CM@arg@iii}% - \@namedef{#2}{\@ifnextchar[{\@nameuse{CM@#2@ii}}{\@nameuse{CM@#2@i}}}% - \@namedef{CM@#2@i}##1{\ensuremath{\State[\@nameuse{CM@#2@supscript},\@nameuse{CM@#2@delta},\@nameuse{CM@#2@right}]{#3}{}=\SI{##1}{#4}}}% - \@namedef{CM@#2@ii}[##1]##2{% - \CM@splitting{##1}{4}% [<index>,<exp>,<unit>,<subscript pos>] - \let\CM@State@index\CM@arg@i - \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@State@supscript{\@nameuse{CM@#2@supscript}}}{\let\CM@State@supscript\CM@arg@ii}% - \CM@compareCs{CM@arg@iii}{@empty}{\def\CM@State@unit{#4}}{\let\CM@State@unit\CM@arg@iii}% - \CM@compareCs{CM@arg@iv}{@empty}{\def\CM@State@right{\@nameuse{CM@#2@right}}}{\let\CM@State@right\CM@arg@iv}% - \ensuremath{\State[\CM@State@supscript,\@nameuse{CM@#2@delta},\CM@State@right]{#3}{\CM@State@index} = \SI{##2}{\CM@State@unit}}% - }% -} -\newcommand*\setnewstate[4][]{% - \@ifundefined{#2}{\CM@setnewstate[#1]{#2}{#3}{#4}}{\PackageError{chemmacros}{\string\setnewstate: state #2 is already defined}{}}% -} -\newcommand*\renewstate[4][]{% - \@ifundefined{#2}{\PackageError{chemmacros}{\string\renewstate: state #2 is not defined}{}}{\CM@setnewstate[#1]{#2}{#3}{#4}}% -} -\setnewstate{Enthalpy}{H}{\kilo\joule\per\mole}% -\setnewstate[, ]{Entropy}{S}{\joule\per\kelvin\per\mole}% -\setnewstate{Gibbs}{G}{\kilo\joule\per\mole}% - -\ExplSyntaxOn - -% --------------------------------------------------------------------------- % -% \newreaction -\NewDocumentCommand \newreaction { s t+ m m } - { - \cs_if_exist:cTF { #3 } - { - \msg_error:nnx { chemmacros } { already-defined } { #3 } - } - { - \IfBooleanTF { #1 } - { \bool_set_true:N \l_chemmacros_reactions_star_bool } - { \bool_set_false:N \l_chemmacros_reactions_star_bool } - \IfBooleanTF { #2 } - { \bool_set_true:N \l_chemmacros_reactions_args_bool } - { \bool_set_false:N \l_chemmacros_reactions_args_bool } - \bool_if:NTF \l_chemmacros_reactions_args_bool - { - \NewEnviron { #3 } [ 1 ] - { - \chemmacros_begin_reaction: - \begin { #4 } { ##1 } - \chemmacros_cee:f { \BODY } - \end{ #4 } - \chemmacros_end_reaction: - } - \bool_if:NT \l_chemmacros_reactions_star_bool - { - \NewEnviron { #3* } [ 1 ] - { - \begin { #4* } { ##1 } - \chemmacros_cee:f { \BODY } - \end { #4* } - } - } - } - { - \NewEnviron { #3 } - { - \chemmacros_begin_reaction: - \begin { #4 } - \chemmacros_cee:f { \BODY } - \end { #4 } - \chemmacros_end_reaction: - } - \bool_if:NT \l_chemmacros_reactions_star_bool - { - \NewEnviron { #3* } - { - \begin { #4* } - \chemmacros_cee:f { \BODY } - \end { #4* } - } - } - } - } - } - -\newreaction* { reaction } { equation } -\newreaction* { reactions } { align } - -% --------------------------------------------------------------------------- % -% \mhName -% copy of definition in v1.1 -% placing text below atom/molecule - \newcommand*\CM@mhName@textattr@default{\centering\tiny} -% \setmhName{<commands>} - \newcommand*\setmhName[1]{ - \ifx\@empty#1\@empty - \renewcommand*\CM@mhName@textattr@default{\centering\tiny} - \else - \renewcommand*\CM@mhName@textattr@default{#1} - \fi - } -% \mhName[<width>][<textattr>]{<formula>}{<text>} - \newlength{\CM@mhName@boxlength} - \NewDocumentCommand\mhName{oomm}{ - \IfNoValueTF{#1}{ - \settowidth{\CM@mhName@boxlength}{#3} - }{ - \ifx\@empty#1\@empty - \settowidth{\CM@mhName@boxlength}{#3} - \else - \setlength{\CM@mhName@boxlength}{#1} - \fi - }% - \IfNoValueTF{#2}{ - \let\CM@mhName@textattr\CM@mhName@textattr@default - }{ - \def\CM@mhName@textattr{#2} - } - \def\CM@mhName@formula{#3} - \ensuremath{\underset{\parbox{\CM@mhName@boxlength} - {\CM@mhName@textattr#4}}{\expandafter\ce\expandafter{\CM@mhName@formula}}} - } - -\ExplSyntaxOff -% --------------------------------------------------------------------------- % -% \newman -% copy of definition in v1.1 -\NewDocumentCommand\newman{ooom}{% - \IfNoValueTF{#1}{% - \def\CM@newman@angle{0}% - \def\CM@newman@scale{1}% - \def\CM@newman@tikz@ring{}% - }{% - \CM@splitting{#1}{3}% - \CM@compareCs{CM@arg@i}{@empty}{\def\CM@newman@angle{0}}{\let\CM@newman@angle\CM@arg@i}% - \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@newman@scale{1}}{\let\CM@newman@scale\CM@arg@ii}% - \expandafter\def\expandafter\CM@newman@tikz@ring\expandafter{\CM@arg@iii}% - } - \IfNoValueTF{#2}{% - \let\CM@newman@tikz@one\@empty% - }{% - \def\CM@newman@tikz@one{#2}% - } - \IfNoValueTF{#3}{% - \let\CM@newman@tikz@two\CM@newman@tikz@one% - }{% - \def\CM@newman@tikz@two{#3}% - } - \CM@splitting{#4}{6}% - \edef\CM@newman@tikz{scale=\CM@newman@scale,CMatomFront/.style={inner sep=0,outer sep=0,\CM@newman@tikz@one},CMatomBack/.style={inner sep=0,outer sep=0,\CM@newman@tikz@two}} - \expandafter\tikz\expandafter[\CM@newman@tikz]{% - \expandafter\draw\expandafter[\CM@newman@tikz@ring] (0,0) circle (.5);% - \foreach\i in{30+\CM@newman@angle,150+\CM@newman@angle,270+\CM@newman@angle}{% - \expandafter\draw\expandafter[\CM@newman@tikz@ring] (\i:0.5) --++(\i:.5);% - }% - \node[CMatomBack,anchor=-150+\CM@newman@angle] at (30+\CM@newman@angle:1.05) {\CM@arg@v};% - \node[CMatomBack,anchor=-30+\CM@newman@angle] at (150+\CM@newman@angle:1.05) {\CM@arg@vi};% - \node[CMatomBack,anchor=90+\CM@newman@angle] at (270+\CM@newman@angle:1.05) {\CM@arg@iv};% - \foreach\i in{90,210,330}{% - \expandafter\draw\expandafter[\CM@newman@tikz@ring] (0,0) --++(\i:1);% - }% - \node[CMatomFront,anchor=-90] at (90:1.05) {\CM@arg@i};% - \node[CMatomFront,anchor=30] at (210:1.05) {\CM@arg@ii};% - \node[CMatomFront,anchor=150] at (330:1.05) {\CM@arg@iii};% - }% -} - -% --------------------------------------------------------------------------- % -% - p-orbitals -------------------------------------------------------------- % -% copy of definition in v1.1 -\newcommand*\CM@porb[1][]{% - \CM@splitting{#1}{3}% - \CM@compareCs{CM@arg@i}{@empty}{\let\CM@orbital@height\CM@orb@height}{\def\CM@orbital@height{\CM@arg@i*\CM@orb@height}}% - \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@orb@color{black}}{\let\CM@orb@color\CM@arg@ii}% - \CM@compareStr{\CM@orb@color}{white}{\def\CM@orb@color@draw{black}}{\let\CM@orb@color@draw\CM@orb@color}% - \CM@compareCs{CM@arg@iii}{@empty}{\def\CM@orb@ang{0}}{\let\CM@orb@ang\CM@arg@iii}% - \tikzpicture[overlay,rotate={\CM@orb@ang-90},opacity=.5,inner sep=0pt,outer sep=0pt,text height=0pt,text depth=0pt]% - \pgfsetfillopacity{.5}% - \CM@compareStr{\CM@orb@half}{false}{% - \draw[draw=black] (0,0) .. controls ++(-.9*\CM@orbital@height,-1.5*\CM@orbital@height) and ++(.9*\CM@orbital@height,-1.5*\CM@orbital@height) .. (0,0);% - }{}% - \draw[draw=\CM@orb@color@draw,fill=\CM@orb@color] (0,0) .. controls ++(-.9*\CM@orbital@height,1.5*\CM@orbital@height) and ++(.9*\CM@orbital@height,1.5*\CM@orbital@height) .. (0,0);% - \endtikzpicture% -} -% full orbital: -% \porb[<size factor>,<color>,<angle>] -\newcommand*\porb{\def\CM@orb@half{false}\CM@porb}% -% half of an orbital: -% \phorb[<size factor>,<color>,<angle>] -\newcommand*\phorb{\def\CM@orb@half{true}\CM@porb}% - -% predefined orbitals: -\newcommand*\pzorb{\porb[,,90]}% -\newcommand*\pyorb{\porb[,,0]}% -\newcommand*\pxorb{\porb[,,-135]}% - -% change orbital settings: -\newcommand*\CM@orb@height{1em}% -\newcommand*\setorbheight[1]{% - \ifx\@empty#1\@empty - \renewcommand*\CM@orb@height{1em}% - \else - \renewcommand*\CM@orb@height{#1}% - \fi -} - -\ExplSyntaxOn - -\tex_endinput:D
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index 4f393c2b2a1..fd13bbf4440 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -26,8 +26,8 @@ % - The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- \RequirePackage{ expl3 , xparse , l3keys2e } -\def\chemmacros@version{4.2e} -\def\chemmacros@date{2014/01/09} +\def\chemmacros@version{4.3} +\def\chemmacros@date{2014/01/24} \ProvidesExplPackage {chemmacros} @@ -52,7 +52,7 @@ % -------------------------------------------------------------------------- % variants of kernel commands: \cs_generate_variant:Nn \prop_if_in:NnTF { NV , Nx } -\cs_generate_variant:Nn \prop_put:Nnn { NV , NVx } +\cs_generate_variant:Nn \prop_put:Nnn { NV , NVV , NVx } \cs_generate_variant:Nn \prop_get:NnNTF { NV } \cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV } \cs_generate_variant:Nn \tl_if_eq:nnTF { V } @@ -74,12 +74,6 @@ % -------------------------------------------------------------------------- % boolean variables for the package options -% versioning: -\bool_new:N \l__chemmacros_version_one_bool -\bool_new:N \l__chemmacros_version_three_bool -\bool_new:N \l__chemmacros_version_four_bool -\bool_set_true:N \l__chemmacros_version_four_bool - \bool_new:N \l__chemmacros_xspace_bool \bool_set_true:N \l__chemmacros_xspace_bool @@ -122,27 +116,6 @@ % -------------------------------------------------------------------------- % warning / error messages -\cs_new_protected:Npn \chemmacros_msg:nnxx #1#2#3#4 - { - \bool_if:NTF \l_chemmacros_strict_bool - { \msg_error:nnxx { #1 } { #2 } { #3 } { #4 } } - { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } } - } - -\cs_new_protected:Npn \chemmacros_msg:nn #1#2 - { - \bool_if:NTF \l_chemmacros_strict_bool - { \msg_error:nn { #1 } { #2 } } - { \msg_warning:nn { #1 } { #2 } } - } - -\cs_new_protected:Npn \chemmacros_warning:nnxx #1#2#3#4 - { - \bool_if:NTF \l_chemmacros_strict_bool - { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } } - { \msg_info:nnxx { #1 } { #2 } { #3 } { #4 } } - } - \msg_new:nnnn { chemmacros } { language-not-defined } { The~ language~ `#1'~ is~ not~ defined~ by~ chemmacros. } { @@ -152,11 +125,17 @@ } \msg_new:nnnn { chemmacros } { already-defined } - { The~ command~ #1~ has~ also~ been~ defined~ by~ another~ package. } + { The~ command~ #1~ is~ already~ defined. } + { + The~ command~ #1~ has~ already~ been~ otherwise.~ chemmacros~ also~ tries~ + to~ define~ it~ and~ fails.~ + } + +\msg_new:nnnn { chemmacros } { not-defined } + { The~ command~ #1~ is~ not~ defined,~ yet. } { - The~ command~ #1~ has~ also~ been~ defined~ by~ another~ package.~ - chemmacros~ provides~ an~ alternative~ definition.~ See~ the~ - documentation~ for~ more~ information. + The~ command~ #1~ is~ not~ defined,~ yet.~ chemmacros~ tries~ to~ + redefine~ it~ and~ fails.~ } \msg_new:nnnn { chemmacros } { option-deprecated } @@ -186,14 +165,14 @@ sorry. } -\msg_new:nnnn { chemmacros } { declare-particle } +\msg_new:nnnn { chemmacros } { new-particle } { The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ defined. } { You've~ tried~ to~ define~ a~ particle~ with~ \token_to_str:N - \DeclareChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \NewChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 \c_space_tl already~ exists.~ Please~ choose~ another~ name. } @@ -204,14 +183,14 @@ doesn't~ exist. } -\msg_new:nnnn { chemmacros } { declare-latin } +\msg_new:nnnn { chemmacros } { new-latin } { The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ defined. } { You've~ tried~ to~ define~ a~ latin~ phrase~ with~\token_to_str:N - \DeclareChemLatin ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \NewChemLatin ,~ but~ the~ command~ sequence~ \token_to_str:N #1 \c_space_tl already~ exists.~ Please~ choose~ another~ name. } @@ -222,14 +201,14 @@ it~ doesn't~ exist. } -\msg_new:nnnn { chemmacros } { declare-nmr } +\msg_new:nnnn { chemmacros } { new-nmr } { The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ defined. } { You've~ tried~ to~ define~ a~ NMR~ command~ with~\token_to_str:N - \DeclareChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \NewChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 \c_space_tl already~ exists.~ Please~ choose~ another~ name. } @@ -240,14 +219,14 @@ it~ doesn't~ exist. } -\msg_new:nnnn { chemmacros } { declare-phase } +\msg_new:nnnn { chemmacros } { new-phase } { The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ defined. } { You've~ tried~ to~ define~ a~ phase~ with~ \token_to_str:N - \DeclareChemPhase ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \NewChemPhase ,~ but~ the~ command~ sequence~ \token_to_str:N #1 \c_space_tl already~ exists.~ Please~ choose~ another~ name. } @@ -258,14 +237,14 @@ doesn't~ exist. } -\msg_new:nnnn { chemmacros } { declare-iupac } +\msg_new:nnnn { chemmacros } { new-iupac } { The~ iupac~ naming~ command~ \token_to_str:N #1 \c_space_tl is~ already~ defined. } { You've~ tried~ to~ define~ a~ iupac~ naming~ command~ with~ - \token_to_str:N \DeclareChemIUPAC ,~ but~ the~ iupac~ command~ + \token_to_str:N \NewChemIUPAC ,~ but~ the~ iupac~ command~ \token_to_str:N #1 \c_space_tl already~ exists.~ Choose~ another~ name~ or~ use~ \token_to_str:N \RenewChemIUPAC . } @@ -277,10 +256,22 @@ } { You've~ tried~ to~ renew~ the~ iupac~ command~ \token_to_str:N #1 ,~ but~ - it~ doesn't~ exist.~ Use~ \token_to_str:N \DeclareChemIUPAC \c_space_tl + it~ doesn't~ exist.~ Use~ \token_to_str:N \NewChemIUPAC \c_space_tl instead. } +\msg_new:nnnn { chemmacros } { let-iupac } + { + The~ iupac~ naming~ command~ \token_to_str:N #2 \c_space_tl is~ not~ + defined. + } + { + You've~ tried~ to~ let~ the~ iupac~ command~ \token_to_str:N #1 ~ to~ the~ + iupac~ command~ \token_to_str:N #2 ,~ but~ the~ latter~ doesn't~ exist.~ + Use~ \token_to_str:N \NewChemIUPAC \c_space_tl instead~ or~declare~ + \token_to_str:N #2 \c_space_tl first. + } + \msg_new:nnnn { chemmacros } { ox } { \token_to_str:N \ox \c_space_tl : ~ #1 ~ \msg_line_context: . } { \token_to_str:N \ox \c_space_tl : ~ #1 ~ \msg_line_context: . } @@ -305,7 +296,7 @@ properly~ \msg_line_context: . } -\msg_new:nnnn { chemmacros } { declare-state } +\msg_new:nnnn { chemmacros } { new-state } { The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl already~ exists.~ You~ need~ to~ use~ \token_to_str:N \RenewChemState @@ -321,12 +312,12 @@ { The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl isn't~ set~ up~ yet.~ You~ need~ to~ use~ \token_to_str:N - \DeclareChemState \c_space_tl to~ create~ it~ \msg_line_context: . + \NewChemState \c_space_tl to~ create~ it~ \msg_line_context: . } { The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl isn't~ set~ up~ yet.~ You~ need~ to~ use~ \token_to_str:N - \DeclareChemState \c_space_tl to~ create ~it~ \msg_line_context: . + \NewChemState \c_space_tl to~ create ~it~ \msg_line_context: . } \msg_new:nnn { chemmacros } { state-syntax } @@ -338,27 +329,27 @@ % declare an option as deprecated: \cs_new_protected:Npn \chemmacros_option_deprecated:n #1 - { \chemmacros_msg:nnn { chemmacros } { option-deprecated } { #1 } } + { \msg_warning:nnn { chemmacros } { option-deprecated } { #1 } } % define a deprecated command with hints to the corresponding new one: -\cs_new_protected:Npn \chemmacros_define_deprecated:NNn #1#2#3 +\cs_new_protected:Npn \chemmacros_define_deprecated:NN #1#2 { \cs_new_protected:Npn #1 { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } + \msg_warning:nnxx { chemmacros } { command-deprecated } { #1 } { #2 } - #3 + #2 } } -\NewDocumentCommand \DeclareChemDeprecated { mmm } - { \chemmacros_define_deprecated:NNn #1 #2 { #3 } } +\NewDocumentCommand \DeclareChemDeprecated { mm } + { \chemmacros_define_deprecated:NN #1 #2 } % define a command as dropped! \cs_new_protected:Npn \chemmacros_define_dropped:N #1 { \cs_new_protected:Npn #1 - { \chemmacros_msg:nnxx { chemmacros } { command-dropped } { #1 } { } } + { \msg_error:nnn { chemmacros } { command-dropped } { #1 } } } \NewDocumentCommand \DeclareChemDropped { m } @@ -404,20 +395,6 @@ } % -------------------------------------------------------------------------- -% version management: -\tl_const:Nn \c__chemmacros_versions_tl { {one} {three} {four} } - -\cs_new_protected:Npn \chemmacros_set_version:n #1 - { - \tl_map_inline:Nn \c__chemmacros_versions_tl - { - \tl_if_eq:nnTF { #1 } { ##1 } - { \bool_set_true:c { l__chemmacros_version_##1_bool } } - { \bool_set_false:c { l__chemmacros_version_##1_bool } } - } - } - -% -------------------------------------------------------------------------- % package options % circled => circle charges % detect-bold => behaviour when font series bold @@ -429,13 +406,12 @@ % method => use `chemformula' or `mhchem' % strict => errors or warnings % synchronize => let particles et.al. adapt chemformula's font selection -% ugreek => behaviour of \ChemDelta, \Chemalpha, ... +% ugreek => behaviour of \chemDelta, \chemalpha, ... % version=1 => compatibility for documents set with v1.* % xspace => add an \xspace after a whole bunch of macros % this boolean has to be public since the other packages of the bundle may % want to know its value -\bool_new:N \l_chemmacros_strict_bool \bool_new:N \l__chemmacros_detect_bold_bool \bool_set_true:N \l__chemmacros_detect_bold_bool @@ -508,8 +484,8 @@ \bool_set_true:N \l__chemmacros_Nu_mathspec_bool , Nu / chemmacros .code:n = \bool_set_false:N \l__chemmacros_Nu_mathspec_bool , - strict .bool_set:N = \l_chemmacros_strict_bool , - strict .default:n = true , + strict .code:n = + \chemmacros_option_deprecated:n { strict } , synchronize .choice: , synchronize / true .code:n = \cs_set_eq:NN \chemmacros_inner_font: \chemformula_font_inner: , @@ -521,31 +497,32 @@ \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / textgreek .code:n = \chemgreek_activate_mapping:n { textgreek } - \bool_set_true:N \l__chemmacros_option_greek_set_bool, + \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / kpfonts .code:n = \chemgreek_activate_mapping:n { kpfonts } - \bool_set_true:N \l__chemmacros_option_greek_set_bool, - greek / newtx .code:n = + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / newtx .code:n = \chemgreek_activate_mapping:n { newtx } - \bool_set_true:N \l__chemmacros_option_greek_set_bool, + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / mathdesign .code:n = + \chemgreek_activate_mapping:n { mathdesign } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / fourier .code:n = + \chemgreek_activate_mapping:n { fourier } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , + greek / textalpha .code:n = + \chemgreek_activate_mapping:n { textalpha } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / math .code:n = \chemgreek_activate_mapping:n { default } - \bool_set_true:N \l__chemmacros_option_greek_set_bool, + \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / auto .code:n = - \bool_set_false:N \l__chemmacros_option_greek_set_bool, + \bool_set_false:N \l__chemmacros_option_greek_set_bool , greek .default:n = auto , upgreek .code:n = \chemmacros_option_deprecated:n { upgreek } , - % dummy version for compatibility with KOMA's global option and backwards - % compatibility of chemmacros version .code:n = \chemmacros_option_deprecated:n { version } , + cmversion .code:n = \chemmacros_option_deprecated:n { cmversion } , cmversion .choice: , - cmversion / 1 .code:n = \chemmacros_set_version:n { one } , - cmversion / 2 .code:n = \chemmacros_set_version:n { three } , - cmversion / 3 .code:n = \chemmacros_set_version:n { three } , - cmversion / 4 .code:n = \chemmacros_set_version:n { four } , - cmversion / newest .code:n = \chemmacros_set_version:n { four } , - cmversion / bundle .code:n = - \chemmacros_option_deprecated:n { cmversion/bundle } , xspace .bool_set:N = \l__chemmacros_xspace_bool , xspace .default:n = true } @@ -559,38 +536,53 @@ % - is `ghsystem' requested? % - do we need `xspace'? % - what about the greek letters? -\AtEndPreamble + +\seq_new:N \l__chemmacros_greek_packages_seq +\prop_new:N \l__chemmacros_greek_mapping_prop + +\cs_new_protected:Npn \chemmacros_add_greek_package_mapping:nn #1#2 + { + \seq_put_right:Nn \l__chemmacros_greek_packages_seq {#1} + \prop_put:Nnn \l__chemmacros_greek_mapping_prop {#1} {#2} + } + +\cs_generate_variant:Nn \chemgreek_activate_mapping:n { V } + +\cs_new_protected:Npn \__chemmacros_select_greek_mapping:n #1 { - \bool_if:NT \l__chemmacros_ghsystem_bool - { \RequirePackage { ghsystem } } - \bool_if:NT \l__chemmacros_xspace_bool - { \RequirePackage { xspace } } \bool_if:NF \l__chemmacros_option_greek_set_bool { - \@ifpackageloaded { upgreek } - { \bool_set_true:N \l__chemmacros_use_upgreek_bool } + \@ifpackageloaded { #1 } { - \@ifpackageloaded { textgreek } - { \bool_set_true:N \l__chemmacros_use_textgreek_bool } - { - \@ifpackageloaded { kpfonts } - { \bool_set_true:N \l__chemmacros_use_kpfonts_bool } - { - \@ifpackageloaded { newtxmath } - { \bool_set_true:N \l__chemmacros_use_newtx_bool } - { } - } - } + \prop_get:NnN + \l__chemmacros_greek_mapping_prop + { #1 } + \l__chemmacros_tmpa_tl + \chemgreek_activate_mapping:V \l__chemmacros_tmpa_tl + \bool_set_true:N \l__chemmacros_option_greek_set_bool + \seq_map_break: } + { } } - \bool_if:NT \l__chemmacros_use_upgreek_bool - { \chemgreek_activate_mapping:n { upgreek } } - \bool_if:NT \l__chemmacros_use_textgreek_bool - { \chemgreek_activate_mapping:n { textgreek } } - \bool_if:NT \l__chemmacros_use_kpfonts_bool - { \chemgreek_activate_mapping:n { kpfonts } } - \bool_if:NT \l__chemmacros_use_newtx_bool - { \chemgreek_activate_mapping:n { newtx } } + } + +\chemmacros_add_greek_package_mapping:nn {upgreek} {upgreek} +\chemmacros_add_greek_package_mapping:nn {textgreek} {textgreek} +\chemmacros_add_greek_package_mapping:nn {mathdesign} {mathdesign} +\chemmacros_add_greek_package_mapping:nn {kpfonts} {kpfonts} +\chemmacros_add_greek_package_mapping:nn {newtxmath} {newtx} +\chemmacros_add_greek_package_mapping:nn {fourier} {fourier} +\chemmacros_add_greek_package_mapping:nn {textalpha} {textalpha} + +\AtEndPreamble + { + \bool_if:NT \l__chemmacros_ghsystem_bool + { \RequirePackage { ghsystem } } + \bool_if:NT \l__chemmacros_xspace_bool + { \RequirePackage { xspace } } + \seq_map_function:NN + \l__chemmacros_greek_packages_seq + \__chemmacros_select_greek_mapping:n } \cs_new_protected:Npn \chemmacros_xspace: @@ -632,7 +624,7 @@ \cs_new:Npn \chemmacros_remove_backslash:N #1 { \exp_after:wN \use_none:n \token_to_str:N #1 } -\prg_new_conditional:Npnn \chemmacros_if_is_cs:n #1 { T,F,TF } +\prg_new_protected_conditional:Npnn \chemmacros_if_is_cs:n #1 { T,F,TF } { \tl_set:Nx \l__chemmacros_tmpa_tl { \token_if_cs:NTF #1 { } { x } } \tl_if_blank:VTF \l__chemmacros_tmpa_tl @@ -641,7 +633,7 @@ } % detection and handling of bold face: -\prg_new_conditional:Npnn \chemmacros_if_bold: { T,F,TF } +\prg_new_protected_conditional:Npnn \chemmacros_if_bold: { T,F,TF } { \seq_if_in:NVTF \l__chemmacros_if_bf_seq \f@series { \prg_return_true: } @@ -740,21 +732,24 @@ % -------------------------------------------------------------------------- % particles, charges -\NewDocumentCommand \DeclareChemParticle { mm } +\NewDocumentCommand \NewChemParticle { mm } { \cs_if_free:NTF #1 - { \chemmacros_new_particle:Nn #1 { #2 } } - { \chemmacros_msg:nnxx { chemmacros } { declare-particle } { #1 } {} } + { \chemmacros_define_particle:Nn #1 { #2 } } + { \msg_error:nnn { chemmacros } { new-particle } { #1 } } } \NewDocumentCommand \RenewChemParticle { mm } { \cs_if_free:NTF #1 - { \chemmacros_msg:nnxx { chemmacros } { renew-particle } { #1 } {} } - { \chemmacros_new_particle:Nn #1 { #2 } } + { \msg_error:nnn { chemmacros } { renew-particle } { #1 } } + { \chemmacros_define_particle:Nn #1 { #2 } } } -\cs_new_protected:Nn \chemmacros_new_particle:Nn +\NewDocumentCommand \DeclareChemParticle { mm } + { \chemmacros_define_particle:Nn #1 { #2 } } + +\cs_new_protected:Nn \chemmacros_define_particle:Nn { \cs_set_protected:Npn #1 { @@ -763,9 +758,9 @@ } } -\DeclareChemParticle \el { e- } -\DeclareChemParticle \prt { p+ } -\DeclareChemParticle \ntr { n^0 } +\NewChemParticle \el { e- } +\NewChemParticle \prt { p+ } +\NewChemParticle \ntr { n^0 } \DeclareChemDropped \Rad @@ -891,11 +886,11 @@ % -------------------------------------------------------------------------- % ions, molecules % proton, hydroxide, hydronium/oxonium, water, nucleophile, electrophile -\DeclareChemParticle \Hpl { H+ } -\DeclareChemParticle \Hyd { OH- } -\DeclareChemParticle \HtO { H3O+ } -\DeclareChemParticle \El { E+ } -\DeclareChemParticle \water { H2O } +\NewChemParticle \Hpl { H+ } +\NewChemParticle \Hyd { OH- } +\NewChemParticle \HtO { H3O+ } +\NewChemParticle \El { E+ } +\NewChemParticle \water { H2O } \NewDocumentCommand \chemmacros_Nu:w { o } { @@ -939,7 +934,7 @@ % { { \chemmacros_inner_font: #1 \chlewis { 0=| } { \vphantom { #1 } } } } } { - \chemmacros_msg:nnxx { chemmacros } { chemfig } { #1 } {} + \msg_error:nnn { chemmacros } { chemfig } { #1 } \chemmacros_atom:n { #1 } } } @@ -969,12 +964,12 @@ % IUPAC \prop_new:N \l__chemmacros_iupac_prop -\cs_new_protected:Npn \chemmacros_declare_iupac:Nn #1#2 +\cs_new_protected:Npn \chemmacros_new_iupac:Nn #1#2 { \tl_set:Nx \l__chemmacros_tmpa_tl { \chemmacros_remove_backslash:N #1 } \prop_if_in:NVTF \l__chemmacros_iupac_prop \l__chemmacros_tmpa_tl - { \chemmacros_msg:nnxx { chemmacros } { declare-iupac } { #1 } { } } + { \msg_error:nnn { chemmacros } { new-iupac } { #1 } } { \prop_put:NVn \l__chemmacros_iupac_prop \l__chemmacros_tmpa_tl @@ -983,23 +978,59 @@ \chemmacros_make_iupac: } +\cs_new_protected:Npn \chemmacros_define_iupac:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \prop_put:NVn \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + { #2 } + \chemmacros_make_iupac: + } + \cs_new_protected:Npn \chemmacros_renew_iupac:Nn #1#2 { - \tl_set_rescan:Nnn \l__chemmacros_tmpa_tl - { \char_set_catcode_letter:N \\ } - { #1 } - \tl_set:Nf \l__chemmacros_tmpa_tl - { \tl_tail:V \l__chemmacros_tmpa_tl } + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } \prop_if_in:NVTF \l__chemmacros_iupac_prop \l__chemmacros_tmpa_tl { \prop_put:NVn \l__chemmacros_iupac_prop \l__chemmacros_tmpa_tl { #2 } } - { \chemmacros_msg:nnxx { chemmacros } { renew-iupac } { #1 } { } } + { \msg_error:nnn { chemmacros } { renew-iupac } { #1 } } \chemmacros_make_iupac: } +\cs_new_protected:Npn \chemmacros_let_iupac:NN #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \tl_set:Nx \l__chemmacros_tmpb_tl + { \chemmacros_remove_backslash:N #2 } + \prop_get:NVNTF \l__chemmacros_iupac_prop + \l__chemmacros_tmpb_tl + \l__chemmacros_tmpc_tl + { + \prop_put:NVV \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + \l__chemmacros_tmpc_tl + } + { \msg_error:nnnn { chemmacros } { let-iupac } { #1 } { #2 } } + \chemmacros_make_iupac: + } + +\cs_new_protected:Npn \chemmacros_define_deprecated_iupac:NN #1#2 + { + \chemmacros_define_iupac:Nn #1 + { + \msg_warning:nnnn { chemmacros } { command-deprecated } + { #1 } { #2 } + #2 + } + } + + \cs_new_protected:Npn \chemmacros_make_iupac: { \bool_if:NT \l__chemmacros_in_document_bool @@ -1032,11 +1063,20 @@ \AtBeginDocument { \chemmacros_make_iupac: } \NewDocumentCommand \DeclareChemIUPAC { mm } - { \chemmacros_declare_iupac:Nn #1 { #2 } } + { \chemmacros_define_iupac:Nn #1 { #2 } } + +\NewDocumentCommand \NewChemIUPAC { mm } + { \chemmacros_new_iupac:Nn #1 { #2 } } \NewDocumentCommand \RenewChemIUPAC { mm } { \chemmacros_renew_iupac:Nn #1 { #2 } } +\NewDocumentCommand \LetChemIUPAC { mm } + { \chemmacros_let_iupac:NN #1 #2 } + +\NewDocumentCommand \DeprecateChemIUPAC { mm } + { \chemmacros_define_deprecated_iupac:NN #1 #2 } + % stereo descriptors and other nomenclature commands % Cahn-Ingold-Prelog \dim_new:N \l__chemmacros_cip_kern_dim @@ -1051,11 +1091,14 @@ \cs_new_protected:Npn \chemmacros_cip:n #1 { ( \textit{#1} \tex_kern:D \l__chemmacros_cip_kern_dim ) } -\DeclareChemDeprecated \Rcip \R { \cip { R } } -\DeclareChemDeprecated \Scip \S { \cip { S } } +\DeprecateChemIUPAC \Rcip \rectus +\DeprecateChemIUPAC \Scip \sinister -\DeclareChemIUPAC \R { \cip { R } } -\DeclareChemIUPAC \S { \cip { S } } +\NewChemIUPAC \rectus { \cip { R } } +\NewChemIUPAC \sinister { \cip { S } } + +\LetChemIUPAC \R \rectus +\LetChemIUPAC \S \sinister % TikZ needs : to be other \ExplSyntaxOff @@ -1088,35 +1131,41 @@ \NewDocumentCommand \Rconf { O{R} } { \chemmacros@rconf { #1 } } % E(ntgegen)/Z(usammen) -\DeclareChemIUPAC \E { \cip { E } } -\DeclareChemIUPAC \Z { \cip { Z } } +\NewChemIUPAC \entgegen { \cip { E } } +\NewChemIUPAC \zusammen { \cip { Z } } + +\LetChemIUPAC \E \entgegen +\LetChemIUPAC \Z \zusammen % cis/trans -\DeclareChemIUPAC \cis { \textit { cis } } -\DeclareChemIUPAC \trans { \textit { trans } } +\NewChemIUPAC \cis { \textit { cis } } +\NewChemIUPAC \trans { \textit { trans } } % fac/mer -\DeclareChemIUPAC \fac { \textit { fac } } -\DeclareChemIUPAC \mer { \textit { mer } } +\NewChemIUPAC \fac { \textit { fac } } +\NewChemIUPAC \mer { \textit { mer } } % tert -\DeclareChemIUPAC \tert { \textit { tert } } +\NewChemIUPAC \tert { \textit { tert } } % Fischer \DeclareChemDropped \Dfi \DeclareChemDropped \Lfi -\DeclareChemIUPAC \D { \textsc { d } } -\DeclareChemIUPAC \L { \textsc { l } } +\NewChemIUPAC \dexter { \textsc { d } } +\NewChemIUPAC \laevus { \textsc { l } } + +\LetChemIUPAC \D \dexter +\LetChemIUPAC \L \laevus % ortho/meta/para -\DeclareChemIUPAC \ortho { \textit { o } } -\DeclareChemIUPAC \meta { \textit { m } } -\DeclareChemIUPAC \para { \textit { p } } +\NewChemIUPAC \ortho { \textit { o } } +\NewChemIUPAC \meta { \textit { m } } +\NewChemIUPAC \para { \textit { p } } % syn/anti -\DeclareChemIUPAC \syn { \textit { syn } } -\DeclareChemIUPAC \anti { \textit { anti } } +\NewChemIUPAC \syn { \textit { syn } } +\NewChemIUPAC \anti { \textit { anti } } % coordination chemistry \bool_new:N \l__chemmacros_bridge_super_bool @@ -1134,14 +1183,21 @@ \cs_new_protected:Npn \chemformula_hapto:n #1 { - \Chemeta \chemformula_superscript:n { #1 } + \chemeta \chemformula_superscript:n { #1 } + \bool_if:NT \l__chemmacros_coord_use_hyphen_bool + { \chemmacros_break_point_hyphen: } + } + +\cs_new_protected:Npn \chemformula_dento:n #1 + { + \chemkappa \chemformula_superscript:n { #1 } \bool_if:NT \l__chemmacros_coord_use_hyphen_bool { \chemmacros_break_point_hyphen: } } \cs_new_protected:Npn \chemformula_bridge:n #1 { - \Chemmu + \chemmu \tl_if_blank:nF { #1 } { \bool_if:NTF \l__chemmacros_bridge_super_bool @@ -1152,35 +1208,42 @@ { \chemmacros_break_point_hyphen: } } -\DeclareChemIUPAC \hapto { \chemformula_hapto:n } -\DeclareChemIUPAC \bridge { \chemformula_bridge:n } +\NewChemIUPAC \hapto { \chemformula_hapto:n } +\NewChemIUPAC \dento { \chemformula_dento:n } +\NewChemIUPAC \bridge { \chemformula_bridge:n } % attachments to heteroatoms / added hydrogen -\DeclareChemIUPAC \H { \textit { H } } -\DeclareChemIUPAC \O { \textit { O } } -\DeclareChemIUPAC \N { \textit { N } } -\DeclareChemIUPAC \Sf { \textit { S } } -\DeclareChemIUPAC \P { \textit { P } } +\NewChemIUPAC \hydrogen { \textit { H } } +\NewChemIUPAC \oxygen { \textit { O } } +\NewChemIUPAC \nitrogen { \textit { N } } +\NewChemIUPAC \sulfur { \textit { S } } +\NewChemIUPAC \phosphorus { \textit { P } } + +\LetChemIUPAC \H \hydrogen +\LetChemIUPAC \O \oxygen +\LetChemIUPAC \N \nitrogen +\LetChemIUPAC \Sf \sulfur +\LetChemIUPAC \P \phosphorus % language specific settings \AtBeginDocument { \bool_if:NT \l__chemmacros_italian_bool { - \DeclareChemIUPAC \sin { \textit { sin } } - \DeclareChemIUPAC \ter { \textit { ter } } + \NewChemIUPAC \sin { \textit { sin } } + \NewChemIUPAC \ter { \textit { ter } } } } % greek letters -\DeclareChemIUPAC \a { \Chemalpha } -\DeclareChemIUPAC \b { \Chembeta } -\DeclareChemIUPAC \g { \Chemgamma } -\DeclareChemIUPAC \d { \Chemdelta } -\DeclareChemIUPAC \k { \Chemkappa } -\DeclareChemIUPAC \m { \Chemmu } -\DeclareChemIUPAC \n { \Chemeta } -\DeclareChemIUPAC \w { \Chemomega } +\NewChemIUPAC \a { \chemalpha } +\NewChemIUPAC \b { \chembeta } +\NewChemIUPAC \g { \chemgamma } +\NewChemIUPAC \d { \chemdelta } +\NewChemIUPAC \k { \chemkappa } +\NewChemIUPAC \m { \chemmu } +\NewChemIUPAC \n { \chemeta } +\NewChemIUPAC \w { \chemomega } % \iupac (basically the same as bpchem's \IUPAC) % - allows multiple breaking points as compound names can get really long and @@ -1267,7 +1330,7 @@ \prop_new:N \l__chemmacros_latin_prop -\cs_new_protected:Npn \chemmacros_declare_latin:Nn #1#2 +\cs_new_protected:Npn \chemmacros_new_latin:Nn #1#2 { \cs_if_free:NTF #1 { @@ -1275,22 +1338,40 @@ { \chemmacros_latin:n { #2 } \chemmacros_xspace: } \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } } - { \chemmacros_msg:nnxx { chemmacros } { declare-latin } { #1 } { } } + { \msg_error:nnn { chemmacros } { new-latin } { #1 } } + } + +\cs_new_protected:Npn \chemmacros_define_latin:Nn #1#2 + { + \cs_if_free:NTF #1 + { + \cs_new_protected:Npn #1 + { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } + } + { + \cs_set_protected:Npn #1 + { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } + } } \cs_new_protected:Npn \chemmacros_renew_latin:Nn #1#2 { \prop_if_in:NnTF \l__chemmacros_latin_prop { #1 } { \cs_set:Npn #1 { \chemmacros_latin:n { #2 } \chemmacros_xspace: } } - { \chemmacros_msg:nnxx { chemmacros } { renew-latin } { #1 } { } } + { \msg_error:nnn { chemmacros } { renew-latin } { #1 } } } -\NewDocumentCommand \DeclareChemLatin { mm } - { \chemmacros_declare_latin:Nn #1 { #2 } } +\NewDocumentCommand \NewChemLatin { mm } + { \chemmacros_new_latin:Nn #1 { #2 } } \NewDocumentCommand \RenewChemLatin { mm } { \chemmacros_renew_latin:Nn #1 { #2 } } +\NewDocumentCommand \DeclareChemLatin { mm } + { \chemmacros_define_latin:Nn #1 { #2 } } + \AtBeginDocument { \bool_if:NTF \l__chemmacros_chemstyle_bool @@ -1304,9 +1385,9 @@ { \cs_new_eq:NN \latin \chemmacros_latin:n } - \DeclareChemLatin \insitu { in~situ } - \DeclareChemLatin \abinitio { ab~initio } - \DeclareChemLatin \invacuo { in~vacuo } + \NewChemLatin \insitu { in~situ } + \NewChemLatin \abinitio { ab~initio } + \NewChemLatin \invacuo { in~vacuo } } % --------------------------------------------------------------------------- % @@ -1760,9 +1841,7 @@ { \group_begin: \tl_if_blank:nF { #1 } { \__chemmacros_ox_pos_super: } - \bool_if:NTF \l__chemmacros_version_one_bool - { \keys_set:nn { chemmacros / ox } { parse = false } } - { \tl_if_blank:nF { #2 } { \keys_set:nn { chemmacros / ox } { #2 } } } + \keys_set:nn { chemmacros / ox } { #2 } \__chemmacros_ox_write:nn { #3 } { #4 } \group_end: } @@ -1907,23 +1986,22 @@ sep .default:n = { .2em } } -\bool_if:NT \l__chemmacros_version_one_bool - { - \NewDocumentCommand \setredoxdist { m } - { - \tl_if_blank:nTF { #1 } - { \dim_set:Nn \l__chemmacros_redox_dist_dim { .6em } } - { \dim_set:Nn \l__chemmacros_redox_dist_dim { #1 } } - } - } - % --------------------------------------------------------------------------- % % spectroscopy \tl_new:N \g__chemmacros_nmr_isotope_tl \tl_new:N \l__chemmacros_nmr_isotope_default_tl \tl_set:Nn \l__chemmacros_nmr_isotope_default_tl { 1 } \tl_new:N \l__chemmacros_nmr_coupling_nuclei_tl +\tl_new:N \l__chemmacros_nmr_coupling_nuclei_pre_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_pre_tl { ( } +\tl_new:N \l__chemmacros_nmr_coupling_nuclei_post_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_post_tl { ) } \tl_new:N \l__chemmacros_nmr_coupling_bonds_tl +\tl_new:N \l__chemmacros_nmr_coupling_bonds_pre_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_bonds_pre_tl { ( } +\tl_set:Nn \l__chemmacros_nmr_coupling_bonds_post_tl { \! } +\tl_new:N \l__chemmacros_nmr_coupling_symbol_tl +\tl_set:Nn \l__chemmacros_nmr_coupling_symbol_tl { J } \tl_new:N \g__chemmacros_nmr_element_coupled_tl \tl_new:N \g__chemmacros_nmr_element_tl \tl_new:N \l__chemmacros_nmr_element_default_tl @@ -1941,13 +2019,15 @@ \itemsep\z@ \parsep\z@ \itemindent\z@ \leftmargin\z@ } +\tl_new:N \l__chemmacros_nmr_position_tl +\bool_new:N \l__chemmacros_nmr_coupling_nuclei_sub_bool \bool_new:N \l__chemmacros_nmr_frequency_bool \bool_new:N \l__chemmacros_nmr_solvent_bool \bool_new:N \l__chemmacros_nmr_delimiters_bool \bool_new:N \l__chemmacros_nmr_comma_bool \bool_new:N \l__chemmacros_nmr_inner_bool -\bool_new:N \l__chemmacros_nmr_position_sub_bool +\bool_new:N \l__chemmacros_nmr_position_side_bool \bool_new:N \l__chemmacros_nmr_parse_bool \bool_set_true:N \l__chemmacros_nmr_parse_bool \bool_new:N \l__chemmacros_nmr_list_bool @@ -2009,34 +2089,59 @@ \keys_define:nn { chemmacros / nmr } { - unit .tl_set:N = \l__chemmacros_nmr_unit_tl , - unit .default:n = \mega\hertz , - nucleus .code:n = + unit .tl_set:N = \l__chemmacros_nmr_unit_tl , + unit .default:n = \mega\hertz , + nucleus .code:n = { \__chemmacros_nmr_default_nucleus:w #1 \q_stop } , - nucleus .default:n = { 1,H } , - format .tl_set:N = \l__chemmacros_nmr_format_tl , - pos-number .choice: , + nucleus .default:n = { 1,H } , + format .tl_set:N = \l__chemmacros_nmr_format_tl , + pos-number .choice: , pos-number / sub .code:n = - \bool_set_true:N \l__chemmacros_nmr_position_sub_bool , + \tl_set:Nn \l__chemmacros_nmr_position_tl { _ } + \bool_set_false:N \l__chemmacros_nmr_position_side_bool , + pos-number / super .code:n = + \tl_set:Nn \l__chemmacros_nmr_position_tl { ^ } + \bool_set_false:N \l__chemmacros_nmr_position_side_bool , pos-number / side .code:n = - \bool_set_false:N \l__chemmacros_nmr_position_sub_bool , + \tl_set:Nn \l__chemmacros_nmr_position_tl { - } + \bool_set_true:N \l__chemmacros_nmr_position_side_bool , coupling-unit .tl_set:N = \l__chemmacros_nmr_coupling_unit_tl , - parse .bool_set:N = \l__chemmacros_nmr_parse_bool , - delta .code:n = + coupling-pos .choice: , + coupling-pos / sub .code:n = + \bool_set_true:N \l__chemmacros_nmr_coupling_nuclei_sub_bool , + coupling-pos / side .code:n = + \bool_set_false:N \l__chemmacros_nmr_coupling_nuclei_sub_bool , + coupling-nuclei-pre .tl_set:N = + \l__chemmacros_nmr_coupling_nuclei_pre_tl , + coupling-nuclei-post .tl_set:N = + \l__chemmacros_nmr_coupling_nuclei_post_tl , + coupling-bonds-pre .tl_set:N = + \l__chemmacros_nmr_coupling_bonds_pre_tl , + coupling-bonds-post .tl_set:N = + \l__chemmacros_nmr_coupling_bonds_post_tl , + coupling-symbol .tl_set:N = + \l__chemmacros_nmr_coupling_symbol_tl , + parse .bool_set:N = \l__chemmacros_nmr_parse_bool , + delta .code:n = \tl_set:Nn \l__chemmacros_nmr_delta_tl { \, #1 } , - list .bool_set:N = \l__chemmacros_nmr_list_bool , - list .default:n = true , - list-setup .tl_set:N = \l__chemmacros_nmr_list_setup_tl , - use-equal .bool_set:N = \l__chemmacros_nmr_use_equal_bool , - use-equal .default:n = true + list .bool_set:N = \l__chemmacros_nmr_list_bool , + list .default:n = true , + list-setup .tl_set:N = \l__chemmacros_nmr_list_setup_tl , + use-equal .bool_set:N = \l__chemmacros_nmr_use_equal_bool , + use-equal .default:n = true } \prop_new:N \l__chemmacros_nmr_prop -\cs_new_protected:Npn \chemmacros_declare_nmr:Nn #1#2 +\cs_new_protected:Npn \chemmacros_new_nmr:Nn #1#2 { - \prop_if_in:NnTF \l__chemmacros_nmr_prop { #1 } - { \chemmacros_msg:nnxx { chemmacros } { declare-nmr } { #1 } { } } + \bool_if:nTF + { + \prop_if_in_p:Nn \l__chemmacros_nmr_prop { #1 } + || + \cs_if_exist_p:N #1 + } + { \msg_error:nnn { chemmacros } { new-nmr } { #1 } } { \prop_put:Nnn \l__chemmacros_nmr_prop { #1 } { #2 } \NewDocumentCommand #1 { s } @@ -2044,23 +2149,45 @@ } } +\cs_new_protected:Npn \chemmacros_define_nmr:Nn #1#2 + { + \prop_put:Nnn \l__chemmacros_nmr_prop { #1 } { #2 } + \cs_if_exist:NTF #1 + { + \RenewDocumentCommand #1 { s } + { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } + } + { + \NewDocumentCommand #1 { s } + { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } + } + } + \cs_new_protected:Npn \chemmacros_renew_nmr:Nn #1#2 { - \prop_if_in:NnTF \l__chemmacros_nmr_prop { #1 } + \bool_if:nTF + { + \prop_if_in_p:Nn \l__chemmacros_nmr_prop { #1 } + && + \cs_if_exist_p:N #1 + } { \prop_put:Nnn \l__chemmacros_nmr_prop { #1 } { #2 } - \NewDocumentCommand #1 { s } + \RenewDocumentCommand #1 { s } { \IfBooleanTF {##1} { \NMR*{#2} } { \NMR{#2} } } } - { \chemmacros_msg:nnxx { chemmacros } { renew-nmr } { #1 } { } } + { \msg_error:nnn { chemmacros } { renew-nmr } { #1 } } } -\NewDocumentCommand \DeclareChemNMR { mm } - { \chemmacros_declare_nmr:Nn #1 { #2 } } +\NewDocumentCommand \NewChemNMR { mm } + { \chemmacros_new_nmr:Nn #1 { #2 } } \NewDocumentCommand \RenewChemNMR { mm } { \chemmacros_renew_nmr:Nn #1 { #2 } } +\NewDocumentCommand \DeclareChemNMR { mm } + { \chemmacros_define_nmr:Nn #1 { #2 } } + \NewDocumentCommand \NMR { s G{} D(){} O{} } { \IfBooleanTF { #1 } @@ -2214,9 +2341,17 @@ \cs_new_protected:Npn \chemmacros_nmr_position:n #1 { - \bool_if:NTF \l__chemmacros_nmr_position_sub_bool - { \chemmacros_chemformula:x { \g__chemmacros_nmr_element_tl _ #1 } } - { \chemmacros_atom:V \g__chemmacros_nmr_element_tl - #1 } + \chemmacros_chemformula:x + { + \exp_not:V \g__chemmacros_nmr_element_tl + \bool_if:NF \l__chemmacros_nmr_position_side_bool + { + \exp_not:V \l__chemmacros_nmr_position_tl + \exp_not:n { {#1} } + } + } + \bool_if:NT \l__chemmacros_nmr_position_side_bool + { \tl_use:N \l__chemmacros_nmr_position_tl #1 } } \cs_new_protected:Npn \chemmacros_nmr_coupling:w @@ -2230,10 +2365,28 @@ \cs_new_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2) { - \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl { #1 } - \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl { #2 } - \tl_put_right:Nn \l__chemmacros_nmr_coupling_nuclei_tl { ) } - \tl_put_left:Nn \l__chemmacros_nmr_coupling_nuclei_tl { ( } + \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl + { + \l__chemmacros_nmr_coupling_bonds_pre_tl + #1 + \l__chemmacros_nmr_coupling_bonds_post_tl + } + \bool_if:NTF \l__chemmacros_nmr_coupling_nuclei_sub_bool + { + \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl + { + \c_math_subscript_token + { \chemmacros_chemformula:n {#2} } + } + } + { + \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl + { + \l__chemmacros_nmr_coupling_nuclei_pre_tl + \chemmacros_chemformula:n {#2} + \l__chemmacros_nmr_coupling_nuclei_post_tl + } + } \__chemmacros_nmr_coupling_aux_i:w } @@ -2254,7 +2407,8 @@ list-units=single } \( - ^{ \l__chemmacros_nmr_coupling_bonds_tl } J + ^{ \l__chemmacros_nmr_coupling_bonds_tl } + \l__chemmacros_nmr_coupling_symbol_tl \l__chemmacros_nmr_coupling_nuclei_tl = \SIlist{#2}{#1} \) \group_end: @@ -2278,63 +2432,9 @@ } % -------------------------------------------------------------------------- -% placing text below atom/molecule -- only for `mhchem' users or users of -% version 1 -\cs_new_eq:NN \chemmacros_dim_to_width:Nn \chemformula_dim_to_width:Nn - -\bool_new:N \l__chemmacros_mhname_width_bool -\bool_set_false:N \l__chemmacros_mhname_width_bool -\dim_new:N \l__chemmacros_mhname_width_dim - -\tl_new:N \l__chemmacros_mhname_align_tl -\tl_set:Nn \l__chemmacros_mhname_align_tl { \centering } -\tl_new:N \l__chemmacros_mhname_format_tl -\tl_new:N \l__chemmacros_mhname_fontsize_tl -\tl_set:Nn \l__chemmacros_mhname_fontsize_tl { \tiny } - -\keys_define:nn { chemmacros / mhName } - { - align .tl_set:N = \l__chemmacros_mhname_align_tl , - format .tl_set:N = \l__chemmacros_mhname_format_tl , - fontsize .tl_set:N = \l__chemmacros_mhname_fontsize_tl , - width .code:n = - { - \tl_if_eq:nnTF { #1 } { auto } - { \bool_set_false:N \l__chemmacros_mhname_width_bool } - { - \bool_set_true:N \l__chemmacros_mhname_width_bool - \dim_set:Nn \l__chemmacros_mhname_width_dim { #1 } - } - } - } - -% \mhName[<keyval>]{<chemformula>}{<text>} -\bool_if:NF \l__chemmacros_version_one_bool - { - \NewDocumentCommand \mhName { o m m } - { - \group_begin: - \IfNoValueF { #1 } { \keys_set:nn { chemmacros / mhName } { #1 } } - \ensuremath - { - \underset - { - \bool_if:NF \l__chemmacros_mhname_width_bool - { \chemmacros_dim_to_width:Nn \l__chemmacros_mhname_width_dim { #2 } } - \parbox - { \dim_use:N \l__chemmacros_mhname_width_dim } - { - \tl_use:N \l__chemmacros_mhname_align_tl - \tl_use:N \l__chemmacros_mhname_format_tl - \tl_use:N \l__chemmacros_mhname_fontsize_tl - #3 - } - } - { \cf { #2 } } - } - \group_end: - } - } +% deprecated mhName: +\keys_define:nn { chemmacros } + { mhName .code:n = \chemmacros_option_deprecated:n { mhName } } % --------------------------------------------------------------------------- % % - phases @@ -2352,12 +2452,24 @@ space .dim_set:N = \l__chemmacros_phases_space_dim } -\cs_new_protected:Npn \chemmacros_declare_phase:Nn #1#2 +\cs_new_protected:Npn \chemmacros_new_phase:Nn #1#2 { \tl_set:Nx \l__chemmacros_tmpa_tl { \chemmacros_remove_backslash:N #1 } \cs_if_free:NF #1 - { \chemmacros_msg:nnxx { chemmacros } { declare-phase } { #1 } {} } + { \msg_error:nnn { chemmacros } { new-phase } { #1 } } + \DeclareTranslationFallback { phase-\l__chemmacros_tmpa_tl } { #2 } + \__chemmacros_define_phase:Nx #1 + { + \exp_not:N \chemmacros_translate:n + { phase-\l__chemmacros_tmpa_tl } + } + } + +\cs_new_protected:Npn \chemmacros_define_phase:Nn #1#2 + { + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } \DeclareTranslationFallback { phase-\l__chemmacros_tmpa_tl } { #2 } \__chemmacros_define_phase:Nx #1 { @@ -2371,7 +2483,7 @@ \tl_set:Nx \l__chemmacros_tmpa_tl { \chemmacros_remove_backslash:N #1 } \cs_if_free:NT #1 - { \chemmacros_msg:nnxx { chemmacros } { renew-phase } { #1 } {} } + { \msg_error:nnn { chemmacros } { renew-phase } { #1 } } \DeclareTranslationFallback { phase-\l__chemmacros_tmpa_tl } { #2 } \__chemmacros_define_phase:Nx #1 { @@ -2380,8 +2492,11 @@ } } +\NewDocumentCommand \NewChemPhase { mom } + { \chemmacros_new_phase:Nn #1 { #3 } } + \NewDocumentCommand \DeclareChemPhase { mom } - { \chemmacros_declare_phase:Nn #1 { #3 } } + { \chemmacros_define_phase:Nn #1 { #3 } } \NewDocumentCommand \RenewChemPhase { mom } { \chemmacros_renew_phase:Nn #1 { #3 } } @@ -2407,10 +2522,10 @@ } \cs_generate_variant:Nn \__chemmacros_define_phase:Nn { Nx } -\DeclareChemPhase\sld{ s } -\DeclareChemPhase\lqd{ l } -\DeclareChemPhase\gas{ g } -\DeclareChemPhase\aq { aq } +\NewChemPhase\sld{ s } +\NewChemPhase\lqd{ l } +\NewChemPhase\gas{ g } +\NewChemPhase\aq { aq } \cs_new_protected:Npn \chemmacros_phase:n #1 { @@ -2428,12 +2543,6 @@ \NewDocumentCommand \phase { m } { \chemmacros_phase:n { #1 } } -\bool_if:NT \l__chemmacros_version_one_bool - { - \cs_new_eq:NN \solid \sld - \cs_new_eq:NN \liquid \lqd - } - % -------------------------------------------------------------------------- % reaction environments \cs_new_protected:Npn \__chemmacros_record_for_lor:nnnnn #1#2#3#4#5 @@ -2489,10 +2598,10 @@ % define \listofreactions \tl_new:N \l__chemmacros_reaction_lorname_tl \tl_new:N \reactionlistname +\tl_new:N \l__chemmacros_reaction_heading_tl -% TODO: add option \cs_new:Npn \__chemmacros_reaction_heading:n #1 - { \section* { #1 } } + { \l__chemmacros_reaction_heading_tl { #1 } } \cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V } \cs_new_protected:Npn \listofreactions @@ -2505,9 +2614,7 @@ { \@dottedtocline { 1 } { 1.5em } { 2.3em } { #1 } { #2 } } % create tagform -\bool_if:NTF \l__chemmacros_version_one_bool - { \newtagform { CMreaction } { \{ } { \} } } - { \newtagform { reaction } { \{ } { \} } } +\newtagform { reaction } { \{ } { \} } \newcounter { chemmacros_save_reaction } \newcounter { reaction } @@ -2525,9 +2632,7 @@ { \cs_set_eq:NN \p@equation \p@reaction } \setcounter { chemmacros_save_reaction } { \value { equation } } \setcounter { equation } { \value { reaction } } - \bool_if:NTF \l__chemmacros_version_one_bool - { \usetagform { CMreaction } } - { \usetagform { reaction } } + \usetagform { reaction } } % switch back to equation tags @@ -2550,86 +2655,95 @@ list-name .tl_set:N = \reactionlistname , list-entry .code:n = \tl_set:Nn \l__chemmacros_reaction_lorname_tl { #1 } , - list-heading .code:n = - \cs_set:Npn \__chemmacros_reaction_heading:n ##1 { #1 { ##1 } } + list-heading .tl_set:N = \l__chemmacros_reaction_heading_tl } % \DeclareChemReaction[<keyval>]{<name>}{<type>} -\cs_new_protected:Npn \chemmacros_new_reaction:nnn #1#2#3 +\cs_new_protected:Npn \__chemmacros_define_reaction:Nnnn #1#2#3#4 { - \cs_if_exist:cTF { #2 } - { \msg_error:nnx { chemmacros } { already-defined } { #2 } } + \bool_set_false:N \l__chemmacros_reactions_star_bool + \bool_set_false:N \l__chemmacros_reactions_args_bool + \keys_set:nn { chemmacros / reaction } { #2 } + \bool_if:NTF \l__chemmacros_reactions_args_bool { - \bool_set_false:N \l__chemmacros_reactions_star_bool - \bool_set_false:N \l__chemmacros_reactions_args_bool - \keys_set:nn { chemmacros / reaction } { #1 } - \bool_if:NTF \l__chemmacros_reactions_args_bool + #1 { #3 } [ 2 ] [] { - \NewEnviron { #2 } [ 2 ] [] + \__chemmacros_begin_reaction: + \AddRxnDesc { ##1 } + \begin { #4 } { ##2 } + \chemmacros_equation_chemformula:V \BODY + \end{ #4 } + \__chemmacros_end_reaction: + } + \bool_if:NT \l__chemmacros_reactions_star_bool + { + #1 { #3* } [ 1 ] { - \__chemmacros_begin_reaction: - \AddRxnDesc { ##1 } - \begin { #3 } { ##2 } + \begin { #4* } { ##1 } \chemmacros_equation_chemformula:V \BODY - \end{ #3 } - \__chemmacros_end_reaction: - } - \bool_if:NT \l__chemmacros_reactions_star_bool - { - \NewEnviron { #2* } [ 1 ] - { - \begin { #3* } { ##1 } - \chemmacros_equation_chemformula:V \BODY - \end { #3* } - } + \end { #4* } } } + } + { + #1 { #3 } [ 1 ] [] { - \NewEnviron { #2 } [ 1 ] [] + \__chemmacros_begin_reaction: + \AddRxnDesc { ##1 } + \begin { #4 } + \chemmacros_equation_chemformula:V \BODY + \end { #4 } + \__chemmacros_end_reaction: + } + \bool_if:NT \l__chemmacros_reactions_star_bool + { + #1 { #3* } { - \__chemmacros_begin_reaction: - \AddRxnDesc { ##1 } - \begin { #3 } + \begin { #4* } \chemmacros_equation_chemformula:V \BODY - \end { #3 } - \__chemmacros_end_reaction: - } - \bool_if:NT \l__chemmacros_reactions_star_bool - { - \NewEnviron { #2* } - { - \begin { #3* } - \chemmacros_equation_chemformula:V \BODY - \end { #3* } - } + \end { #4* } } } } \ignorespaces } -\bool_if:NF \l__chemmacros_version_one_bool +\cs_new_protected:Npn \chemmacros_define_reaction:nnn #1#2#3 { - \NewDocumentCommand \DeclareChemReaction { o m m } - { - \IfNoValueTF { #1 } - { \chemmacros_new_reaction:nnn { } { #2 } { #3 } } - { \chemmacros_new_reaction:nnn { #1 } { #2 } { #3 } } - } - \DeclareChemDeprecated \newreaction \DeclareChemReaction - { \DeclareChemReaction } + \cs_if_exist:cTF { #2 } + { \__chemmacros_define_reaction:Nnnn \RenewEnviron { #1 } { #2 } { #3 } } + { \__chemmacros_define_reaction:Nnnn \NewEnviron { #1 } { #2 } { #3 } } } +\cs_new_protected:Npn \chemmacros_new_reaction:nnn #1#2#3 + { + \cs_if_exist:cTF { #2 } + { \msg_error:nnx { chemmacros } { already-defined } { #2 } } + { \__chemmacros_define_reaction:Nnnn \NewEnviron { #1 } { #2 } { #3 } } + } + +\cs_new_protected:Npn \chemmacros_renew_reaction:nnn #1#2#3 + { + \cs_if_exist:cTF { #2 } + { \__chemmacros_define_reaction:Nnnn \RenewEnviron { #1 } { #2 } { #3 } } + { \msg_error:nnx { chemmacros } { not-defined } { #2 } } + } + +\NewDocumentCommand \NewChemReaction { O{} m m } + { \chemmacros_new_reaction:nnn { #1 } { #2 } { #3 } } +\NewDocumentCommand \RenewChemReaction { O{} m m } + { \chemmacros_renew_reaction:nnn { #1 } { #2 } { #3 } } +\NewDocumentCommand \DeclareChemReaction { O{} m m } + { \chemmacros_declare_reaction:nnn { #1 } { #2 } { #3 } } +\DeclareChemDeprecated \newreaction \NewChemReaction + \cs_new_protected:Npn \chemmacros_equation_chemformula:n #1 { \chemformula_ch:nn { } { #1 } } \cs_generate_variant:Nn \chemmacros_equation_chemformula:n { V } % predefined: -\bool_if:NF \l__chemmacros_version_one_bool - { - \DeclareChemReaction [ star ] { reaction } { equation } - \DeclareChemReaction [ star ] { reactions } { align } - } +\NewChemReaction [ star ] { reaction } { equation } +\NewChemReaction [ star ] { reactions } { align } % -------------------------------------------------------------------------- % thermodynamics et.al. @@ -2658,7 +2772,7 @@ } \cs_new_protected:Npn \changestate - { \mathop{} \! \ChemDelta } + { \mathop{} \! \chemDelta } % -------------------------------------------------------------------------- % \State @@ -2724,19 +2838,16 @@ } \cs_generate_variant:Nn \chemmacros_state:nnn { xnV } -\bool_if:NF \l__chemmacros_version_one_bool +\NewDocumentCommand \State { s O{} m G{} } { - \NewDocumentCommand \State { s O{} m G{} } - { - \group_begin: - \IfBooleanT { #1 } - { - \keys_set:nn { chemmacros / state } - { subscript-left = false , exponent = } - } - \chemmacros_state:nnn { #2 } { #3 } { #4 } - \group_end: - } + \group_begin: + \IfBooleanT { #1 } + { + \keys_set:nn { chemmacros / state } + { subscript-left = false , exponent = } + } + \chemmacros_state:nnn { #2 } { #3 } { #4 } + \group_end: } % -------------------------------------------------------------------------- @@ -2753,6 +2864,7 @@ \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \changestate } \bool_new:N \l__chemmacros_renewstate_bool +\bool_new:N \l__chemmacros_state_overwrite_error_bool \keys_define:nn { chemmacros } { @@ -2777,45 +2889,58 @@ \l__chemmacros_thermod_delta_default_tl } -\bool_if:NF \l__chemmacros_version_one_bool +% \NewChemState{<name>}[<keyval>]{<symbol>}{<unit>} +\NewDocumentCommand \NewChemState { omO{}mm } { - % \DeclareChemState{<name>}[<keyval>]{<symbol>}{<unit>} - \NewDocumentCommand \DeclareChemState { omO{}mm } - { - \bool_set_false:N \l__chemmacros_renewstate_bool - \__chemmacros_setnewstate_reset: - \IfNoValueTF { #1 } - { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } - { - \chemmacros_msg:nn { chemmacros } { state-syntax } - \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } - } - } - % \RenewChemState{<name>}[<keyval>]{<symbol>}{<unit>} - \NewDocumentCommand \RenewChemState { omO{}mm } + \bool_set_false:N \l__chemmacros_renewstate_bool + \bool_set_true:N \l__chemmacros_state_overwrite_error_bool + \__chemmacros_setnewstate_reset: + \IfNoValueTF { #1 } + { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } { - \bool_set_true:N \l__chemmacros_renewstate_bool - \__chemmacros_setnewstate_reset: - \IfNoValueTF { #1 } - { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } - { - \chemmacros_msg:nn { chemmacros } { state-syntax } - \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } - } + \msg_warning:nn { chemmacros } { state-syntax } + \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } } - \cs_set_protected:Npn \setnewstate + } +% \DeclareChemState{<name>}[<keyval>]{<symbol>}{<unit>} +\NewDocumentCommand \DeclareChemState { omO{}mm } + { + \bool_set_false:N \l__chemmacros_renewstate_bool + \bool_set_false:N \l__chemmacros_state_overwrite_error_bool + \__chemmacros_setnewstate_reset: + \IfNoValueTF { #1 } + { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \setnewstate } { \DeclareChemState } - \DeclareChemState + \msg_warning:nn { chemmacros } { state-syntax } + \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } } - \cs_set_protected:Npn \renewstate + } +% \RenewChemState{<name>}[<keyval>]{<symbol>}{<unit>} +\NewDocumentCommand \RenewChemState { omO{}mm } + { + \bool_set_true:N \l__chemmacros_renewstate_bool + \bool_set_true:N \l__chemmacros_state_overwrite_error_bool + \__chemmacros_setnewstate_reset: + \IfNoValueTF { #1 } + { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } } { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \renewstate } { \RenewChemState } - \RenewChemState + \msg_warning:nn { chemmacros } { state-syntax } + \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 } } } +% TODO +\cs_set_protected:Npn \setnewstate + { + \msg_warning:nnnn { chemmacros } { command-deprecated } + { \setnewstate } { \NewChemState } + \NewChemState + } +\cs_set_protected:Npn \renewstate + { + \msg_warning:nnnn { chemmacros } { command-deprecated } + { \renewstate } { \RenewChemState } + \RenewChemState + } \cs_new_protected:Npn \__chemmacros_setnewstate_reset: { @@ -2831,32 +2956,35 @@ \chemmacros_if_is_cs:nTF { #2 } { \__chemmacros_set_state:xnn { \cs_to_str:N #2 } { #3 } { #4 } } { - \chemmacros_msg:nn { chemmacros } { state-syntax } + \msg_warning:nn { chemmacros } { state-syntax } \__chemmacros_set_state:nnn { #2 } { #3 } { #4 } } } \cs_new_protected:Npn \__chemmacros_set_state:nnn #1#2#3 { - \bool_if:NTF \l__chemmacros_renewstate_bool + \bool_if:NT \l__chemmacros_state_overwrite_error_bool { - \cs_if_exist:cF { #1 } - { \msg_error:nnx { chemmacros } { renew-state } { #1 } } - \cs_undefine:c {chemmacros_ #1 _reset: } - \cs_undefine:c { c__chemmacros_ #1 _subscript_tl } - \cs_undefine:c { c__chemmacros_ #1 _exponent_tl } - \cs_undefine:c { c__chemmacros_ #1 _delta_tl } - \cs_undefine:c { c__chemmacros_ #1 _left_tl } - \cs_undefine:c { c__chemmacros_ #1 _unit_tl } - \cs_undefine:c { #1 } - \cs_undefine:c { #1 _aux_i:n } - \cs_undefine:c { #1 _aux_ii:n } - \cs_undefine:c { #1 _aux_iii:n } - } - { - \cs_if_exist:cT { #1 } - { \msg_error:nnx { chemmacros } { declare-state } { #1 } } + \bool_if:NTF \l__chemmacros_renewstate_bool + { + \cs_if_exist:cF { #1 } + { \msg_error:nnx { chemmacros } { nenew-state } { #1 } } + } + { + \cs_if_exist:cT { #1 } + { \msg_error:nnx { chemmacros } { new-state } { #1 } } + } } + \cs_undefine:c { chemmacros_ #1 _reset: } + \cs_undefine:c { c__chemmacros_ #1 _subscript_tl } + \cs_undefine:c { c__chemmacros_ #1 _exponent_tl } + \cs_undefine:c { c__chemmacros_ #1 _delta_tl } + \cs_undefine:c { c__chemmacros_ #1 _left_tl } + \cs_undefine:c { c__chemmacros_ #1 _unit_tl } + \cs_undefine:c { #1 } + \cs_undefine:c { #1 _aux_i:n } + \cs_undefine:c { #1 _aux_ii:n } + \cs_undefine:c { #1 _aux_iii:n } \group_begin: \tl_const:cV { c__chemmacros_ #1 _subscript_tl } @@ -2953,13 +3081,10 @@ \cs_generate_variant:Nn \__chemmacros_set_state:nnn { x } % predefined: -\bool_if:NF \l__chemmacros_version_one_bool - { - \DeclareChemState \Enthalpy {H} {\kilo\joule\per\mole} - \DeclareChemState \Entropy [ delta=false, subscript-left=false ] - {S} {\joule\per\kelvin\per\mole} - \DeclareChemState \Gibbs {G} {\kilo\joule\per\mole} - } +\NewChemState \Enthalpy {H} {\kilo\joule\per\mole} +\NewChemState \Entropy [ delta=false, subscript-left=false ] + {S} {\joule\per\kelvin\per\mole} +\NewChemState \Gibbs {G} {\kilo\joule\per\mole} % -------------------------------------------------------------------------- % Newman projections @@ -2995,17 +3120,14 @@ } % \newman[<keyval>](<angle>){<1>,<2>,<3>,<4>,<5>,<6>} -\bool_if:NF \l__chemmacros_version_one_bool +\NewDocumentCommand \newman { o d() > { \SplitArgument { 5 } { , } } m } { - \NewDocumentCommand \newman { o d() > { \SplitArgument { 5 } { , } } m } - { - \group_begin: - \IfNoValueF { #1 } { \keys_set:nn { chemmacros / newman } { #1 } } - \IfNoValueTF { #2 } - { \chemmacros_newman_atoms:nnnnnnn { } #3 } - { \chemmacros_newman_atoms:nnnnnnn { #2 } #3 } - \group_end: - } + \group_begin: + \IfNoValueF { #1 } { \keys_set:nn { chemmacros / newman } { #1 } } + \IfNoValueTF { #2 } + { \chemmacros_newman_atoms:nnnnnnn { } #3 } + { \chemmacros_newman_atoms:nnnnnnn { #2 } #3 } + \group_end: } % place atoms: @@ -3783,21 +3905,13 @@ \IfNoValueTF { #1 } { \keys_set:nn { chemmacros } { #2 } } { - \bool_if:NTF \l__chemmacros_version_four_bool - { - \tl_if_eq:nnTF { #1 } { chemformula } - { \setchemformula { #2 } } - { \keys_set:nn { chemmacros / #1 } { #2 } } - } + \tl_if_eq:nnTF { #1 } { chemformula } + { \setchemformula { #2 } } { \keys_set:nn { chemmacros / #1 } { #2 } } } \ignorespaces } -% -------------------------------------------------------------------------- -% load old definitions: -\bool_if:NT \l__chemmacros_version_one_bool - { \file_input:n { chemmacros-version1 . cfg } } % -------------------------------------------------------------------------- % hyperref support @@ -4069,6 +4183,34 @@ Version history and `acid-base/K-water' - adapt \ox to updates in `l3fp' 2014/01/09 - version 4.2e - step bundle version due to changes in `ghsystem' +2014/01/24 - version 4.3 - \NewChemIUPAC, \LetChemIUPAC + - \NewChemParticle + - \NewChemNMR + - \NewChemPhase + - \NewChemReaction, \RenewChemReaction + - \NewChemState + - added macro names with more meaningfule names to + each of the one-letter name commands + - changed behaviour of \DeclareChem to match + \DeclareRobustCommand, i.e., no check if command + is defined; added a \NewChem variant to each that + /does/ check; use \NewChem instead of \DeclareChem + for definitions + - new iupac command \dento + - new option choice `nmr/pos=super' + - bug fix in appearance of coupling nuclei + - new possibilities for formatting the output of the + NMR coupling constants output with \J: + `coupling-pos=side/sub', `coupling-nuclei-pre', + coupling-nuclei-post', `coupling-bonds-pre', + coupling-bonds-post', `coupling-symbol' + - internal changes to the greek letter mapping + selection mechanism + - deprecate package option `strict' + - deprecate package option `cmversion': also all + backwards compatibility for version 1 has been + dropped + - drop command \mhName % --------------------------------------------------------------------------- % % TODO: |