diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | 100 |
1 files changed, 76 insertions, 24 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index 77dab7f9d0c..b06c416bc68 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -5,7 +5,7 @@ % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % -% - 2012/03/14 - % +% - 2012/03/20 - % % --------------------------------------------------------------------------- % % - https://bitbucket.org/cgnieder/chemmacros/ - % % - contact@mychemistry.eu - % @@ -33,8 +33,8 @@ \ProvidesExplPackage {chemmacros} - {2012/03/14} - {3.1c} + {2012/03/20} + {3.2} {macros and commands for chemists} \@ifpackageloaded { chemformula } {} { \RequirePackage { chemformula } } @@ -305,6 +305,23 @@ exist. } +\msg_set:nnnn { chemmacros } { declare-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 \c_space_tl + already~exists.~Choose~another~name. + } + +\msg_set:nnnn { chemmacros } { f } + { The~latin~phrase \token_to_str:N #1 \c_space_tl is~not~defined. } + { + You've~tried~to~renew~the~latin~phrase~\token_to_str:N #1 ,~but~it~doesn't~ + exist. + } + \msg_set:nnnn { chemmacros } { declare-phase } { The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. @@ -600,7 +617,7 @@ \tl_set_rescan:Nno \l_tmpa_tl { \ExplSyntaxOn } { \l_chemformula_input_tl } - \chemformula_write:n { \l_tmpa_tl } + \chemformula_write:V \l_tmpa_tl \group_end: \chemmacros_xspace: } @@ -996,17 +1013,49 @@ \cs_set_eq:NN \iupac \chemmacros_iupac:n % latin phrases +\tl_new:N \l_chemmacros_latin_format_tl +\tl_set:Nn \l_chemmacros_latin_format_tl { \itshape } + +\keys_define:nn { chemmacros / latin } + { format . tl_set:N = \l_chemmacros_latin_format_tl } + +\cs_new:Npn \chemmacros_latin:n #1 + { { \l_chemmacros_latin_format_tl #1 } } + +\prop_new:N \l_chemmacros_latin_prop +\NewDocumentCommand \DeclareChemLatin { mm } + { + \cs_if_free:NTF #1 + { + \cs_new:Npn #1 { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \prop_put:Nnn \l_chemmacros_latin_prop { #1 } { #2 } + } + { \chemmacros_msg:nnxx { chemmacros } { declare-latin } { #1 } { } } + } + +\NewDocumentCommand \RenewChemLatin { mm } + { + \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 } { } } + } + \AtBeginDocument { \bool_if:NTF \l_chemmacros_chemstyle_bool { - \cs_new_nopar:Npn \insitu { \latin{in~situ} \chemmacros_xspace: } - \cs_new_nopar:Npn \abinitio { \latin{ab~initio} \chemmacros_xspace: } + \AfterPackage* { chemstyle } + { + \cs_undefine:N \invacuo + \cs_set_eq:NN \chemmacros_latin:n \cst@latin + } } { - \cs_new_nopar:Npn \insitu { \textit{in~situ} \chemmacros_xspace: } - \cs_new_nopar:Npn \abinitio { \textit{ab~initio} \chemmacros_xspace: } + \cs_new_eq:NN \latin \chemmacros_latin:n } + \DeclareChemLatin \insitu { in~situ } + \DeclareChemLatin \abinitio { ab~initio } + \DeclareChemLatin \invacuo { in~vacuo } } % --------------------------------------------------------------------------- % @@ -1447,7 +1496,7 @@ \tl_set:Nn \l_chemmacros_redox_end_tl { #2 } } -\NewDocumentCommand \redox { > { \SplitArgument { 1 } { , } } d() o o m } +\NewDocumentCommand \redox { > { \SplitArgument { 1 } { , } } r() o o G{} } { \IfNoValueT { #1 } { @@ -1820,7 +1869,7 @@ \char_set_catcode_letter:N \@ % --------------------------------------------------------------------------- % -% reaction environments for mhchem +% reaction environments % redefine mathtools' command \MT_define_tagform:nwnn to ensure we add an % entry to the list of reactions even if the user redefines the reaction tag @@ -1838,13 +1887,21 @@ \addcontentsline { lor } { reaction } { \l_chemmacros_reaction_lorname_tl #3 #2 ##1 #4 - \tl_use:c { l_chemmacros_reaction_ \thereaction _tl } + \tl_use:N \g_chemmacros_reaction_description_tl } + \tl_gclear:N \g_chemmacros_reaction_description_tl } } } } +\tl_new:N \g_chemmacros_reaction_description_tl +\NewDocumentCommand \AddRxnDesc { m } + { + \tl_if_blank:nF { #1 } + { \tl_gset:Nn \g_chemmacros_reaction_description_tl { : ~ #1 } } + } + % define \listofreactions \tl_new:N \l_chemmacros_reaction_lorname_tl \tl_new:N \reactionlistname @@ -1886,7 +1943,7 @@ { \usetagform { CMreaction } } { \usetagform { reaction } } % => this is problematic because it disallows resetting the counter: - \tl_new:c { l_chemmacros_reaction_ \thereaction _tl } +% \tl_new:c { l_chemmacros_reaction_ \thereaction _tl } } % switch back to equation tags @@ -1930,12 +1987,7 @@ \NewEnviron { #2 } [ 2 ] [] { \chemmacros_begin_reaction: - \tl_if_blank:nF { ##1 } - { - \tl_set:cn - { l_chemmacros_reaction_ \thereaction _tl } - { : ~ ##1 } - } + \AddRxnDesc { ##1 } \begin { #3 } { ##2 } \chemmacros_equation_chemformula:o { \BODY } \end{ #3 } @@ -1955,12 +2007,7 @@ \NewEnviron { #2 } [ 1 ] [] { \chemmacros_begin_reaction: - \tl_if_blank:nF { ##1 } - { - \tl_set:cn - { l_chemmacros_reaction_ \thereaction _tl } - { : ~ ##1 } - } + \AddRxnDesc { ##1 } \begin { #3 } \chemmacros_equation_chemformula:o { \BODY } \end { #3 } @@ -3265,6 +3312,11 @@ Version history 2012/03/14 - version 3.1c - compatibility with KOMA's global option "version = <value>" - bugfix in the list of reactions +2012/03/20 - version 3.2 - new feature in chemformula + - improved list of reactions: resetting the "reaction" + counter now doesn't cause errors any more + - \AddRxnDesc added which allows to add descriptions + to each reaction in the "reactions" environment % --------------------------------------------------------------------------- % % TODO: |