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 /Master/texmf-dist/tex | |
parent | ca3052a995aa72637d7cc9132e4ba1d2f6f3b8a5 (diff) |
chemmacros (25jan14)
git-svn-id: svn://tug.org/texlive/trunk@32786 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-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 |
4 files changed, 1055 insertions, 1002 deletions
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: |