summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty443
1 files changed, 443 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty b/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty
new file mode 100644
index 00000000000..dc072de4205
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemgreek.sty
@@ -0,0 +1,443 @@
+% ----------------------------------------------------------------------------
+% - the CHEMMACROS bundle
+% - chemgreek.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}
+\def\chemgreek@version{0.1a}
+\def\chemgreek@date{2013/07/06}
+
+\ProvidesExplPackage{chemgreek}{\chemgreek@date}{\chemgreek@version}
+ {interface for upright greek letters for use in chemistry (CN)}
+
+% ----------------------------------------------------------------------------
+% temporary variables:
+\seq_new:N \l__chemgreek_tmpa_seq
+\tl_new:N \l__chemgreek_tmpa_tl
+\tl_new:N \l__chemgreek_tmpb_tl
+\int_new:N \l__chemgreek_tmpa_int
+\int_new:N \g__chemgreek_tmpa_int
+
+% ----------------------------------------------------------------------------
+% 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 .
+ }
+
+\msg_new:nnnn { chemgreek } { mapping-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 .
+ }
+
+% ----------------------------------------------------------------------------
+% 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
+ {
+ { alpha } % 1
+ { beta } % 2
+ { gamma } % 3
+ { delta } % 4
+ { epsilon } % 5
+ { zeta } % 6
+ { eta } % 7
+ { theta } % 8
+ { iota } % 9
+ { kappa } % 10
+ { lambda } % 11
+ { mu } % 12
+ { nu } % 13
+ { xi } % 14
+ { omikron } % 15
+ { pi } % 16
+ { rho } % 17
+ { sigma } % 18
+ { tau } % 19
+ { upsilon } % 20
+ { phi } % 21
+ { psi } % 22
+ { chi } % 23
+ { omega } % 24
+ }
+
+% ----------------------------------------------------------------------------
+% variants of kernel functions:
+\cs_generate_variant:Nn \prop_put:Nnn { cxV }
+
+% ----------------------------------------------------------------------------
+% helper function to retrieve upper- and lowercase entries while the mapping
+% happens:
+\cs_new: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:
+\prg_new_conditional:Npnn \chemgreek_if_mapping_exists:n #1 {p,T,F,TF}
+ {
+ \bool_if:nTF
+ {
+ \prop_if_exist_p:c { l__chemgreek_uppercase_mapping_#1_prop } &&
+ \prop_if_exist_p:c { l__chemgreek_lowercase_mapping_#1_prop }
+ }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+
+% ----------------------------------------------------------------------------
+% the main mapping function:
+% #1: mapping-name
+% #2: mapping-entries
+\cs_new_protected:Npn \chemgreek_new_mapping:nn #1#2
+ {
+ \chemgreek_if_mapping_exists:nTF { #1 }
+ { \msg_error:nn { chemgreek } { mapping-defined } }
+ {
+ \prop_new:c { l__chemgreek_uppercase_mapping_#1_prop }
+ \prop_new:c { l__chemgreek_lowercase_mapping_#1_prop }
+ \__chemgreek_set_mapping:nn { #1 } { #2 }
+ }
+ }
+
+\cs_new_protected:Npn \chemgreek_renew_mapping:nn #1#2
+ {
+ \chemgreek_if_mapping_exists:nTF { #1 }
+ { \__chemgreek_set_mapping:nn { #1 } { #2 } }
+ { \msg_error:nn { chemgreek } { mapping-not-defined } }
+ }
+
+\cs_new_protected:Npn \chemgreek_declare_mapping:nn #1#2
+ {
+ \chemgreek_if_mapping_exists:nF { #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 }
+ }
+
+\cs_new_protected:Npn \__chemgreek_set_mapping:nn #1#2
+ {
+ \int_zero:N \l__chemgreek_tmpa_int
+ \clist_map_inline:nn { #2 }
+ {
+ \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 } }
+ \l__chemgreek_tmpa_tl
+ \prop_put:cxV { l__chemgreek_uppercase_mapping_#1_prop }
+ { \tl_item:Nn \c__chemgreek_order_tl { \l__chemgreek_tmpa_int } }
+ \l__chemgreek_tmpb_tl
+ }
+ }
+
+% the user command:
+\NewDocumentCommand \newchemgreekmapping { mm }
+ { \chemgreek_new_mapping:nn { #1 } { #2 } }
+
+\NewDocumentCommand \renewchemgreekmapping { mm }
+ { \chemgreek_renew_mapping:nn { #1 } { #2 } }
+
+\NewDocumentCommand \declarechemgreekmapping { mm }
+ { \chemgreek_declare_mapping:nn { #1 } { #2 } }
+
+% ----------------------------------------------------------------------------
+% a function to selectively change specific entries in a mapping:
+% #1: mapping-name
+% #2: upper / lower
+% #3: entry-name
+% #4: entry
+\cs_new_protected:Npn \chemgreek_change:nnnn #1#2#3#4
+ {
+ \chemgreek_if_mapping_exists:nTF { #1 }
+ {
+ \prop_put:cnn { l__chemgreek_#2 case_mapping_#1_prop }
+ { #3 }
+ { #4 }
+ }
+ { \msg_error:nn { chemgreek } { mapping-not-defined } }
+ }
+
+% the user command:
+\NewDocumentCommand \changechemgreeksymbol { mmmm }
+ { \chemgreek_change:nnnn { #1 } { #2 } { #3 } { #4 } }
+
+% ----------------------------------------------------------------------------
+% a function to activate a mapping:
+% #1: mapping-name
+\cs_new_protected:Npn \chemgreek_activate_mapping:n #1
+ {
+ \chemgreek_if_mapping_exists:nTF { #1 }
+ {
+ \tl_map_inline:Nn \c__chemgreek_order_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 } }
+ }
+ }
+ { \msg_error:nn { chemgreek } { mapping-not-defined } }
+ }
+
+% user command that also loads the needed package:
+% #1: load package
+% #2: option
+% #3: mapping-name
+\NewDocumentCommand \activatechemgreekmapping { som }
+ {
+ \IfBooleanT { #1 }
+ {
+ \IfNoValueTF { #2 }
+ { \RequirePackage { #3 } }
+ { \RequirePackage [ #2 ] { #3 } }
+ }
+ \chemgreek_activate_mapping:n { #3 }
+ }
+\@onlypreamble\activatechemgreekmapping
+
+% user command that activates a new mapping without loading the package:
+\NewDocumentCommand \selectchemgreekmapping { m }
+ { \chemgreek_activate_mapping:n { #1 } }
+
+% ----------------------------------------------------------------------------
+% a debugging command:
+\cs_new_protected:Npn \chemgreek_show_mapping:n #1
+ {
+ \chemgreek_activate_mapping:n { #1 }
+ \int_gzero:N \g__chemgreek_tmpa_int
+ \begin { tabular } { llll }
+ pos & name & lower & upper \\
+ \tl_map_inline:Nn \c__chemgreek_order_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 } \\
+ }
+ \end{tabular}
+ }
+
+\cs_new_eq:NN \showchemgreekmapping \chemgreek_show_mapping:n
+
+% ----------------------------------------------------------------------------
+% predefine some mappings
+% default:
+\chemgreek_new_mapping:nn { default }
+ {
+ \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1
+ \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2
+ \ensuremath{\gamma} / \ensuremath{\Gamma} , % 3
+ \ensuremath{\delta} / \ensuremath{\Delta} , % 4
+ \ensuremath{\epsilon} / \ensuremath{\mathrm{E}} , % 5
+ \ensuremath{\zeta} / \ensuremath{\mathrm{Z}} , % 6
+ \ensuremath{\eta} / \ensuremath{\mathrm{H}} , % 7
+ \ensuremath{\theta} / \ensuremath{\Theta} , % 8
+ \ensuremath{\iota} / \ensuremath{\mathrm{I}} , % 9
+ \ensuremath{\kappa} / \ensuremath{\mathrm{K}} , % 10
+ \ensuremath{\lambda} / \ensuremath{\Lambda} , % 11
+ \ensuremath{\mu} / \ensuremath{\mathrm{M}} , % 12
+ \ensuremath{\nu} / \ensuremath{\mathrm{N}} , % 13
+ \ensuremath{\xi} / \ensuremath{\Xi} , % 14
+ \ensuremath{o} / \ensuremath{\mathrm{O}} , % 15
+ \ensuremath{\pi} / \ensuremath{\Pi} , % 16
+ \ensuremath{\rho} / \ensuremath{\mathrm{P}} , % 17
+ \ensuremath{\sigma} / \ensuremath{\Sigma} , % 18
+ \ensuremath{\tau} / \ensuremath{\mathrm{T}} , % 19
+ \ensuremath{\upsilon} / \ensuremath{\Upsilon} , % 20
+ \ensuremath{\phi} / \ensuremath{\Phi} , % 21
+ \ensuremath{\psi} / \ensuremath{\Psi} , % 22
+ \ensuremath{\chi} / \ensuremath{\mathrm{X}} , % 23
+ \ensuremath{\omega} / \ensuremath{\Omega} % 24
+ }
+
+% default-variant:
+\chemgreek_new_mapping:nn { var-default }
+ {
+ \ensuremath{\alpha} / \ensuremath{\mathrm{A}} , % 1
+ \ensuremath{\beta} / \ensuremath{\mathrm{B}} , % 2
+ \ensuremath{\gamma} / \ensuremath{\Gamma} , % 3
+ \ensuremath{\delta} / \ensuremath{\Delta} , % 4
+ \ensuremath{\varepsilon} / \ensuremath{\mathrm{E}} , % 5
+ \ensuremath{\zeta} / \ensuremath{\mathrm{Z}} , % 6
+ \ensuremath{\eta} / \ensuremath{\mathrm{H}} , % 7
+ \ensuremath{\theta} / \ensuremath{\Theta} , % 8
+ \ensuremath{\iota} / \ensuremath{\mathrm{I}} , % 9
+ \ensuremath{\kappa} / \ensuremath{\mathrm{K}} , % 10
+ \ensuremath{\lambda} / \ensuremath{\Lambda} , % 11
+ \ensuremath{\mu} / \ensuremath{\mathrm{M}} , % 12
+ \ensuremath{\nu} / \ensuremath{\mathrm{N}} , % 13
+ \ensuremath{\xi} / \ensuremath{\Xi} , % 14
+ \ensuremath{o} / \ensuremath{\mathrm{O}} , % 15
+ \ensuremath{\pi} / \ensuremath{\Pi} , % 16
+ \ensuremath{\varrho} / \ensuremath{\mathrm{P}} , % 17
+ \ensuremath{\sigma} / \ensuremath{\Sigma} , % 18
+ \ensuremath{\tau} / \ensuremath{\mathrm{T}} , % 19
+ \ensuremath{\upsilon} / \ensuremath{\Upsilon} , % 20
+ \ensuremath{\phi} / \ensuremath{\Phi} , % 21
+ \ensuremath{\psi} / \ensuremath{\Psi} , % 22
+ \ensuremath{\chi} / \ensuremath{\mathrm{X}} , % 23
+ \ensuremath{\omega} / \ensuremath{\Omega} % 24
+ }
+
+% 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
+ }
+
+% upgreek:
+\chemgreek_new_mapping:nn { upgreek }
+ {
+ \ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1
+ \ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2
+ \ensuremath{\upgamma} / \ensuremath{\Upgamma} , % 3
+ \ensuremath{\updelta} / \ensuremath{\Updelta} , % 4
+ \ensuremath{\upepsilon} / \ensuremath{\mathrm{E}} , % 5
+ \ensuremath{\upzeta} / \ensuremath{\mathrm{Z}} , % 6
+ \ensuremath{\upeta} / \ensuremath{\mathrm{H}} , % 7
+ \ensuremath{\uptheta} / \ensuremath{\Uptheta} , % 8
+ \ensuremath{\upiota} / \ensuremath{\mathrm{I}} , % 9
+ \ensuremath{\upkappa} / \ensuremath{\mathrm{K}} , % 10
+ \ensuremath{\uplambda} / \ensuremath{\Uplambda} , % 11
+ \ensuremath{\upmu} / \ensuremath{\mathrm{M}} , % 12
+ \ensuremath{\upnu} / \ensuremath{\mathrm{N}} , % 13
+ \ensuremath{\upxi} / \ensuremath{\Upxi} , % 14
+ \ensuremath{\mathrm{o}} / \ensuremath{\mathrm{O}} , % 15
+ \ensuremath{\uppi} / \ensuremath{\Uppi} , % 16
+ \ensuremath{\uprho} / \ensuremath{\mathrm{R}} , % 17
+ \ensuremath{\upsigma} / \ensuremath{\Upsigma} , % 18
+ \ensuremath{\uptau} / \ensuremath{\mathrm{T}} , % 19
+ \ensuremath{\upupsilon} / \ensuremath{\Upupsilon} , % 20
+ \ensuremath{\upphi} / \ensuremath{\Upphi} , % 21
+ \ensuremath{\uppsi} / \ensuremath{\Uppsi} , % 22
+ \ensuremath{\upchi} / \ensuremath{\mathrm{X}} , % 23
+ \ensuremath{\upomega} / \ensuremath{\Upomega} % 24
+ }
+
+% kpfonts:
+\chemgreek_new_mapping:nn { kpfonts }
+ {
+ \ensuremath{\alphaup} / \ensuremath{\mathrm{A}} , % 1
+ \ensuremath{\betaup} / \ensuremath{\mathrm{B}} , % 2
+ \ensuremath{\gammaup} / \ensuremath{\Gammaup} , % 3
+ \ensuremath{\deltaup} / \ensuremath{\Deltaup} , % 4
+ \ensuremath{\epsilonup} / \ensuremath{\mathrm{E}} , % 5
+ \ensuremath{\zetaup} / \ensuremath{\mathrm{Z}} , % 6
+ \ensuremath{\etaup} / \ensuremath{\mathrm{H}} , % 7
+ \ensuremath{\thetaup} / \ensuremath{\Thetaup} , % 8
+ \ensuremath{\iotaup} / \ensuremath{\mathrm{I}} , % 9
+ \ensuremath{\kappaup} / \ensuremath{\mathrm{K}} , % 10
+ \ensuremath{\lambdaup} / \ensuremath{\Lambdaup} , % 11
+ \ensuremath{\muup} / \ensuremath{\mathrm{M}} , % 12
+ \ensuremath{\nuup} / \ensuremath{\mathrm{N}} , % 13
+ \ensuremath{\xiup} / \ensuremath{\Xiup} , % 14
+ \ensuremath{\mathrm{o}} / \ensuremath{\mathrm{O}} , % 15
+ \ensuremath{\piup} / \ensuremath{\Piup} , % 16
+ \ensuremath{\rhoup} / \ensuremath{\mathrm{R}} , % 17
+ \ensuremath{\sigmaup} / \ensuremath{\Sigmaup} , % 18
+ \ensuremath{\tauup} / \ensuremath{\mathrm{T}} , % 19
+ \ensuremath{\upsilonup} / \ensuremath{\Upsilonup} , % 20
+ \ensuremath{\phiup} / \ensuremath{\Phiup} , % 21
+ \ensuremath{\psiup} / \ensuremath{\Psiup} , % 22
+ \ensuremath{\chiup} / \ensuremath{\mathrm{X}} , % 23
+ \ensuremath{\omegaup} / \ensuremath{\Omegaup} % 24
+ }
+
+% newtx:
+\chemgreek_new_mapping:nn { newtx }
+ {
+ \ensuremath{\upalpha} / \ensuremath{\mathrm{A}} , % 1
+ \ensuremath{\upbeta} / \ensuremath{\mathrm{B}} , % 2
+ \ensuremath{\upgamma} / \ensuremath{\upGamma} , % 3
+ \ensuremath{\updelta} / \ensuremath{\upDelta} , % 4
+ \ensuremath{\upepsilon} / \ensuremath{\mathrm{E}} , % 5
+ \ensuremath{\upzeta} / \ensuremath{\mathrm{Z}} , % 6
+ \ensuremath{\upeta} / \ensuremath{\mathrm{H}} , % 7
+ \ensuremath{\uptheta} / \ensuremath{\upTheta} , % 8
+ \ensuremath{\upiota} / \ensuremath{\mathrm{I}} , % 9
+ \ensuremath{\upkappa} / \ensuremath{\mathrm{K}} , % 10
+ \ensuremath{\uplambda} / \ensuremath{\upLambda} , % 11
+ \ensuremath{\upmu} / \ensuremath{\mathrm{M}} , % 12
+ \ensuremath{\upnu} / \ensuremath{\mathrm{N}} , % 13
+ \ensuremath{\upxi} / \ensuremath{\upXi} , % 14
+ \ensuremath{\mathrm{o}} / \ensuremath{\mathrm{O}} , % 15
+ \ensuremath{\uppi} / \ensuremath{\upPi} , % 16
+ \ensuremath{\uprho} / \ensuremath{\mathrm{R}} , % 17
+ \ensuremath{\upsigma} / \ensuremath{\upSigma} , % 18
+ \ensuremath{\uptau} / \ensuremath{\mathrm{T}} , % 19
+ \ensuremath{\upupsilon} / \ensuremath{\upUpsilon} , % 20
+ \ensuremath{\upphi} / \ensuremath{\upPhi} , % 21
+ \ensuremath{\uppsi} / \ensuremath{\upPsi} , % 22
+ \ensuremath{\upchi} / \ensuremath{\mathrm{X}} , % 23
+ \ensuremath{\upomega} / \ensuremath{\upOmega} % 24
+ }
+
+% activate default mapping
+\chemgreek_activate_mapping:n { default }
+
+\tex_endinput:D
+
+HISTORY:
+2013/06/26 - v0.1 - first working version to be bundled with chemmacros
+2013/07/06 - v0.1a - fixed stupid bug in `upgreek' mapping
+ - added error messages and added \renewchemgreekmapping and
+ \declarechemgreekmapping