diff options
author | Karl Berry <karl@freefriends.org> | 2013-07-09 22:44:28 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-07-09 22:44:28 +0000 |
commit | e125f261f3433bb88672b645160d97b4ac2ea3f6 (patch) | |
tree | 1bd4b6e1451dc821f7178ebafe235826a1a8e0e8 /Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | |
parent | 20abcceaa3fb6a4c4417a871772b4edc49bab39d (diff) |
upmethodology (7jul13)
git-svn-id: svn://tug.org/texlive/trunk@31148 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty | 2015 |
1 files changed, 1007 insertions, 1008 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty index efa0b0d2138..a1c7aa6c46f 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty @@ -1,67 +1,105 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% --------------------------------------------------------------------------- % -% - the CHEMMACROS bundle - % -% - chemmacros.sty - % -% - macros and commands for chemists - % -% --------------------------------------------------------------------------- % -% - Clemens Niederberger - % -% --------------------------------------------------------------------------- % -% - https://bitbucket.org/cgnieder/chemmacros/ - % -% - contact@mychemistry.eu - % -% --------------------------------------------------------------------------- % -% - If you have any ideas, questions, suggestions or bugs to report, please - % -% - feel free to contact me. - % -% --------------------------------------------------------------------------- % -% - Copyright 2011-2013 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. - % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\RequirePackage{ expl3 , xparse , l3keys2e , xfrac , siunitx } -\RequirePackage{ tikz , mathtools , environ , scrlfile , etoolbox , bm } -\usetikzlibrary{calc,arrows} -\def\chemmacros@version{3.6b} -\def\chemmacros@date{2013/04/19} +% -------------------------------------------------------------------------- +% - the CHEMMACROS bundle +% - chemmacros.sty +% - loads of little helpers for chemists +% -------------------------------------------------------------------------- +% - Clemens Niederberger +% -------------------------------------------------------------------------- +% - https://bitbucket.org/cgnieder/chemmacros/ +% - contact@mychemistry.eu +% -------------------------------------------------------------------------- +% - If you have any ideas, questions, suggestions or bugs to report, please +% - feel free to contact me. +% -------------------------------------------------------------------------- +% - Copyright 2011-2013 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. +% -------------------------------------------------------------------------- +\RequirePackage{ expl3 , xparse , l3keys2e } +\def\chemmacros@version{4.0} +\def\chemmacros@date{2013/07/06} \ProvidesExplPackage {chemmacros} {\chemmacros@date} {\chemmacros@version} - {macros and commands for chemists} - -\@ifpackageloaded { chemformula } {} { \RequirePackage { chemformula } } - -\bool_new:N \l__chemmacros_version_one_bool -\bool_new:N \l__chemmacros_xspace_bool - \bool_set_true:N \l__chemmacros_xspace_bool -\bool_new:N \l__chemmacros_bpchem_bool -\bool_new:N \l__chemmacros_circled_bool - \bool_set_true:N \l__chemmacros_circled_bool -\bool_new:N \l__chemmacros_circled_formal_bool - \bool_set_true:N \l__chemmacros_circled_formal_bool -\bool_new:N \l__chemmacros_circled_chem_bool - \bool_set_true:N \l__chemmacros_circled_chem_bool -\bool_new:N \l__chemmacros_EZ_cool_bool -\bool_new:N \l__chemmacros_Nu_mathspec_bool -\bool_new:N \l__chemmacros_use_mhchem_bool -\bool_new:N \l__chemmacros_chemstyle_bool -\bool_new:N \l__chemmacros_hyperref_bool -\bool_new:N \l__chemmacros_varioref_bool -\bool_new:N \l__chemmacros_chemfig_bool -\bool_new:N \l__chemmacros_ghsystem_bool - \bool_set_true:N \l__chemmacros_ghsystem_bool -\bool_new:N \l__chemmacros_iupac_restricted_bool -\bool_new:N \l__chemmacros_iupac_strict_bool -\bool_new:N \l__chemmacros_in_document_bool + {loads of little helpers for chemists (CN)} + +% -------------------------------------------------------------------------- +% check expl3 version: +\@ifpackagelater { expl3 } { 2012/11/21 } + { } + { + \PackageError { chemmacros } { Support~package~expl3~too~old } + { + You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~ + 'l3packages'.\MessageBreak + Loading~chemmacros~will~abort! + } + \tex_endinput:D + } + +% -------------------------------------------------------------------------- +% 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_get:NnNTF { NV } +\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV } + +% -------------------------------------------------------------------------- +% load required packages +% the technical ones: +\RequirePackage { environ , scrlfile , etoolbox , translations } +% related to other topics like mathematics or graphics: +\RequirePackage { xfrac , siunitx , tikz, mathtools , bm } +% other packages of this bundle -- ghsystem is not loaded here but at the end +% of the preamble depending on a package option: +\RequirePackage { chemformula , chemgreek } +% TikZ libraries (the don't like expl3 syntax): +\ExplSyntaxOff +\usetikzlibrary{calc,arrows} +\ExplSyntaxOn + +% -------------------------------------------------------------------------- +% 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 + +\bool_new:N \l__chemmacros_circled_bool +\bool_set_true:N \l__chemmacros_circled_bool +\bool_new:N \l__chemmacros_circled_formal_bool +\bool_set_true:N \l__chemmacros_circled_formal_bool +\bool_new:N \l__chemmacros_circled_chem_bool +\bool_set_true:N \l__chemmacros_circled_chem_bool + +\bool_new:N \l__chemmacros_EZ_cool_bool +\bool_new:N \l__chemmacros_Nu_mathspec_bool +\bool_new:N \l__chemmacros_chemstyle_bool +\bool_new:N \l__chemmacros_hyperref_bool +\bool_new:N \l__chemmacros_varioref_bool +\bool_new:N \l__chemmacros_chemfig_bool +\bool_new:N \l__chemmacros_ghsystem_bool +\bool_set_true:N \l__chemmacros_ghsystem_bool + +\bool_new:N \l__chemmacros_iupac_restricted_bool +\bool_new:N \l__chemmacros_iupac_strict_bool +\bool_new:N \l__chemmacros_in_document_bool \AtBeginDocument { @@ -80,211 +118,293 @@ { \bool_set_false:N \l__chemmacros_chemfig_bool } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % warning / error messages -\cs_new:Npn \chemmacros_msg:nnxx #1#2#3#4 +\cs_new_protected:Npn \chemmacros_msg:nnxx #1#2#3#4 { - \bool_if:NTF \l__chemmacros_strict_bool + \bool_if:NTF \l_chemmacros_strict_bool { \msg_error:nnxx { #1 } { #2 } { #3 } { #4 } } { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } } } -\msg_set:nnnn { chemmacros } { language-not-defined } +\cs_new_protected:Npn \chemmacros_warning:nnxx #1#2#3#4 { - The~language~#1~is~not~defined~by~chemmacros. - } - { - You~chose~the~language~`#1'~which~is~not~defined~by~chemmacros.~`english'~is - ~used~instead.~If~you~just~mistyped~try~again!~Otherwise~contact~the~author~ - and~he'll~probably~add~your~language. + \bool_if:NTF \l_chemmacros_strict_bool + { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } } + { \msg_info:nnxx { #1 } { #2 } { #3 } { #4 } } } -\msg_set:nnnn { chemmacros } { already-defined } +\msg_new:nnnn { chemmacros } { language-not-defined } + { The~ language~ `#1'~ is~ not~ defined~ by~ chemmacros. } { - The~command~#1~has~also~been~defined~by~another~package. + You~ chose~ the~ language~ `#1'~ which~ is~ not~ defined~ by~ chemmacros.~ + `english'~ is~ used~ instead.~ If~ you~ just~ mistyped~ try~ again!~ + Otherwise~ contact~ the~ author~ and~ he'll~ probably~ add~ your~ language. } + +\msg_new:nnnn { chemmacros } { already-defined } + { The~ command~ #1~ has~ also~ been~ defined~ by~ another~ package. } { - The~command~#1~has~also~been~defined~by~another~package.~ - chemmacros~provides~an~alternative~definition.~ - See~the~documentation~for~more~information. + The~ command~ #1~ has~ also~ been~ defined~ by~ another~ package.~ + chemmacros~ provides~ an~ alternative~ definition.~ See~ the~ + documentation~ for~ more~ information. } -\msg_set:nnnn { chemmacros } { option-deprecated } - { The~option~#1~is~deprecated.~I~will~ignore~it. } +\msg_new:nnnn { chemmacros } { option-deprecated } + { The~ option~ `#1'~ is~ deprecated.~ I~ will~ ignore~ it. } { - The~package~option~#1~is~deprecated~and~not~used~by~chemmacros~any~more. - ~It~will~therefore~simply~be~ignored. + The~ package~ option~ `#1'~ is~ deprecated~ and~ not~ used~ by~ + chemmacros~ any~ more.~ It~ will~ therefore~ simply~ be~ ignored. } -\msg_set:nnnn { chemmacros } { command-deprecated } +\msg_new:nnnn { chemmacros } { command-deprecated } { - The~command~\token_to_str:N #1 \c_space_tl is~deprecated.~Use~ + The~ command~ \token_to_str:N #1 \c_space_tl is~ deprecated.~ Use~ \token_to_str:N #2 \c_space_tl instead. } { - The~command~\token_to_str:N #1 \c_space_tl is~deprecated.~Use~ + The~ command~ \token_to_str:N #1 \c_space_tl is~ deprecated.~ Use~ \token_to_str:N #2 \c_space_tl instead. } -\cs_new_protected:Npn \chemmacros_define_deprecated:NNn #1#2#3 +\msg_new:nnnn { chemmacros } { command-dropped } { - \cs_new_protected:Npn #1 - { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { #1 } { #2 } - #3 - } + The~ command~ \token_to_str:N #1 \c_space_tl has~ been~ dropped.~ I'm~ + sorry. + } + { + The~ command~ \token_to_str:N #1 \c_space_tl has~ been~ dropped.~ I'm~ + sorry. } -\NewDocumentCommand \DeclareChemDeprecated { mmm } - { \chemmacros_define_deprecated:NNn #1 #2 { #3 } } - -\msg_set:nnnn { chemmacros } { command-dropped } - { The~command~\token_to_str:N #1 \c_space_tl has~been~dropped.~I'm~sorry. } - { The~command~\token_to_str:N #1 \c_space_tl has~been~dropped.~I'm~sorry. } -\msg_set:nnnn { chemmacros } { declare-particle } +\msg_new:nnnn { chemmacros } { declare-particle } { - The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. + 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 \c_space_tl already~exists. - ~Please~choose~another~name. + You've~ tried~ to~ define~ a~ particle~ with~ \token_to_str:N + \DeclareChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. } -\msg_set:nnnn { chemmacros } { renew-particle } - { The~particle~ \token_to_str:N #1 \c_space_tl is~not~defined. } +\msg_new:nnnn { chemmacros } { renew-particle } + { The~ particle~ \token_to_str:N #1 \c_space_tl is~ not~ defined. } { - You've~tried~to~renew~the~particle~\token_to_str:N #1 ,~but~it~doesn't~ - exist. + You've~ tried~ to~ renew~ the~ particle~ \token_to_str:N #1 ,~ but~ it~ + doesn't~ exist. } -\msg_set:nnnn { chemmacros } { declare-latin } +\msg_new:nnnn { chemmacros } { declare-latin } { - The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. + The~ command~ sequence~ \token_to_str:N #1 \c_space_tl is~ already~ + defined. } { - You've~tried~to~define~a~latin~phrase~with~\token_to_str:N - \DeclareChemLatin,~but~the~command~sequence~ \token_to_str:N #1 \c_space_tl - already~exists.~Please~choose~another~name. + You've~ tried~ to~ define~ a~ latin~ phrase~ with~\token_to_str:N + \DeclareChemLatin ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. } -\msg_set:nnnn { chemmacros } { renew-latin } - { The~latin~phrase \token_to_str:N #1 \c_space_tl is~not~defined. } +\msg_new:nnnn { chemmacros } { renew-latin } + { The~ latin~ phrase \token_to_str:N #1 \c_space_tl is~ not~ defined. } { - You've~tried~to~renew~the~latin~phrase~\token_to_str:N #1 ,~but~it~doesn't~ - exist. + You've~ tried~ to~ renew~ the~ latin~ phrase~ \token_to_str:N #1 ,~ but~ + it~ doesn't~ exist. } -\msg_set:nnnn { chemmacros } { declare-nmr } +\msg_new:nnnn { chemmacros } { declare-nmr } { - The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. + 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 - \c_space_tl already~exists.~Please~choose~another~name. + You've~ tried~ to~ define~ a~ NMR~ command~ with~\token_to_str:N + \DeclareChemParticle ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. } -\msg_set:nnnn { chemmacros } { renew-nmr } - { The~NMR~command~ \token_to_str:N #1 \c_space_tl is~not~defined. } +\msg_new:nnnn { chemmacros } { renew-nmr } + { The~ NMR~ command~ \token_to_str:N #1 \c_space_tl is~ not~ defined. } { - You've~tried~to~renew~the~NMR~command~\token_to_str:N #1 ,~but~it~doesn't~ - exist. + You've~ tried~ to~ renew~ the~ NMR~ command~ \token_to_str:N #1 ,~ but~ + it~ doesn't~ exist. } -\msg_set:nnnn { chemmacros } { declare-phase } +\msg_new:nnnn { chemmacros } { declare-phase } { - The~command~sequence~ \token_to_str:N #1 \c_space_tl is~already~defined. + 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 \DeclareChemPhase , - ~but~the~command~sequence~ \token_to_str:N #1 \c_space_tl already~exists. - ~Please~choose~another~name. + You've~ tried~ to~ define~ a~ phase~ with~ \token_to_str:N + \DeclareChemPhase ,~ but~ the~ command~ sequence~ \token_to_str:N #1 + \c_space_tl already~ exists.~ Please~ choose~ another~ name. } -\msg_set:nnnn { chemmacros } { renew-phase } - { The~phase~ \token_to_str:N #1 \c_space_tl is~not~defined. } +\msg_new:nnnn { chemmacros } { renew-phase } + { The~ phase~ \token_to_str:N #1 \c_space_tl is~ not~ defined. } { - You've~tried~to~renew~the~phase~\token_to_str:N #1 ,~but~it~doesn't~ - exist. + You've~ tried~ to~ renew~ the~ phase~ \token_to_str:N #1 ,~ but~ it~ + doesn't~ exist. } -\msg_set:nnnn { chemmacros } { declare-iupac } +\msg_new:nnnn { chemmacros } { declare-iupac } { - The~iupac~naming~command~ \token_to_str:N #1 \c_space_tl is~already~defined. + 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 #1 \c_space_tl - already~exists.~Choose~another~name~or~use~\token_to_str:N \RenewChemIUPAC . + You've~ tried~ to~ define~ a~ iupac~ naming~ command~ with~ + \token_to_str:N \DeclareChemIUPAC ,~ but~ the~ iupac~ command~ + \token_to_str:N #1 \c_space_tl already~ exists.~ Choose~ another~ name~ + or~ use~ \token_to_str:N \RenewChemIUPAC . } -\msg_set:nnnn { chemmacros } { renew-iupac } - { The~iupac~naming~command~ \token_to_str:N #1 \c_space_tl is~not~defined. } +\msg_new:nnnn { chemmacros } { renew-iupac } { - 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 instead . + The~ iupac~ naming~ command~ \token_to_str:N #1 \c_space_tl is~ not~ + defined. + } + { + 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 + instead. } -\msg_set:nnnn { chemmacros } { ox } +\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: . } -\msg_set:nnnn { chemmacros } { OX } +\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: . } -\msg_set:nnnn { chemmacros } { redox } +\msg_new:nnnn { chemmacros } { redox } { \token_to_str:N \redox \c_space_tl : ~ #1 ~ \msg_line_context: . } { \token_to_str:N \redox \c_space_tl : ~ #1 ~ \msg_line_context: . } -\msg_set:nnnn { chemmacros } { chemfig } +\msg_new:nnnn { chemmacros } { chemfig } { - You~need~to~load~the~chemfig~package~in~order~to~make~ - \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl - work~properly~\msg_line_context: . + You~ need~ to~ load~ the~ `chemfig'~ package~ in~ order~ to~ make~ + \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl work~ + properly~ \msg_line_context: . } { - You~need~to~load~the~chemfig~package~in~order~to~make~ - \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl - work~properly~\msg_line_context: . + You~ need~ to~ load~ the~ `chemfig'~ package~ in~ order~ to~ make~ + \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl work~ + properly~ \msg_line_context: . } -\msg_set:nnnn { chemmacros } { DeclareChemState } +\msg_new:nnnn { chemmacros } { DeclareChemState } { - 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 \c_space_tl to~alter~it. + 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 + \c_space_tl to~ alter~ it. } { - 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 \c_space_tl to~alter~it. + 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 + \c_space_tl to~ alter~ it. } -\msg_set:nnnn { chemmacros } { RenewChemState } +\msg_new:nnnn { chemmacros } { RenewChemState } { - 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. + 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. } { - 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. + 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. } -% --------------------------------------------------------------------------- % -% scratch variables +% declare an option as deprecated: +\cs_new_protected:Npn \chemmacros_option_deprecated:n #1 + { \chemmacros_msg: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 #1 + { + \chemmacros_msg:nnxx { chemmacros } { command-deprecated } + { #1 } { #2 } + #3 + } + } + +\NewDocumentCommand \DeclareChemDeprecated { mmm } + { \chemmacros_define_deprecated:NNn #1 #2 { #3 } } + +% 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 } { } } + } + +\NewDocumentCommand \DeclareChemDropped { m } + { \chemmacros_define_dropped:N #1 } + +% -------------------------------------------------------------------------- +% temporary variables \tl_new:N \l__chemmacros_tmpa_tl \tl_new:N \l__chemmacros_tmpb_tl \int_new:N \l__chemmacros_tmpa_int \box_new:N \l__chemmacros_tmpa_box -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- +% language settings: +\bool_new:N \l__chemmacros_language_auto_bool +\bool_set_true:N \l__chemmacros_language_auto_bool +% this token list will hold the chosen language for chemmacros; since the +% language is either chosen automatically or by option it is only available at +% begin document +\tl_new:N \l_chemmacros_language_tl +\tl_set:Nn \l_chemmacros_language_tl { english } +\tl_new:N \l__chemmacros_current_language_tl + +% translate the key #1 or insert #2 +\cs_new:Npn \chemmacros_translate:nn #1#2 + { + \@trnslt@if@translation + { #1 } + { \l_chemmacros_language_tl } + { \GetTranslation{#1} } + { #2 } + } + +\AtBeginDocument{ + \bool_if:NTF \l__chemmacros_language_auto_bool + { + \tl_set:Nx \l_chemmacros_language_tl + { \@trnslt@language{\@trnslt@current@language} } + } + { + \tl_set_eq:NN + \l_chemmacros_language_tl + \l__chemmacros_current_language_tl + } +} + +% -------------------------------------------------------------------------- +% 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 -% bpchem => use \IUPAC inside for \NMR command % circled => circle charges % detect-bold => behaviour when font series bold % EZ => cool or chemmacros version of \E @@ -299,55 +419,52 @@ % version=1 => compatibility for documents set with v1.* % xspace => add an \xspace after a whole bunch of macros -\bool_new:N \l__chemmacros_strict_bool +% 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 + +\bool_new:N \l__chemmacros_option_greek_set_bool \bool_new:N \l__chemmacros_use_upgreek_bool \bool_new:N \l__chemmacros_use_textgreek_bool -\bool_new:N \l__chemmacros_option_greek_set_bool - -\tl_new:N \l__chemmacros_language_tl -\tl_set:Nn \l__chemmacros_language_tl { english } -\tl_new:N \l__chemmacros_current_language_tl -\tl_set:Nn \l__chemmacros_current_language_tl { english } +\bool_new:N \l__chemmacros_use_kpfonts_bool +\bool_new:N \l__chemmacros_use_newtx_bool \cs_new:Npn \chemmacros_inner_font: {} \keys_define:nn { chemmacros / option } { - bpchem .bool_set:N = \l__chemmacros_bpchem_bool , - bpchem .default:n = true , + bpchem .code:n = \chemmacros_option_deprecated:n { bpchem } , circletype .choice: , circletype / math .code:n = { \bool_set_false:N \l__chemmacros_circled_chem_bool } , circletype / chem .code:n = { \bool_set_true:N \l__chemmacros_circled_chem_bool } , circled .choice: , - circled / none .code:n = + circled / none .code:n = { \bool_set_false:N \l__chemmacros_circled_bool \bool_set_false:N \l__chemmacros_circled_formal_bool } , - circled / formal .code:n = + circled / formal .code:n = { \bool_set_true:N \l__chemmacros_circled_bool \bool_set_true:N \l__chemmacros_circled_formal_bool } , - circled / all .code:n = + circled / all .code:n = { \bool_set_true:N \l__chemmacros_circled_bool \bool_set_false:N \l__chemmacros_circled_formal_bool } , circled .default:n = all , - detect-bold .code:n = - \chemmacros_msg:nnxx { chemmacros } { option-deprecated } - { detect-bold } {} , - EZ .code:n = - \chemmacros_msg:nnxx { chemmacros } { option-deprecated } { EZ } {} , + detect-bold .code:n = \chemmacros_option_deprecated:n { detect-bold } , + EZ .code:n = \chemmacros_option_deprecated:n { EZ } , german .code:n = - \tl_set:Nn \l__chemmacros_language_tl { german } , + \tl_set:Nn \l__chemmacros_current_language_tl { german } , ngerman .code:n = - \tl_set:Nn \l__chemmacros_language_tl { ngerman } , + \tl_set:Nn \l__chemmacros_current_language_tl { ngerman } , ghsystem .bool_set:N = \l__chemmacros_ghsystem_bool , ghsystem .default:n = true , iupac .choice: , @@ -360,18 +477,20 @@ iupac / strict .code:n = \bool_set_false:N \l__chemmacros_iupac_restricted_bool \bool_set_true:N \l__chemmacros_iupac_strict_bool , - language .tl_set:N = \l__chemmacros_language_tl , + language .code:n = + \bool_set_false:N \l__chemmacros_language_auto_bool + \tl_set:Nn \l__chemmacros_current_language_tl { #1 } , method .choice: , method / chemformula .code:n = - \bool_set_false:N \l__chemmacros_use_mhchem_bool , + \chemmacros_option_deprecated:n { method } , method / mhchem .code:n = - \bool_set_true:N \l__chemmacros_use_mhchem_bool , + \chemmacros_option_deprecated:n { method } , Nu .choice: , Nu / mathspec .code:n = \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 .bool_set:N = \l_chemmacros_strict_bool , strict .default:n = true , synchronize .choice: , synchronize / true .code:n = @@ -380,88 +499,54 @@ synchronize .default:n = true , greek .choice: , greek / upgreek .code:n = - \bool_set_true:N \l__chemmacros_use_upgreek_bool - \bool_set_false:N \l__chemmacros_use_textgreek_bool - \bool_set_true:N \l__chemmacros_option_greek_set_bool , + \chemgreek_activate_mapping:n { upgreek } + \bool_set_true:N \l__chemmacros_option_greek_set_bool , greek / textgreek .code:n = - \bool_set_false:N \l__chemmacros_use_upgreek_bool - \bool_set_true:N \l__chemmacros_use_textgreek_bool - \bool_set_true:N \l__chemmacros_option_greek_set_bool , + \chemgreek_activate_mapping:n { textgreek } + \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 = + \chemgreek_activate_mapping:n { newtx } + \bool_set_true:N \l__chemmacros_option_greek_set_bool, greek / math .code:n = - \bool_set_false:N \l__chemmacros_use_upgreek_bool - \bool_set_false:N \l__chemmacros_use_textgreek_bool - \bool_set_true:N \l__chemmacros_option_greek_set_bool , + \chemgreek_activate_mapping:n { default } + \bool_set_true:N \l__chemmacros_option_greek_set_bool, greek / auto .code:n = - \bool_set_false:N \l__chemmacros_use_upgreek_bool - \bool_set_false:N \l__chemmacros_use_textgreek_bool - \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_msg:nnxx { chemmacros } { option-deprecated } - { upgreek } {} , + 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_msg:nnxx { chemmacros } { option-deprecated } - { version } {} , + version .code:n = \chemmacros_option_deprecated:n { version } , cmversion .choice: , - cmversion / 1 .code:n = - { \bool_set_true:N \l__chemmacros_version_one_bool } , - cmversion / 2 .code:n = - { \bool_set_false:N \l__chemmacros_version_one_bool } , - cmversion / bundle .code:n = - { \bool_set_false:N \l__chemmacros_version_one_bool } , + 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 } -\ProcessKeysOptions { chemmacros / option } -% --------------------------------------------------------------------------- % -% language settings: -\prop_new:N \l__chemmacros_language_prop -\prop_put:Nnn \l__chemmacros_language_prop { english } { english } -\prop_put:Nnn \l__chemmacros_language_prop { american } { english } -\prop_put:Nnn \l__chemmacros_language_prop { british } { english } -\prop_put:Nnn \l__chemmacros_language_prop { german } { german } -\prop_put:Nnn \l__chemmacros_language_prop { ngerman } { german } -\prop_put:Nnn \l__chemmacros_language_prop { italian } { italian } -\prop_put:Nnn \l__chemmacros_language_prop { french } { french } - -\prop_map_inline:Nn \l__chemmacros_language_prop - { - \cs_if_exist:cF { l__chemmacros_ #2 _bool } - { \bool_new:c { l__chemmacros_ #2 _bool } } - } -\cs_new_protected:Npn \chemmacros_set_language: - { - \prop_get:NoNTF - \l__chemmacros_language_prop - { \l__chemmacros_language_tl } - \l__chemmacros_current_language_tl - { - \bool_set_true:c - { l__chemmacros_ \l__chemmacros_current_language_tl _bool } - } - { - \chemmacros_msg:nnxx { chemmacros } { language-not-defined } - { \l__chemmacros_language_tl } { } - } - } +\ProcessKeysOptions { chemmacros / option } +% -------------------------------------------------------------------------- +% set up a few things: +% - is `ghsystem' requested? +% - do we need `xspace'? +% - what about the greek letters? \AtEndPreamble { - \chemmacros_set_language: - \chemmacros_make_phases: \bool_if:NT \l__chemmacros_ghsystem_bool { \RequirePackage { ghsystem } } - \bool_if:NT \l__chemmacros_bpchem_bool - { \RequirePackage { bpchem } } \bool_if:NT \l__chemmacros_xspace_bool { \RequirePackage { xspace } } - \bool_if:NT \l__chemmacros_use_mhchem_bool - { \RequirePackage[ version=3 ]{ mhchem } } \bool_if:NF \l__chemmacros_option_greek_set_bool { \@ifpackageloaded { upgreek } @@ -469,205 +554,113 @@ { \@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 } + { } + } + } } } - \bool_if:NTF \l__chemmacros_use_upgreek_bool - { - \cs_set:Npn \Chemalpha { \ensuremath { \upalpha } } - \cs_set:Npn \Chembeta { \ensuremath { \upbeta } } - \cs_set:Npn \Chemgamma { \ensuremath { \upgamma } } - \cs_set:Npn \Chemdelta { \ensuremath { \updelta } } - \cs_set:Npn \Chemepsilon { \ensuremath { \upvarepsilon } } - \cs_set:Npn \Chemeta { \ensuremath { \upeta } } - \cs_set:Npn \Chemkappa { \ensuremath { \upkappa } } - \cs_set:Npn \Chemmu { \ensuremath { \upmu } } - \cs_set:Npn \Chemnu { \ensuremath { \upnu } } - \cs_set:Npn \Chemrho { \ensuremath { \uprho } } - \cs_set:Npn \Chempi { \ensuremath { \uppi } } - \cs_set:Npn \Chemsigma { \ensuremath { \upsigma } } - \cs_set:Npn \Chemomega { \ensuremath { \upomega } } - \cs_set:Npn \ChemDelta { \ensuremath { \Updelta } } - } - { - \bool_if:NT \l__chemmacros_use_textgreek_bool - { - \cs_set_protected:Npn \Chemalpha { \ensuremath { \text { \textalpha } } } - \cs_set_protected:Npn \Chembeta { \ensuremath { \text { \textbeta } } } - \cs_set_protected:Npn \Chemgamma { \ensuremath { \text { \textgamma } } } - \cs_set_protected:Npn \Chemdelta { \ensuremath { \text { \textdelta } } } - \cs_set_protected:Npn \Chemepsilon { \ensuremath { \text { \textepsilon } } } - \cs_set_protected:Npn \Chemeta { \ensuremath { \text { \texteta } } } - \cs_set_protected:Npn \Chemkappa { \ensuremath { \text { \textkappa } } } - \cs_set_protected:Npn \Chemmu { \ensuremath { \text { \textmu } } } - \cs_set_protected:Npn \Chemnu { \ensuremath { \text { \textnu } } } - \cs_set_protected:Npn \Chemrho { \ensuremath { \text { \textrho } } } - \cs_set_protected:Npn \Chempi { \ensuremath { \text { \textpi } } } - \cs_set_protected:Npn \Chemsigma { \ensuremath { \text { \textsigma } } } - \cs_set_protected:Npn \Chemomega { \ensuremath { \text { \textomega } } } - \cs_set_protected:Npn \ChemDelta { \ensuremath { \text { \textDelta } } } - } - } - } - -\cs_new:Npn \Chemalpha { \ensuremath { \alpha } } -\cs_new:Npn \Chembeta { \ensuremath { \beta } } -\cs_new:Npn \Chemgamma { \ensuremath { \gamma } } -\cs_new:Npn \Chemdelta { \ensuremath { \delta } } -\cs_new:Npn \Chemepsilon { \ensuremath { \varepsilon } } -\cs_new:Npn \Chemeta { \ensuremath { \eta } } -\cs_new:Npn \Chemkappa { \ensuremath { \kappa } } -\cs_new:Npn \Chemmu { \ensuremath { \mu } } -\cs_new:Npn \Chemnu { \ensuremath { \nu } } -\cs_new:Npn \Chemrho { \ensuremath { \rho } } -\cs_new:Npn \Chempi { \ensuremath { \pi } } -\cs_new:Npn \Chemsigma { \ensuremath { \sigma } } -\cs_new:Npn \Chemomega { \ensuremath { \omega } } -\cs_new:Npn \ChemDelta { \ensuremath { \Delta } } - -\cs_new:Npn \chemmacros_xspace: + \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 } } + } + +\cs_new_protected:Npn \chemmacros_xspace: { \bool_if:NT \l__chemmacros_xspace_bool { \xspace } } -% --------------------------------------------------------------------------- % -% TikZ drawings -\cs_new:Npn \chemmacros_tikz_picture:nn #1#2 +% -------------------------------------------------------------------------- +% TikZ drawings - helper macros +\cs_new_protected:Npn \chemmacros_tikz_picture:nn #1#2 { \tikzpicture[#1] #2 \endtikzpicture } \cs_generate_variant:Nn \chemmacros_tikz_picture:nn { fn,xn } -\cs_new:Npn \chemmacros_tikz_draw:n #1 +\cs_new_protected:Npn \chemmacros_tikz_draw:n #1 { \draw[#1] } \cs_generate_variant:Nn \chemmacros_tikz_draw:n { f,x } -\cs_new:Npn \chemmacros_tikz_node:n #1 +\cs_new_protected:Npn \chemmacros_tikz_node:n #1 { \node[#1] } \cs_generate_variant:Nn \chemmacros_tikz_node:n { f,x } -\cs_new:Npn \chemmacros_tikz_shade:n #1 +\cs_new_protected:Npn \chemmacros_tikz_shade:n #1 { \shade[#1] } \cs_generate_variant:Nn \chemmacros_tikz_shade:n { f,x } -\cs_new:Npn \chemmacros_tikz_shadedraw:n #1 +\cs_new_protected:Npn \chemmacros_tikz_shadedraw:n #1 { \shadedraw[#1] } \cs_generate_variant:Nn \chemmacros_tikz_shadedraw:n { f,x } -\cs_new:Npn \chemmacros_tikz_node_in_draw:n #1 +\cs_new_protected:Npn \chemmacros_tikz_node_in_draw:n #1 { node[#1] } \cs_generate_variant:Nn \chemmacros_tikz_node_in_draw:n { f,x } -% --------------------------------------------------------------------------- % -% general functions -\cs_new_protected:Npn \chemmacros_leave_vmode: - { \hbox_unpack:N \c_empty_box } - +% -------------------------------------------------------------------------- +% a few general functions: +\cs_new_eq:NN \chemmacros_leave_vmode: \chemformula_leave_vmode: \cs_new_eq:NN \chemmacros_ignore_spaces: \tex_ignorespaces:D +\cs_new_eq:NN \chemmacros_nobreak: \chemformula_nobreak: +\cs_new_eq:NN \chemmacros_allow_break: \chemformula_allow_break: +\cs_new_eq:NN \chemmacros_skip_nobreak:N \chemformula_skip_nobreak:N +\cs_new:Npn \chemmacros_remove_backslash:N #1 + { \exp_after:wN \use_none:n \token_to_str:N #1 } -\cs_new:Npn \chemmacros_nobreak: - { \tex_penalty:D \c_ten_thousand } -\cs_new:Npn \chemmacros_allow_break: - { \tex_penalty:D \c_zero } - -\cs_new:Npn \chemmacros_skip_nobreak:N #1 +% detection and handling of bold face: +\prg_new_conditional:Npnn \chemmacros_if_bold: { T,F,TF } { - \chemmacros_nobreak: - \skip_horizontal:N #1 - \chemmacros_nobreak: + \seq_if_in:NVTF \l__chemmacros_if_bf_seq \f@series + { \prg_return_true: } + { \prg_return_false: } } -% --------------------------------------------------------------------------- % -% circled charge signs -\cs_new_protected:Npn \chemmacros_fplus: - { \ensuremath { \__chemmacros_fplus: } } - -\cs_new:Npn \__chemmacros_fplus: - { \mathpalette \__chemmacros_fplus_aux: \bigcirc } +\seq_new:N \l__chemmacros_if_bf_seq -% TODO: can I rewrite this in a more "expl3-way"? -% and what about a ``text'' version? -\cs_new:Npn \__chemmacros_fplus_aux: #1#2 +\seq_set_split:Nnn \l__chemmacros_if_bf_seq { , } { - \ooalign - { - \tex_hfil:D - $#1+$ - \tex_hfil:D - \tex_cr:D - \tex_hfil:D - $#1#2$ - \tex_hfil:D - \tex_cr:D - } + b , bc , bm , bx , bux , + eb , ebc , ebx , mb , + sb , sbc , sbx , + ub , ubc , ubx } -\cs_new_protected:Npn \chemmacros_fminus: - { \ensuremath { \__chemmacros_fminus: } } - -\cs_new:Npn \__chemmacros_fminus: - { \mathpalette \__chemmacros_fminus_aux_aux: \bigcirc } - -\cs_new:Npn \__chemmacros_fminus_aux_aux: #1#2 +\cs_new_protected:Npn \chemmacros_bm:n #1 { - \ooalign - { - \tex_hfil:D - $#1-$ - \tex_hfil:D - \tex_cr:D - \tex_hfil:D - $#1#2$ - \tex_hfil:D - \tex_cr:D - } + \bool_if:NTF \l__chemmacros_detect_bold_bool + { \bm { #1 } } + { #1 } } -% use directly: -\cs_new_eq:NN \fplus \chemmacros_fplus: -\cs_new_eq:NN \fminus \chemmacros_fminus: - -% change output depending on circled-option -\cs_new:Npn \chemmacros_plus: +\cs_new_protected:Npn \chemmacros_bf:n #1 { - \bool_if:nTF - { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool } - { - \bool_if:NTF \l__chemmacros_circled_chem_bool - { \chemmacros_fplus: } - { \oplus } - } - { + } + \bool_if:NTF \l__chemmacros_detect_bold_bool + { { \normalfont \bfseries #1 } } + { { \normalfont #1 } } } -\cs_new:Npn \chemmacros_minus: +\cs_new_protected:Npn \chemmacros_detect_bold:n #1 { - \bool_if:nTF - { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool } + \chemmacros_if_bold:TF { - \bool_if:NTF \l__chemmacros_circled_chem_bool - { \chemmacros_fminus: } - { \ominus } + \mode_if_math:TF + { \chemmacros_bm:n { #1 } } + { \chemmacros_bf:n { #1 } } } - { - } - } - -\cs_new_protected:Npn \chemmacros_formal_plus: - { - \group_begin: - \bool_set_false:N \l__chemmacros_circled_formal_bool - \chemmacros_plus: - \group_end: - } - -\cs_new_protected:Npn \chemmacros_formal_minus: - { - \group_begin: - \bool_set_false:N \l__chemmacros_circled_formal_bool - \chemmacros_minus: - \group_end: + { #1 } } -% --------------------------------------------------------------------------- % +% --------------------------------------------------------------------------- % transition state symbol -\cs_new:Npn \__chemmacros_transition_state: +\cs_new_protected:Npn \__chemmacros_transition_state: { \text { @@ -693,165 +686,100 @@ } } +% \DeclareDocumentCommand? \cs_new_eq:NN \transitionstatesymbol \chemmacros_transition_state: -\cs_new:Nn \chemmacros_atom:n +% -------------------------------------------------------------------------- +% let's make use of `chemformula' inside some of `chemmacros' commands: +\cs_new_protected:Nn \chemmacros_atom:n { \mode_if_math:TF { \text { \chemmacros_inner_font: #1 } } { \group_begin: \chemmacros_inner_font: #1 \group_end: } } -\cs_generate_variant:Nn \chemmacros_atom:n { o,f,x,V } +\cs_generate_variant:Nn \chemmacros_atom:n { V } -\cs_new:Npn \chemmacros_text:n #1 +\cs_new_protected:Npn \chemmacros_text:n #1 { \mode_if_math:TF { \text { #1 } } { #1 } } -% add a possibility to let chemformula use the chemformula -% with method=chemformula, too \tl_new:N \l__chemmacros_chemformula_tl + \cs_new_protected:Npn \chemmacros_chemformula:n #1 { - \bool_if:NTF \l__chemmacros_use_mhchem_bool - { \ce { #1 } } - { - \group_begin: - \cs_set_eq:NN \chemformula_font_inner: \chemmacros_inner_font: - \chemformula_input_cmpd:nN { #1 } \l__chemmacros_chemformula_tl - \mode_if_math:TF - { \text { \l__chemmacros_chemformula_tl } } - { { \l__chemmacros_chemformula_tl } } - \group_end: - } + \group_begin: + \cs_set_eq:NN \chemformula_font_inner: \chemmacros_inner_font: + \chemformula_chcpd:nn {} { #1 } + \group_end: } \cs_generate_variant:Nn \chemmacros_chemformula:n { x,V } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % particles, charges -\bool_new:N \l__chemmacros_charge_append_bool -\bool_set_false:N \l__chemmacros_charge_append_bool - -% \DeclareChemParticle, \RenewChemParticle -\bool_if:NTF \l__chemmacros_use_mhchem_bool +\NewDocumentCommand \DeclareChemParticle { mm } { - \NewDocumentCommand \DeclareChemParticle { mm } - { - \cs_if_free:NTF #1 - { \cs_new:Npn #1 { \ce { #2 } \chemmacros_xspace: } } - { \chemmacros_msg:nnxx { chemmacros } { declare-particle } { #1 } {} } - } - \NewDocumentCommand \RenewChemParticle { mm } - { - \cs_if_free:NTF #1 - { \chemmacros_msg:nnxx { chemmacros } { renew-particle } { #1 } {} } - { \cs_set:Npn #1 { \ce { #2 } \chemmacros_xspace: } } - } + \cs_if_free:NTF #1 + { \chemmacros_new_particle:Nn #1 { #2 } } + { \chemmacros_msg:nnxx { chemmacros } { declare-particle } { #1 } {} } } + +\NewDocumentCommand \RenewChemParticle { mm } { - \NewDocumentCommand \DeclareChemParticle { mm } - { - \cs_if_free:NTF #1 - { \chemmacros_chem_particle:Nn #1 { #2 } } - { \chemmacros_msg:nnxx { chemmacros } { declare-particle } { #1 } {} } - } - \NewDocumentCommand \RenewChemParticle { mm } - { - \cs_if_free:NTF #1 - { \chemmacros_msg:nnxx { chemmacros } { renew-particle } { #1 } {} } - { \chemmacros_chem_particle:Nn #1 { #2 } } - } + \cs_if_free:NTF #1 + { \chemmacros_msg:nnxx { chemmacros } { renew-particle } { #1 } {} } + { \chemmacros_new_particle:Nn #1 { #2 } } } -\cs_new_protected:Nn \chemmacros_chem_particle:Nn +\cs_new_protected:Nn \chemmacros_new_particle:Nn { - \cs_set:Npn #1 + \cs_set_protected:Npn #1 { - \bool_if:NTF \l__chemformula_inside_ch_bool - { - \chemformula_input_cmpd:nN { #2 } \l__chemmacros_chemformula_tl - \tl_set_rescan:Nno \l__chemmacros_chemformula_tl - { \ExplSyntaxOn } - { \l__chemmacros_chemformula_tl } - \tl_use:N \l__chemmacros_chemformula_tl - \tl_clear:N \l__chemmacros_chemformula_tl - } - { - \group_begin: - \chemformula_input:n { #2 } - \tl_set_rescan:Nno \l__chemmacros_tmpa_tl - { \ExplSyntaxOn } - { \l__chemformula_input_tl } - \chemformula_write:V \l__chemmacros_tmpa_tl - \group_end: - \chemmacros_xspace: - } + \chemformula_chcpd:nn {} { #2 } + \chemmacros_xspace: } } -\bool_if:NTF \l__chemmacros_use_mhchem_bool - { - \cs_new:Npn \el { \chemmacros_atom:n { e } \mch \chemmacros_xspace: } - \cs_new:Npn \prt { \chemmacros_atom:n { p } \pch \chemmacros_xspace: } - } - { - \DeclareChemParticle \el { e- } - \DeclareChemParticle \prt { p+ } - } - +\DeclareChemParticle \el { e- } +\DeclareChemParticle \prt { p+ } \DeclareChemParticle \ntr { n^0 } -\cs_new:Npn \chemmacros_bm:n #1 - { - \bool_if:NTF \l__chemmacros_detect_bold_bool - { \bm { #1 } } - { #1 } - } +\DeclareChemDropped \Rad -\cs_new:Npn \chemmacros_bf:n #1 - { - \bool_if:NTF \l__chemmacros_detect_bold_bool - { { \normalfont \bfseries #1 } } - { { \normalfont #1 } } - } +% -------------------------------------------------------------------------- +% charges +% circled charge signs: they are defined in the `chemformula' module: +% use directly: + +\cs_new_protected:Npn \fplus { { \chemformula_fplus: } } +\cs_new_protected:Npn \fminus { { \chemformula_fminus: } } + +% change output depending on circled-option +\cs_new_eq:NN \chemmacros_plus: \chemformula_plus: +\cs_new_eq:NN \chemmacros_minus: \chemformula_minus: -\cs_new:Npn \chemmacros_detect_bold:n #1 +\cs_new_protected:Npn \chemmacros_formal_plus: { - \chemmacros_if_bold:TF - { - \mode_if_math:TF - { \chemmacros_bm:n { #1 } } - { \chemmacros_bf:n { #1 } } - } - { #1 } + \group_begin: + \bool_set_true:N \l__chemformula_formal_charges_bool + \chemformula_plus: + \group_end: } -\NewDocumentCommand \Rad { O{}G{} } +\cs_new_protected:Npn \chemmacros_formal_minus: { - \chemmacros_msg:nnxx { chemmacros } { command-dropped } - { \Rad } { } - #1#2 + \group_begin: + \bool_set_true:N \l__chemformula_formal_charges_bool + \chemformula_minus: + \group_end: } -% charges -\cs_new:Npn \chemmacros_charge:n #1 +\cs_new_protected:Npn \chemmacros_charge:n #1 { - \bool_if:NTF \l__chemmacros_charge_append_bool - { - \mode_if_math:TF - { {}^ { \chemmacros_detect_bold:n { #1 } } } - { $ {}^ { \chemmacros_detect_bold:n { #1 } } $ } - } - { - \mode_if_math:TF - { ^ { \chemmacros_detect_bold:n { #1 } } } - { $ ^ { \chemmacros_detect_bold:n { #1 } } $ } - } + \chemformula_superscript:n + { \chemmacros_detect_bold:n { #1 } } } \keys_define:nn { chemmacros / charges } - { - append .bool_set:N = \l__chemmacros_charge_append_bool , - append .default:n = true - } + { append .code:n = \chemmacros_option_deprecated:n { append } } \NewDocumentCommand \mch { o } { @@ -881,44 +809,67 @@ { \chemmacros_charge:n { #1 \chemmacros_formal_plus: } } } -\cs_new:Npn \delm - { \mbox { \tiny \( \delta \chemmacros_minus: \) } \chemmacros_xspace: } -\cs_new:Npn \delp - { \mbox { \tiny \( \delta \chemmacros_plus: \) } \chemmacros_xspace: } -\cs_new:Npn \fdelm - { \mbox { \tiny \( \delta \chemmacros_formal_minus: \) } \chemmacros_xspace: } -\cs_new:Npn \fdelp - { \mbox { \tiny \( \delta \chemmacros_formal_plus: \) } \chemmacros_xspace: } -\cs_new:Npn \scrm +\tl_new:N \l__chemmacros_partial_charge_format_tl +\tl_set:Nn \l__chemmacros_partial_charge_format_tl { \tiny } + +\cs_new_protected:Npn \delm + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \( \delta \chemmacros_minus: \) + } + \chemmacros_xspace: + } +\cs_new_protected:Npn \delp + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \( \delta \chemmacros_plus: \) + } + \chemmacros_xspace: + } +\cs_new_protected:Npn \fdelm + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \( \delta \chemmacros_formal_minus: \) + } + \chemmacros_xspace: + } +\cs_new_protected:Npn \fdelp + { + \mbox { + \l__chemmacros_partial_charge_format_tl + \( \delta \chemmacros_formal_plus: \) + } + \chemmacros_xspace: + } + +\cs_new_protected:Npn \scrm { \ensuremath { \scriptstyle \chemmacros_minus: } } -\cs_new:Npn \scrp +\cs_new_protected:Npn \scrp { \ensuremath { \scriptstyle \chemmacros_plus: } } -\cs_new:Npn \fscrm +\cs_new_protected:Npn \fscrm { \ensuremath { \scriptstyle \chemmacros_formal_minus: } } -\cs_new:Npn \fscrp +\cs_new_protected:Npn \fscrp { \ensuremath { \scriptstyle \chemmacros_formal_plus: } } -\cs_new:Npn \fsscrm +\cs_new_protected:Npn \fsscrm { \ensuremath { \scriptscriptstyle \chemmacros_formal_minus: } } -\cs_new:Npn \fsscrp +\cs_new_protected:Npn \fsscrp { \ensuremath { \scriptscriptstyle \chemmacros_formal_plus: } } -% --------------------------------------------------------------------------- % -% ions, molecules -% proton, hydroxide, hydronium/oxonium, water, nucleophile, electrophile -\bool_if:NTF \l__chemmacros_use_mhchem_bool - { - \cs_new:Npn \Hpl { \chemmacros_atom:n { H } \pch \chemmacros_xspace: } - \cs_new:Npn \Hyd { \chemmacros_atom:n { OH } \mch \chemmacros_xspace: } - \cs_new:Npn \HtO { \chemmacros_chemformula:n { H3O } \pch \chemmacros_xspace: } - \cs_new:Npn \El { \chemmacros_atom:n { E } \pch \chemmacros_xspace: } - } +\keys_define:nn { chemmacros / charges } { - \DeclareChemParticle \Hpl { H+ } - \DeclareChemParticle \Hyd { OH- } - \DeclareChemParticle \HtO { H3O+ } - \DeclareChemParticle \El { E+ } + partial-format .tl_set:N = \l__chemmacros_partial_charge_format_tl } +% -------------------------------------------------------------------------- +% ions, molecules +% proton, hydroxide, hydronium/oxonium, water, nucleophile, electrophile +\DeclareChemParticle \Hpl { H+ } +\DeclareChemParticle \Hyd { OH- } +\DeclareChemParticle \HtO { H3O+ } +\DeclareChemParticle \El { E+ } \DeclareChemParticle \water { H2O } \NewDocumentCommand \chemmacros_Nu:w { o } @@ -926,11 +877,7 @@ \IfNoValueF { #1 } { \keys_set:nn { chemmacros / particle } { #1 } } \bool_if:NTF \l__chemmacros_particle_elpair_bool { \chemmacros_elpair:n { Nu } \mch } - { - \bool_if:NTF \l__chemmacros_use_mhchem_bool - { \chemmacros_atom:n { Nu } \mch } - { \chemmacros_chemformula:n { Nu- } } - } + { \chemmacros_chemformula:n { Nu- } } \chemmacros_xspace: } @@ -941,15 +888,11 @@ { \cs_set_eq:NN \Nu \chemmacros_Nu:w } } -\cs_new:Npn \chemmacros_ba: +\cs_new_protected:Npn \chemmacros_ba: { \bool_if:NTF \l__chemmacros_particle_elpair_bool { \chemmacros_elpair:n { ba } \mch } - { - \bool_if:NTF \l__chemmacros_use_mhchem_bool - { \chemmacros_atom:n { ba } \mch } - { \chemmacros_chemformula:n { ba- } } - } + { \chemmacros_chemformula:n { ba- } } \chemmacros_xspace: } @@ -961,7 +904,7 @@ \group_end: } -\cs_new:Npn \chemmacros_elpair:n #1 +\cs_new_protected:Npn \chemmacros_elpair:n #1 { \bool_if:NTF \l__chemmacros_chemfig_bool { @@ -998,20 +941,21 @@ elpair .default:n = dots } -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% -------------------------------------------------------------------------- % IUPAC \prop_new:N \l__chemmacros_iupac_prop \cs_new_protected:Npn \chemmacros_declare_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 } - \prop_if_in:NoTF \l__chemmacros_iupac_prop { \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 { \chemmacros_msg:nnxx { chemmacros } { declare-iupac } { #1 } { } } - { \prop_put:Non \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } { #2 } } + { + \prop_put:NVn \l__chemmacros_iupac_prop + \l__chemmacros_tmpa_tl + { #2 } + } \chemmacros_make_iupac: } @@ -1022,8 +966,12 @@ { #1 } \tl_set:Nf \l__chemmacros_tmpa_tl { \tl_tail:V \l__chemmacros_tmpa_tl } - \prop_if_in:NoTF \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } - { \prop_put:Non \l__chemmacros_iupac_prop { \l__chemmacros_tmpa_tl } { #2 } } + \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 } { } } \chemmacros_make_iupac: } @@ -1076,8 +1024,8 @@ \NewDocumentCommand \cip { m } { \chemmacros_cip:n { #1 } } -\cs_new:Npn \chemmacros_cip:n #1 - { (\textit{#1}\tex_kern:D \l__chemmacros_cip_kern_dim) } +\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 } } @@ -1087,7 +1035,7 @@ % TikZ needs : to be other \ExplSyntaxOff -\def\chemmacros@sconf#1% +\protected\def\chemmacros@sconf#1% {% \tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex] { @@ -1096,7 +1044,7 @@ }% } -\def\chemmacros@rconf#1% +\protected\def\chemmacros@rconf#1% {% \tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex] { @@ -1119,8 +1067,8 @@ \DeclareChemIUPAC \tert { \textit { tert } } % Fischer -\DeclareChemDeprecated \Dfi \D { \textsc { d } } -\DeclareChemDeprecated \Lfi \L { \textsc { l } } +\DeclareChemDropped \Dfi +\DeclareChemDropped \Lfi \DeclareChemIUPAC \D { \textsc { d } } \DeclareChemIUPAC \L { \textsc { l } } @@ -1148,10 +1096,10 @@ coord-use-hyphen .default:n = true } -\cs_new:Npn \chemformula_hapto:n #1 +\cs_new_protected:Npn \chemformula_hapto:n #1 { \Chemeta \chemformula_superscript:n { #1 } \chemmacros_break_point_hyphen: } -\cs_new:Npn \chemformula_bridge:n #1 +\cs_new_protected:Npn \chemformula_bridge:n #1 { \Chemmu \tl_if_blank:nF { #1 } @@ -1167,11 +1115,11 @@ \DeclareChemIUPAC \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 } } +\DeclareChemIUPAC \H { \textit { H } } +\DeclareChemIUPAC \O { \textit { O } } +\DeclareChemIUPAC \N { \textit { N } } +\DeclareChemIUPAC \Sf { \textit { S } } +\DeclareChemIUPAC \P { \textit { P } } % language specific settings \AtBeginDocument @@ -1265,6 +1213,7 @@ \NewDocumentCommand \iupac { m } { \chemmacros_iupac:n { #1 } } +% -------------------------------------------------------------------------- % latin phrases \tl_new:N \l__chemmacros_latin_format_tl \tl_set:Nn \l__chemmacros_latin_format_tl { \itshape } @@ -1272,7 +1221,7 @@ \keys_define:nn { chemmacros / latin } { format . tl_set:N = \l__chemmacros_latin_format_tl } -\cs_new:Npn \chemmacros_latin:n #1 +\cs_new_protected:Npn \chemmacros_latin:n #1 { { \l__chemmacros_latin_format_tl #1 } } \prop_new:N \l__chemmacros_latin_prop @@ -1281,7 +1230,8 @@ { \cs_if_free:NTF #1 { - \cs_new:Npn #1 { \chemmacros_latin:n { #2 } \chemmacros_xspace: } + \cs_new_protected:Npn #1 + { \chemmacros_latin:n { #2 } \chemmacros_xspace: } \prop_put:Nnn \l__chemmacros_latin_prop { #1 } { #2 } } { \chemmacros_msg:nnxx { chemmacros } { declare-latin } { #1 } { } } @@ -1313,13 +1263,13 @@ { \cs_new_eq:NN \latin \chemmacros_latin:n } - \DeclareChemLatin \insitu { in~situ } + \DeclareChemLatin \insitu { in~situ } \DeclareChemLatin \abinitio { ab~initio } - \DeclareChemLatin \invacuo { in~vacuo } + \DeclareChemLatin \invacuo { in~vacuo } } % --------------------------------------------------------------------------- % -% acid/base +% acid / base \keys_define:nn { chemmacros / acid-base } { p-style .choice: , @@ -1330,64 +1280,56 @@ \cs_new_eq:NN \chemmacros_p_style:n \textup -% TODO: rewrite in expl3 style -\cs_new:Npn \chemmacros_if_bold:TF #1#2 - { - \ifx\f@series\l__chemmacros_if_bf_tl - \expandafter\@firstoftwo - \else - \expandafter\@secondoftwo - \fi - { #1 }{ #2 } - } - -\tl_new:N \l__chemmacros_if_bf_tl -\tl_set:Nn \l__chemmacros_if_bf_tl { bx } - \cs_new_protected:Npn \Ka { - \mbox + \ensuremath { - \( - \chemmacros_detect_bold:n - { - K \c_math_subscript_token \mathrm - { \bool_if:NTF \l__chemmacros_german_bool { S } { A } } - } - \) + \chemmacros_detect_bold:n + { + K + \c_math_subscript_token + { \chemmacros_translate:nn { K-acid } { A } } + } } \chemmacros_xspace: } \cs_new_protected:Npn \Kb { - \mbox + \ensuremath { - \( - \chemmacros_detect_bold:n - { K \c_math_subscript_token \mathrm { B } } - \) + \chemmacros_detect_bold:n + { + K + \c_math_subscript_token + { \chemmacros_translate:nn { K-base } { B } } + } } \chemmacros_xspace: } \cs_new_protected:Npn \Kw { - \mbox + \ensuremath { - \( - \chemmacros_detect_bold:n - { K \c_math_subscript_token \mathrm { W } } - \) + \chemmacros_detect_bold:n + { + K + \c_math_subscript_token + { \chemmacros_translate:nn { K-water } { W } } + } } \chemmacros_xspace: } -\cs_new:Npn \chemmacros_p:n #1 +\cs_new_protected:Npn \chemmacros_p:n #1 { \group_begin: - \chemmacros_p_style:n { p } - \ensuremath { #1 } + \mbox + { + \chemmacros_p_style:n { p } + \ensuremath { #1 } + } \group_end: } @@ -1411,7 +1353,7 @@ \chemmacros_p:n { \Ka \IfNoValueF { #1 } - { \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } + { {} \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } } \chemmacros_xspace: } @@ -1421,12 +1363,12 @@ \chemmacros_p:n { \Kb \IfNoValueF { #1 } - { \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } + { {} \c_math_subscript_token { \chemmacros_detect_bold:n { #1 } } } } \chemmacros_xspace: } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % units \DeclareSIUnit { \atm } { atm } \DeclareSIUnit { \atmosphere } { atm } @@ -1448,7 +1390,7 @@ \DeclareSIUnit { \normal } { \textsc{n} } \DeclareSIUnit { \torr } { torr } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % reaction mechanisms % \mech[<type>] % <type> - substitutions: {}, 1, 2, se, 1e, 2e, ar @@ -1545,27 +1487,27 @@ { \chemmacros_mech:n { #1 } } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % oxidation numbers % \ox{<number>,<atom>} -\bool_new:N \l__chemmacros_ox_sign_bool -\bool_new:N \l__chemmacros_ox_integer_bool -\bool_new:N \l__chemmacros_ox_explicit_sign_bool +\bool_new:N \l__chemmacros_ox_sign_bool +\bool_new:N \l__chemmacros_ox_integer_bool +\bool_new:N \l__chemmacros_ox_explicit_sign_bool \bool_set_false:N \l__chemmacros_ox_explicit_sign_bool -\bool_new:N \l__chemmacros_ox_format_roman_bool -\bool_set_true:N \l__chemmacros_ox_format_roman_bool -\bool_new:N \l__chemmacros_ox_decimal_marker_comma_bool +\bool_new:N \l__chemmacros_ox_format_roman_bool +\bool_set_true:N \l__chemmacros_ox_format_roman_bool +\bool_new:N \l__chemmacros_ox_decimal_marker_comma_bool \bool_set_false:N \l__chemmacros_ox_decimal_marker_comma_bool -\bool_new:N \l__chemmacros_ox_parse_bool -\bool_set_true:N \l__chemmacros_ox_parse_bool -\bool_new:N \l__chemmacros_ox_side_bool -\bool_new:N \l__chemmacros_ox_super_bool -\bool_new:N \l__chemmacros_ox_top_bool -\bool_set_true:N \l__chemmacros_ox_top_bool -\bool_new:N \l__chemmacros_ox_align_center_bool +\bool_new:N \l__chemmacros_ox_parse_bool +\bool_set_true:N \l__chemmacros_ox_parse_bool +\bool_new:N \l__chemmacros_ox_side_bool +\bool_new:N \l__chemmacros_ox_super_bool +\bool_new:N \l__chemmacros_ox_top_bool +\bool_set_true:N \l__chemmacros_ox_top_bool +\bool_new:N \l__chemmacros_ox_align_center_bool -\int_new:N \l__chemmacros_ox_number_int -\fp_new:N \l__chemmacros_ox_number_fp +\int_new:N \l__chemmacros_ox_number_int +\fp_new:N \l__chemmacros_ox_number_fp \cs_new_protected:Npn \__chemmacros_ox_process_number:n #1 { @@ -1591,16 +1533,20 @@ slash-symbol-font = lmr } -\cs_new:Npn \__chemmacros_ox_fraction:n #1/#2 +\cs_new_protected:Npn \__chemmacros_ox_fraction:n #1/#2 { \bool_set_false:N \l__chemmacros_ox_format_roman_bool \__chemmacros_ox_sign:n { #1 } \bool_if:NTF \l__chemmacros_ox_side_bool { \sfrac { \__chemmacros_ox_value:n { #1 } } { #2 } } - { \sfrac [ chemmacros-ox-frac ] { \__chemmacros_ox_value:n { #1 } } { #2 } } + { + \sfrac [ chemmacros-ox-frac ] + { \__chemmacros_ox_value:n { #1 } } + { #2 } + } } -\cs_new:Npn \__chemmacros_ox_sign:n #1 +\cs_new_protected:Npn \__chemmacros_ox_sign:n #1 { \fp_compare:nNnT { #1 } > { 0 } { \bool_if:NT \l__chemmacros_ox_explicit_sign_bool { $+$ } } @@ -1616,13 +1562,11 @@ \fp_abs:N \l__chemmacros_ox_number_fp \__chemmacros_ox_is_integer:V \l__chemmacros_ox_number_fp \bool_if:NTF \l__chemmacros_ox_format_roman_bool - { - \__chemmacros_fp_to_Roman:V \l__chemmacros_ox_number_fp - } + { \__chemmacros_fp_to_Roman:V \l__chemmacros_ox_number_fp } { \bool_if:NTF \l__chemmacros_ox_integer_bool - { \__chemmacros_fp_to_arabic:V \l__chemmacros_ox_number_fp } - { \__chemmacros_fp_show:V \l__chemmacros_ox_number_fp } + { $ \__chemmacros_fp_to_arabic:V \l__chemmacros_ox_number_fp $ } + { $ \__chemmacros_fp_show:V \l__chemmacros_ox_number_fp $ } } } @@ -1646,10 +1590,11 @@ \group_begin: \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } \fp_round_places:Nn \l__chemmacros_tmpa_tl { 0 } - \int_set:Nn \l__chemmacros_tmpa_int { \fp_to_tl:N \l__chemmacros_tmpa_tl } + \int_set:Nn \l__chemmacros_tmpa_int + { \fp_to_tl:N \l__chemmacros_tmpa_tl } \int_compare:nTF { \l__chemmacros_tmpa_int = 0 } { 0 } - { \int_to_Roman:n { \int_use:N \l__chemmacros_tmpa_int } } + { \int_to_Roman:n { \l__chemmacros_tmpa_int } } \group_end: } \cs_generate_variant:Nn \__chemmacros_fp_to_Roman:n { V } @@ -1669,7 +1614,8 @@ \fp_set:Nn \l__chemmacros_tmpa_tl { #1 } \bool_if:NTF \l__chemmacros_ox_decimal_marker_comma_bool { - \tl_set:Nx \l__chemmacros_tmpb_tl { \fp_to_tl:N \l__chemmacros_tmpa_tl } + \tl_set:Nx \l__chemmacros_tmpb_tl + { \fp_to_tl:N \l__chemmacros_tmpa_tl } \tl_replace_once:Nnn \l__chemmacros_tmpb_tl { . } { {,} } \tl_use:N \l__chemmacros_tmpb_tl } @@ -1810,12 +1756,19 @@ \cs_new_protected:Npn \chemmacros_redox_partner:nn #1#2 { - \tl_if_blank:nT { #1 } - { \msg_error:nnx { chemmacros } { OX } { node~name~missing } } - \tl_if_blank:nT { #2 } - { \msg_error:nnx { chemmacros } { OX } { atom~missing } } - \tikz[baseline=(#1.base),remember~picture] - { \node [inner~sep=0] (#1) { #2 } ; } + \chemformula_latex_if:nTF { measuring@ } + { + \tikz[baseline=(#1.base)] + { \node [inner~sep=0] (#1) { #2 } ; } + } + { + \tl_if_blank:nT { #1 } + { \msg_error:nnx { chemmacros } { OX } { node~name~missing } } + \tl_if_blank:nT { #2 } + { \msg_error:nnx { chemmacros } { OX } { atom~missing } } + \tikz[baseline=(#1.base),remember~picture] + { \node [inner~sep=0] (#1) { #2 } ; } + } } \cs_new_protected:Npn \__chemmacros_redox_coordinates:nn #1#2 @@ -1937,20 +1890,18 @@ \leftmargin\z@ } -\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_parse_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_parse_bool \bool_set_true:N \l__chemmacros_nmr_parse_bool -\bool_new:N \l__chemmacros_nmr_list_bool -% \bool_set_true:N \l__chemmacros_nmr_list_bool -\bool_new:N \l__chemmacros_nmr_use_equal_bool -% \bool_set_true:N \l__chemmacros_nmr_use_equal_bool -\bool_new:N \l__chemmacros_nmr_custom_command_active_bool -\bool_new:N \l__chemmacros_nmr_custom_command_used_bool +\bool_new:N \l__chemmacros_nmr_list_bool +\bool_new:N \l__chemmacros_nmr_use_equal_bool +\bool_new:N \l__chemmacros_nmr_custom_command_active_bool +\bool_new:N \l__chemmacros_nmr_custom_command_used_bool \cs_new_protected:Npn \__chemmacros_nmr_nucleus:w #1,#2 \q_stop { @@ -1983,33 +1934,25 @@ \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} } } \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { #2 } - \bool_if:NTF \l__chemmacros_bpchem_bool - { \IUPAC { \^ { #1 } \g__chemmacros_nmr_element_coupled_tl - NMR } } - { - \iupac { \^ { #1 } } - \bool_if:NTF \l__chemmacros_nmr_parse_bool - { - \bool_if:NTF \l__chemmacros_use_mhchem_bool - { \exp_args:No \ce { \g__chemmacros_nmr_element_coupled_tl } } - { \exp_args:No \ch { \g__chemmacros_nmr_element_coupled_tl } } - } - { \chemmacros_atom:V \g__chemmacros_nmr_element_coupled_tl } - - NMR - } + \iupac { \^ { #1 } } + \bool_if:NTF \l__chemmacros_nmr_parse_bool + { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl } + { \chemmacros_atom:V \g__chemmacros_nmr_element_coupled_tl } + - NMR } \cs_generate_variant:Nn \__chemmacros_nmr_base:nn { VV } -\cs_new:Npn \__chemmacros_nmr_frequency:n #1 +\cs_new_protected:Npn \__chemmacros_nmr_frequency:n #1 { \tl_if_in:nnTF { #1 } { , } { \__chemmacros_nmr_frequency_aux_i:w #1 \q_stop } { \__chemmacros_nmr_frequency_aux_ii:n { #1 } } } -\cs_new:Npn \__chemmacros_nmr_frequency_aux_i:w #1,#2 \q_stop +\cs_new_protected:Npn \__chemmacros_nmr_frequency_aux_i:w #1,#2 \q_stop { \SI { #1 } { #2 } } -\cs_new:Npn \__chemmacros_nmr_frequency_aux_ii:n #1 +\cs_new_protected:Npn \__chemmacros_nmr_frequency_aux_ii:n #1 { \SI { #1 } { \tl_use:N \l__chemmacros_nmr_unit_tl } } \keys_define:nn { chemmacros / nmr } @@ -2066,21 +2009,27 @@ \NewDocumentCommand \RenewChemNMR { mm } { \chemmacros_renew_nmr:Nn #1 { #2 } } -% TODO: separate document and module level +\NewDocumentCommand \NMR { s G{} D(){} O{} } + { + \IfBooleanTF { #1 } + { \chemmacros_nmr:nnnn { * } { #2 } { #3 } { #4 } } + { \chemmacros_nmr:nnnn { } { #2 } { #3 } { #4 } } + } + \AtBeginDocument { % \NMR{<num>,<elem>}(<num>,<unit>)[<solvent>] ALL arguments are optional % \NMR* same but without ": $\delta$" at end - \NewDocumentCommand \NMR { s g d() o } + \cs_new_protected:Npn \chemmacros_nmr:nnnn #1#2#3#4 { \bool_if:NT \l__chemmacros_nmr_list_bool { \item \scan_stop: } \group_begin: \chemmacros_leave_vmode: \bool_set_false:N \l__chemmacros_nmr_frequency_bool \bool_set_false:N \l__chemmacros_nmr_solvent_bool - \IfNoValueF { #3 } + \tl_if_empty:nF { #3 } { \bool_set_true:N \l__chemmacros_nmr_frequency_bool } - \IfNoValueF { #4 } + \tl_if_empty:nF { #4 } { \bool_set_true:N \l__chemmacros_nmr_solvent_bool } \bool_if:nT { @@ -2096,7 +2045,7 @@ \l__chemmacros_nmr_solvent_bool } { \bool_set_true:N \l__chemmacros_nmr_comma_bool } - \IfNoValueTF { #2 } + \tl_if_empty:nTF { #2 } { \__chemmacros_nmr_nucleus:w \l__chemmacros_nmr_isotope_default_tl , @@ -2122,10 +2071,10 @@ { \chemmacros_atom:n { #4 } } \bool_if:NT \l__chemmacros_nmr_delimiters_bool { ) } - \IfBooleanF { #1 } { : ~ } + \tl_if_blank:nT { #1 } { : ~ } \group_end: } - \IfBooleanF { #1 } + \tl_if_blank:nT { #1 } { \delta \text { \l__chemmacros_nmr_delta_tl } @@ -2147,25 +2096,21 @@ \bool_if:NT \l__chemmacros_nmr_solvent_bool { \bool_if:NTF \l__chemmacros_nmr_parse_bool - { - \bool_if:NTF \l__chemmacros_use_mhchem_bool - { \ce { #4 } } - { \ch { #4 } } - } + { \chemformula_ch:nn { } { #4 } } { #4 } } \bool_if:NT \l__chemmacros_nmr_delimiters_bool { ) } - \IfBooleanF { #1 } { : } + \tl_if_blank:nT { #1 } { : } \group_end: - \IfBooleanF { #1 } + \tl_if_blank:nT { #1 } { \tl_use:N \c_space_tl $ \delta $ \l__chemmacros_nmr_delta_tl \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } } \bool_if:NF \l__chemmacros_nmr_comma_bool - { \IfBooleanF { #1 } { \chemmacros_xspace: } } + { \tl_if_blank:nT { #1 } { \chemmacros_xspace: } } } \group_end: } @@ -2188,6 +2133,7 @@ { \chemmacros_val_aux:w #1 \q_nil } { \num { #1 } } } + \cs_new_protected:Npn \chemmacros_val_aux:w #1--#2 \q_nil { \numrange { #1 } { #2 } } @@ -2211,30 +2157,14 @@ \chemmacros_ignore_spaces: } -\cs_new:Npn \chemmacros_nmr_number:n #1 - { - #1 \, - \bool_if:NTF \l__chemmacros_bpchem_bool - { \g__chemmacros_nmr_element_tl } - { \chemmacros_atom:V \g__chemmacros_nmr_element_tl } - } +\cs_new_protected:Npn \chemmacros_nmr_number:n #1 + { #1 \, \chemmacros_atom:V \g__chemmacros_nmr_element_tl } -\cs_new:Npn \chemmacros_nmr_position:n #1 +\cs_new_protected:Npn \chemmacros_nmr_position:n #1 { - \bool_if:NTF \l__chemmacros_bpchem_bool - { - \tl_use:N \g__chemmacros_nmr_element_tl - \bool_if:NTF \l__chemmacros_nmr_position_sub_bool - { $\sb{#1}$ } - { - #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 } - } + \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 } } \cs_new_protected:Npn \chemmacros_nmr_coupling:w @@ -2255,14 +2185,14 @@ \__chemmacros_nmr_coupling_aux_i:w } -\cs_new:Npn \__chemmacros_nmr_coupling_aux_i:w +\cs_new_protected:Npn \__chemmacros_nmr_coupling_aux_i:w { \peek_meaning:NTF [ { \__chemmacros_nmr_coupling_aux_ii:w } { \__chemmacros_nmr_coupling_aux_iii:n } } -\cs_new:Npn \__chemmacros_nmr_coupling_aux_ii:w [#1]#2 +\cs_new_protected:Npn \__chemmacros_nmr_coupling_aux_ii:w [#1]#2 { \group_begin: \sisetup @@ -2278,7 +2208,7 @@ \group_end: } -\cs_new:Npn \__chemmacros_nmr_coupling_aux_iii:n #1 +\cs_new_protected:Npn \__chemmacros_nmr_coupling_aux_iii:n #1 { \group_begin: \sisetup @@ -2295,14 +2225,10 @@ \group_end: } -% --------------------------------------------------------------------------- % -% placing text below atom/molecule -\cs_new_protected:Npn \chemmacros_dim_to_width:Nn #1#2 - { - \hbox_set:Nn \l__chemmacros_tmpa_box { #2 } - \dim_set:Nn #1 { \box_wd:N \l__chemmacros_tmpa_box } - \box_clear:N \l__chemmacros_tmpa_box - } +% -------------------------------------------------------------------------- +% 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 @@ -2331,7 +2257,7 @@ } % \mhName[<keyval>]{<chemformula>}{<text>} -\bool_if:nF { \l__chemmacros_version_one_bool || \l__chemmacros_use_mhchem_bool } +\bool_if:NF \l__chemmacros_version_one_bool { \NewDocumentCommand \mhName { o m m } { @@ -2352,7 +2278,7 @@ #3 } } - { \ce { #2 } } + { \cf { #2 } } } \group_end: } @@ -2374,75 +2300,57 @@ space .dim_set:N = \l__chemmacros_phases_space_dim } -\cs_new_protected:Npn \chemmacros_declare_phase:Nnn #1#2#3 +\cs_new_protected:Npn \chemmacros_declare_phase: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 } - \cs_if_free:NTF #1 - { \cs_new:Npn #1 {} } + \tl_set:Nx \l__chemmacros_tmpa_tl + { \chemmacros_remove_backslash:N #1 } + \cs_if_free:NF #1 { \chemmacros_msg:nnxx { chemmacros } { declare-phase } { #1 } {} } - \tl_if_blank:nTF { #2 } - { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #3 } } - { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #2 } } - \prop_put:Non \l__chemmacros_phases_prop - { \l__chemmacros_tmpa_tl } - { #3 } - \chemmacros_make_phases: + \DeclareTranslationFallback { phase-\l__chemmacros_tmpa_tl } { #2 } + \__chemmacros_define_phase:Nx #1 + { + \exp_not:N \chemmacros_translate:nn + { phase-\l__chemmacros_tmpa_tl } + { #2 } + } } -\cs_new_protected:Npn \chemmacros_renew_phase:Nnn #1#2#3 +\cs_new_protected:Npn \chemmacros_renew_phase: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 } \cs_if_free:NT #1 { \chemmacros_msg:nnxx { chemmacros } { renew-phase } { #1 } {} } - \tl_if_blank:nTF { #2 } - { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #3 } } - { \prop_put:Non \l__chemmacros_phases_german_prop { \l__chemmacros_tmpa_tl } { #2 } } - \prop_put:Non \l__chemmacros_phases_prop - { \l__chemmacros_tmpa_tl } - { #3 } - \chemmacros_make_phases: + \DeclareTranslationFallback { phase-\l__chemmacros_tmpa_tl } { #2 } + \__chemmacros_define_phase:Nx #1 + { + \exp_not:N \chemmacros_translate:nn + { phase-\l__chemmacros_tmpa_tl } + { #2 } + } } \NewDocumentCommand \DeclareChemPhase { mom } { \IfNoValueTF { #2 } - { \chemmacros_declare_phase:Nnn #1 { } { #3 } } - { \chemmacros_declare_phase:Nnn #1 { #2 } { #3 } } + { \chemmacros_declare_phase:Nn #1 { #3 } } + { \chemmacros_declare_phase:Nn #1 { #3 } } } \NewDocumentCommand \RenewChemPhase { mom } { \IfNoValueTF { #2 } - { \chemmacros_renew_phase:Nnn #1 { } { #3 } } - { \chemmacros_renew_phase:Nnn #1 { #2 } { #3 } } - } - -\cs_new_protected:Npn \chemmacros_make_phases: - { - \bool_if:NTF \l__chemmacros_german_bool - { - \prop_map_function:NN \l__chemmacros_phases_german_prop - \__chemmacros_define_phases:nn - } - { - \prop_map_function:NN \l__chemmacros_phases_prop - \__chemmacros_define_phases:nn - } + { \chemmacros_renew_phase:Nn #1 { #3 } } + { \chemmacros_renew_phase:Nn #1 { #3 } } } -\cs_new_protected:Npn \__chemmacros_define_phases:nn #1#2 +\cs_new_protected:Npn \__chemmacros_define_phase:Nn #1#2 { - \cs_set:cpn { #1 } + \cs_set_protected:Npn #1 { \bool_if:NTF \l__chemmacros_phases_sub_bool { - \bool_if:NTF \l__chemformula_inside_ch_bool + \bool_if:NTF \l_chemformula_inside_ch_bool { \chemformula_subscript:n { ( #2 ) } } { \ensuremath { \c_math_subscript_token { \text { (#2) } } } } } @@ -2455,13 +2363,14 @@ } } } +\cs_generate_variant:Nn \__chemmacros_define_phase:Nn { Nx } -\DeclareChemPhase \sld [ f ] { s } -\DeclareChemPhase \lqd [ f{}l ] { l } -\DeclareChemPhase \gas { g } -\DeclareChemPhase \aq { aq } +\DeclareChemPhase\sld{ s } +\DeclareChemPhase\lqd{ l } +\DeclareChemPhase\gas{ g } +\DeclareChemPhase\aq { aq } -\cs_new:Npn \chemmacros_phase:n #1 +\cs_new_protected:Npn \chemmacros_phase:n #1 { \bool_if:NTF \l__chemmacros_phases_sub_bool { \ensuremath { \c_math_subscript_token { \text { (#1) } } } } @@ -2483,29 +2392,42 @@ \cs_new_eq:NN \liquid \lqd } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % reaction environments +\cs_new_protected:Npn \__chemmacros_record_for_lor:nnnnn #1#2#3#4#5 + { + \tl_if_eq:nnT { #1 } { reaction } + { + \group_begin: + % we need to prevent \Hy@make@anchor from being written to the lor + % file: + \bool_if:NT \l__chemmacros_hyperref_bool + { \cs_set:Npn \Hy@make@anchor {} } + \addcontentsline { lor } { reaction } + { + \tl_use:N \l__chemmacros_reaction_lorname_tl + #2 #3 #4 #5 + \tl_use:N \g__chemmacros_reaction_description_tl + } + \tl_gclear:N \g__chemmacros_reaction_description_tl + \group_end: + } + } % redefine mathtools' command \MT_define_tagform:nwnn to ensure we add an % entry to the list of reactions even if the user redefines the reaction tag +% this should probably be done via patching... \AfterPackage* { mathtools } { - \cs_set:Npn \MT_define_tagform:nwnn #1[#2]#3#4 + \cs_set_protected:Npn \MT_define_tagform:nwnn #1[#2]#3#4 { \@namedef{MT_tagform_#1:n}##1 { % this is the original part: \maketag@@@{#3\ignorespaces#2{##1}\unskip\@@italiccorr#4} - % this is added: - \tl_if_eq:nnT { #1 } { reaction } - { - \addcontentsline { lor } { reaction } - { - \l__chemmacros_reaction_lorname_tl #3 #2 ##1 #4 - \tl_use:N \g__chemmacros_reaction_description_tl - } - \tl_gclear:N \g__chemmacros_reaction_description_tl - } + % this is added => this disturbs hyperref: + \__chemmacros_record_for_lor:nnnnn + { #1 } { #3 } { #2 } { ##1 } { #4 } } } } @@ -2522,35 +2444,21 @@ { \chemmacros_add_reaction_description:n { #1 } } % define \listofreactions -\tl_new:N \l__chemmacros_reaction_lorname_tl -\tl_set:Nn \l__chemmacros_reaction_lorname_tl { Reaction ~ } -\tl_new:N \reactionlistname -\tl_set:Nn \reactionlistname { List~of~reactions } +\tl_new:N \l__chemmacros_reaction_lorname_tl +\tl_new:N \reactionlistname -% language settings % TODO -\AtBeginDocument +% TODO: add option +\cs_new:Npn \__chemmacros_reaction_heading:n #1 + { \section* { #1 } } +\cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V } + +\cs_new_protected:Npn \listofreactions { - \bool_if:NT \l__chemmacros_german_bool - { - \tl_set:Nn \reactionlistname { Reaktionsverzeichnis } - \tl_set:Nn \l__chemmacros_reaction_lorname_tl { Reaktion ~ } - } - \bool_if:NT \l__chemmacros_italian_bool - { - \tl_set:Nn \reactionlistname { Elenco ~ delle ~ reazioni } - \tl_set:Nn \l__chemmacros_reaction_lorname_tl { Reazione ~ } - } - \bool_if:NT \l__chemmacros_french_bool - { - \tl_set:Nn \reactionlistname { Table ~ des ~ r\'eactions } - \tl_set:Nn \l__chemmacros_reaction_lorname_tl { R\'eaction ~ } - } + \__chemmacros_reaction_heading:V \reactionlistname + \@starttoc { lor } } -\cs_new:Npn \listofreactions - { \section* { \reactionlistname } \@starttoc { lor } } - -\cs_new:Npn \l@reaction #1#2 +\cs_new_protected:Npn \l@reaction #1#2 { \@dottedtocline { 1 } { 1.5em } { 2.3em } { #1 } { #2 } } % create tagform @@ -2561,7 +2469,7 @@ \newcounter { reaction } % switch to reaction tags -\cs_new:Npn \__chemmacros_begin_reaction: +\cs_new_protected:Npn \__chemmacros_begin_reaction: { % create individual names for `hyperref': \bool_if:NT \l__chemmacros_hyperref_bool @@ -2580,7 +2488,7 @@ } % switch back to equation tags -\cs_new:Npn \__chemmacros_end_reaction: +\cs_new_protected:Npn \__chemmacros_end_reaction: { \setcounter { reaction } { \value { equation } } \setcounter { equation } { \value { chemmacros_save_reaction } } @@ -2592,88 +2500,85 @@ \keys_define:nn { chemmacros / reaction } { - star .bool_set:N = \l__chemmacros_reactions_star_bool , - star .default:n = true , - arg .bool_set:N = \l__chemmacros_reactions_args_bool , - arg .default:n = true , - list-name .tl_set:N = \reactionlistname , - list-entry .code:n = - \tl_set:Nn \l__chemmacros_reaction_lorname_tl { #1 ~ } + star .bool_set:N = \l__chemmacros_reactions_star_bool , + star .default:n = true , + arg .bool_set:N = \l__chemmacros_reactions_args_bool , + arg .default:n = true , + 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 } } } -% TODO separate document and module level % \DeclareChemReaction[<keyval>]{<name>}{<type>} -\bool_if:NF \l__chemmacros_version_one_bool +\cs_new_protected:Npn \chemmacros_new_reaction:nnn #1#2#3 { - \NewDocumentCommand \DeclareChemReaction { o m m } - { - \cs_if_exist:cTF { #2 } - { \msg_error:nnx { chemmacros } { already-defined } { #2 } } - { - \IfNoValueTF { #1 } - { - \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 - { - \NewEnviron { #2 } [ 2 ] [] - { - \__chemmacros_begin_reaction: - \AddRxnDesc { ##1 } - \begin { #3 } { ##2 } - \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* } - } - } - } - { - \NewEnviron { #2 } [ 1 ] [] - { - \__chemmacros_begin_reaction: - \AddRxnDesc { ##1 } - \begin { #3 } - \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* } - } - } - } - } - \ignorespaces - } - \cs_set:Npn \newreaction + \cs_if_exist:cTF { #2 } + { \msg_error:nnx { chemmacros } { already-defined } { #2 } } { - \chemmacros_msg:nnxx { chemmacros } { command-deprecated } - { \newreaction } { \DeclareChemReaction } - \DeclareChemReaction + \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 + { + \NewEnviron { #2 } [ 2 ] [] + { + \__chemmacros_begin_reaction: + \AddRxnDesc { ##1 } + \begin { #3 } { ##2 } + \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* } + } + } + } + { + \NewEnviron { #2 } [ 1 ] [] + { + \__chemmacros_begin_reaction: + \AddRxnDesc { ##1 } + \begin { #3 } + \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* } + } + } + } } + \ignorespaces } -\cs_new:Npn \chemmacros_equation_chemformula:n #1 +\bool_if:NF \l__chemmacros_version_one_bool { - \bool_if:NTF \l__chemmacros_use_mhchem_bool - { \cee { #1 } } - { \ch { #1 } } + \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_new_protected:Npn \chemmacros_equation_chemformula:n #1 + { \chemformula_ch:nn { } { #1 } } \cs_generate_variant:Nn \chemmacros_equation_chemformula:n { V } % predefined: @@ -2683,43 +2588,44 @@ \DeclareChemReaction [ star ] { reactions } { align } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % thermodynamics et.al. % \standardstate as defined by the chemstyle package. Thanks to Joseph Wright -\cs_if_exist:NF \standardstate +% the `chemstyle' provides it with \providecommand so it doesn't matter which +% package defines it first +\ProvideDocumentCommand \standardstate {} + { \ensuremath { \chemmacros_standardstate: } } + +\cs_new_protected:Npn \chemmacros_standardstate: + { \mathpalette \chemmacros_standardstate_aux: \circ } + +\cs_new_protected:Npn \chemmacros_standardstate_aux: #1#2 { - \cs_new:Npn \standardstate - { \ensuremath { \chemmacros_standardstate: } } - \cs_new:Npn \chemmacros_standardstate: - { \mathpalette \chemmacros_standardstate_aux: \circ } - \cs_new:Npn \chemmacros_standardstate_aux: #1#2 + \ooalign { - \ooalign - { - \tex_hfil:D - $#1-$ - \tex_hfil:D - \tex_cr:D - \tex_hfil:D - $#1#2$ - \tex_hfil:D - \tex_cr:D - } + \tex_hfil:D + $#1-$ + \tex_hfil:D + \tex_cr:D + \tex_hfil:D + $#1#2$ + \tex_hfil:D + \tex_cr:D } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % \State -\tl_new:N \l__chemmacros_State_delta_tl -\tl_set:Nn \l__chemmacros_State_delta_tl { \Delta } -\tl_new:N \l__chemmacros_State_exponent_tl -\tl_set:Nn \l__chemmacros_State_exponent_tl { \standardstate } +\tl_new:N \l__chemmacros_State_delta_tl +\tl_set:Nn \l__chemmacros_State_delta_tl { \Delta } +\tl_new:N \l__chemmacros_State_exponent_tl +\tl_set:Nn \l__chemmacros_State_exponent_tl { \standardstate } -\bool_new:N \l__chemmacros_State_delta_bool +\bool_new:N \l__chemmacros_State_delta_bool \bool_set_true:N \l__chemmacros_State_delta_bool -\bool_new:N \l__chemmacros_State_subscript_left_bool +\bool_new:N \l__chemmacros_State_subscript_left_bool \bool_set_true:N \l__chemmacros_State_subscript_left_bool -\bool_new:N \l__chemmacros_State_exponent_bool +\bool_new:N \l__chemmacros_State_exponent_bool \bool_set_true:N \l__chemmacros_State_exponent_bool \keys_define:nn { chemmacros / state } @@ -2752,7 +2658,7 @@ % old syntax (v2.0): % \State[<keyval>]{<Symbol>}{<subscript>} % {<subscript>} is an optional argument! -\cs_new:Npn \chemmacros_state:nnn #1#2#3 +\cs_new_protected:Npn \chemmacros_state:nnn #1#2#3 { \group_begin: \IfNoValueF { #1 } @@ -2788,7 +2694,7 @@ } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- \tl_new:N \l__chemmacros_thermod_subscript_left_tl \tl_new:N \l__chemmacros_thermod_subscript_left_default_tl \tl_new:N \l__chemmacros_thermod_subscript_tl @@ -2829,7 +2735,7 @@ % \DeclareChemState[<keyval>]{<name>}{<symbol>}{<unit>} \bool_if:NF \l__chemmacros_version_one_bool { - \cs_new:Npn \DeclareChemState + \cs_new_protected:Npn \DeclareChemState { \bool_set_false:N \l__chemmacros_renewstate_bool \__chemmacros_setnewstate_reset: @@ -2838,7 +2744,7 @@ { \__chemmacros_setnewstate_aux:nnn } } % \RenewChemState[<keyval>]{<name>}{<symbol>}{<unit>} - \cs_new:Npn \RenewChemState + \cs_new_protected:Npn \RenewChemState { \bool_set_true:N \l__chemmacros_renewstate_bool \__chemmacros_setnewstate_reset: @@ -2846,13 +2752,13 @@ { \__chemmacros_setnewstate:n } { \__chemmacros_setnewstate_aux:nnn } } - \cs_set:Npn \setnewstate + \cs_set_protected:Npn \setnewstate { \chemmacros_msg:nnxx { chemmacros } { command-deprecated } { \setnewstate } { \DeclareChemState } \DeclareChemState } - \cs_set:Npn \renewstate + \cs_set_protected:Npn \renewstate { \chemmacros_msg:nnxx { chemmacros } { command-deprecated } { \renewstate } { \RenewChemState } @@ -2860,7 +2766,7 @@ } } -\cs_new:Npn \__chemmacros_setnewstate_reset: +\cs_new_protected:Npn \__chemmacros_setnewstate_reset: { \tl_set:Nn \l__chemmacros_thermod_subscript_left_default_tl { true } \tl_clear:N \l__chemmacros_thermod_subscript_default_tl @@ -2868,13 +2774,13 @@ \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \Delta } } -\cs_new:Npn \__chemmacros_setnewstate:n [#1] +\cs_new_protected:Npn \__chemmacros_setnewstate:n [#1] { \keys_set:nn { chemmacros / setnewstate } { #1 } \__chemmacros_setnewstate_aux:nnn } -\cs_new:Npn \__chemmacros_setnewstate_aux:nnn #1#2#3 +\cs_new_protected:Npn \__chemmacros_setnewstate_aux:nnn #1#2#3 { \bool_if:NTF \l__chemmacros_renewstate_bool { @@ -2911,7 +2817,7 @@ \tl_const:cn { l__chemmacros_ #1 _unit_tl } { #3 } - \cs_new:cpn {chemmacros_ #1 _reset: } + \cs_new_protected:cpn {chemmacros_ #1 _reset: } { \tl_set_eq:Nc \l__chemmacros_thermod_subscript_tl @@ -2929,7 +2835,7 @@ \l__chemmacros_thermod_unit_tl { l__chemmacros_ #1 _unit_tl } } - \cs_new:cpn { #1 } + \cs_new_protected:cpn { #1 } { \use:c {chemmacros_ #1 _reset: } \peek_meaning:NTF [ @@ -2940,19 +2846,19 @@ { \tl_use:c { #1 _aux_iii:n } } } } - \cs_new:cpn { #1 _aux_i:n } [##1] + \cs_new_protected:cpn { #1 _aux_i:n } [##1] { \keys_set:nn { chemmacros / State } { ##1 } \peek_meaning:NTF ( { \tl_use:c { #1 _aux_ii:n } } { \tl_use:c { #1 _aux_iii:n } } } - \cs_new:cpn { #1 _aux_ii:n } (##1) + \cs_new_protected:cpn { #1 _aux_ii:n } (##1) { \tl_set:Nn \l__chemmacros_thermod_subscript_tl { ##1 } \tl_use:c { #1 _aux_iii:n } } - \cs_new:cpn { #1 _aux_iii:n } ##1 + \cs_new_protected:cpn { #1 _aux_iii:n } ##1 { \ensuremath { @@ -3000,21 +2906,21 @@ {G} {\kilo\joule\per\mole} } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % Newman projections -\fp_new:N \l__chemmacros_newman_rel_angle_fp -\fp_zero:N \l__chemmacros_newman_rel_angle_fp -\fp_new:N \l__chemmacros_newman_tmp_angle_fp -\fp_new:N \l__chemmacros_newman_abs_angle_fp -\fp_zero:N \l__chemmacros_newman_abs_angle_fp -\fp_new:N \l__chemmacros_newman_scale_fp -\fp_set:Nn \l__chemmacros_newman_scale_fp { 1 } -\fp_new:N \l__chemmacros_newman_x_fp -\fp_new:N \l__chemmacros_newman_y_fp - -\tl_new:N \l__chemmacros_newman_tikz_ring_tl -\tl_new:N \l__chemmacros_newman_tikz_front_tl -\tl_new:N \l__chemmacros_newman_tikz_back_tl +\fp_new:N \l__chemmacros_newman_rel_angle_fp +\fp_zero:N \l__chemmacros_newman_rel_angle_fp +\fp_new:N \l__chemmacros_newman_tmp_angle_fp +\fp_new:N \l__chemmacros_newman_abs_angle_fp +\fp_zero:N \l__chemmacros_newman_abs_angle_fp +\fp_new:N \l__chemmacros_newman_scale_fp +\fp_set:Nn \l__chemmacros_newman_scale_fp { 1 } +\fp_new:N \l__chemmacros_newman_x_fp +\fp_new:N \l__chemmacros_newman_y_fp + +\tl_new:N \l__chemmacros_newman_tikz_ring_tl +\tl_new:N \l__chemmacros_newman_tikz_front_tl +\tl_new:N \l__chemmacros_newman_tikz_back_tl \bool_new:N \l__chemmacros_newman_tikz_back_bool @@ -3050,7 +2956,7 @@ % place atoms: % #1: angle % #2 - #7: atoms -\cs_new:Npn \chemmacros_newman_atoms:nnnnnnn #1#2#3#4#5#6#7 +\cs_new_protected:Npn \chemmacros_newman_atoms:nnnnnnn #1#2#3#4#5#6#7 { \tl_if_blank:nTF { #1 } { @@ -3107,14 +3013,14 @@ % #2: fp variable for y % #3: angle % #4: radius -\cs_new:Npn \chemmacros_polar_to_cartesian:NNnn #1#2#3#4 +\cs_new_protected:Npn \chemmacros_polar_to_cartesian:NNnn #1#2#3#4 { \fp_set:Nn #1 { #4 * cos( #3 / 180 * pi ) }% x \fp_set:Nn #2 { #4 * sin( #3 / 180 * pi ) }% y } % place back nodes -\cs_new:Npn \chemmacros_newman_back_node:nn #1#2 +\cs_new_protected:Npn \chemmacros_newman_back_node:nn #1#2 { \group_begin: \fp_add:Nn \l__chemmacros_newman_rel_angle_fp { #1 } @@ -3155,7 +3061,7 @@ \cs_generate_variant:Nn \chemmacros_newman_back_node:nn { nf } % place front nodes: -\cs_new:Npn \chemmacros_newman_front_node:nn #1#2 +\cs_new_protected:Npn \chemmacros_newman_front_node:nn #1#2 { \chemmacros_polar_to_cartesian:NNnn \l__chemmacros_newman_x_fp @@ -3185,27 +3091,27 @@ } \cs_generate_variant:Nn \chemmacros_newman_front_node:nn { nf } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % \orbital[<keyval>]{<type>} % variables: -\bool_new:N \l__chemmacros_orbital_type_s_bool -\bool_new:N \l__chemmacros_orbital_type_p_bool -\bool_new:N \l__chemmacros_orbital_type_sp_bool -\bool_new:N \l__chemmacros_orbital_type_sptwo_bool -\bool_new:N \l__chemmacros_orbital_type_spthree_bool -\bool_new:N \l__chemmacros_orbital_s_phase_bool +\bool_new:N \l__chemmacros_orbital_type_s_bool +\bool_new:N \l__chemmacros_orbital_type_p_bool +\bool_new:N \l__chemmacros_orbital_type_sp_bool +\bool_new:N \l__chemmacros_orbital_type_sptwo_bool +\bool_new:N \l__chemmacros_orbital_type_spthree_bool +\bool_new:N \l__chemmacros_orbital_s_phase_bool \bool_set_true:N \l__chemmacros_orbital_s_phase_bool -\bool_new:N \l__chemmacros_orbital_p_phase_bool +\bool_new:N \l__chemmacros_orbital_p_phase_bool \bool_set_true:N \l__chemmacros_orbital_p_phase_bool -\bool_new:N \l__chemmacros_orbital_sp_phase_bool +\bool_new:N \l__chemmacros_orbital_sp_phase_bool \bool_set_true:N \l__chemmacros_orbital_sp_phase_bool -\bool_new:N \l__chemmacros_orbital_sptwo_phase_bool +\bool_new:N \l__chemmacros_orbital_sptwo_phase_bool \bool_set_true:N \l__chemmacros_orbital_sptwo_phase_bool -\bool_new:N \l__chemmacros_orbital_spthree_phase_bool +\bool_new:N \l__chemmacros_orbital_spthree_phase_bool \bool_set_true:N \l__chemmacros_orbital_spthree_phase_bool -\bool_new:N \l__chemmacros_orbital_p_half_bool -\bool_new:N \l__chemmacros_orbital_overlay_bool -\bool_new:N \l__chemmacros_orbital_opacity_bool +\bool_new:N \l__chemmacros_orbital_p_half_bool +\bool_new:N \l__chemmacros_orbital_overlay_bool +\bool_new:N \l__chemmacros_orbital_opacity_bool \tl_new:N \l__chemmacros_orbital_s_color_tl \tl_set:Nn \l__chemmacros_orbital_s_color_tl { black } @@ -3260,9 +3166,9 @@ { opacity = { \fp_use:N \l__chemmacros_orbital_opacity_fp } } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % s-orbitals -\cs_new:Npn \__chemmacros_orbital_type_s: +\cs_new_protected:Npn \__chemmacros_orbital_type_s: { \bool_set_true:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool @@ -3282,7 +3188,7 @@ color .tl_set:N = \l__chemmacros_orbital_s_color_tl } -\cs_new:Npn \__chemmacros_orbital_s_draw:n #1 +\cs_new_protected:Npn \__chemmacros_orbital_s_draw:n #1 { \keys_set:nn { chemmacros / orbital / s } { #1 } \bool_if:NTF \l__chemmacros_orbital_s_phase_bool @@ -3309,9 +3215,9 @@ } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % p-orbitals -\cs_new:Npn \__chemmacros_orbital_type_p: +\cs_new_protected:Npn \__chemmacros_orbital_type_p: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_true:N \l__chemmacros_orbital_type_p_bool @@ -3334,7 +3240,7 @@ half .default:n = true } -\cs_new:Npn \__chemmacros_orbital_p_draw:n #1 +\cs_new_protected:Npn \__chemmacros_orbital_p_draw:n #1 { \keys_set:nn { chemmacros / orbital / p } { #1 } \bool_if:NTF \l__chemmacros_orbital_p_phase_bool @@ -3405,9 +3311,9 @@ } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % sp-orbitals -\cs_new:Npn \__chemmacros_orbital_type_sp: +\cs_new_protected:Npn \__chemmacros_orbital_type_sp: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool @@ -3428,7 +3334,7 @@ color .tl_set:N = \l__chemmacros_orbital_sp_color_tl } -\cs_new:Npn \__chemmacros_orbital_sp_draw:n #1 +\cs_new_protected:Npn \__chemmacros_orbital_sp_draw:n #1 { \keys_set:nn { chemmacros / orbital / sp } { #1 } \bool_if:NTF \l__chemmacros_orbital_sp_phase_bool @@ -3496,9 +3402,9 @@ } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % sp2-orbitals -\cs_new:Npn \__chemmacros_orbital_type_sptwo: +\cs_new_protected:Npn \__chemmacros_orbital_type_sptwo: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool @@ -3519,7 +3425,7 @@ color .tl_set:N = \l__chemmacros_orbital_sptwo_color_tl } -\cs_new:Npn \__chemmacros_orbital_sptwo_draw:n #1 +\cs_new_protected:Npn \__chemmacros_orbital_sptwo_draw:n #1 { \keys_set:nn { chemmacros / orbital / sp2 } { #1 } \bool_if:NTF \l__chemmacros_orbital_sptwo_phase_bool @@ -3587,9 +3493,9 @@ } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % sp3-orbitals -\cs_new:Npn \__chemmacros_orbital_type_spthree: +\cs_new_protected:Npn \__chemmacros_orbital_type_spthree: { \bool_set_false:N \l__chemmacros_orbital_type_s_bool \bool_set_false:N \l__chemmacros_orbital_type_p_bool @@ -3610,7 +3516,7 @@ color .tl_set:N = \l__chemmacros_orbital_spthree_color_tl } -\cs_new:Npn \__chemmacros_orbital_spthree_draw:n #1 +\cs_new_protected:Npn \__chemmacros_orbital_spthree_draw:n #1 { \keys_set:nn { chemmacros / orbital / sp3 } { #1 } \bool_if:NTF \l__chemmacros_orbital_spthree_phase_bool @@ -3678,7 +3584,7 @@ } } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % main command \keys_define:nn { chemmacros / orbital } { @@ -3702,7 +3608,7 @@ sp3 .code:n = { \__chemmacros_orbital_type_spthree: } } -\cs_new:Npn \chemmacros_orbital:n #1 +\cs_new_protected:Npn \chemmacros_orbital:n #1 { \bool_if:NT \l__chemmacros_orbital_type_s_bool { \__chemmacros_orbital_s_draw:n { #1 } } @@ -3726,7 +3632,7 @@ \group_end: } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % arrow tips for electron movement \dim_new:N \l__chemmacros_el_length_dim @@ -3815,22 +3721,30 @@ \pgfusepathqfillstroke } -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- % setup \NewDocumentCommand \chemsetup { o m } { \IfNoValueTF { #1 } { \keys_set:nn { chemmacros } { #2 } } - { \keys_set:nn { chemmacros / #1 } { #2 } } + { + \bool_if:NTF \l__chemmacros_version_four_bool + { + \tl_if_eq:nnTF { #1 } { chemformula } + { \setchemformula { #2 } } + { \keys_set:nn { chemmacros / #1 } { #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 % ?? unsure about adding IUPAC commands \AfterPackage* { hyperref } @@ -3839,15 +3753,72 @@ { \cs_set:Npn \- { - }% myabe not a good idea... \cs_set:Npn \| { } - \cs_set:Npn \iupac #1 { #1 } \cs_set:Npn \pH { pH } \cs_set:Npn \pOH { pOH } - } + \cs_set:Npn \iupac #1 { #1 } + % \cs_set:Npn \a { alpha } + % \cs_set:Npn \g { gamma } + % \cs_set:Npn \d { delta } + % \cs_set:Npn \m { mu } + % \cs_set:Npn \n { eta } + % \cs_set:Npn \w { omega } + % \cs_set:Npn \N { N } + % \cs_set:Npn \O { O } + % \cs_set:Npn \Sf { S } + % \cs_set:Npn \P { P } + % \cs_set:Npn \R { (R) } + \cs_set:Npn \cip #1 { (#1) } + % \cs_set:Npn \E { (E) } + % \cs_set:Npn \Z { (Z) } + \cs_set:Npn \cis { cis } + \cs_set:Npn \trans { trans } + \cs_set:Npn \tert { tert } + % \cs_set:Npn \D { D } + \cs_set:Npn \ortho { o } + \cs_set:Npn \meta { m } + \cs_set:Npn \para { p } + \cs_set:Npn \syn { syn } + \cs_set:Npn \anti { anti } + } + } + +% -------------------------------------------------------------------------- +% language support -- provided through `translations' +% equilibrium constants: +\DeclareTranslationFallback{K-acid}{A} +\DeclareTranslationFallback{K-base}{B} +\DeclareTranslationFallback{K-water}{W} +\DeclareTranslation{German}{K-acid}{S} +% phases: +\DeclareTranslation{German}{phase-sld}{ f } +\DeclareTranslation{German}{phase-lqd}{ f{}l } +% list of reactions: +\DeclareTranslationFallback {list-of-reactions} { List ~ of ~ reactions } +\DeclareTranslation{English} {list-of-reactions} { List ~ of ~ reactions } +\DeclareTranslation{German} {list-of-reactions} { Reaktionsverzeichnis } +\DeclareTranslation{Italian} {list-of-reactions} { Elenco ~ delle ~ reazioni } +\DeclareTranslation{French} {list-of-reactions} { Table ~ des ~ r\'eactions } +% +\DeclareTranslationFallback {lor-reaction} { Reaction ~ } +\DeclareTranslation{English} {lor-reaction} { Reaction ~ } +\DeclareTranslation{German} {lor-reaction} { Reaktion ~ } +\DeclareTranslation{Italian} {lor-reaction} { Reazione ~ } +\DeclareTranslation{French} {lor-reaction} { R\'eaction ~ } + +\tl_set:Nn \l__chemmacros_reaction_lorname_tl + { + \chemmacros_translate:nn + {lor-reaction} { Reaction ~ } + } +\tl_set:Nn \reactionlistname + { + \chemmacros_translate:nn + {list-of-reactions} { List ~ of ~ reactions } } \tex_endinput:D -% --------------------------------------------------------------------------- % +% -------------------------------------------------------------------------- Version history 2011/05/15 - version 1.0 - CTAN release 2011/06/22 - version 1.1 - "LaTeXified" whole package for safer usage @@ -4005,11 +3976,39 @@ Version history 2013/04/19 - version 3.6b - chemformula: new key `arrow-min-length' - bug fix: stoichiometric fractions correctly displayed - changed appearance of \cip to use upright parentheses +2013/07/06 - version 4.0 - `chemformula' doesn't automatically load + `chemmacros' any more but can be used stand-alone + - option `bpchem' has been dropped + - improved detection of bold font series + - changed wrongly used \mbox in definition of \Ka, + \Kb and \Kw into \ensuremath + - adapt \mch and \pch to match `chemformula's + charges + - dropped option `method=mhchem' + - support for `kpfonts' and `newtxmath' upright + greek letters added, greek alphabet complete both + for uppercase and lowercase; this is handled by + the new package in the family: `chemgreek' + - \OX and \redox now work in `amsmath's environment + by ignoring the measuring phase + - language management with the halp of the + `translations' package => + recognize document language automatically and use + it if it a) is known to `chemmacros' and b) has + not been overwritten by the `language' option; + this also made minor changes to `ghsystem' + necessary; additionally this lead to changes in + the way phases are defined + - status of \Dfi and \Lfi changed from `deprecated' + to `dropped' + - new option `charges/partial-format' + - fixed wrongly written contents to the lor when + used together with `hyperref' + - new option `reaction/list-heading' + - option `charges/append' deprecated + % --------------------------------------------------------------------------- % -% TODO: -- ox-option xfrac vs math? -- drop option `bpchem' +% TODO: fuer version 4 - add d-orbitals -- add kpfonts to `greek' option so \Chemalpha and kin use \alphaup ... of kpfonts - package
\ No newline at end of file +- make electron movement arrow tips (`el', `left el' and `right el') public |