summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mhchem
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-11-30 23:01:17 +0000
committerKarl Berry <karl@freefriends.org>2015-11-30 23:01:17 +0000
commit92a3670e2756790a48c372626853cb511e8dcc40 (patch)
tree4ed0daa7cd4bb6999af9d86e6ae58c3be1d70827 /Master/texmf-dist/tex/latex/mhchem
parent507d332bb4ae197fe5580c92b1280e132c5fe981 (diff)
mhchem (30nov15)
git-svn-id: svn://tug.org/texlive/trunk@38982 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mhchem')
-rw-r--r--Master/texmf-dist/tex/latex/mhchem/mhchem.sty836
1 files changed, 388 insertions, 448 deletions
diff --git a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
index f9d1fe25f25..2bb6a5041e8 100644
--- a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
+++ b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
@@ -27,7 +27,7 @@
% This work consists of all files listed in manifest.txt.
%
%
-\ProvidesPackage{mhchem}[2015/07/23 v4.02 for typesetting chemical formulae]
+\ProvidesPackage{mhchem}[2015/11/29 v4.03 for typesetting chemical formulae]
\RequirePackage{expl3}
\RequirePackage{l3keys2e}
\RequirePackage{l3regex}
@@ -58,17 +58,61 @@
\cs_generate_variant:Nn \str_case:nnF { VnF }
\cs_generate_variant:Nn \regex_match:nnTF { nV }
\cs_generate_variant:Nn \regex_match:nnTF { no }
-\cs_new_protected:Npn \__mhchem_regex_peek:nTF #1 #2 #3
+\cs_generate_variant:Nn \regex_match:NnTF { NV }
+\cs_generate_variant:Nn \regex_match:NnTF { No }
+\cs_new_protected:Npn \__mhchem_regex_peek_compile:Nn #1#2
+ {
+ \regex_const:Nn #1 { \A the\ (character|letter)\ (#2) \Z }
+}
+
+\cs_new_protected:Npn \__mhchem_regex_peek:NTF #1#2#3
{
\peek_catcode:NTF ##
{#3}
{
- \regex_match:noTF
- { \A the\ (character|letter)\ (#1) \Z }
- { \token_to_meaning:N \l_peek_token } {#2} {#3}
+ \regex_match:NoTF
+ #1
+ { \token_to_meaning:N \l_peek_token } {#2} {#3}
}
}
+\regex_const:Nn \l__mhchem_regex_digitCommaDigit_regex { \d\,\d }
+\regex_const:Nn \l__mhchem_regex_oneLetter_regex { [nmpx] }
+\regex_const:Nn \l__mhchem_regex_hyphen_regex { - }
+\regex_const:Nn \l__mhchem_regex_letters_regex { [a-zA-Z]+ }
+\regex_const:Nn \l__mhchem_regex_spaces_regex { [\ ]+ }
+
+\regex_const:Nn \l__mhchem_regex_digits_fregex { \A [0-9]+ \Z}
+\regex_const:Nn \l__mhchem_regex_oneToThreeLetters_fregex { \A (.+) (\([a-z]{1,3}\)) \Z }
+\regex_const:Nn \l__mhchem_regex_oneLetter_fregex { \A [nmpx] \Z }
+\regex_const:Nn \l__mhchem_regex_oneLetterPlus_fregex
+ { \A ([nmpx]|\c{eta}|\c{mu}|\c{kappa}|\c{__mhchem_cg_withinMathTokens:n}\cB.[nmpx]\cE.|\d+) \Z }
+\regex_const:Nn \l__mhchem_regex_oneGreekLetter_fregex { \A (\c{eta}|\c{mu}|\c{kappa}) \Z }
+\regex_const:Nn \l__mhchem_regex_romanNumeral_fregex { \A [IVX]+ \Z }
+\regex_const:Nn \l__mhchem_regex_bracedGroup_fregex { \A \cB. [^\cE.]* \cE. \Z }
+\regex_const:Nn \l__mhchem_regex_greekLetter_fregex
+ { \A [\c{alpha}\c{beta}\c{gamma}\c{delta}\c{epsilon}\c{zeta}\c{eta}\c{theta}\c{iota}\c{kappa}\c{lambda}\c{mu}\c{nu}\c{xi}\c{omicron}\c{pi}\c{rho}\c{sigma}\c{tau}\c{upsilon}\c{phi}\c{chi}\c{psi}\c{omega}\c{Alpha}\c{Beta}\c{Gamma}\c{Delta}\c{Epsilon}\c{Zeta}\c{Eta}\c{Theta}\c{Iota}\c{Kappa}\c{Lambda}\c{Mu}\c{Nu}\c{Xi}\c{Omicron}\c{Pi}\c{Rho}\c{Sigma}\c{Tau}\c{Upsilon}\c{Phi}\c{Chi}\c{Psi}\c{Omega}] \Z }
+\regex_const:Nn \l__mhchem_regex_digitOrLetterOrGreek_fregex
+ { \A [1-9a-zA-Z\ \~\+\-\,\.\(\)\c{alpha}\c{beta}\c{gamma}\c{delta}\c{epsilon}\c{zeta}\c{eta}\c{theta}\c{iota}\c{kappa}\c{lambda}\c{mu}\c{nu}\c{xi}\c{omicron}\c{pi}\c{rho}\c{sigma}\c{tau}\c{upsilon}\c{phi}\c{chi}\c{psi}\c{omega}\c{Alpha}\c{Beta}\c{Gamma}\c{Delta}\c{Epsilon}\c{Zeta}\c{Eta}\c{Theta}\c{Iota}\c{Kappa}\c{Lambda}\c{Mu}\c{Nu}\c{Xi}\c{Omicron}\c{Pi}\c{Rho}\c{Sigma}\c{Tau}\c{Upsilon}\c{Phi}\c{Chi}\c{Psi}\c{Omega}]+ \Z }
+\regex_const:Nn \l__mhchem_regex_formula_fregex
+ { \A ( [nmpx] | ([0-9\ \+\-\,\.\(\)]+ [nmpx] [0-9\ \+\-\,\.\(\)]*)+ | ([0-9\ \+\-\,\.\(\)]* [nmpx] [0-9\ \+\-\,\.\(\)]+)+ ) \Z }
+\regex_const:Nn \l__mhchem_regex_formulaAmount_fregex
+ { \A \c{__mhchem_cg_withinMathTokens:n}\cB. (([0-9nmpx]+ [\+\-])? [nmpx] ([\+\-] [0-9nmpx]+)?) \cE. \Z }
+\regex_const:Nn \l__mhchem_regex_fraction_fregex
+ { \A ([0-9]+)\/([0-9]+) \Z }
+
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_digit_pregex { [ 0-9 ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_digitOrPlus_pregex { [ 0-9 \+ ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_digitOrDot_pregex { [ 0-9 . ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_digitOrSlash_pregex { [ 0-9 \/ ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_digitOrDotPlus_pregex { [ 0-9 \) \. \/ ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_dotOrAsterisk_pregex { [ \. \* ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_letter_pregex { [ a-zA-Z ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_uppercaseLetter_pregex { [ A-Z ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_openingBrace_pregex { [ \( \[ ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_closingBrace_pregex { [ \) \] \/ ] }
+\__mhchem_regex_peek_compile:Nn \l__mhchem_regex_oneLetter_pregex { [ nmpx ] }
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% loop helpers %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -811,12 +855,12 @@
{
\bool_if:NT \l__mhchem_ce_potentialSpacing_bool
{ \tl_put_right:Nn \l__mhchem_ce_result_tl { \__mhchem_output_skipAfterAmount: } }
- \regex_match:nVTF
- { \A (.+) (\([a-z]{1,3}\)) \Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_oneToThreeLetters_fregex
\l__mhchem_ce_part_tl
{
- \regex_replace_once:nnN
- { \A (.+) (\([a-z]{1,3}\)) \Z }
+ \regex_replace_once:NnN
+ \l__mhchem_regex_oneToThreeLetters_fregex
{
\c{__mhchem_cf:nn}\cB[\cE]\cB[ \1 \cE]
\c{__mhchem_output_skipBeforeStateOfAggregation:}
@@ -949,16 +993,83 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% arrows %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-\def\mhchem@arrow@minlength{{2em}}%
-
-%%% Deployment of arrow macros
\ExplSyntaxOn
+\cs_new:Npn \__mhchem_arrow_options_minLength:n { {2em} }
+\tl_new:N \mhchem@option@arrow@pgf@tip
+\tl_new:N \mhchem@option@arrow@pgf@halftip
+\tl_new:N \mhchem@option@arrow@pgf@linewidth
+
+\msg_new:nnn { mhchem } { error-arrow-type }
+ {
+ Cannot~understand~arrow~type~'#1'.
+ }
\msg_new:nnn { mhchem } { unexpected-arrow-type }
{
Assertion~failed:~Unexpected~arrow~type~'#1'.~
You~found~a~bug.~Please~contact~the~package~author.
}
+\msg_new:nnn { mhchem } { unexpected-arrow-name }
+ {
+ Assertion~failed:~Unexpected~arrow~name~'#1'.~
+ You~found~a~bug.~Please~contact~the~package~author.
+ }
+\msg_new:nnn { mhchem } { unexpected-arrow-label-type }
+ {
+ Assertion~failed:~Unexpected~arrow~label~type~'#1'.~
+ You~found~a~bug.~Please~contact~the~package~author.
+ }
+
+\cs_new_protected:Npn \__mhchem_arrow_init_pgf: #1
+ {
+ \bool_if:NTF { \l__mhchem_option_inPreamble_bool }
+ {
+ \RequirePackage{pgf} %. for finding the tikz package more easily
+ \RequirePackage{tikz}
+ \AtBeginDocument {
+ \usetikzlibrary{arrows.meta}
+ \__mhchem_arrow_init_pgf_ii: {#1}
+ }
+ }
+ { \__mhchem_arrow_init_pgf_ii: {#1} }
+ }
+\tl_new:N \l__mhchem_arrow_init_pgf_tl
+\cs_new_protected:Npn \__mhchem_arrow_init_pgf_ii: #1
+ {
+ \tl_set:Nn \l__mhchem_option_arrowType_tl { pgf }
+ \str_case:nnF {#1}
+ {
+ { pgf }
+ {
+ \tikzset{mhchemtip /.tip = {Computer~Modern~Rightarrow[length=0pt~5,width'=0pt~1.8]}}
+ \tl_set:Nn \mhchem@option@arrow@pgf@linewidth { 0.09ex }
+ }
+ { pgf-filled }
+ {
+ \tikzset{mhchemtip /.tip = {Stealth[round,length=0pt~10,width'=0pt~0.65]}}
+ \tl_set:Nn \mhchem@option@arrow@pgf@linewidth { 0.09ex }
+ }
+ }
+ {
+ \regex_extract_once:nnNTF
+ { \A pgf \cB. (.+?) \cE. \cB. (.+?) \cE. \Z } %. pgf{arrowname}{linewidth}
+ {#1}
+ \l__mhchem_tmp_arrow_seq
+ {
+ \seq_pop_left:NN \l__mhchem_tmp_arrow_seq \l__mhchem_option_tmpa_tl
+ \seq_pop_left:NN \l__mhchem_tmp_arrow_seq \l__mhchem_option_tmpa_tl
+ \tl_set:Nx \l__mhchem_arrow_init_pgf_tl { mhchemtip /.tip = {\l__mhchem_option_tmpa_tl} }
+ \exp_after:wN \tikzset \exp_after:wN { \l__mhchem_arrow_init_pgf_tl }
+ \seq_pop_left:NN \l__mhchem_tmp_arrow_seq \l__mhchem_option_tmpa_tl
+ \tl_set_eq:NN \mhchem@option@arrow@pgf@linewidth \l__mhchem_option_tmpa_tl
+ }
+ {
+ { \msg_error:nnn { mhchem } { error-arrow-type } {#1} }
+ }
+ }
+ }
+
+\tl_new:N \l__mhchem_arrow_deploy_a_tl
+\tl_new:N \l__mhchem_arrow_deploy_b_tl
\cs_new_protected:Npn \__mhchem_arrow_deploy:nnnnn #1#2#3#4#5
{
\str_case:nnF {#2}
@@ -966,385 +1077,211 @@
{ }
{
\int_compare:nTF { \l__mhchem_option_version_int > 3 }
- { \cs:w mhchem@arrow@#1C \cs_end: {#3}{#5} }
- { \cs:w mhchem@arrow@#1M \cs_end: {#3}{#5} }
+ {
+ \tl_if_empty:nTF
+ {#3}
+ { \tl_clear:N \l__mhchem_arrow_deploy_a_tl }
+ { \tl_set:Nn \l__mhchem_arrow_deploy_a_tl { \ce {#3} } }
+ \tl_if_empty:nTF
+ {#5}
+ { \tl_clear:N \l__mhchem_arrow_deploy_b_tl }
+ { \tl_set:Nn \l__mhchem_arrow_deploy_b_tl { \ce {#5} } }
+ \__mhchem_arrow_output:nVV {#1} \l__mhchem_arrow_deploy_a_tl \l__mhchem_arrow_deploy_b_tl
+ }
+ { \__mhchem_arrow_output:nnn {#1} {#3} {#5} }
}
{ M }
- { \cs:w mhchem@arrow@#1M \cs_end: {#3}{#5} }
+ { \__mhchem_arrow_output:nnn {#1} {#3} {#5} }
{ T }
- { \cs:w mhchem@arrow@#1T \cs_end: {#3}{#5} }
+ {
+ \tl_if_empty:nTF
+ {#3}
+ { \tl_clear:N \l__mhchem_arrow_deploy_a_tl }
+ { \tl_set:Nn \l__mhchem_arrow_deploy_a_tl { \__mhchem_output_escapeFromMathToText:n {#3} } }
+ \tl_if_empty:nTF
+ {#5}
+ { \tl_clear:N \l__mhchem_arrow_deploy_b_tl }
+ { \tl_set:Nn \l__mhchem_arrow_deploy_b_tl { \__mhchem_output_escapeFromMathToText:n {#5} } }
+ \__mhchem_arrow_output:nVV {#1} \l__mhchem_arrow_deploy_a_tl \l__mhchem_arrow_deploy_b_tl
+ }
{ C }
- { \cs:w mhchem@arrow@#1C \cs_end: {#3}{#5} }
+ {
+ \tl_if_empty:nTF
+ {#3}
+ { \tl_clear:N \l__mhchem_arrow_deploy_a_tl }
+ { \tl_set:Nn \l__mhchem_arrow_deploy_a_tl { \ce {#3} } }
+ \tl_if_empty:nTF
+ {#5}
+ { \tl_clear:N \l__mhchem_arrow_deploy_b_tl }
+ { \tl_set:Nn \l__mhchem_arrow_deploy_b_tl { \ce {#5} } }
+ \__mhchem_arrow_output:nVV {#1} \l__mhchem_arrow_deploy_a_tl \l__mhchem_arrow_deploy_b_tl
+ }
}
- { \msg_error:nnn { mhchem } { unexpected-arrow-type } {#2} }
+ { \msg_error:nnn { mhchem } { unexpected-arrow-label-type } {#2} }
}
-\ExplSyntaxOff
-
-%%% Definition of arrows (with math text) for font/pgf/pgf-filled
-\newcommand*\mhchem@arrow@yieldsM[2]{}
-\newcommand*\mhchem@arrow@yieldsLeftM[2]{}
-\newcommand*\mhchem@arrow@yieldsLeftRightM[2]{}
-\newcommand*\mhchem@arrow@mesomerismM[2]{}
-\newcommand*\mhchem@arrow@equilibriumM[2]{}
-\newcommand*\mhchem@arrow@equilibriumRightM[2]{}
-\newcommand*\mhchem@arrow@equilibriumLeftM[2]{}
-\newcommand\mhchem@definearrows[1]{%
- %%% font
- \ifthenelse{\equal{#1}{font}}{%
- \renewcommand*\mhchem@arrow@yieldsM[2]{%
- \ensuremath{{}\mhchem@ext@arrow{5}{9}{##1}{5}{9}{##2}{\mhchem@arrow@minlength}{\rightarrowfill@}{}}}%
- \renewcommand*\mhchem@arrow@yieldsLeftM[2]{%
- \ensuremath{{}\mhchem@ext@arrow{9}{5}{##1}{9}{5}{##2}{\mhchem@arrow@minlength}{\leftarrowfill@}{}}}%
- \renewcommand*\mhchem@arrow@yieldsLeftRightM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##2}%
- {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\rightarrowfill@}$}}}%
- {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{\hphantom{##2}}{\mhchem@arrow@minlength}{\rightarrowfill@}$}}}%
- \@ifempty{##1}%
- {\raisebox{-.44ex}{$\mhchem@ext@arrow{9}{9}{}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftarrowfill@}$}}%
- {\raisebox{-.44ex}{$\mhchem@ext@arrow{9}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftarrowfill@}$}}%
- }{}}}%
- \renewcommand*\mhchem@arrow@mesomerismM[2]{%
- \ensuremath{{}\mhchem@ext@arrow{9}{9}{##1}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftrightarrowfill@}{}}}%
- \renewcommand*\mhchem@arrow@equilibriumM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##2}%
- {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow{5}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}}%
- {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{5}{\hphantom{##2}}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}}%
- \@ifempty{##1}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow{9}{9}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow{5}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}%
- }{}}}%
- \renewcommand*\mhchem@arrow@equilibriumRightM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##1}{%
- \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondownfill@}$}}%
- \@ifempty{##2}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow{0}{0}{}{9}{5}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}%
- }{%
- \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow{5}{9}{\hphantom{##1}\kern-1em}{9}{9}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondownfill@}$}}%
- \@ifempty{##2}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}%
- }%
- }{}}}%
- \renewcommand*\mhchem@arrow@equilibriumLeftM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##2}{%
- \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonupfill@}$}}%
- \@ifempty{##1}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow{5}{9}{\hphantom{##1}\kern1em}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}%
- }{%
- \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow{9}{9}{##1}{5}{9}{\hphantom{##2}\kern-1em}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonupfill@}$}}%
- \@ifempty{##1}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow{9}{9}{\hphantom{##1}\kern1em}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}%
- }%
- }{}}}%
- %%% pgf
- }{\ifthenelse{\equal{#1}{pgf} \or \equal{#1}{pgf-filled}}{%
- \renewcommand*\mhchem@arrow@yieldsM[2]{%
- \ensuremath{{}\mhchem@ext@arrow@pgf{5}{9}{##1}{5}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@rightarrow@pgf}{}}}%
- \renewcommand*\mhchem@arrow@yieldsLeftM[2]{%
- \ensuremath{{}\mhchem@ext@arrow@pgf{9}{5}{##1}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}{}}}%
- \renewcommand*\mhchem@arrow@yieldsLeftRightM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##2}%
- {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\mhchem@rightarrow@pgf}$}}}%
- {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{\hphantom{##2}}{\mhchem@arrow@minlength}{\mhchem@rightarrow@pgf}$}}}%
- \@ifempty{##1}%
- {\raisebox{-.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}$}}%
- {\raisebox{-.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}$}}%
- }{}}}%
- \renewcommand*\mhchem@arrow@mesomerismM[2]{%
- \ensuremath{{}\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftrightarrow@pgf}{}}}%
- \renewcommand*\mhchem@arrow@equilibriumM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##2}%
- {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}}%
- {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{5}{\hphantom{##2}}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}}%
- \@ifempty{##1}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}%
- }{}}}%
- \renewcommand*\mhchem@arrow@equilibriumRightM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##1}{%
- \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondown@pgf}$}}%
- \@ifempty{##2}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{9}{5}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}%
- }{%
- \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{5}{9}{\hphantom{##1}\kern-1em}{9}{9}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondown@pgf}$}}%
- \@ifempty{##2}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}%
- {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}%
- }%
- }{}}}%
- \renewcommand*\mhchem@arrow@equilibriumLeftM[2]{%
- \ensuremath{{}\mathrel{%
- \@ifempty{##2}{%
- \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonup@pgf}$}}%
- \@ifempty{##1}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{\hphantom{##1}\kern1em}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}%
- }{%
- \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{9}{9}{##1}{5}{9}{\hphantom{##2}\kern-1em}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonup@pgf}$}}%
- \@ifempty{##1}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}%
- {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{\hphantom{##1}\kern1em}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}%
- }%
- }{}}}%
- \ifthenelse{\equal{#1}{pgf}}{%
- \let\mhchem@rightarrow@pgf\mhchem@rightarrow@pgfopen%
- \let\mhchem@leftarrow@pgf\mhchem@leftarrow@pgfopen%
- \let\mhchem@leftrightarrow@pgf\mhchem@leftrightarrow@pgfopen%
- \let\mhchem@rightharpoonup@pgf\mhchem@rightharpoonup@pgfopen%
- \let\mhchem@leftharpoondown@pgf\mhchem@leftharpoondown@pgfopen%
- }{%
- \let\mhchem@rightarrow@pgf\mhchem@rightarrow@pgffilled%
- \let\mhchem@leftarrow@pgf\mhchem@leftarrow@pgffilled%
- \let\mhchem@leftrightarrow@pgf\mhchem@leftrightarrow@pgffilled%
- \let\mhchem@rightharpoonup@pgf\mhchem@rightharpoonup@pgffilled%
- \let\mhchem@leftharpoondown@pgf\mhchem@leftharpoondown@pgffilled%
- }%
- }{%
- \PackageError{mhchem}{The option font=#1 is not supported}%
- }}%
-}
-
-%%% Arrow compositions with text or chemistry
-\newtoks\mhchem@arrow@params%
-\ExplSyntaxOn
-\def\mhchem@arrow@setParamsT#1#2{%
- \mhchem@arrow@params={}%
- \@ifempty{#1}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{\__mhchem_output_escapeFromMathToText:n{#1}}}}%
- \@ifempty{#2}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{\__mhchem_output_escapeFromMathToText:n{#2}}}}%
-}%
-\def\mhchem@arrow@setParamst#1#2{%
- \mhchem@arrow@params={}%
- \@ifempty{#1}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{\__mhchem_cg_escapeFromMathToTextOrFaketext:n{#1}}}}%
- \@ifempty{#2}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{\__mhchem_cg_escapeFromMathToTextOrFaketext:n{#2}}}}%
-}%
-\ExplSyntaxOff
-\def\mhchem@arrow@setParamsC#1#2{%
- \mhchem@arrow@params={}%
- \@ifempty{#1}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{\ce{#1}}}}%
- \@ifempty{#2}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
- {\mhchem@appendToks{\mhchem@arrow@params}{{\ce{#2}}}}%
-}%
-\newcommand*\mhchem@arrow@yieldsT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldst[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsLeftT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsLeftt[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsLeftC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsLeftRightT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsLeftRightt[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@yieldsLeftRightC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@mesomerismT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@mesomerismt[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@mesomerismC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumt[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumRightT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumRightt[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumRightC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumLeftT[2]{%
- \mhchem@arrow@setParamsT{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumLeftt[2]{%
- \mhchem@arrow@setParamst{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}%
-\newcommand*\mhchem@arrow@equilibriumLeftC[2]{%
- \mhchem@arrow@setParamsC{#1}{#2}%
- \expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}%
+\cs_new_protected:Npn \__mhchem_arrow_output:nnn #1#2#3
+ {
+ \str_case:VnF \l__mhchem_option_arrowType_tl
+ {
+ { font }
+ {
+ \cs_set_protected:Npn \__mhchem_arrow_base: { \__mhchem_arrow_ext:nnnnnnnn }
+ \cs_set_protected:Npn \__mhchem_arrow_rightArrowFill: { \rightarrowfill@ }
+ \cs_set_protected:Npn \__mhchem_arrow_leftArrowFill: { \leftarrowfill@ }
+ \cs_set_protected:Npn \__mhchem_arrow_leftRightArrowFill: { \leftrightarrowfill@ }
+ \cs_set_protected:Npn \__mhchem_arrow_rightHarpoonUpFill: { \__mhchem_arrow_rightharpoonupfill }
+ \cs_set_protected:Npn \__mhchem_arrow_leftHarpoonDownFill: { \__mhchem_arrow_leftharpoondownfill }
+ }
+ { pgf }
+ {
+ \cs_set_protected:Npn \__mhchem_arrow_base: { \__mhchem_arrow_extPgf:nnnnnnnn }
+ \cs_set_protected:Npn \__mhchem_arrow_rightArrowFill: { \mhchem@arrow@right@pgf }
+ \cs_set_protected:Npn \__mhchem_arrow_leftArrowFill: { \mhchem@arrow@left@pgf }
+ \cs_set_protected:Npn \__mhchem_arrow_leftRightArrowFill: { \mhchem@arrow@leftright@pgf }
+ \cs_set_protected:Npn \__mhchem_arrow_rightHarpoonUpFill: { \mhchem@arrow@rightharpoonup@pgf }
+ \cs_set_protected:Npn \__mhchem_arrow_leftHarpoonDownFill: { \mhchem@arrow@leftharpoondown@pgf }
+ }
+ }
+ { \msg_error:nnx { mhchem } { unexpected-arrow-type } { \l__mhchem_option_arrowType_tl } }
+ \str_case:nnF {#1}
+ {
+ { yields }
+ { \ensuremath{{}\__mhchem_arrow_base:{5}{9}{#2}{5}{9}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightArrowFill:}{}} }
+ { yieldsLeft }
+ { \ensuremath{{}\__mhchem_arrow_base:{9}{5}{#2}{9}{5}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftArrowFill:}{}} }
+ { yieldsLeftRight }
+ {
+ \ensuremath{{}\mathrel{
+ \@ifempty{#3}
+ {\rlap{\raisebox{.44ex}{$\__mhchem_arrow_base:{9}{9}{#2}{9}{9}{}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightArrowFill:}$}}}
+ {\rlap{\raisebox{.44ex}{$\__mhchem_arrow_base:{9}{9}{#2}{9}{9}{\hphantom{#3}}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightArrowFill:}$}}}
+ \@ifempty{#2}
+ {\raisebox{-.44ex}{$\__mhchem_arrow_base:{9}{9}{}{9}{9}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftArrowFill:}$}}
+ {\raisebox{-.44ex}{$\__mhchem_arrow_base:{9}{9}{\hphantom{#2}}{9}{9}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftArrowFill:}$}}
+ }{}}
+ }
+ { mesomerism }
+ { \ensuremath{{}\__mhchem_arrow_base:{9}{9}{#2}{9}{9}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftRightArrowFill:}{}} }
+ { equilibrium }
+ {
+ \ensuremath{{}\mathrel{
+ \@ifempty{#3}
+ {\rlap{\raisebox{.22ex}{$\__mhchem_arrow_base:{5}{9}{#2}{9}{9}{}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightHarpoonUpFill:}$}}}
+ {\rlap{\raisebox{.22ex}{$\__mhchem_arrow_base:{9}{9}{#2}{9}{5}{\hphantom{#3}}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightHarpoonUpFill:}$}}}
+ \@ifempty{#2}
+ {\raisebox{-.22ex}{$\__mhchem_arrow_base:{9}{9}{}{9}{5}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ {\raisebox{-.22ex}{$\__mhchem_arrow_base:{5}{9}{\hphantom{#2}}{9}{9}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ }{}}
+ }
+ { equilibriumRight }
+ {
+ \ensuremath{{}\mathrel{
+ \@ifempty{#2}{
+ \rlap{\raisebox{-.22ex}{$\kern0.5em\__mhchem_arrow_base:{0}{0}{}{9}{5}{#3}{\__mhchem_arrow_options_minLength:n-1em}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ \@ifempty{#3}
+ {\raisebox{.22ex}{$\__mhchem_arrow_base:{0}{0}{}{0}{0}{}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightHarpoonUpFill:}$}}
+ {\raisebox{.22ex}{$\__mhchem_arrow_base:{0}{0}{}{9}{5}{\hphantom{#3}\kern1em}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightHarpoonUpFill:}$}}
+ }{
+ \rlap{\raisebox{-.22ex}{$\kern0.5em\__mhchem_arrow_base:{5}{9}{\hphantom{#2}\kern-1em}{9}{9}{#3}{\__mhchem_arrow_options_minLength:n-1em}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ \@ifempty{#3}
+ {\raisebox{.22ex}{$\__mhchem_arrow_base:{5}{9}{#2}{0}{0}{}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightHarpoonUpFill:}$}}
+ {\raisebox{.22ex}{$\__mhchem_arrow_base:{9}{9}{#2}{9}{9}{\hphantom{#3}\kern1em}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_rightHarpoonUpFill:}$}}
+ }
+ }{}}
+ }
+ { equilibriumLeft }
+ {
+ \ensuremath{{}\mathrel{
+ \@ifempty{#3}{
+ \rlap{\raisebox{.22ex}{$\kern0.5em\__mhchem_arrow_base:{5}{9}{#2}{0}{0}{}{\__mhchem_arrow_options_minLength:n-1em}{\__mhchem_arrow_rightHarpoonUpFill:}$}}
+ \@ifempty{#2}
+ {\raisebox{-.22ex}{$\__mhchem_arrow_base:{0}{0}{}{0}{0}{}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ {\raisebox{-.22ex}{$\__mhchem_arrow_base:{5}{9}{\hphantom{#2}\kern1em}{0}{0}{}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ }{
+ \rlap{\raisebox{.22ex}{$\kern0.5em\__mhchem_arrow_base:{9}{9}{#2}{5}{9}{\hphantom{#3}\kern-1em}{\__mhchem_arrow_options_minLength:n-1em}{\__mhchem_arrow_rightHarpoonUpFill:}$}}
+ \@ifempty{#2}
+ {\raisebox{-.22ex}{$\__mhchem_arrow_base:{0}{0}{}{9}{5}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ {\raisebox{-.22ex}{$\__mhchem_arrow_base:{9}{9}{\hphantom{#2}\kern1em}{9}{9}{#3}{\__mhchem_arrow_options_minLength:n}{\__mhchem_arrow_leftHarpoonDownFill:}$}}
+ }
+ }{}}
+ }
+ }
+ { \msg_error:nnn { mhchem } { unexpected-arrow-name } {#1} }
+ }
+\cs_generate_variant:Nn \__mhchem_arrow_output:nnn {nVV}
%%% Font arrows
-\def\mhchem@ext@arrow#1#2#3#4#5#6#7#8{% adaption of amsmath's ext@arrow
- \mathrel{%
- \mathop{\makebox[#7]{#8\displaystyle}}%
- \limits%
- \@ifnotempty{#3}{^{\mkern#1mu#3\mkern#2mu}}%
- \@ifnotempty{#6}{_{%
- \makebox{\raisebox{1.25ex-\heightof{$\scriptstyle\mkern#4mu#6\mkern#5mu$}}[0pt]%
- {$\scriptstyle\mkern#4mu#6\mkern#5mu$}}
- }}%
- }%
-}
-\def\mhchem@rightharpoonupfill@{\arrowfill@\relbar\relbar\rightharpoonup}
-\def\mhchem@leftharpoondownfill@{\arrowfill@\leftharpoondown\relbar\relbar}
-
+\cs_new_protected:Npn \__mhchem_arrow_ext:nnnnnnnn #1#2#3#4#5#6#7#8 % adaption of amsmath's ext@arrow
+ {
+ \mathrel{
+ \mathop{\makebox[#7]{#8\displaystyle}}
+ \limits
+ \@ifnotempty{#3}{^{\mkern#1mu#3\mkern#2mu}}
+ \@ifnotempty{#6}
+ {
+ \c_math_subscript_token{\makebox{
+ \raisebox{1.25ex-\heightof{$\scriptstyle\mkern#4mu#6\mkern#5mu$}}[0pt]
+ {$\scriptstyle\mkern#4mu#6\mkern#5mu$}
+ }}
+ }
+ }
+ }
+\cs_new_protected:Npn \__mhchem_arrow_rightharpoonupfill
+ { \arrowfill@\relbar\relbar\rightharpoonup }
+\cs_new_protected:Npn \__mhchem_arrow_leftharpoondownfill
+ { \arrowfill@\leftharpoondown\relbar\relbar }
%%% pgf arrows
-\newlength{\mhchem@arrowlength@pgf}
-\def\mhchem@ext@arrow@pgf#1#2#3#4#5#6#7#8{%
- \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{%
- \mhchem@ext@arrow{#1}{#2}{#3}{#4}{#5}{#6}{#7}{\rightarrowfill@}%
- }}}%
- \mathrel{%
- \mathop{\kern0.7pt#8{\mhchem@arrowlength@pgf-1.8pt}\kern0.7pt}%
- \limits%
- \@ifnotempty{#3}{^{\mkern#1mu#3\mkern#2mu}}%
- \@ifnotempty{#6}{_{\mkern#4mu#6\mkern#5mu}}%
- }%
-}%
-\newcommand*\mhchem@rightarrow@pgfopen[1]{%
- \begin{tikzpicture}[baseline]%
- \draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex) -- ++(#1,0cm)
- arc (250:198:0.6ex) arc (198:250:0.6ex)
- arc (110:162:0.6ex);
- \end{tikzpicture}%
-}%
-\newcommand*\mhchem@leftarrow@pgfopen[1]{%
- \begin{tikzpicture}[baseline]%
- \draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex]
- (#1,0.575ex) -- (0cm,0.575ex)
- arc (70:18:0.6ex) arc (18:70:0.6ex)
- arc (-70:-18:0.6ex);
- \end{tikzpicture}%
-}%
-\newcommand*\mhchem@leftrightarrow@pgfopen[1]{%
- \begin{tikzpicture}[baseline]%
- \draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex)
- arc (70:18:0.6ex) arc (18:70:0.6ex)
- arc (-70:-18:0.6ex) arc (-18:-70:0.6ex)
- -- ++(#1,0cm)
- arc (250:198:0.6ex) arc (198:250:0.6ex)
- arc (110:162:0.6ex);
- \end{tikzpicture}%
-}%
-\newcommand*\mhchem@rightharpoonup@pgfopen[1]{%
- \begin{tikzpicture}[baseline]%
- \draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex) -- ++(#1,0cm) arc (250:198:0.6ex);
- \end{tikzpicture}%
-}%
-\newcommand*\mhchem@leftharpoondown@pgfopen[1]{%
- \begin{tikzpicture}[baseline]%
- \draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex) arc (70:18:0.6ex) arc (18:70:0.6ex)
- -- ++(#1,0cm);
- \end{tikzpicture}%
-}%
+\skip_new:N \__mhchem_arrow_extPgfLength_skip
+\cs_new_protected:Npn \__mhchem_arrow_extPgf:nnnnnnnn #1#2#3#4#5#6#7#8
+ {
+ \setlength \__mhchem_arrow_extPgfLength_skip
+ {
+ \widthof{\ensuremath{
+ \__mhchem_arrow_ext:nnnnnnnn{#1}{#2}{#3}{#4}{#5}{#6}{#7}{\rightarrowfill@}
+ }}
+ }
+ \mathrel{
+ \mathop{\kern0.7pt#8{\__mhchem_arrow_extPgfLength_skip-1.8pt}\kern0.7pt}
+ \limits
+ \@ifnotempty{#3}{^{\mkern#1mu#3\mkern#2mu}}
+ \@ifnotempty{#6}{\c_math_subscript_token{\mkern#4mu#6\mkern#5mu}}
+ }
+ }
+\ExplSyntaxOff
-\newcommand*\mhchem@rightarrow@pgffilled[1]{%
+\newcommand*\mhchem@arrow@right@pgf[1]{%
\begin{tikzpicture}[baseline]%
\draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex]
+ \draw[arrows={-mhchemtip}, shorten <=0.5*\mhchem@option@arrow@pgf@linewidth, cap=round, line width=\mhchem@option@arrow@pgf@linewidth]
(0cm,0.575ex) -- ++(#1,0cm);
- \filldraw[cap=round, join=round, line width=0.09ex]
- (#1,0.575ex)
- -- ++(-0.6ex,0.2ex) -- ++(0.15ex,-0.2ex)
- -- ++(-0.15ex,-0.2ex)
- -- cycle;
\end{tikzpicture}%
}%
-\newcommand*\mhchem@leftarrow@pgffilled[1]{%
+\newcommand*\mhchem@arrow@left@pgf[1]{%
\begin{tikzpicture}[baseline]%
\draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex]
+ \draw[arrows={mhchemtip-}, shorten >=0.5*\mhchem@option@arrow@pgf@linewidth, cap=round, line width=\mhchem@option@arrow@pgf@linewidth]
(0cm,0.575ex) -- ++(#1,0cm);
- \filldraw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex)
- -- ++(0.6ex,0.2ex) -- ++(-0.15ex,-0.2ex)
- -- ++(+0.15ex,-0.2ex)
- -- cycle;
\end{tikzpicture}%
}%
-\newcommand*\mhchem@leftrightarrow@pgffilled[1]{%
+\newcommand*\mhchem@arrow@leftright@pgf[1]{%
\begin{tikzpicture}[baseline]%
\draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex]
+ \draw[arrows={mhchemtip-mhchemtip}, cap=round, line width=\mhchem@option@arrow@pgf@linewidth]
(0cm,0.575ex) -- ++(#1,0cm);
- \filldraw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex)
- -- ++(0.6ex,0.2ex) -- ++(-0.15ex,-0.2ex)
- -- ++(+0.15ex,-0.2ex)
- -- cycle;
- \filldraw[cap=round, join=round, line width=0.09ex]
- (#1,0.575ex)
- -- ++(-0.6ex,0.2ex) -- ++(0.15ex,-0.2ex)
- -- ++(-0.15ex,-0.2ex)
- -- cycle;
\end{tikzpicture}%
}%
-\newcommand*\mhchem@rightharpoonup@pgffilled[1]{%
+\newcommand*\mhchem@arrow@rightharpoonup@pgf[1]{%
\begin{tikzpicture}[baseline]%
\draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex]
+ \draw[arrows={-mhchemtip[harpoon]}, shorten <=0.5*\mhchem@option@arrow@pgf@linewidth, cap=round, line width=\mhchem@option@arrow@pgf@linewidth, ]
(0cm,0.575ex) -- ++(#1,0cm);
- \filldraw[cap=round, join=round, line width=0.09ex]
- (#1,0.575ex)
- -- ++(-0.6ex,0.25ex) -- ++(0.15ex,-0.25ex)
- -- cycle;
\end{tikzpicture}%
}%
-\newcommand*\mhchem@leftharpoondown@pgffilled[1]{%
+\newcommand*\mhchem@arrow@leftharpoondown@pgf[1]{%
\begin{tikzpicture}[baseline]%
\draw[use as bounding box] (0,0) (#1,0.85ex);
- \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex]
+ \draw[arrows={mhchemtip[harpoon]-}, shorten >=0.5*\mhchem@option@arrow@pgf@linewidth, cap=round, line width=\mhchem@option@arrow@pgf@linewidth, ]
(0cm,0.575ex) -- ++(#1,0cm);
- \filldraw[cap=round, join=round, line width=0.09ex]
- (0cm,0.575ex)
- -- ++(0.6ex,-0.25ex) -- ++(-0.15ex,0.25ex)
- -- cycle;
\end{tikzpicture}%
}%
@@ -1461,8 +1398,10 @@
\bool_set_false:N \l__mhchem_cf_startedWithBond_bool
\__mhchem_cf_resetOutput:
\tl_set:Nn \l__mhchem_cf_result_tl {#2}
- \regex_replace_once:nnNTF
- { \A [nmpx] \Z } { \c{__mhchem_output_withFont:n}\cB[ \c{__mhchem_cg_itshape:n}\cB[ \0 \cE]\cE] } \l__mhchem_cf_result_tl
+ \regex_replace_once:NnNTF
+ \l__mhchem_regex_oneLetter_fregex
+ { \c{__mhchem_output_withFont:n}\cB[ \c{__mhchem_cg_itshape:n}\cB[ \0 \cE]\cE] }
+ \l__mhchem_cf_result_tl
{}
{
\tl_clear:N \l__mhchem_cf_result_tl
@@ -1509,8 +1448,8 @@
{ - }
{
\__mhchem_cf_outputAndReset:
- \regex_match:nVTF
- { \A ([nmpx]|\c{eta}|\c{mu}|\c{kappa}|\c{__mhchem_cg_withinMathTokens:n}\cB.[nmpx]\cE.|\d+) \Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_oneLetterPlus_fregex
\l__mhchem_cf_lastElement_tl
{
\__mhchem_cf_outputRawElementAndReset:n
@@ -1525,7 +1464,7 @@
}
{ ( }
{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\tl_set:Nn \l__mhchem_cf_state_tl { 1 }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -1542,10 +1481,10 @@
{ ps }
{
\__mhchem_cf_outputAndReset:
- \__mhchem_regex_peek:nTF { [ A-Z ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_uppercaseLetter_pregex
{
- \regex_match:nVTF
- { \A \c{__mhchem_cg_withinMathTokens:n}\cB. (([0-9nmpx]+ [\+\-])? [nmpx] ([\+\-] [0-9nmpx]+)?) \cE. \Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_formulaAmount_fregex
\l__mhchem_cf_lastElement_tl
{
\tl_put_right:Nn
@@ -1711,20 +1650,20 @@
{ s }
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ \) \] \/ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_closingBrace_pregex
{
\__mhchem_loopHelper_outputAndReset_appendNextTokenToResult_setState:nNn
{ a }
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ a-zA-Z ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_letter_pregex
{
\tl_set:Nn \l__mhchem_cf_state_tl { a }
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_element_tl
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ 0-9 . ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digitOrDot_pregex
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \l__mhchem_cf_state_tl { 1 }
@@ -1736,8 +1675,8 @@
}
{ c }
{
- \regex_match:nVTF
- { \A [\c{alpha}\c{beta}\c{gamma}\c{delta}\c{epsilon}\c{zeta}\c{eta}\c{theta}\c{iota}\c{kappa}\c{lambda}\c{mu}\c{nu}\c{xi}\c{omicron}\c{pi}\c{rho}\c{sigma}\c{tau}\c{upsilon}\c{phi}\c{chi}\c{psi}\c{omega}\c{Alpha}\c{Beta}\c{Gamma}\c{Delta}\c{Epsilon}\c{Zeta}\c{Eta}\c{Theta}\c{Iota}\c{Kappa}\c{Lambda}\c{Mu}\c{Nu}\c{Xi}\c{Omicron}\c{Pi}\c{Rho}\c{Sigma}\c{Tau}\c{Upsilon}\c{Phi}\c{Chi}\c{Psi}\c{Omega}] \Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_greekLetter_fregex
\l__mhchem_cf_element_tl
{
\tl_set:Nn \l__mhchem_cf_state_tl { a }
@@ -1760,7 +1699,7 @@
}
{ 1 }
{
- \__mhchem_regex_peek:nTF { [ 0-9 \) \. \/ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digitOrDotPlus_pregex
{
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_element_tl
@@ -1898,7 +1837,7 @@
\__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}{
- \__mhchem_regex_peek:nTF { [ \. \* ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_dotOrAsterisk_pregex
{
\__mhchem_loopHelper_outputAndReset_appendToResult_setState_useNone:nnNn
{ \__mhchem_output_additionCompound: }
@@ -1911,19 +1850,19 @@
\tl_set:Nn \l__mhchem_cf_state_tl { e }
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ \( \[ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_openingBrace_pregex
{
\__mhchem_loopHelper_outputAndReset_appendNextTokenToResult_setState:nNn
{ s }
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ \) \] \/ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_closingBrace_pregex
{
\__mhchem_loopHelper_outputAndReset_appendNextTokenToResult_setState:nNn
{ a }
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ a-zA-Z ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_letter_pregex
{
\str_if_eq:VnTF \l__mhchem_cf_supState_tl { - }
{
@@ -1931,8 +1870,8 @@
{ \__mhchem_cf_outputAndReset: }
}
{
- \regex_match:nVTF
- { \A [0-9]+ \Z}
+ \regex_match:NVTF
+ \l__mhchem_regex_digits_fregex
\l__mhchem_cf_sup_tl
{
\tl_set:NV \l__mhchem_cf_loop_tmpa_l \l__mhchem_cf_sup_tl
@@ -1955,7 +1894,7 @@
\l__mhchem_cf_element_tl
\__mhchem_cf_loop:
}{
- \__mhchem_regex_peek:nTF { [ 0-9 ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\str_if_eq:VnF \l__mhchem_cf_subState_tl { - }
{ \__mhchem_cf_outputAndReset: }
@@ -1982,7 +1921,7 @@
{ l__mhchem_cf_sup_tl }
{ __mhchem_cf_loop: }
}{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\tl_set:Nn \l__mhchem_cf_state_tl { e+ }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -2000,7 +1939,7 @@
}
{ e+ }
{
- \__mhchem_regex_peek:nTF { [ 0-9 \+ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digitOrPlus_pregex
{
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_sup_tl
@@ -2008,8 +1947,8 @@
}{
\peek_charcode:NTF -
{
- \regex_match:nVTF
- { \A (\c{eta}|\c{mu}|\c{kappa}) \Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_oneGreekLetter_fregex
\l__mhchem_cf_element_tl
{
\tl_set:Nn \l__mhchem_cf_state_tl { - }
@@ -2038,7 +1977,7 @@
{ l__mhchem_cf_sub_tl }
{ __mhchem_cf_loop: }
}{
- \__mhchem_regex_peek:nTF { [ 0-9 \/ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digitOrSlash_pregex
{
\tl_set:Nn \l__mhchem_cf_state_tl { f+ }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -2056,7 +1995,7 @@
}
{ f+ }
{
- \__mhchem_regex_peek:nTF { [ 0-9 \/ ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digitOrSlash_pregex
{
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_sub_tl
@@ -2077,7 +2016,7 @@
{ l__mhchem_cf_presup_tl }
{ __mhchem_cf_loop: }
}{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\tl_set:Nn \l__mhchem_cf_state_tl { p+ }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -2095,7 +2034,7 @@
}
{ p+ }
{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_presup_tl
@@ -2116,7 +2055,7 @@
{ l__mhchem_cf_presub_tl }
{ __mhchem_cf_loop: }
}{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\tl_set:Nn \l__mhchem_cf_state_tl { q+ }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -2134,7 +2073,7 @@
}
{ q+ }
{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_presub_tl
@@ -2213,8 +2152,8 @@
\str_if_eq:VnTF \l__mhchem_cf_supState_tl { rm }
{ \tl_set:Nx \l__mhchem_cf_sup_tl { \exp_not:N \__mhchem_output_escapeToRomanMath:n { \exp_not:V \l__mhchem_cf_sup_tl } } }
{ \__mhchem_cg_replaceForSuperscript:N \l__mhchem_cf_sup_tl }
- \regex_match:nVTF
- { \A [IVX]+ \Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_romanNumeral_fregex
\l__mhchem_cf_sup_tl
{ \tl_set:Nn \l__mhchem_cf_supState_tl { ox } }
{}
@@ -2301,15 +2240,16 @@
{
\int_compare:nTF { \l__mhchem_option_version_int > 3 }
{
- \regex_match:nnTF
- { \A \cB. [^\cE.]* \cE. \Z } {#1}
+ \regex_match:NnTF
+ \l__mhchem_regex_bracedGroup_fregex
+ {#1}
{
\__mhchem_output_escapeFromMathToItalicMath:n {#1}
}
% else
{
- \regex_match:nnTF
- { \A [1-9a-zA-Z\ \~\+\-\,\.\(\)\c{alpha}\c{beta}\c{gamma}\c{delta}\c{epsilon}\c{zeta}\c{eta}\c{theta}\c{iota}\c{kappa}\c{lambda}\c{mu}\c{nu}\c{xi}\c{omicron}\c{pi}\c{rho}\c{sigma}\c{tau}\c{upsilon}\c{phi}\c{chi}\c{psi}\c{omega}\c{Alpha}\c{Beta}\c{Gamma}\c{Delta}\c{Epsilon}\c{Zeta}\c{Eta}\c{Theta}\c{Iota}\c{Kappa}\c{Lambda}\c{Mu}\c{Nu}\c{Xi}\c{Omicron}\c{Pi}\c{Rho}\c{Sigma}\c{Tau}\c{Upsilon}\c{Phi}\c{Chi}\c{Psi}\c{Omega}]+ \Z }
+ \regex_match:NnTF
+ \l__mhchem_regex_digitOrLetterOrGreek_fregex
{#1}
{
\group_begin:
@@ -2322,16 +2262,16 @@
}
{
\tl_set:Nn \l__mhchem_cg_withinMathTokens_tmpa_tl { #1 }
- \regex_replace_all:nnN
- { [a-zA-Z]+ }
+ \regex_replace_all:NnN
+ \l__mhchem_regex_letters_regex
{ \c{__mhchem_output_escapeFromTextToItalicText:n} \cB[ \0 \cE] }
\l__mhchem_cg_withinMathTokens_tmpa_tl
- \regex_replace_all:nnN
- { [\ ]+ }
+ \regex_replace_all:NnN
+ \l__mhchem_regex_spaces_regex
{}
\l__mhchem_cg_withinMathTokens_tmpa_tl
- \regex_replace_all:nnN
- { - }
+ \regex_replace_all:NnN
+ \l__mhchem_regex_hyphen_regex
{ \c{mhchem@option@textminus} }
\l__mhchem_cg_withinMathTokens_tmpa_tl
\tl_use:N \l__mhchem_cg_withinMathTokens_tmpa_tl
@@ -2422,8 +2362,10 @@
\cs_new_protected:Npn \__mhchem_cg_replaceForAmount:N #1
{
- \regex_replace_once:nnN
- { \A ([0-9]+)\/([0-9]+) \Z } { \c{__mhchem_cg_frac:nn} \cB[\1\cE] \cB[\2\cE] } #1
+ \regex_replace_once:NnN
+ \l__mhchem_regex_fraction_fregex
+ { \c{__mhchem_cg_frac:nn} \cB[\1\cE] \cB[\2\cE] }
+ #1
}
\cs_new_protected:Npn \__mhchem_cg_frac:nn #1#2
{
@@ -2442,20 +2384,20 @@
{
\int_compare:nTF { \l__mhchem_option_version_int > 3}
{
- \regex_match:nVTF
- { \A( [nmpx] | ([0-9\ \+\-\,\.\(\)]+ [nmpx] [0-9\ \+\-\,\.\(\)]*)+ | ([0-9\ \+\-\,\.\(\)]* [nmpx] [0-9\ \+\-\,\.\(\)]+)+ )\Z }
+ \regex_match:NVTF
+ \l__mhchem_regex_formula_fregex
#1
{
- \regex_replace_all:nnN
- { [nmpx] }
+ \regex_replace_all:NnN
+ \l__mhchem_regex_oneLetter_regex
{ \c{__mhchem_output_withFont:n}\cB[ \c{__mhchem_cg_itshape:n}\cB[ \0 \cE]\cE] }
#1
- \regex_replace_all:nnN
- { - }
+ \regex_replace_all:NnN
+ \l__mhchem_regex_hyphen_regex
{ \c{__mhchem_output_minus:} }
#1
- \regex_replace_all:nnN
- { \d\,\d }
+ \regex_replace_all:NnN
+ \l__mhchem_regex_digitCommaDigit_regex
{ \c{__mhchem_output_commaDecimal:} }
#1
}
@@ -2494,7 +2436,7 @@
\l__mhchem_cg_replaceForSubscript_result_tl
\__mhchem_cg_replaceForSubscript_loop:
}{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { 9 }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -2613,7 +2555,7 @@
}
\__mhchem_cg_replaceForSuperscript_loop:
}{
- \__mhchem_regex_peek:nTF { [ nmpx ] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_oneLetter_pregex
{
\str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
{
@@ -2627,7 +2569,7 @@
\l__mhchem_cg_replaceForSuperscript_result_tl
\__mhchem_cg_replaceForSuperscript_loop:
}{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{
\str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
{ \tl_put_right:Nn \l__mhchem_cg_replaceForSuperscript_result_tl { . } }
@@ -2952,7 +2894,7 @@
{ \__mhchem_output_withFont:n { , } \ensuremath { \mkern3mu } }
\cs_new_protected:Npn \__mhchem_output_commaAuto:
{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{ \__mhchem_output_commaDecimal: }
{ \__mhchem_output_commaEnumeration: }
}
@@ -2960,7 +2902,7 @@
{ \__mhchem_output_withFont:n { , } \ensuremath { \mkern1mu } }
\cs_new_protected:Npn \__mhchem_output_commaAutoSmall:
{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:NTF \l__mhchem_regex_digit_pregex
{ \__mhchem_output_commaDecimal: }
{ \__mhchem_output_commaEnumerationSmall: }
}
@@ -3188,6 +3130,7 @@
\ExplSyntaxOn
+\tl_new:N \l__mhchem_option_tmpa_tl
\msg_new:nnn { mhchem } { options / no-version }
{
You~did~not~specify~a~'version'~option~for~the~mhchem~package.~
@@ -3213,16 +3156,16 @@
\def\mhchem@hook@beforeItalicText{}
\def\mhchem@hook@beforeRomanMath{}
\def\mhchem@hook@beforeItalicMath{}
-\bool_new:N \l__mhchem_option_layoutWasSet
-\bool_set_false:N \l__mhchem_option_layoutWasSet
+\bool_new:N \l__mhchem_option_layoutWasSet_bool
+\bool_set_false:N \l__mhchem_option_layoutWasSet_bool
\bool_new:N \l__mhchem_option_superscriptsStacked_bool
\bool_new:N \l__mhchem_option_subscriptsDeep_bool
\cs_new_protected:Npn \mhchem@option@textElectronDot {}
\cs_new_protected:Npn \mhchem@option@cdot {}
-\bool_new:N \l__mhchem_option_textgreekSelectedByUser
-\bool_set_false:N \l__mhchem_option_textgreekSelectedByUser
-\bool_new:N \l__mhchem_option_mathgreekSelectedByUser
-\bool_set_false:N \l__mhchem_option_mathgreekSelectedByUser
+\bool_new:N \l__mhchem_option_textgreekSelectedByUser_bool
+\bool_set_false:N \l__mhchem_option_textgreekSelectedByUser_bool
+\bool_new:N \l__mhchem_option_mathgreekSelectedByUser_bool
+\bool_set_false:N \l__mhchem_option_mathgreekSelectedByUser_bool
\keys_define:nn {mhchem}
{
@@ -3250,29 +3193,29 @@
text-greek .code:n =
{
\chemgreek_declare_mapping_alias:nn { mhchem-text } {#1}
- \bool_set_true:N \l__mhchem_option_textgreekSelectedByUser
+ \bool_set_true:N \l__mhchem_option_textgreekSelectedByUser_bool
},
math-greek .code:n =
{
\chemgreek_declare_mapping_alias:nn { mhchem-math } {#1}
- \bool_set_true:N \l__mhchem_option_mathgreekSelectedByUser
+ \bool_set_true:N \l__mhchem_option_mathgreekSelectedByUser_bool
},
layout .choice:,
layout / stacked .code:n =
{
- \bool_set_true:N \l__mhchem_option_layoutWasSet
+ \bool_set_true:N \l__mhchem_option_layoutWasSet_bool
\bool_set_true:N \l__mhchem_option_superscriptsStacked_bool
},
layout / staggered-deep .code:n =
{
- \bool_set_true:N \l__mhchem_option_layoutWasSet
+ \bool_set_true:N \l__mhchem_option_layoutWasSet_bool
\bool_set_false:N \l__mhchem_option_superscriptsStacked_bool
\bool_set_true:N \l__mhchem_option_subscriptsDeep_bool
},
layout / staggered-flat .code:n =
{
- \bool_set_true:N \l__mhchem_option_layoutWasSet
+ \bool_set_true:N \l__mhchem_option_layoutWasSet_bool
\bool_set_false:N \l__mhchem_option_superscriptsStacked_bool
\bool_set_false:N \l__mhchem_option_subscriptsDeep_bool
},
@@ -3288,34 +3231,31 @@
minus-text-sidebearing-right .dim_set:N = \mhchem@option@minustextsidebearingright,
minus-text-sidebearing-right .initial:n = { 0.16em },
- arrows .choice:,
- arrows / font .code:n = { \mhchem@definearrows{#1} },
- arrows / pgf .code:n =
+ arrows .code:n =
{
- \bool_if:NT { \l__mhchem_option_inPreamble_bool }
+ \str_case:nnF {#1}
{
- \RequirePackage{pgf}
- \RequirePackage{tikz}
+ { font }
+ { \tl_set:Nn \l__mhchem_option_arrowType_tl {#1} }
}
- \mhchem@definearrows{#1}
- },
- arrows / pgf-filled .code:n =
- {
- \bool_if:NT { \l__mhchem_option_inPreamble_bool }
{
- \RequirePackage{pgf}
- \RequirePackage{tikz}
+ \regex_match:nnTF
+ { \A pgf .* \Z }
+ {#1}
+ { \__mhchem_arrow_init_pgf: {#1} }
+ {
+ { \msg_error:nnn { mhchem } { error-arrow-type } {#1} }
+ }
}
- \mhchem@definearrows{#1}
},
arrows .initial:n = { font },
- textminus .code:n = { \def\mhchem@option@textminus{#1} },
+ textminus .tl_set:N = \mhchem@option@textminus,
textminus .initial:n = { \hspace{0.3ex} -- \hspace{0.3ex} },
- cdot .code:n = { \def\mhchem@option@cdot{#1} },
+ cdot .tl_set:N = \mhchem@option@cdot,
cdot .initial:n = { \cdot },
- textelectrondot .code:n = { \cs_set_protected:Npn \mhchem@option@textElectronDot {#1} },
+ textelectrondot .tl_set:N = \mhchem@option@textElectronDot,
textelectrondot .initial:n =
{
\int_compare:nTF { \l__mhchem_option_version_int < 4 }
@@ -3345,7 +3285,7 @@
\msg_warning:nn { mhchem } { options / version-too-high }
}
}
-\bool_if:NF \l__mhchem_option_layoutWasSet
+\bool_if:NF \l__mhchem_option_layoutWasSet_bool
{
\int_compare:nTF { \l__mhchem_option_version_int < 4 }
{ \mhchemoptions{layout=staggered-deep} }
@@ -3354,11 +3294,11 @@
\AtBeginDocument
{
- \bool_if:nF \l__mhchem_option_textgreekSelectedByUser
+ \bool_if:nF \l__mhchem_option_textgreekSelectedByUser_bool
{
\chemgreek_declare_mapping_alias:nn { mhchem-text } { \l_chemgreek_active_mapping_tl }
}
- \bool_if:nF \l__mhchem_option_mathgreekSelectedByUser
+ \bool_if:nF \l__mhchem_option_mathgreekSelectedByUser_bool
{
\chemgreek_declare_mapping_alias:nn { mhchem-math } { \l_chemgreek_active_mapping_tl }
}