diff options
author | Karl Berry <karl@freefriends.org> | 2014-01-25 22:33:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-01-25 22:33:11 +0000 |
commit | 00162491a0a38dd40e88a84e63192f10868f0df4 (patch) | |
tree | e42dd812872b36f33a7d245b206e65d0d79f4b5a /Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty | |
parent | ca3052a995aa72637d7cc9132e4ba1d2f6f3b8a5 (diff) |
chemmacros (25jan14)
git-svn-id: svn://tug.org/texlive/trunk@32786 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty | 494 |
1 files changed, 364 insertions, 130 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty b/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty index 0a90ba4809f..7471dc7f8a8 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty @@ -26,8 +26,8 @@ % - The Current Maintainer of this work is Clemens Niederberger. % ---------------------------------------------------------------------------- \RequirePackage{expl3,xparse} -\def\chemgreek@version{0.2a} -\def\chemgreek@date{2013/11/20} +\def\chemgreek@version{0.3} +\def\chemgreek@date{2014/01/24} \ProvidesExplPackage{chemgreek}{\chemgreek@date}{\chemgreek@version} {interface for upright greek letters for use in chemistry (CN)} @@ -47,30 +47,99 @@ \prg_new_conditional:Npnn \chemgreek_latex_if:n #1 {p,T,F,TF} { \use:c { if #1 } \prg_return_true: \else: \prg_return_false: \fi: } +% let's see if we can test if a package has been loaded after begin document: +\prg_new_conditional:Npnn \chemgreek_if_package_loaded:n #1 {p,T,F,TF} + { + \cs_if_exist:cTF { ver@#1.sty } + { \prg_return_true: } + { \prg_return_false: } + } +\cs_generate_variant:Nn \chemgreek_if_package_loaded:nF { V } + +\prg_new_protected_conditional:Npnn \chemgreek_if_package_with:nn #1#2 {T,F,TF} + { + \cs_if_exist:cTF {opt@#1.sty} + { + \clist_if_in:cnTF {opt@#1.sty} {#2} + { \prg_return_true: } + { \prg_return_false: } + } + { \prg_return_false: } + } + % ---------------------------------------------------------------------------- % messages \msg_new:nnnn { chemgreek } { mapping-not-defined } { The~ mapping~ `#1'~ does~ not~ exist~ \msg_line_context: } { - You~ chose~ the~ mapping~ `#1'~ which~ has~ apparently~ not~ been~ - defined,~ yet.~ If~ this~ is~ due~ to~ a~ miss-spelling~ you~ need~ to~ - declare~ it~ first~ via~ \token_to_str:N \newchemgreekmapping \c_space_tl - or~ \token_to_str:N \declarechemgreekmapping . + You~ chose~ the~ mapping~ `#1'~ \msg_line_context: \c_space_tl which~ has~ + apparently~ not~ been~ defined,~ yet.~ If~ this~ is~ due~ to~ a~ + miss-spelling~ you~ need~ to~ declare~ it~ first~ via~ \token_to_str:N + \newchemgreekmapping \c_space_tl or~ \token_to_str:N + \declarechemgreekmapping . } -\msg_new:nnnn { chemgreek } { mapping-defined } +\msg_new:nnnn { chemgreek } { mapping-already-defined } { The~ mapping~ `#1'~ does~ already~ exist~ \msg_line_context: } { - It~ seems~ you're~ trying~ to~ define~ the~ mapping~ `#1'.~ However,~ - this~ mapping~ does~ already~ exist.~ If~ this~ is~ not~ due~ to~ a~ - miss-spelling~ you~ need~ to~ redefine~ it~ via~ \token_to_str:N - \renewchemgreekmapping . + It~ seems~ you're~ trying~ to~ define~ the~ mapping~ `#1'~ + \msg_line_context: .~ However,~ this~ mapping~ does~ already~ exist.~ If~ + this~ is~ not~ due~ to~ a~ miss-spelling~ you~ need~ to~ redefine~ it~ + via~ \token_to_str:N \renewchemgreekmapping . + } + +\msg_new:nnnn { chemgreek } { mapping-active } + { + The~ mapping~ `#1'~ already~ is~ active~ \msg_line_context: .~ I'm~ doing~ + nothing. + } + { + The~ mapping~ `#1'~ already~ is~ active~ \msg_line_context: .~ I'm~ doing~ + nothing. + } + +\msg_new:nnnn { chemgreek } { package-missing } + { + You've~ activated~ mapping~ `#1'~ which~ needs~ package~ `#2'~ loaded.~ + However, package~ `#2'~ does~ not~ seem~ to~ be~ loaded~ + \msg_line_context: .~ If~ I'm~ mistaken~ then~ ignore~ this~ warning. + } + { + You've~ activated~ mapping~ `#1'~ which~ needs~ package~ `#2'~ loaded.~ + However,~ package~ `#2'~ does~ not~ seem~ to~ be~ loaded~ + \msg_line_context: .~ Using~ the~ letter~ macros~ will~ probably~ not~ + work.~ If~ I'm~ mistaken~ then~ ignore~ this~ warning. + } + +\msg_new:nnnn { chemgreek } { command-deprecated } + { + The~ command~ \token_to_str:N #1 is~ deprecated.~ Use~ \token_to_str:N #2 + instead~ \msg_line_context: .~ \token_to_str:N #1 may~ be~ dropped~ in~ + the~ future~ without~ further~ warning. + } + { + The~ command~ \token_to_str:N #1 is~ deprecated.~ Use~ \token_to_str:N #2 + instead~ \msg_line_context: .~ \token_to_str:N #1 may~ be~ dropped~ in~ + the~ future~ without~ further~ warning. + } + +% ---------------------------------------------------------------------------- +% define a deprecated command with hints to the corresponding new one: +\cs_new_protected:Npn \chemgreek_define_deprecated:NN #1#2 + { + \cs_new_protected:Npn #1 + { + \msg_warning:nnnn { chemgreek } { command-deprecated } + { #1 } { #2 } + #2 + } } +\cs_generate_variant:Nn \chemgreek_define_deprecated:NN { cc } % ---------------------------------------------------------------------------- % a tokenlist constant that will be used to build the mapping property lists % both for uppercase and lowercase and also for setting the output macros -\tl_const:Nn \c__chemgreek_order_tl +\tl_const:Nn \c__chemgreek_alphabet_tl { { alpha } % 1 { beta } % 2 @@ -101,18 +170,19 @@ % ---------------------------------------------------------------------------- % variants of kernel functions: \cs_generate_variant:Nn \prop_put:Nnn { cxV } +\cs_generate_variant:Nn \tl_if_eq:nnTF { V } % ---------------------------------------------------------------------------- % helper function to retrieve upper- and lowercase entries while the mapping % happens: -\cs_new:Npn \__chemgreek_get_upper_lower:w #1 / #2 \q_stop +\cs_new_protected:Npn \__chemgreek_get_upper_lower:w #1 / #2 \q_stop { \tl_set:Nn \l__chemgreek_tmpa_tl { #1 } \tl_set:Nn \l__chemgreek_tmpb_tl { #2 } } % ---------------------------------------------------------------------------- -% a conditional to test if a mapping exists: +% a conditional for testing if a mapping exists: \prg_new_conditional:Npnn \chemgreek_if_mapping_exists:n #1 {p,T,F,TF} { \bool_if:nTF @@ -124,36 +194,59 @@ { \prg_return_false: } } +% a conditional for testing if a mapping is active: +\tl_new:N \l__chemgreek_active_mapping_tl +\prg_new_conditional:Npnn \chemgreek_if_mapping_active:n #1 {p,T,F,TF} + { + \tl_if_eq:NcTF + \l__chemgreek_active_mapping_tl + { c__chemgreek_mapping_#1_tl } + { \prg_return_true: } + { \prg_return_false: } + } + +% ---------------------------------------------------------------------------- +% a property lists that holds the needed package names for a mapping +\prop_new:N \l__chemgreek_packages_prop + % ---------------------------------------------------------------------------- % the main mapping function: % #1: mapping-name -% #2: mapping-entries -\cs_new_protected:Npn \chemgreek_new_mapping:nn #1#2 +% #2: package name +% #3: mapping-entries +\cs_new_protected:Npn \chemgreek_new_mapping:nnn #1#2#3 { \chemgreek_if_mapping_exists:nTF { #1 } - { \msg_error:nnn { chemgreek } { mapping-defined } { #1 } } + { \msg_error:nnn { chemgreek } { mapping-already-defined } { #1 } } { \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop } \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop } - \__chemgreek_set_mapping:nn { #1 } { #2 } + \tl_const:cn { c__chemgreek_mapping_#1_tl } { #1 } + \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 } + \__chemgreek_set_mapping:nn { #1 } { #3 } } } -\cs_new_protected:Npn \chemgreek_renew_mapping:nn #1#2 +\cs_new_protected:Npn \chemgreek_renew_mapping:nnn #1#2#3 { \chemgreek_if_mapping_exists:nTF { #1 } - { \__chemgreek_set_mapping:nn { #1 } { #2 } } + { + \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 } + \__chemgreek_set_mapping:nn { #1 } { #3 } + } { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } } } -\cs_new_protected:Npn \chemgreek_declare_mapping:nn #1#2 +\cs_new_protected:Npn \chemgreek_declare_mapping:nnn #1#2#3 { \chemgreek_if_mapping_exists:nF { #1 } { \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop } \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop } + \tl_const:cn { c__chemgreek_mapping_#1_tl } { #1 } } - \__chemgreek_set_mapping:nn { #1 } { #2 } + \prop_put:Nnn \l__chemgreek_packages_prop { #1 } { #2 } + \__chemgreek_set_mapping:nn { #1 } { #3 } } \cs_new_protected:Npn \__chemgreek_set_mapping:nn #1#2 @@ -166,26 +259,32 @@ \int_incr:N \l__chemgreek_tmpa_int \__chemgreek_get_upper_lower:w ##1 \q_stop \prop_put:cxV { l__chemgreek_lowercase_mapping_#1_prop } - { \tl_item:Nn \c__chemgreek_order_tl { \l__chemgreek_tmpa_int } } + { \tl_item:Nn \c__chemgreek_alphabet_tl { \l__chemgreek_tmpa_int } } \l__chemgreek_tmpa_tl \prop_put:cxV { l__chemgreek_uppercase_mapping_#1_prop } - { \tl_item:Nn \c__chemgreek_order_tl { \l__chemgreek_tmpa_int } } + { \tl_item:Nn \c__chemgreek_alphabet_tl { \l__chemgreek_tmpa_int } } \l__chemgreek_tmpb_tl } } -% the user command: -\NewDocumentCommand \newchemgreekmapping { mm } - { \chemgreek_new_mapping:nn { #1 } { #2 } } +% the user commands: +\NewDocumentCommand \newchemgreekmapping { O{}mm } + { \chemgreek_new_mapping:nn { #2 } { #1 } { #3 } } -\NewDocumentCommand \renewchemgreekmapping { mm } - { \chemgreek_renew_mapping:nn { #1 } { #2 } } +\NewDocumentCommand \renewchemgreekmapping { O{}mm } + { \chemgreek_renew_mapping:nnn { #2 } { #1 } { #3 } } -\NewDocumentCommand \declarechemgreekmapping { mm } - { \chemgreek_declare_mapping:nn { #1 } { #2 } } +\NewDocumentCommand \declarechemgreekmapping { O{}mm } + { \chemgreek_declare_mapping:nnn { #2 } { #1 } { #3 } } % ---------------------------------------------------------------------------- % a function to selectively change specific entries in a mapping: + +% this will hold all changed mappings until they've been (re-)activated +% logically a sequence or clist would make more sense; however, +% \prop_if_in:Nn(TF) is expandable +\prop_new:N \l__chemgreek_changed_mappings_prop + % #1: mapping-name % #2: upper / lower % #3: entry-name @@ -197,6 +296,9 @@ \prop_put:cnn { l__chemgreek_#2 case_mapping_#1_prop } { #3 } { #4 } + \prop_put:Nnn \l__chemgreek_changed_mappings_prop + { #1 } + { #1 } } { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } } } @@ -208,16 +310,42 @@ % ---------------------------------------------------------------------------- % a function to activate a mapping: % #1: mapping-name +% TODO: error if needed package has not been loaded \cs_new_protected:Npn \chemgreek_activate_mapping:n #1 { \chemgreek_if_mapping_exists:nTF { #1 } { - \tl_map_inline:Nn \c__chemgreek_order_tl + \bool_if:nTF + { + ( \chemgreek_if_mapping_active_p:n { #1 } ) + && + !( \prop_if_in_p:Nn \l__chemgreek_changed_mappings_prop { #1 } ) + } + { \msg_info:nnn { chemgreek } { mapping-active } { #1 } } { - \cs_set_protected:cpx { Chem \tl_expandable_uppercase:n ##1 } - { \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } } - \cs_set_protected:cpx { Chem ##1 } - { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } } + \tl_set:Nn \l__chemgreek_active_mapping_tl { #1 } + \prop_get:NnN \l__chemgreek_packages_prop { #1 } + \l__chemgreek_tmpa_tl + \tl_if_blank:VF \l__chemgreek_tmpa_tl + { + \chemgreek_if_package_loaded:VF \l__chemgreek_tmpa_tl + { + \msg_warning:nnxx { chemgreek } { package-missing } + { #1 } + { \l__chemgreek_tmpa_tl } + } + } + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \cs_set_protected:cpx { chem \tl_expandable_uppercase:n ##1 } + { \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } } + \cs_set_protected:cpx { chem ##1 } + { \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } } + } + \prop_get:NnNT \l__chemgreek_changed_mappings_prop + { #1 } + \l__chemgreek_tmpa_tl + { \prop_remove:Nn \l__chemgreek_changed_mappings_prop { #1 } } } } { \msg_error:nnn { chemgreek } { mapping-not-defined } { #1 } } @@ -225,17 +353,18 @@ % user command that also loads the needed package: % #1: load package -% #2: option -% #3: mapping-name -\NewDocumentCommand \activatechemgreekmapping { som } +% #2: mapping-name +\NewDocumentCommand \activatechemgreekmapping { sm } { \IfBooleanT { #1 } { - \IfNoValueTF { #2 } - { \RequirePackage { #3 } } - { \RequirePackage [ #2 ] { #3 } } + \prop_get:NnN \l__chemgreek_packages_prop + { #2 } + \l__chemgreek_tmpa_tl + \tl_if_blank:VF \l__chemgreek_tmpa_tl + { \exp_args:No \RequirePackage { \l__chemgreek_tmpa_tl } } } - \chemgreek_activate_mapping:n { #3 } + \chemgreek_activate_mapping:n { #2 } } \@onlypreamble\activatechemgreekmapping @@ -245,56 +374,99 @@ % ---------------------------------------------------------------------------- % a debugging command: -\cs_new_protected:Npn \chemgreek_show_mapping:n #1 +\cs_new_protected:Npn \chemgreek_print_mapping:n #1 { - \chemgreek_activate_mapping:n { #1 } \int_gzero:N \g__chemgreek_tmpa_int - \begin { tabular } { llll } + \begin { tabular } { llcc } pos & name & lower & upper \\ - \tl_map_inline:Nn \c__chemgreek_order_tl + \tl_map_inline:Nn \c__chemgreek_alphabet_tl { \int_gincr:N \g__chemgreek_tmpa_int \int_use:N \g__chemgreek_tmpa_int . & ##1 & - \use:c { Chem ##1 } & - \use:c { Chem \tl_expandable_uppercase:n ##1 } \\ + \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } & + \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } \\ } \end{tabular} } +\cs_new_eq:NN \printchemgreekmapping \chemgreek_print_mapping:n + +\cs_new_protected:Npn \chemgreek_show_mapping:n #1 + { + \int_gzero:N \g__chemgreek_tmpa_int + \iow_log:n { ................................................. } + \iow_log:n { . ~ chemgreek~ mapping~ `#1': } + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \int_gincr:N \g__chemgreek_tmpa_int + \iow_log:x + { . ~ \int_use:N \g__chemgreek_tmpa_int . } + \iow_log:x + { + . \c_space_tl \c_space_tl \c_space_tl \c_space_tl \c_space_tl + ##1 ~ => ~ + \prop_get:cn { l__chemgreek_lowercase_mapping_#1_prop } { ##1 } + } + \iow_log:x + { + . \c_space_tl \c_space_tl \c_space_tl \c_space_tl \c_space_tl + \tl_expandable_uppercase:n ##1 ~ => ~ + \prop_get:cn { l__chemgreek_uppercase_mapping_#1_prop } { ##1 } + } + } + \iow_log:n { ................................................. } + } + \cs_new_eq:NN \showchemgreekmapping \chemgreek_show_mapping:n % ---------------------------------------------------------------------------- +% deprecate old macro names that started with an uppercase C: +\cs_new_protected:Npn \chemgreek_deprecate_symbol:n #1 + { \chemgreek_define_deprecated:cc { Chem#1 } { chem#1 } } + +\cs_new_protected:Npn \chemgreek_deprecate_symbols: + { + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \chemgreek_deprecate_symbol:n { ##1 } + \chemgreek_deprecate_symbol:n { \tl_expandable_uppercase:n ##1 } + } + } + +\chemgreek_deprecate_symbols: + +% ---------------------------------------------------------------------------- % functions to format integers with greek letters; these are basically copies % of \int_to_alph:n \cs_new:Npn \chemgreek_int_to_greek:n #1 { \int_to_symbols:nnn { #1 } { 24 } { - { 1 } { \Chemalpha } - { 2 } { \Chembeta } - { 3 } { \Chemgamma } - { 4 } { \Chemdelta } - { 5 } { \Chemepsilon } - { 6 } { \Chemzeta } - { 7 } { \Chemeta } - { 8 } { \Chemiota } - { 9 } { \Chemtheta } - { 10 } { \Chemkappa } - { 11 } { \Chemlambda } - { 12 } { \Chemmu } - { 13 } { \Chemnu } - { 14 } { \Chemxi } - { 15 } { \Chemomikron } - { 16 } { \Chempi } - { 17 } { \Chemrho } - { 18 } { \Chemsigma } - { 19 } { \Chemtau } - { 20 } { \Chemupsilon } - { 21 } { \Chemphi } - { 22 } { \Chempsi } - { 23 } { \Chemchi } - { 24 } { \Chemomega } + { 1 } { \chemalpha } + { 2 } { \chembeta } + { 3 } { \chemgamma } + { 4 } { \chemdelta } + { 5 } { \chemepsilon } + { 6 } { \chemzeta } + { 7 } { \chemeta } + { 8 } { \chemiota } + { 9 } { \chemtheta } + { 10 } { \chemkappa } + { 11 } { \chemlambda } + { 12 } { \chemmu } + { 13 } { \chemnu } + { 14 } { \chemxi } + { 15 } { \chemomikron } + { 16 } { \chempi } + { 17 } { \chemrho } + { 18 } { \chemsigma } + { 19 } { \chemtau } + { 20 } { \chemupsilon } + { 21 } { \chemphi } + { 22 } { \chempsi } + { 23 } { \chemchi } + { 24 } { \chemomega } } } @@ -302,37 +474,37 @@ { \int_to_symbols:nnn { #1 } { 24 } { - { 1 } { \ChemAlpha } - { 2 } { \ChemBeta } - { 3 } { \ChemGamma } - { 4 } { \ChemDelta } - { 5 } { \ChemEpsilon } - { 6 } { \ChemZeta } - { 7 } { \ChemEta } - { 8 } { \ChemIota } - { 9 } { \ChemTheta } - { 10 } { \ChemKappa } - { 11 } { \ChemLambda } - { 12 } { \ChemMu } - { 13 } { \ChemNu } - { 14 } { \ChemXi } - { 15 } { \ChemOmikron } - { 16 } { \ChemPi } - { 17 } { \ChemRho } - { 18 } { \ChemSigma } - { 19 } { \ChemTau } - { 20 } { \ChemUpsilon } - { 21 } { \ChemPhi } - { 22 } { \ChemPsi } - { 23 } { \ChemChi } - { 24 } { \ChemOmega } + { 1 } { \chemAlpha } + { 2 } { \chemBeta } + { 3 } { \chemGamma } + { 4 } { \chemDelta } + { 5 } { \chemEpsilon } + { 6 } { \chemZeta } + { 7 } { \chemEta } + { 8 } { \chemIota } + { 9 } { \chemTheta } + { 10 } { \chemKappa } + { 11 } { \chemLambda } + { 12 } { \chemMu } + { 13 } { \chemNu } + { 14 } { \chemXi } + { 15 } { \chemOmikron } + { 16 } { \chemPi } + { 17 } { \chemRho } + { 18 } { \chemSigma } + { 19 } { \chemTau } + { 20 } { \chemUpsilon } + { 21 } { \chemPhi } + { 22 } { \chemPsi } + { 23 } { \chemChi } + { 24 } { \chemOmega } } } % ---------------------------------------------------------------------------- % predefine some mappings % default: -\chemgreek_new_mapping:nn { default } +\chemgreek_new_mapping:nnn { default } { } { \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2 @@ -361,7 +533,7 @@ } % default-variant: -\chemgreek_new_mapping:nn { var-default } +\chemgreek_new_mapping:nnn { var-default } { } { \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2 @@ -390,7 +562,7 @@ } % mathdesign: -\chemgreek_new_mapping:nn { mathdesign } +\chemgreek_new_mapping:nnn { mathdesign } { mathdesign } { \ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2 @@ -419,36 +591,36 @@ } % textgreek: -\chemgreek_new_mapping:nn { textgreek } - { - \textalpha / \textAlpha , % 1 - \textbeta / \textBeta , % 2 - \textgamma / \textGamma , % 3 - \textdelta / \textDelta , % 4 - \textepsilon / \textEpsilon , % 5 - \textzeta / \textZeta , % 6 - \texteta / \textEta , % 7 - \texttheta / \textTheta , % 8 - \textiota / \textIota , % 9 - \textkappa / \textKappa , % 10 - \textlambda / \textLambda , % 11 - \textmugreek / \textMu , % 12 - \textnu / \textNu , % 13 - \textxi / \textXi , % 14 - \textomikron / \textOmikron , % 15 - \textpi / \textPi , % 16 - \textrho / \textRho , % 17 - \textsigma / \textSigma , % 18 - \texttau / \textTau , % 19 - \textupsilon / \textUpsilon , % 20 - \textphi / \textPhi , % 21 - \textpsi / \textPsi , % 22 - \textchi / \textChi , % 23 - \textomega / \textOmega % 24 +\chemgreek_new_mapping:nnn { textgreek } { textgreek } + { + \mbox{\textalpha} / \mbox{\textAlpha} , % 1 + \mbox{\textbeta} / \mbox{\textBeta} , % 2 + \mbox{\textgamma} / \mbox{\textGamma} , % 3 + \mbox{\textdelta} / \mbox{\textDelta} , % 4 + \mbox{\textepsilon} / \mbox{\textEpsilon} , % 5 + \mbox{\textzeta} / \mbox{\textZeta} , % 6 + \mbox{\texteta} / \mbox{\textEta} , % 7 + \mbox{\texttheta} / \mbox{\textTheta} , % 8 + \mbox{\textiota} / \mbox{\textIota} , % 9 + \mbox{\textkappa} / \mbox{\textKappa} , % 10 + \mbox{\textlambda} / \mbox{\textLambda} , % 11 + \mbox{\textmugreek} / \mbox{\textMu} , % 12 + \mbox{\textnu} / \mbox{\textNu} , % 13 + \mbox{\textxi} / \mbox{\textXi} , % 14 + \mbox{\textomikron} / \mbox{\textOmikron} , % 15 + \mbox{\textpi} / \mbox{\textPi} , % 16 + \mbox{\textrho} / \mbox{\textRho} , % 17 + \mbox{\textsigma} / \mbox{\textSigma} , % 18 + \mbox{\texttau} / \mbox{\textTau} , % 19 + \mbox{\textupsilon} / \mbox{\textUpsilon} , % 20 + \mbox{\textphi} / \mbox{\textPhi} , % 21 + \mbox{\textpsi} / \mbox{\textPsi} , % 22 + \mbox{\textchi} / \mbox{\textChi} , % 23 + \mbox{\textomega} / \mbox{\textOmega} % 24 } % upgreek: -\chemgreek_new_mapping:nn { upgreek } +\chemgreek_new_mapping:nnn { upgreek } { upgreek } { \ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2 @@ -477,7 +649,7 @@ } % kpfonts: -\chemgreek_new_mapping:nn { kpfonts } +\chemgreek_new_mapping:nnn { kpfonts } { kpfonts } { \ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2 @@ -506,7 +678,7 @@ } % newtx: -\chemgreek_new_mapping:nn { newtx } +\chemgreek_new_mapping:nnn { newtx } { newtxmath } { \ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1 \ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2 @@ -549,7 +721,7 @@ { \ensuremath { \use:c { other #1 } } } } -\chemgreek_new_mapping:nn { fourier } +\chemgreek_new_mapping:nnn { fourier } { fourier } { \__chemgreek_lfourier:n {alpha} / \ensuremath{\mathrm{A}} , % 1 \__chemgreek_lfourier:n {beta} / \ensuremath{\mathrm{B}} , % 2 @@ -577,9 +749,58 @@ \__chemgreek_lfourier:n {omega} / \__chemgreek_ufourier:n {Omega} % 24 } +% textalpha: +\chemgreek_new_mapping:nnn { textalpha } { textalpha } + { + \mbox{\textalpha} / \mbox{\textAlpha} , % 1 + \mbox{\textbeta} / \mbox{\textBeta} , % 2 + \mbox{\textgamma} / \mbox{\textGamma} , % 3 + \mbox{\textdelta} / \mbox{\textDelta} , % 4 + \mbox{\textepsilon} / \mbox{\textEpsilon} , % 5 + \mbox{\textzeta} / \mbox{\textZeta} , % 6 + \mbox{\texteta} / \mbox{\textEta} , % 7 + \mbox{\texttheta} / \mbox{\textTheta} , % 8 + \mbox{\textiota} / \mbox{\textIota} , % 9 + \mbox{\textkappa} / \mbox{\textKappa} , % 10 + \mbox{\textlambda} / \mbox{\textLambda} , % 11 + \mbox{\textmu} / \mbox{\textMu} , % 12 + \mbox{\textnu} / \mbox{\textNu} , % 13 + \mbox{\textxi} / \mbox{\textXi} , % 14 + \mbox{\textomicron} / \mbox{\textOmicron} , % 15 + \mbox{\textpi} / \mbox{\textPi} , % 16 + \mbox{\textrho} / \mbox{\textRho} , % 17 + \mbox{\textsigma} / \mbox{\textSigma} , % 18 + \mbox{\texttau} / \mbox{\textTau} , % 19 + \mbox{\textupsilon} / \mbox{\textUpsilon} , % 20 + \mbox{\textphi} / \mbox{\textPhi} , % 21 + \mbox{\textpsi} / \mbox{\textPsi} , % 22 + \mbox{\textchi} / \mbox{\textChi} , % 23 + \mbox{\textomega} / \mbox{\textOmega} % 24 + } + % activate default mapping \chemgreek_activate_mapping:n { default } +\AtBeginDocument + { + \chemgreek_if_package_with:nnT {hyperref} {unicode} + { + \chemgreek_if_package_loaded:nT {textalpha} + { + \pdfstringdefDisableCommands + { + \tl_map_inline:Nn \c__chemgreek_alphabet_tl + { + \cs_set_eq:cc + { chem \tl_expandable_uppercase:n #1 } + { text \tl_expandable_uppercase:n #1 } + \cs_set_eq:cc { chem #1 } { text #1 } + } + } + } + } + } + \tex_endinput:D HISTORY: @@ -593,6 +814,19 @@ HISTORY: 2013/11/20 - v0.2a - fixed typos in `fourier' mapping - added missing \prop_clear: to \__chemgreek_set_mapping:nn - added missing argument to message calls +2014/01/24 - v0.3 - rename \Chem<name => \chem<name>, the old names will + issue warnings but still work + - new mappings `textalpha' (cf the package with the same + name, part of `greek-fontenc') + - \chemgreek_new_mapping:nnn redefined so that package name + must be given if needed; \chemgreek_activate_mapping:n + now issues a warning if the needed package hasn't been + loaded + - if hyperref has been loaded with package option `unicode' + and the active mapping is `textalpha' we can use greek + letters in PDF bookmarks + - new command \printchemgreekmapping + - \showchemgreekmapping now writes information to the log TODO: |