diff options
author | Karl Berry <karl@freefriends.org> | 2015-10-15 21:18:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-10-15 21:18:08 +0000 |
commit | 1a53ed5fef3415d75bf09d6c089f10085113434a (patch) | |
tree | e16e66c5b79962741c8d456729c4bedd8d4c19d5 | |
parent | 4018267c3c2e5466bff0abae9561a686d05da81e (diff) |
chemmacros (15oct15)
git-svn-id: svn://tug.org/texlive/trunk@38649 c570f23f-e606-0410-a88d-b1316a301751
13 files changed, 623 insertions, 126 deletions
diff --git a/Master/texmf-dist/doc/latex/chemmacros/README b/Master/texmf-dist/doc/latex/chemmacros/README index 6df29699053..6780d16b274 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/README +++ b/Master/texmf-dist/doc/latex/chemmacros/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -the CHEMMACROS package v5.1 2015/09/23 +the CHEMMACROS package v5.2 2015/10/14 comprehensive support for typesetting chemistry documents 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 2d244e91c23..083395dcf6e 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 c7c283a6835..f900d35b4d5 100644 --- a/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex +++ b/Master/texmf-dist/doc/latex/chemmacros/chemmacros_en.tex @@ -33,7 +33,7 @@ % -------------------------------------------------------------------------- \documentclass[load-preamble+]{cnltx-doc} \usepackage[utf8]{inputenc} -\usepackage{chemmacros} +\usepackage[compatibility=newest]{chemmacros} \setcnltx{ package = {chemmacros}, info = {comprehensive support for typesetting chemistry documents}, @@ -59,15 +59,15 @@ DeclareChemIUPACShorthand, DeclareChemLatin, DeclareChemNMR, DeclareChemNucleophile, DeclareChemPartialCharge, DeclareChemParticle, DeclareChemPhase, DeclareChemReaction, DeclareChemState, - delm, delp, Delta, Dfi, - el, ElPot, endo, Enthalpy, enthalpy, entropy, + delm, delp, Delta, descter, Dfi, + el, ElPot, endo, entgegen, Enthalpy, enthalpy, entropy, fdelm, fdelp, fmch, fminus, fpch, fplus, fscrm, fscrp, gas, ghs, ghslistall, ghspic, gibbs, gram, hapto, HNMR, Helmholtz, hydrogen, IfChemCompatibilityF, IfChemCompatibilityT, IfChemCompatibilityTF, insitu, invacuo, isotope, iupac, Ka, Kb, Kw, - Lfi, listofreactions, lqd, + laevus, Lfi, listofreactions, lqd, mch, mega, meta, mhName, NewChemArrow, NewChemBond, NewChemBondAlias, newchemgreekmapping, NewChemCharge, NewChemIUPAC, NewChemIUPACShorthand, @@ -90,7 +90,8 @@ ShowChemArrow, ShowChemBond, sld, Sod, state, sulfur, trans, usechemmodule, - val + val, + zusammen } , add-silent-cmds = { addplot, @@ -197,7 +198,6 @@ formula = chemformula , chemformula/format = \libertineLF } -% \setchemformula{format = \libertineLF} \usepackage{siunitx} @@ -408,6 +408,8 @@ } \ExplSyntaxOff +\AtBeginDocument{\renewcommand*\reftextfaraway[1]{from page~\pageref{#1}}} + \begin{document} \part{Preliminaries} @@ -437,7 +439,7 @@ package: \code{\cs*{textit}\Marg{o}-dichlorobenzene}); the first variant in my opinion also is more in the spirit of \LaTeXe. \item As much customizability as I could think of so every user can adapt - the commands to his or her own wishes. Every now an then users have + the commands to his or her own wishes. Every now and then users have wishes which can't be solved with the available options. Almost always I'll add options then. If you find something please contact me, see section~\vref{sec:sugg-bug-reports}. @@ -494,7 +496,7 @@ an alphabetical order. \subsection{Using \chemmacros' Options}\label{sec:using-chemm-opti} Prior to v5.0 \chemmacros\ had quite a number of package options. -\chemmacros\ v5.0 or higher has none! All of \chemmacros's options are set +\chemmacros\ v5.0 or higher has none! All of \chemmacros' options are set using the command \begin{commands} \command{chemsetup}[\oarg{module}\marg{option list}] @@ -600,7 +602,7 @@ important and \emph{breaking} differences: It is actually not true that \chemmacros' has no package options any more. It has one very important package option: \begin{options} - \keyval{compatibility}{num}\Default{\chemmacrosversion} + \keychoice{compatibility}{\meta{num},newest,latest}\Default{\chemmacrosversion} Let's you specify the version number of \chemmacros\ you want to use. Any version earlier than 5.0 will load v4.7. \ie, the last version before \chemmacros\ got its modular structure\footnote{Mostly: the loaded v4.7 @@ -608,6 +610,9 @@ has one very important package option: version. Please note that you only can specify the \emph{number} of the version. For a version \enquote{5.2c} you can only set compatibility mode \enquote{5.2} but not specify the subrelease. + + Both values \code{newest} and \code{latest} will choose the latest version + available. \end{options} In your document you can check for the compatibility mode. For the following @@ -932,11 +937,11 @@ also loads the package \pkg{scrlfile} which is part of the Similar to the \pkg{bpchem} package~\cite{pkg:bpchem} \chemmacros\ provides a command\footnote{The idea and initial implementation is shamelessly borrowed - from \pkg{bpchem} by \pedersen.} to typeset \ac{iupac} names. Why is that -useful? \ac{iupac} names can get very long. So long indeed that they span -over more than two lines, especially in two-column documents. This means they -must be allowed to be broken more than one time. This is what the following -command does. + from \pkg{bpchem} by \pedersen.} for typesetting \ac{iupac} names. Why is +that useful? \ac{iupac} names can get very long. So long indeed that they +span over more than two lines, especially in two-column documents. This means +they must be allowed to be broken more than one time. This is what the +following command does. \begin{commands} \command{iupac}[\marg{IUPAC name}] Inside this command use \sym{\textbar} indicate a breaking point @@ -974,7 +979,8 @@ and \cs*{textsuperscript} instead of \sym{\textasciicircum} without 2,4-Dichlorpentan \end{example} -The spaces inserted by \sym{-} and \sym{\textbar} can be customized. +The spaces inserted by \sym{-} and \sym{\textbar} can be +customized. \begin{options} \keyval{hyphen-pre-space}{dim}\Module{nomenclature}\Default{.01em} Set the space that is inserted before the hyphen set with \sym{-}. @@ -1117,7 +1123,8 @@ most common ones. \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} + Typeset Cahn-Ingol-Prelog descriptors, \eg: \cs{cip}\Marg{R,S} + \cip{R,S}. \meta{conf} may be a csv list of entries. \command{rectus}[\quad\iupac{\rectus}] Typeset rectus descriptor. (An alias for this command is \cs{R}.) \command{sinister}[\quad\iupac{\sinister}] @@ -1525,8 +1532,8 @@ some tools which can (and should) be used in other modules. This means this section is only interesting for you if you plan to write a module yourself (see section~\vref{sec:own-modules} for details). -This module requires the packages \pkg{bm}~\cite{pkg:bm} and -\pkg{amstext}~\cite{pkg:amstext}. +This module requires the packages \pkg{bm}~\cite{pkg:bm}, +\pkg{amstext}~\cite{pkg:amstext}, and \pkg{etoolbox}~\cite{pkg:etoolbox}. This module also provides \cs{chemsetup} and the option \option{modules}. @@ -1619,8 +1626,9 @@ The following macros strictly speaking are not provided by the \subsection{The \chemmodule*{chemformula} Module}\label{sec:chemformula-module} The \chemmodule{chemformula} module loads the \pkg{chemformula} -package~\cite{pkg:chemformula} and the \pkg{amstext} -package~\cite{pkg:amstext}. It also loads the \chemmodule{charges} module. +package~\cite{pkg:chemformula} or the \pkg{mhchem} package~\cite{pkg:mhchem} +and the \pkg{amstext} package~\cite{pkg:amstext}. It also loads the +\chemmodule{charges} module. \subsubsection{For Users} @@ -1634,6 +1642,12 @@ This module provides a general option: If you explicitly set this option the corresponding package is loaded immediately. Otherwise the option is set at the end of the preamble. +If\sinceversion{5.2} you load either \pkg{mhchem} or \pkg{chemformula} and +haven't set \option{formula} \chemmacros\ will choose the corresponding +package. If you have loaded both \pkg{mhchem} and \pkg{chemformula} +\chemmacros\ will raise a warning and choose \pkg{chemformula}. \emph{All + automatic choices only happen at the end of the preamble}. + \paragraph{Using the \pkg*{chemformula} Package} If you set \keyis{formula}{chemformula} the \chemmodule{chemformula} module makes it possible that you can set all \chemformula\ options via the @@ -1680,17 +1694,22 @@ There's are two macros for module writers: \command*{chemmacros_chemformula:n}[ \marg{formula}] This is only a wrapper for \cs{chcpd} or \cs{ce}. It is recommended that module writers use this macro (or a variant thereof) inside of - \chemmacros's macros whenever they want to display a chemical formula. + \chemmacros' macros whenever they want to display a chemical formula. Writers who prefer traditional \LaTeXe\ programming over expl3 should use \cs*{chemmacros@formula}. \command*{chemmacros_reaction:n}[ \marg{reaction}] This is only a wrapper for \cs{ch} or \cs{ce}. It is recommended that module writers use this macro (or a variant thereof) inside of - \chemmacros's macros whenever they want to display a chemical reaction. + \chemmacros' macros whenever they want to display a chemical reaction. Writers who prefer traditional \LaTeXe\ programming over expl3 should use \cs*{chemmacros@reaction}. \end{commands} +\subsection{The \chemmodule*{errorcheck} Module}\label{sec:errorcheck-module} +The\sinceversion{5.2} \chemmodule{errorcheck} module provides some rudimentary +support for giving users more meaningful messages when they use a command or +environment provided by a module that they haven't loaded. + \subsection{The \chemmodule*{greek} Module}\label{sec:greek-module} The \chemmodule{greek} module loads the \pkg{chemgreek} @@ -1767,7 +1786,7 @@ in the preamble: This command can only be used in the preamble and is defined by the \pkg{translations} package. \end{commands} -f you send me an email (see section~\vref{sec:sugg-bug-reports}) with the +If you send me an email (see section~\vref{sec:sugg-bug-reports}) with the translations for your language I'll gladly add them to the next release of \chemmacros! @@ -1808,7 +1827,7 @@ translations for your language I'll gladly add them to the next release of \begin{commands} \expandable\command*{chemmacros_translate:n}[ \marg{translation key}] Translates the given key to the language which is detected automatically - or given by the user. Should be used in \chemmacros's macros instead of + or given by the user. Should be used in \chemmacros' macros instead of \pkg{translations}' \cs*{GetTranslation}. \command*{l_chemmacros_language_tl} A token list variable that holds the language which is used by @@ -2073,22 +2092,32 @@ You can use these environments for numbered\ldots \begin{environments} \environment{reaction} A single reaction where \chemformula\ code is placed directly in the - environment body. A wrapper around the \env*{equation} environment. + environment body. A wrapper around the \env*{equation} environment. The + environment body is parsed with \cs{ch} or \cs{ce} depending on the value + of the \option{formula} option, see + section~\vref{sec:chemformula-module}. \environment{reactions} Several aligned reactions. A wrapper around \pkg{amsmath}'s \env*{align} - environment. + environment. The environment body is parsed with \cs{ch} or \cs{ce} + depending on the value of the \option{formula} option, see + section~\vref{sec:chemformula-module}. \end{environments} \ldots and their starred versions for unnumbered reactions. \begin{environments} \environment{reaction*} - A wrapper around the \env*{equation*} environment. + A wrapper around the \env*{equation*} environment. The environment body + is parsed with \cs{ch} or \cs{ce} depending on the value of the + \option{formula} option, see section~\vref{sec:chemformula-module}. \environment{reactions*} - A wrapper around \pkg{amsmath}'s \env*{align*} environment. + A wrapper around \pkg{amsmath}'s \env*{align*} environment. The + environment body is parsed with \cs{ch} or \cs{ce} depending on the value + of the \option{formula} option, see + section~\vref{sec:chemformula-module}. \end{environments} -With them you can create (un)numbered reaction equations similar to -mathematical equations. +With those environments you can create (un)numbered reaction equations similar +to mathematical equations. Theses environments use the \env*{equation}/\env*{equation*} environments or the \env*{align}/\env*{align*} environments, respectively, to display the @@ -2213,13 +2242,19 @@ the reactions created with the \env{reaction} environment. The output of this list can be modified by two options: \begin{options} - \keyval{list-name}{name of the list}\Module{reaction}\Default{List of - reactions} + \keyval{list-name}{name of the + list}\Module{reactions}\Default{\cs*{ChemTranslate}\Marg{{list-of-reactions}}} Let's you set the name of the list manually. The default name is language dependent, see section~\vref{sec:lang-module}. - \keyval{list-entry}{prefix to each entry}\Module{reaction}\Default{Reaction} + \keyval{list-entry}{prefix to each + entry}\Module{reactions}\Default{\cs*{ChemTranslate}\Marg{reaction}} Let's you set a prefix to each list entry. The default name is language dependent, see section~\vref{sec:lang-module}. + \keyval{list-heading-cmd}{code}\Module{reactions}\Default{\cs*{section}\sarg\Marg{\#1}} + The\sinceversion{5.2} macro that is called at the beginning of the list. + Inside of \meta{code} \code{\#1} refers to the actual heading of the list. + The default setting is not entirely true: if a macro \cs*{chapter} is + defined \code{\cs*{chapter}\sarg\Marg{\#1}} is used. \end{options} Instead of using the option \option{list-name} you also could redefine \cs{reactionlistname}. @@ -3241,6 +3276,15 @@ be a file in a path where \TeX\ can find it following a certain naming scheme. The file for a module \chemmodule*{foo} \emph{must be named} \code{chemmacros.module.foo.code.tex}. +\begin{commands} + \command{ChemModule}[\sarg\marg{name}\marg{description}\oarg{minimal + compatibility version}] + Register module \meta{name}. The optional argument \meta{minimal + compatibility version} ensures that this module is only loaded if the + option \option{compatibility} has a high enough version number. If it is + omitted the module can be loaded in each version~5.0 or higher. +\end{commands} + The first line in the file then should look similar to this: \begin{sourcecode} \ChemModule{foo}{2015/07/14 description of foo} @@ -3256,6 +3300,14 @@ module using traditional \LaTeXe\ methods then use the starred variant: \end{sourcecode} In both variants \code{@} has category code~11 (letter). +Since new modules very likely might rely on code provided first in a certain +version of \chemmacros\ you might want to make sure that your module only is +loaded when the compatibility mode is high enough to provide the features you +want: +\begin{sourcecode} + \ChemModule{foo}{2015/10/14 description of foo}[5.2] +\end{sourcecode} + You should be aware that your module \emph{will not be loaded} with \verbcode+\usechemmodule{all}+! The pseudo-module \chemmodule{all} contains a manually maintained list of the modules that are loaded by it. diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.all.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.all.code.tex index 53226a9aa90..d9b655351ee 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.all.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.all.code.tex @@ -25,11 +25,21 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{all}{2015/06/09 load all libraries} +\ChemModule{all}{2015/10/14 load all libraries} + +\msg_new:nnn {chemmacros} {all-modules} + { + You~ are~ loading~ *all*~ of~ chemmacros'~ module~ through~ the~ `all'~ + module!~ This~ is~ fine~ but~ not~ really~ encouraged.~ Do~ really~ need~ + all~ of~ `isotopes' ,~ `mechanisms' ,~ `newman' ,~ `nomenclature' ,~ + `orbital' ,~ `particles' ,~ `phases' ,~ `reactions' ,~ `redox' ,~ `scheme' + ,~ `spectroscopy' ,~ `symbols' ,~ `thermodynamics' ,~ `units' ...? + } \chemmacros_load_modules:n { base , + errorcheck , lang , greek , chemformula , @@ -53,4 +63,10 @@ xfrac } +\msg_info:nn {chemmacros} {all-modules} + % -------------------------------------------------------------------------- +\tex_endinput:D + +2015/10/14 - add info message discouraging the usage of this module + - add `errorcheck' module diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex index d8a65a0096a..3bb594156c2 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.base.code.tex @@ -25,7 +25,12 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{base}{2015/07/25 basic chemmacros module} +\ChemModule{base}{2015/10/14 basic chemmacros module} + +% for the document hooks +\ChemCompatibilityFrom{5.1} +\RequirePackage {etoolbox} +\EndChemCompatibility % -------------------------------------------------------------------------- \msg_new:nnn {chemmacros} {command-deprecated} @@ -171,14 +176,36 @@ { \prg_return_false: } } +\ChemCompatibilityFrom{5.2} +% this is still true \AtBeginDocument: +\prg_new_conditional:Npnn \chemmacros_if_preamble: {p,T,F,TF} + { + \cs_if_eq:NNTF \@onlypreamble \@notprerr + { \prg_return_false: } + { \prg_return_true: } + } + +% this is still false \AtBeginDocument: +\prg_new_conditional:Npnn \chemmacros_if_document: {p,T,F,TF} + { + \bool_if:NTF \l__chemmacros_in_document_bool + { \prg_return_true: } + { \prg_return_false: } + } +\EndChemCompatibility + % -------------------------------------------------------------------------- % some checks at begin document: \bool_new:N \l__chemmacros_in_document_bool \bool_new:N \l__chemmacros_chemstyle_bool +\chemmacros_if_compatiblity:nnTF {>=} {5.2} + { \AfterEndPreamble } + { \AtBeginDocument } + { \bool_set_true:N \l__chemmacros_in_document_bool } + \AtBeginDocument { - \bool_set_true:N \l__chemmacros_in_document_bool \@ifpackageloaded { chemstyle } { \bool_set_true:N \l__chemmacros_chemstyle_bool } { \bool_set_false:N \l__chemmacros_chemstyle_bool } @@ -270,3 +297,13 @@ % -------------------------------------------------------------------------- +\chemmacros_if_compatiblity:nnT {>=} {5.2} + { \chemmacros_load_module:n {errorcheck} } + +% -------------------------------------------------------------------------- + +\tex_endinput:D + +2015/09/23 - new conditionals \chemmacros_if_preamble:TF and + \chemmacros_if_document:TF +2015/10/14 - load `errorcheck' module diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex index d785ce6c795..7ab4116182b 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.chemformula.code.tex @@ -25,7 +25,7 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{chemformula}{2015/09/19 integration of chemical formulas} +\ChemModule{chemformula}{2015/10/13 integration of chemical formulas} \RequirePackage{amstext} \chemmacros_load_module:n {charges} @@ -37,6 +37,19 @@ I'm~ falling~ back~ to~ `chemformula'~ now. } +\msg_new:nnn {chemmacros} {default-formula-method} + { + You~ haven't~ chosen~ a~ formula~ method~ so~ I'm~ assuming~ the~ default~ + method~ `chemformula'. + } + +\msg_new:nnn {chemmacros} {formula-conflict} + { + You~ have~ loaded~ both~ `mhchem'~ and~ `chemformula'!~ You~ should~ + decide~ for~ only~ one~ of~ both~ packages~ for~ having~ a~ consistent~ + layout.~ I~ will~ use~ `chemformula'. + } + \bool_new:N \l__chemmacros_formula_method_set_bool \tl_new:N \g_chemmacros_formula_method_tl @@ -44,31 +57,34 @@ \cs_new_protected:Npn \chemmacros_set_formula_method:n #1 { - \str_case:nnTF {#1} + \bool_if:NF \l__chemmacros_formula_method_set_bool { - {chemformula} { - \chemmacros_integrate_package:nnn {} {chemformula} {2015/09/08} - \tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula} - } - {mhchem} { - \chemmacros_integrate_package:nnn {version=4} {mhchem} {} - \cs_set_protected:Npn \chemmacros_chemformula:n ##1 { \ce {##1} } - \cs_set_protected:Npn \chemmacros_reaction:n ##1 { \ce {##1} } - \chemmacros_after_module:nn {charges} - { - \cs_set_protected:Npn \chemmacros_elpair:n ##1 { \ce{##1} : } - \cs_set_protected:Npn \chemmacros_plus: { + } - \cs_set_protected:Npn \chemmacros_minus: { - } - \cs_set_protected:Npn \chemmacros_formal_plus: { \ensuremath{\oplus} } - \cs_set_protected:Npn \chemmacros_formal_minus: { \ensuremath{\ominus} } - \cs_set_protected:Npn \fplus { \ensuremath{\oplus} } - \cs_set_protected:Npn \fminus { \ensuremath{\ominus} } + \str_case:nnTF {#1} + { + {chemformula} { + \chemmacros_integrate_package:nnn {} {chemformula} {2015/09/08} + \tl_gset:Nn \g_chemmacros_formula_method_tl {chemformula} + } + {mhchem} { + \chemmacros_integrate_package:nnn {version=4} {mhchem} {} + \cs_set_protected:Npn \chemmacros_chemformula:n ##1 { \ce {##1} } + \cs_set_protected:Npn \chemmacros_reaction:n ##1 { \ce {##1} } + \chemmacros_after_module:nn {charges} + { + \cs_set_protected:Npn \chemmacros_elpair:n ##1 { \ce{##1} : } + \cs_set_protected:Npn \chemmacros_plus: { + } + \cs_set_protected:Npn \chemmacros_minus: { - } + \cs_set_protected:Npn \chemmacros_formal_plus: { \ensuremath{\oplus} } + \cs_set_protected:Npn \chemmacros_formal_minus: { \ensuremath{\ominus} } + \cs_set_protected:Npn \fplus { \ensuremath{\oplus} } + \cs_set_protected:Npn \fminus { \ensuremath{\ominus} } + } + \tl_gset:Nn \g_chemmacros_formula_method_tl {mhchem} } - \tl_gset:Nn \g_chemmacros_formula_method_tl {mhchem} - } + } + { \bool_set_true:N \l__chemmacros_formula_method_set_bool } + { \bool_set_false:N \l__chemmacros_formula_method_set_bool } } - { \bool_set_true:N \l__chemmacros_formula_method_set_bool } - { \bool_set_false:N \l__chemmacros_formula_method_set_bool } } \cs_generate_variant:Nn \chemmacros_set_formula_method:n {V} @@ -81,11 +97,15 @@ \cs_new_protected:Npn \chemmacros_reaction:n #1 { \chemformula_ch:nn {} {#1} } -% for module writes prefering traditional 2e programming: +% for module writers prefering traditional 2e programming: \cs_new_protected:Npn \chemmacros@formula #1 { \chemmacros_chemformula:n {#1} } \cs_new_protected:Npn \chemmacros@reaction #1 { \chemmacros_reaction:n {#1} } % -------------------------------------------------------------------------- +\ChemCompatibilityTo{5.0} +\chemmacros_set_formula_method:n {chemformula} +\EndChemCompatibility + \ChemCompatibilityFrom{5.1} \keys_define:nn {chemmacros} { @@ -98,10 +118,43 @@ } \EndChemCompatibility +\cs_new_protected:Npn \chemmacros_check_formula_method: + { + \bool_if:nTF + { + \chemmacros_if_package_loaded_p:n {chemformula} && + \chemmacros_if_package_loaded_p:n {mhchem} && + } + { + \msg_warning:nn {chemmacros} {formula-conflict} + \bool_if:NF \l__chemmacros_formula_method_set_bool + { + \msg_info:nn {chemmacros} {default-formula-method} + \chemmacros_set_formula_method:n {chemformula} + } + } + { + \chemmacros_if_package_loaded:nTF {mhchem} + { \chemmacros_set_formula_method:n {mhchem} } + { + \chemmacros_if_package_loaded:nF {chemformula} + { \msg_info:nn {chemmacros} {default-formula-method} } + \chemmacros_set_formula_method:n {chemformula} + } + } + } + \AtEndPreamble { \bool_if:NF \l__chemmacros_formula_method_set_bool - { \chemmacros_set_formula_method:V \g_chemmacros_formula_method_tl } + { + \chemmacros_if_compatiblity:nnTF {>=} {5.2} + { \chemmacros_check_formula_method: } + { + \msg_info:nn {chemmacros} {default-formula-method} + \chemmacros_set_formula_method:V \g_chemmacros_formula_method_tl + } + } } % -------------------------------------------------------------------------- @@ -109,4 +162,6 @@ 2015/09/22 - new general option `method' which allows a choice between `chemformula' and `mhchem' - +2015/10/13 - add missing compatibility definitions + - check for `mhchem' and `chemformula' and set method accordingly + if possible diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.errorcheck.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.errorcheck.code.tex new file mode 100644 index 00000000000..70879c15e24 --- /dev/null +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.errorcheck.code.tex @@ -0,0 +1,115 @@ +% -------------------------------------------------------------------------- +% +% the CHEMMACROS package -- module: `errorcheck' +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% -------------------------------------------------------------------------- +% https://github.org/cgnieder/chemmacros/ +% contact@mychemistry.eu +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +% Copyright 2011-2015 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. +% -------------------------------------------------------------------------- +\ChemModule{errorcheck}{2015/10/14 error checking for unloaded modules}[5.2] + +\msg_new:nnn {chemmacros} {undefined} + { The~ #1~ `#2'~ is~ undefined.~ You~ need~ to~ load~ the~ `#3'~ module. } + +\cs_generate_variant:Nn \msg_error:nnnnn {nnnx} + +\cs_new_protected:Npn \chemmacros_command_requires_module:Nn #1#2 + { + \chemmacros_if_module_loaded:nF {#2} + { + \cs_set:Npn #1 + { + \msg_error:nnnxn {chemmacros} {undefined} + {command} + { \token_to_str:N #1 } + {#2} + } + } + \chemmacros_before_module:nn {#2} { \cs_undefine:N #1 } + } + +\cs_new_protected:Npn \chemmacros_environment_requires_module:nn #1#2 + { + \chemmacros_if_module_loaded:nF {#2} + { + \cs_set:cpn {#1} + { + \msg_error:nnnnn {chemmacros} {undefined} + {environment} + {#1} + {#2} + } + } + \chemmacros_before_module:nn {#2} { \cs_undefine:c {#1} } + } + +% -------------------------------------------------------------------------- +% add checking for the most common user commands and environments: +% isotopes module +\chemmacros_command_requires_module:Nn \isotope {isotopes} + +% mechanisms module +\chemmacros_command_requires_module:Nn \mech {mechanisms} + +% newman module +\chemmacros_command_requires_module:Nn \newman {newman} + +% orbital module +\chemmacros_command_requires_module:Nn \orbital {orbital} + +% reactions module +\chemmacros_environment_requires_module:nn {reaction} {reactions} +\chemmacros_environment_requires_module:nn {reaction*} {reactions} +\chemmacros_environment_requires_module:nn {reactions} {reactions} +\chemmacros_environment_requires_module:nn {reactions*} {reactions} +\chemmacros_command_requires_module:Nn \listofreactions {reactions} +\chemmacros_command_requires_module:Nn \AddRxnDesc {reactions} + +% redox module +\chemmacros_command_requires_module:Nn \ox {redox} +\chemmacros_command_requires_module:Nn \OX {redox} +\chemmacros_command_requires_module:Nn \redox {redox} + +% scheme module +\chemmacros_environment_requires_module:nn {scheme} {scheme} +\chemmacros_command_requires_module:Nn \listschemename {scheme} +\chemmacros_command_requires_module:Nn \schemename {scheme} +\chemmacros_command_requires_module:Nn \listofschemes {scheme} + +% spectroscopy module +\chemmacros_command_requires_module:Nn \NMR {spectroscopy} +\chemmacros_environment_requires_module:nn {experimental} {spectroscopy} + +% thermodynamics module +\chemmacros_command_requires_module:Nn \state {thermodynamics} +\chemmacros_command_requires_module:Nn \enthalpy {thermodynamics} +\chemmacros_command_requires_module:Nn \entropy {thermodynamics} +\chemmacros_command_requires_module:Nn \gibbs {thermodynamics} + +% xfrac module +\chemmacros_command_requires_module:Nn \chemfrac {xfrac} + +% -------------------------------------------------------------------------- + +\tex_endinput:D + +2015/10/14 - first version diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex index c13f3b10ded..ec941e31bd2 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.nomenclature.code.tex @@ -25,7 +25,7 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{nomenclature}{2015/09/09 chemical names} +\ChemModule{nomenclature}{2015/09/23 chemical names} \RequirePackage{scrlfile} @@ -141,6 +141,7 @@ \chemmacros_make_iupac: } +\ChemCompatibilityTo{5.1} \cs_new_protected:Npn \chemmacros_make_iupac: { \bool_if:NT \l__chemmacros_in_document_bool @@ -169,8 +170,40 @@ } } } - \AtBeginDocument { \chemmacros_make_iupac: } +\EndChemCompatibility + +\ChemCompatibilityFrom{5.2} +\cs_new_protected:Npn \chemmacros_make_iupac: + { + \chemmacros_if_document:T + { + \bool_if:NTF \l__chemmacros_inside_iupac_bool + { + \prop_map_inline:Nn \l__chemmacros_iupac_prop + { \cs_set_protected:cpn {##1} {##2} } + } + { + \bool_if:NF \l__chemmacros_iupac_restricted_bool + { + \bool_if:NTF \l__chemmacros_iupac_strict_bool + { + \prop_map_inline:Nn \l__chemmacros_iupac_prop + { \cs_set_protected:cpn {##1} {##2} } + } + { + \prop_map_inline:Nn \l__chemmacros_iupac_prop + { + \cs_if_exist:cF {##1} + { \cs_set_protected:cpn {##1} {##2} } + } + } + } + } + } + } +\AfterEndPreamble { \chemmacros_make_iupac: } +\EndChemCompatibility \NewDocumentCommand \DeclareChemIUPAC { mm } { \chemmacros_define_iupac:Nn #1 { #2 } } @@ -209,11 +242,33 @@ \keys_define:nn {chemmacros/nomenclature} { cip-kern .dim_set:N = \l__chemmacros_cip_kern_dim } +\ChemCompatibilityTo{5.1} +\cs_new_protected:Npn \chemmacros_cip:n #1 + { \textit{#1} \tex_kern:D \l__chemmacros_cip_kern_dim } + \NewDocumentCommand \cip { m } { \chemmacros_cip:n { #1 } } +\EndChemCompatibility +\ChemCompatibilityFrom{5.2} \cs_new_protected:Npn \chemmacros_cip:n #1 - { ( \textit{#1} \tex_kern:D \l__chemmacros_cip_kern_dim ) } + { + \int_zero:N \l__chemmacros_tmpa_int + \textup{(} + \clist_map_inline:nn + {#1} + { + \int_incr:N \l__chemmacros_tmpa_int + \textit{##1} + \int_compare:nT + { \l__chemmacros_tmpa_int < \clist_count:n {#1} } + { \textup{,} } + } + \textup{)} + \tex_kern:D \l__chemmacros_cip_kern_dim + } +\DeclareChemIUPAC \cip { \chemmacros_cip:n } +\EndChemCompatibility % remember: TikZ needs : to be other \cs_new_protected:Npn \chemmacros_sconf:n #1 @@ -300,6 +355,32 @@ \skip_horizontal:N \c_zero_dim } +% #1: pre break +% #2: post break +% #3: no break +\ChemCompatibilityTo{5.0} +\cs_new_protected:Npn \__chemmacros_break_point_insert:nnn #1#2#3 + { + \chemmacros_nobreak: + \tex_discretionary:D { - } { } {#3} + \chemmacros_allow_hyphens: + } +\EndChemCompatibility + +\ChemCompatibilityFrom{5.1} +\cs_new_protected:Npn \__chemmacros_break_point_insert:nnn #1#2#3 + { + \mode_if_math:TF + {#3} + { + \chemmacros_nobreak: + \tex_discretionary:D {#1} {#2} {#3} + \chemmacros_allow_hyphens: + } + } +\EndChemCompatibility + + \dim_new:N \l__chemmacros_iupac_hyphen_pre_dim \dim_set:Nn \l__chemmacros_iupac_hyphen_pre_dim { .01em } \dim_new:N \l__chemmacros_iupac_hyphen_post_dim @@ -314,25 +395,39 @@ break-space .dim_set:N = \l__chemmacros_iupac_break_dim } -% #1: pre break -% #2: post break -% #3: no break -\cs_new_protected:Npn \__chemmacros_break_point_insert:nnn #1#2#3 +\ChemCompatibilityTo{5.1} +\cs_new_protected:Npn \chemmacros_break_point_hyphen: { - \mode_if_math:TF - {#3} + \__chemmacros_break_point_insert:nnn + {-} + { } { - \chemmacros_nobreak: - \tex_discretionary:D {#1} {#2} {#3} - \chemmacros_allow_hyphens: + \tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim + - + \tex_kern:D \l__chemmacros_iupac_hyphen_post_dim } } -\cs_new_protected:Npn \chemmacros_break_point_hyphen: + +\cs_new_protected:Npn \chemmacros_break_point: { \__chemmacros_break_point_insert:nnn {-} { } { + \mode_if_math:TF + { | } + { \tex_kern:D \l__chemmacros_iupac_break_dim } + } + } +\EndChemCompatibility + +\ChemCompatibilityFrom{5.2} +\cs_new_protected:Npn \chemmacros_break_point_hyphen: + { + \__chemmacros_break_point_insert:nnn + { \tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim - } + { } + { \tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim - \tex_kern:D \l__chemmacros_iupac_hyphen_post_dim @@ -350,6 +445,7 @@ { \tex_kern:D \l__chemmacros_iupac_break_dim } } } +\EndChemCompatibility \cs_new_protected:Npn \chemmacros_break_point_opening_paren: { \__chemmacros_break_point_insert:nnn { - } { ( } { ( } } @@ -381,7 +477,7 @@ \cs_new_protected:Npn \chemmacros_remove_shorthand:N #1 { - \chemmacros_define_iupac_shorthand:Npn #1 {} + \chemmacros_define_iupac_shorthand:NN #1 \c_empty_tl \seq_remove_all:Nn \l__chemmacros_iupac_shorthands_seq {#1} } @@ -425,6 +521,16 @@ \NewDocumentCommand \RemoveChemIUPACShorthand {m} { \chemmacros_remove_shorthand:N #1 } +\NewChemIUPACShorthand | \chemmacros_break_point: +\NewChemIUPACShorthand - \chemmacros_break_point_hyphen: +\ChemCompatibilityFrom{5.1} +\NewChemIUPACShorthand ( \chemmacros_break_point_opening_paren: +\NewChemIUPACShorthand ) \chemmacros_break_point_closing_paren: +\NewChemIUPACShorthand [ \chemmacros_break_point_opening_bracket: +\NewChemIUPACShorthand ] \chemmacros_break_point_closing_bracket: +\EndChemCompatibility +\NewChemIUPACShorthand ^ \chemmacros_superscript:n + \group_begin: \chemmacros_activate_all_iupac_shorthands: @@ -444,19 +550,13 @@ } \group_end: -\NewChemIUPACShorthand | \chemmacros_break_point: -\NewChemIUPACShorthand - \chemmacros_break_point_hyphen: -\NewChemIUPACShorthand ( \chemmacros_break_point_opening_paren: -\NewChemIUPACShorthand ) \chemmacros_break_point_closing_paren: -\NewChemIUPACShorthand [ \chemmacros_break_point_opening_bracket: -\NewChemIUPACShorthand ] \chemmacros_break_point_closing_bracket: -\NewChemIUPACShorthand ^ \chemmacros_superscript:n - % Thanks to Joseph Wright and Enrico Gregorio for the help on the curious % redefinition of \- and the end of the compilation % see http://tex.stackexchange.com/q/42405/5049 for reference +\ChemCompatibilityTo{5.2} \cs_set_protected:Npx \- { \exp_not:o { \- } } \cs_set_eq:NN \@dischyph \- +\EndChemCompatibility \NewDocumentCommand \iupac {m} { \chemmacros_iupac:n {#1} } @@ -620,3 +720,8 @@ % -------------------------------------------------------------------------- \tex_endinput:D + +2015/10/01 - use new function \chemmacros_if_document:TF for + \chemmacros_make_iupac: + - \cip only italicizes elements of csv list + - fix bug in \RemoveChemIUPACShorthand diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex index a3468239f06..8138ca6e7dc 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex @@ -25,7 +25,7 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{reactions}{2015/09/15 reaction environments} +\ChemModule{reactions}{2015/10/14 reaction environments} \chemmacros_load_module:n {chemformula} @@ -87,21 +87,40 @@ \tl_new:N \reactionlistname \tl_new:N \l__chemmacros_reaction_heading_tl -\cs_if_exist:NTF \chapter - { \tl_set:Nn \l__chemmacros_reaction_heading_tl { \chapter* } } - { \tl_set:Nn \l__chemmacros_reaction_heading_tl { \section* } } +\cs_new:Npn \__chemmacros_reaction_heading:n #1 + { \l__chemmacros_reaction_heading_tl { #1 } } +\cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V } \tl_set:Nn \l__chemmacros_reaction_lorname_tl { \chemmacros_translate:n {reaction} } \tl_set:Nn \reactionlistname { \chemmacros_translate:n {list-of-reactions} } -\cs_new:Npn \__chemmacros_reaction_heading:n #1 - { \l__chemmacros_reaction_heading_tl { #1 } } -\cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V } +\keys_define:nn {chemmacros/reactions} + { + list-name .tl_set:N = \reactionlistname , + list-entry .tl_set:N = \l__chemmacros_reaction_lorname_tl , + } +\ChemCompatibilityFrom{5.2} +\keys_define:nn {chemmacros/reactions} + { + list-heading-cmd .code:n = + \cs_set_protected:Npn \__chemmacros_reaction_heading:n ##1 {#1} + } +\EndChemCompatibility + +\cs_if_exist:NTF \chapter + { + \keys_set:nn {chemmacros/reactions} + { list-heading-cmd = \chapter* {#1} } + } + { + \keys_set:nn {chemmacros/reactions} + { list-heading-cmd = \section* {#1} } + } \cs_new_protected:Npn \listofreactions { \__chemmacros_reaction_heading:V \reactionlistname - \@starttoc { lor } + \@starttoc {lor} } \cs_new_protected:Npn \l@reaction #1#2 @@ -187,3 +206,4 @@ 2015/09/15 - adapt to `method' option => do not use chemformula's macros directly +2015/10/14 - new option `list-heading-cmd' diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex index 1b9ace3108a..11980accdcb 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.redox.code.tex @@ -41,6 +41,9 @@ \bool_new:N \l__chemmacros_ox_sign_bool \bool_new:N \l__chemmacros_ox_integer_bool \bool_new:N \l__chemmacros_ox_explicit_sign_bool +\ChemCompatibilityFrom{5.2} +\bool_new:N \l__chemmacros_ox_explicit_zero_sign_bool +\EndChemCompatibility \bool_new:N \l__chemmacros_ox_format_roman_bool \bool_new:N \l__chemmacros_ox_decimal_marker_comma_bool \bool_new:N \l__chemmacros_ox_parse_bool @@ -79,6 +82,7 @@ \group_end: } +\ChemCompatibilityTo{5.1} \cs_new_protected:Npn \__chemmacros_ox_sign:n #1 { \bool_if:nT @@ -87,15 +91,36 @@ \l__chemmacros_ox_explicit_sign_bool } { \c_math_toggle_token + \c_math_toggle_token } + \bool_if:nT + { + \fp_compare_p:n { #1 = 0 } && + \l__chemmacros_ox_explicit_sign_bool + } + { \c_math_toggle_token \pm \c_math_toggle_token } + \fp_compare:nT { #1 < 0 } + { \c_math_toggle_token - \c_math_toggle_token } + } +\EndChemCompatibility +\ChemCompatibilityFrom{5.2} +\cs_new_protected:Npn \__chemmacros_ox_sign:n #1 + { \bool_if:nT { - \fp_compare_p:n { #1 = 0 } && + \fp_compare_p:n { #1 > 0 } && \l__chemmacros_ox_explicit_sign_bool } - { \c_math_toggle_token \pm \c_math_toggle_token } + { \c_math_toggle_token + \c_math_toggle_token } + \bool_if:nT + { + \fp_compare_p:n { #1 = 0 } && + \l__chemmacros_ox_explicit_sign_bool && + \l__chemmacros_ox_explicit_zero_sign_bool + } + { \c_math_toggle_token \pm \c_math_toggle_token } \fp_compare:nT { #1 < 0 } { \c_math_toggle_token - \c_math_toggle_token } } +\EndChemCompatibility \cs_new_protected:Npn \__chemmacros_ox_value:n #1 { @@ -258,6 +283,14 @@ align .initial:n = center } +\ChemCompatibilityFrom{5.4} +\keys_define:nn {chemmacros/redox} + { + explicit-zero-sign .bool_set:N \l__chemmacros_ox_explicit_zero_sign_bool , + explicit-zero-sign .default:n = true + } +\EndChemCompatibility + % \ox[<keyval>]{<num>,<atom>} % \ox*[<keyval>]{<num>,<atom>} => always number on the top \cs_new_protected:Npn \chemmacros_ox:nnnn #1#2#3#4 @@ -401,3 +434,6 @@ } % -------------------------------------------------------------------------- +\tex_endinput:D +2015/09/30 - new option `explicit-zero-sign' + diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.units.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.units.code.tex index b6bbe6776ef..0ecf2b7407f 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.units.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.units.code.tex @@ -25,7 +25,7 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{units}{2015/07/22 chemical units} +\ChemModule{units}{2015/09/28 chemical units} \RequirePackage{siunitx} @@ -39,7 +39,7 @@ \DeclareSIUnit {\normal } {\textsc{n}} \DeclareSIUnit {\torr } {torr} -\AtBeginDocument +\AtEndPreamble { \chemmacros_if_package_loaded:nF {chemstyle} { @@ -50,3 +50,7 @@ } % -------------------------------------------------------------------------- +\tex_endinput:D + +2015/09/28 - change \AtBeginDocument into \AtEndPreamble + diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index b2907ec4e2f..2843bf1e83a 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -31,9 +31,9 @@ % -------------------------------------------------------------------------- % package information: -\tl_const:Nn \c_chemmacros_date_tl {2015/09/23} +\tl_const:Nn \c_chemmacros_date_tl {2015/10/14} \tl_const:Nn \c_chemmacros_version_major_number_tl {5} -\tl_const:Nn \c_chemmacros_version_minor_number_tl {1} +\tl_const:Nn \c_chemmacros_version_minor_number_tl {2} \tl_const:Nn \c_chemmacros_version_subrelease_tl {} \tl_const:Nx \c_chemmacros_version_number_tl {\c_chemmacros_version_major_number_tl.\c_chemmacros_version_minor_number_tl} @@ -49,29 +49,24 @@ {\c_chemmacros_info_tl \c_space_tl (CN)} % -------------------------------------------------------------------------- -% messages: -\msg_new:nnn {chemmacros} {too-low-compatibility} - { - Compatibility~ for~ versions~ below~ v4.7~ is~ not~ supported!~ You~ - requested~ version~ v #1.~ Loading~ v4.7~ instead. - } - -\msg_new:nnn {chemmacros} {low-compatibility} - { - You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~ - of~ chemmacros~ is~ v \c_chemmacros_version_number_tl .~ Not~ all~ features~ - will~ be~ available! - } - -% -------------------------------------------------------------------------- -% compatibility +% set compatibility \fp_new:N \l__chemmacros_compatibility_version_fp \fp_set:Nn \l__chemmacros_compatibility_version_fp {\c_chemmacros_version_number_tl} \keys_define:nn {chemmacros/compatibility} { - compatibility .fp_set:N = \l__chemmacros_compatibility_version_fp , - unknown .code:n = + compatibility .code:n = + \str_case:nnTF {#1} + { + {newest} {} + {latest} {} + } + { + \fp_set:Nn \l__chemmacros_compatibility_version_fp + { \c_chemmacros_version_number_tl } + } + { \fp_set:Nn \l__chemmacros_compatibility_version_fp {#1} } , + unknown .code:n = \PassOptionsToPackage{\CurrentOption}{chemmacros4} \PassOptionsToPackage{\CurrentOption}{chemmacros5} } @@ -154,6 +149,29 @@ {#3} } +% -------------------------------------------------------------------------- +% messages: +\msg_new:nnn {chemmacros} {too-low-compatibility} + { + Compatibility~ for~ versions~ below~ v4.7~ is~ not~ supported!~ You~ + requested~ version~ v #1.~ Loading~ v4.7~ instead. + } + +\msg_new:nnn {chemmacros} {too-high-compatibility} + { + You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~ + of~ chemmacros~ is~ v \c_chemmacros_version_number_tl .~ Falling~ back~ + to~ v \c_chemmacros_version_number_tl ! + } + +\msg_new:nnn {chemmacros} {low-compatibility} + { + You~ requested~ compatibility~ mode~ v #1~ while~ the~ current~ version~ + of~ chemmacros~ is~ v \c_chemmacros_version_number_tl .~ Not~ all~ features~ + will~ be~ available! + } + +% -------------------------------------------------------------------------- % let's see that the max number is the newest (=current) version \chemmacros_if_compatiblity:nnT {>} { \c_chemmacros_version_number_tl } { @@ -460,3 +478,15 @@ Version history 2015/09/23 - version 5.1 - add option `method' to `chemformula' module - make module `scheme' compatible with `floatrow' - add module hooks `before' and `after' +2015/10/14 - version 5.2 - warn if compatibility version requested is higher + than the current version number + - enable to specify a minimal compatibility version + for a module + - add info message to `all' module + - add values `newest' and `latest' to the + compatibility option + - check for mhchem and chemformula and choose the + formula method accordingly + - fixes in the module hook mechanism + - fix in \chemmacros_if_module_loaded:n + - new internal module `errorcheck' diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty index e8fa9be35f1..c4757bd6e43 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros5.sty @@ -50,6 +50,13 @@ Unknown~ option~ `#1'!~ Since~ v5.0~ chemmacros~ has~ no~ package~ options~ any~ more! } + +\msg_new:nnn {chemmacros} {module-not-available} + { + The~ module~ `#1'~ is~ only~ available~ in~ compatibility~ mode~ #2~ or~ + higher. + } + \cs_generate_variant:Nn \msg_warning:nnn { nnV } \keys_define:nn {chemmacros/package-options} @@ -128,6 +135,9 @@ \tl_const:Nn \c__chemmacros_module_extension_tl {code.tex} \tl_const:Nn \c__chemmacros_module_prefix_tl {chemmacros.module} +\seq_new:N \g__chemmacros_loaded_modules_seq +\prop_new:N \g__chemmacros_loaded_modules_prop + \cs_new_protected:Npn \chemmacros_load_modules:n #1 { \clist_map_inline:nn {#1} { \chemmacros_load_module:n {##1} } } @@ -143,12 +153,12 @@ { \chemmacros_if_module_exist:nTF {#1} { - \__chemmacros_use_module_hook:nn {before} {#1} + \__chemmacros_use_module_hook:nn {#1} {before} \msg_log:nnn {chemmacros} {loading-module} {#1} \@onefilewithoptions {\c__chemmacros_module_prefix_tl.#1}[][] \c__chemmacros_module_extension_tl - \__chemmacros_use_module_hook:nn {after} {#1} + \__chemmacros_use_module_hook:nn {#1} {after} } { \msg_error:nnn {chemmacros} {module-missing} {#1} } } @@ -157,7 +167,7 @@ \prg_new_conditional:Npnn \chemmacros_if_module_loaded:n #1 {p,T,F,TF} { - \cs_if_exist:cTF {chemmacros-module-#1-loaded} + \seq_if_in:NnTF \g__chemmacros_loaded_modules_seq {#1} { \prg_return_true: } { \prg_return_false: } } @@ -171,10 +181,10 @@ } % -------------------------------------------------------------------------- +\ChemCompatibilityFrom{5.1} % module hooks: % #1: module % #2: code -\ChemCompatibilityFrom{5.1} \cs_new_protected:Npn \chemmacros_after_module:nn #1#2 { \chemmacros_if_module_loaded:nTF {#1} @@ -204,6 +214,8 @@ } } +% #1: module +% #2: hook name \cs_new_protected:Npn \__chemmacros_use_module_hook:nn #1#2 { \tl_if_exist:cT {g__chemmacros_module_#1_#2_hook_tl} @@ -214,9 +226,15 @@ } % -------------------------------------------------------------------------- -\cs_new_protected:Npn \chemmacros_module:nnn #1#2#3 +\cs_new_protected:Npn \__chemmacros_module:nnnn #1#2#3#4 { - \cs_new:cpn {chemmacros-module-#2-loaded} {chemmacros:~module~`#2'} + \chemmacros_if_compatiblity:nnF {>=} {#4} + { + \msg_warning:nnnn {chemmacros} {module-not-available} {#2} {#4} + \tex_endinput:D + } + \seq_gput_right:Nn \g__chemmacros_loaded_modules_seq {#2} + \prop_gput:Nnn \g__chemmacros_loaded_modules_prop {#2} {#3} \ProvidesFile {\c__chemmacros_module_prefix_tl.#2.\c__chemmacros_module_extension_tl} [ @@ -236,8 +254,8 @@ % #1: boolean % #2: name % #3: description -\NewDocumentCommand \ChemModule {smm} - { \chemmacros_module:nnn {#1} {#2} {#3} } +\NewDocumentCommand \ChemModule {smmO{5.0}} + { \__chemmacros_module:nnnn {#1} {#2} {#3} {#4} } % -------------------------------------------------------------------------- % command for loading modules: @@ -247,7 +265,7 @@ % load default modules: \chemmacros_load_modules:n { - base, lang, greek, chemformula, % <= those need to be present for all modules + base, errorcheck, lang, greek, chemformula, % <= those need to be present for all modules acid-base, symbols, charges, particles, phases , nomenclature } @@ -258,6 +276,7 @@ Modules: (* = preloaded) - internal modules: - base * + - errorcheck * - lang * - greek * - chemformula * @@ -286,3 +305,11 @@ Modules: (* = preloaded) Version history 2015/08/29 - initial release v5.0 2015/09/23 - add module hooks `before' and `after' + - allow to give minimal compatibility version to a module: this + should be the first version when a module is published and + shouldn't be changed any more; loading the corresponding module + will abort when compatibility is too low + - store loaded modules in a seq and in a prop +2015/10/14 - bug fix in the module hook mechanism + - bug fix in \chemmacros_if_module_loaded:n + - new `errorcheck' module |