summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mhchem
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-04-24 23:19:49 +0000
committerKarl Berry <karl@freefriends.org>2015-04-24 23:19:49 +0000
commit488699dbaca6ce3920fabfdb7ec64d4d3ba0bc59 (patch)
tree839467e1f6213363ce68e19245bd39df82f2a1da /Master/texmf-dist/tex/latex/mhchem
parent0a00b3b492fd27dc12cddae602b2c43206a17d74 (diff)
mhchem (24apr15)
git-svn-id: svn://tug.org/texlive/trunk@37037 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mhchem')
-rw-r--r--Master/texmf-dist/tex/latex/mhchem/mhchem.sty1067
1 files changed, 635 insertions, 432 deletions
diff --git a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
index f2940915438..5d27ecce7ce 100644
--- a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
+++ b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
@@ -27,12 +27,13 @@
% This work consists of all files listed in manifest.txt.
%
%
-\ProvidesPackage{mhchem}[2015/04/07 v4.00 for typesetting chemical formulae]
+\ProvidesPackage{mhchem}[2015/04/23 v4.01 for typesetting chemical formulae]
\RequirePackage{expl3}
\RequirePackage{l3keys2e}
\RequirePackage{l3regex}
\RequirePackage{calc}[1998/07/07]
\RequirePackage{amsmath}
+\RequirePackage{chemgreek}[2015/04/09]
\RequirePackage{graphics}
\RequirePackage{ifthen}
@@ -89,6 +90,7 @@
{ \tl_put_right:Nn #1 { #2 { #5 } } }
#4
}
+
\cs_new_protected:Npn \__mhchem_loopHelper_appendMathA:NNw #1#2#3$
{
\tl_put_right:Nn #1 { $ #3 $ }
@@ -99,36 +101,28 @@
\tl_put_right:Nn #1 { $ { #3 } $ }
#2
}
-\cs_new_protected:Npn \__mhchem_loopHelper_appendMathB:nn #1#2
+\cs_new_protected:Npn \__mhchem_loopHelper_appendWithinMathTokens:nn #1#2
{
\peek_catcode:NTF \c_group_begin_token
- {
- \__mhchem_loopHelper_appendMathB_aux_group:ccw
- {#1}
- {#2}
- }
- {
- \__mhchem_loopHelper_appendMathB_aux:ccw
- {#1}
- {#2}
- }
+ { \__mhchem_loopHelper_appendWithinMathTokens_aux_group:ccw {#1} {#2} }
+ { \__mhchem_loopHelper_appendWithinMathTokens_aux:ccw {#1} {#2} }
}
-\cs_new_protected:Npn \__mhchem_loopHelper_appendMathB_aux:NNw #1#2#3$
+\cs_new_protected:Npn \__mhchem_loopHelper_appendWithinMathTokens_aux:NNw #1#2#3$
{
- \tl_put_right:Nn #1 { \__mhchem_cg_withinMathTokens:n { #3 } }
+ \tl_put_right:Nn #1 { \__mhchem_cg_withinMathTokens:n {#3} }
#2
}
-\cs_generate_variant:Nn \__mhchem_loopHelper_appendMathB_aux:NNw {ccw}
-\cs_new_protected:Npn \__mhchem_loopHelper_appendMathB_aux_group:NNw #1#2#3$
+\cs_generate_variant:Nn \__mhchem_loopHelper_appendWithinMathTokens_aux:NNw {ccw}
+\cs_new_protected:Npn \__mhchem_loopHelper_appendWithinMathTokens_aux_group:NNw #1#2#3$
{
- \tl_put_right:Nn #1 { \__mhchem_cg_withinMathTokens:n { { #3 } } }
+ \tl_put_right:Nn #1 { \__mhchem_cg_withinMathTokens:n { {#3} } }
#2
}
-\cs_generate_variant:Nn \__mhchem_loopHelper_appendMathB_aux_group:NNw {ccw}
+\cs_generate_variant:Nn \__mhchem_loopHelper_appendWithinMathTokens_aux_group:NNw {ccw}
+
\cs_new_protected:Npn \__mhchem_loopHelper_ignoreNextToken:Nn #1#2
- {
- #1
- }
+ { #1 }
+
\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -188,10 +182,11 @@
\cs_generate_variant:Nn \regex_replace_all:nnN { VnN }
\bool_new:N \l__mhchem_cesplit_odd_bool
+\tl_new:N \l__mhchem_cesplit_tmpa_tl
\newcommand\cesplit[2]
{
\bool_set_true:N \l__mhchem_cesplit_odd_bool
- \tl_set:Nn \l_tmpa_tl { \__mhchem_ce:n {#2} }
+ \tl_set:Nn \l__mhchem_cesplit_tmpa_tl { \__mhchem_ce:n {#2} }
\tl_map_inline:nn {#1}
{
@@ -205,11 +200,11 @@
\regex_replace_all:VnN
\__mhchem_cesplit_key_tl
{ \cE] ##1 \c{__mhchem_ce:n}\cB[ }
- \l_tmpa_tl
+ \l__mhchem_cesplit_tmpa_tl
\bool_set_true:N \l__mhchem_cesplit_odd_bool
}
}
- \tl_use:N \l_tmpa_tl
+ \tl_use:N \l__mhchem_cesplit_tmpa_tl
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -237,13 +232,12 @@
\msg_new:nnn { mhchem } { ce / unexpected-state }
{
- Assertion~failed:~Unexpected~internal~state~'#1' (ce).~You~found~a~bug.~
- Please~contact~the~package~author.
+ Assertion~failed:~Unexpected~internal~state~'#1' (ce).~
+ You~found~a~bug.~Please~contact~the~package~author.
}
\bool_new:N \l__mhchem_ce_ceActive_bool
\bool_set_false:N \l__mhchem_ce_ceActive_bool
\tl_new:N \l__mhchem_ce_state_tl
-
\int_new:N \l__mhchem_ce_distanceFromLastComma_int
\tl_new:N \l__mhchem_ce_result_tl
\tl_new:N \l__mhchem_ce_part_tl
@@ -253,7 +247,7 @@
\tl_new:N \l__mhchem_ce_arrowTypeTwo_tl
\tl_new:N \l__mhchem_ce_arrowTextTwo_tl
\bool_new:N \l__mhchem_ce_potentialSpacing_bool
-\bool_new:N \l__mhchem_ce_potentialSpacing_future_bool
+\bool_new:N \l__mhchem_ce_potentialSpacingAllowed_bool
\cs_new_protected:Npn \__mhchem_ce:n #1
{
@@ -264,102 +258,102 @@
\bool_set_true:N \l__mhchem_ce_ceActive_bool
\__mhchem_output_defMathOrText:
\def\hyphen{\mhchem@hyphen}%
- \let\mhchem@orig@alpha\alpha
- \let\mhchem@orig@beta\beta
- \let\mhchem@orig@gamma\gamma
- \let\mhchem@orig@delta\delta
- \let\mhchem@orig@epsilon\epsilon
- \let\mhchem@orig@zeta\zeta
- \let\mhchem@orig@eta\eta
- \let\mhchem@orig@theta\theta
- \let\mhchem@orig@iota\iota
- \let\mhchem@orig@kappa\kappa
- \let\mhchem@orig@lambda\lambda
- \let\mhchem@orig@mu\mu
- \let\mhchem@orig@nu\nu
- \let\mhchem@orig@xi\xi
- \let\mhchem@orig@omicron\omicron
- \let\mhchem@orig@pi\pi
- \let\mhchem@orig@rho\rho
- \let\mhchem@orig@sigma\sigma
- \let\mhchem@orig@tau\tau
- \let\mhchem@orig@upsilon\upsilon
- \let\mhchem@orig@phi\phi
- \let\mhchem@orig@chi\chi
- \let\mhchem@orig@psi\psi
- \let\mhchem@orig@omega\omega
- \let\mhchem@orig@Alpha\Alpha
- \let\mhchem@orig@Beta\Beta
- \let\mhchem@orig@Gamma\Gamma
- \let\mhchem@orig@Delta\Delta
- \let\mhchem@orig@Epsilon\Epsilon
- \let\mhchem@orig@Zeta\Zeta
- \let\mhchem@orig@Eta\Eta
- \let\mhchem@orig@Theta\Theta
- \let\mhchem@orig@Iota\Iota
- \let\mhchem@orig@Kappa\Kappa
- \let\mhchem@orig@Lambda\Lambda
- \let\mhchem@orig@Mu\Mu
- \let\mhchem@orig@Nu\Nu
- \let\mhchem@orig@Xi\Xi
- \let\mhchem@orig@Omicron\Omicron
- \let\mhchem@orig@Pi\Pi
- \let\mhchem@orig@Rho\Rho
- \let\mhchem@orig@Sigma\Sigma
- \let\mhchem@orig@Tau\Tau
- \let\mhchem@orig@Upsilon\Upsilon
- \let\mhchem@orig@Phi\Phi
- \let\mhchem@orig@Chi\Chi
- \let\mhchem@orig@Psi\Psi
- \let\mhchem@orig@Omega\Omega
- \def\alpha{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@alpha}}
- \def\beta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@beta}}
- \def\gamma{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@gamma}}
- \def\delta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@delta}}
- \def\epsilon{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@epsilon}}
- \def\zeta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@zeta}}
- \def\eta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@eta}}
- \def\theta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@theta}}
- \def\iota{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@iota}}
- \def\kappa{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@kappa}}
- \def\lambda{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@lambda}}
- \def\mu{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@mu}}
- \def\nu{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@nu}}
- \def\xi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@xi}}
- \def\omicron{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@omicron}}
- \def\pi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@pi}}
- \def\rho{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@rho}}
- \def\sigma{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@sigma}}
- \def\tau{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@tau}}
- \def\upsilon{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@upsilon}}
- \def\phi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@phi}}
- \def\chi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@chi}}
- \def\psi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@psi}}
- \def\omega{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@omega}}
- \def\Alpha{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Alpha}}
- \def\Beta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Beta}}
- \def\Gamma{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Gamma}}
- \def\Delta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Delta}}
- \def\Epsilon{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Epsilon}}
- \def\Zeta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Zeta}}
- \def\Eta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Eta}}
- \def\Theta{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Theta}}
- \def\Iota{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Iota}}
- \def\Kappa{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Kappa}}
- \def\Lambda{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Lambda}}
- \def\Mu{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Mu}}
- \def\Nu{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Nu}}
- \def\Xi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Xi}}
- \def\Omicron{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Omicron}}
- \def\Pi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Pi}}
- \def\Rho{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Rho}}
- \def\Sigma{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Sigma}}
- \def\Tau{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Tau}}
- \def\Upsilon{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Upsilon}}
- \def\Phi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Phi}}
- \def\Chi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Chi}}
- \def\Psi{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Psi}}
- \def\Omega{\__mhchem_output_escapeToItalicMath:n{\mhchem@orig@Omega}}
+ \cs_set_eq:NN \__mhchem_output_greek_orig_alpha \alpha
+ \cs_set_eq:NN \__mhchem_output_greek_orig_beta \beta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_gamma \gamma
+ \cs_set_eq:NN \__mhchem_output_greek_orig_delta \delta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_epsilon \epsilon
+ \cs_set_eq:NN \__mhchem_output_greek_orig_zeta \zeta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_eta \eta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_theta \theta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_iota \iota
+ \cs_set_eq:NN \__mhchem_output_greek_orig_kappa \kappa
+ \cs_set_eq:NN \__mhchem_output_greek_orig_lambda \lambda
+ \cs_set_eq:NN \__mhchem_output_greek_orig_mu \mu
+ \cs_set_eq:NN \__mhchem_output_greek_orig_nu \nu
+ \cs_set_eq:NN \__mhchem_output_greek_orig_xi \xi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_omicron \omicron
+ \cs_set_eq:NN \__mhchem_output_greek_orig_pi \pi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_rho \rho
+ \cs_set_eq:NN \__mhchem_output_greek_orig_sigma \sigma
+ \cs_set_eq:NN \__mhchem_output_greek_orig_tau \tau
+ \cs_set_eq:NN \__mhchem_output_greek_orig_upsilon \upsilon
+ \cs_set_eq:NN \__mhchem_output_greek_orig_phi \phi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_chi \chi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_psi \psi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_omega \omega
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Alpha \Alpha
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Beta \Beta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Gamma \Gamma
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Delta \Delta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Epsilon \Epsilon
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Zeta \Zeta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Eta \Eta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Theta \Theta
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Iota \Iota
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Kappa \Kappa
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Lambda \Lambda
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Mu \Mu
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Nu \Nu
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Xi \Xi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Omicron \Omicron
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Pi \Pi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Rho \Rho
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Sigma \Sigma
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Tau \Tau
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Upsilon \Upsilon
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Phi \Phi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Chi \Chi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Psi \Psi
+ \cs_set_eq:NN \__mhchem_output_greek_orig_Omega \Omega
+ \def \alpha { \__mhchem_output_greek:n { alpha } }
+ \def \beta { \__mhchem_output_greek:n { beta } }
+ \def\gamma { \__mhchem_output_greek:n { gamma } }
+ \def\delta { \__mhchem_output_greek:n { delta } }
+ \def\epsilon { \__mhchem_output_greek:n { epsilon } }
+ \def\zeta { \__mhchem_output_greek:n { zeta } }
+ \def\eta { \__mhchem_output_greek:n { eta } }
+ \def\theta { \__mhchem_output_greek:n { theta } }
+ \def\iota { \__mhchem_output_greek:n { iota } }
+ \def\kappa { \__mhchem_output_greek:n { kappa } }
+ \def\lambda { \__mhchem_output_greek:n { lambda } }
+ \def\mu { \__mhchem_output_greek:n { mu } }
+ \def\nu { \__mhchem_output_greek:n { nu } }
+ \def\xi { \__mhchem_output_greek:n { xi } }
+ \def\omicron { \__mhchem_output_greek:n { omicron } }
+ \def\pi { \__mhchem_output_greek:n { pi } }
+ \def\rho { \__mhchem_output_greek:n { rho } }
+ \def\sigma { \__mhchem_output_greek:n { sigma } }
+ \def\tau { \__mhchem_output_greek:n { tau } }
+ \def\upsilon { \__mhchem_output_greek:n { upsilon } }
+ \def\phi { \__mhchem_output_greek:n { phi } }
+ \def\chi { \__mhchem_output_greek:n { chi } }
+ \def\psi { \__mhchem_output_greek:n { psi } }
+ \def\omega { \__mhchem_output_greek:n { omega } }
+ \def\Alpha { \__mhchem_output_greek:n { Alpha } }
+ \def\Beta { \__mhchem_output_greek:n { Beta } }
+ \def\Gamma { \__mhchem_output_greek:n { Gamma } }
+ \def\Delta { \__mhchem_output_greek:n { Delta } }
+ \def\Epsilon { \__mhchem_output_greek:n { Epsilon } }
+ \def\Zeta { \__mhchem_output_greek:n { Zeta } }
+ \def\Eta { \__mhchem_output_greek:n { Eta } }
+ \def\Theta { \__mhchem_output_greek:n { Theta } }
+ \def\Iota { \__mhchem_output_greek:n { Iota } }
+ \def\Kappa { \__mhchem_output_greek:n { Kappa } }
+ \def\Lambda { \__mhchem_output_greek:n { Lambda } }
+ \def\Mu { \__mhchem_output_greek:n { Mu } }
+ \def\Nu { \__mhchem_output_greek:n { Nu } }
+ \def\Xi { \__mhchem_output_greek:n { Xi } }
+ \def\Omicron { \__mhchem_output_greek:n { Omicron } }
+ \def\Pi { \__mhchem_output_greek:n { Pi } }
+ \def\Rho { \__mhchem_output_greek:n { Rho } }
+ \def\Sigma { \__mhchem_output_greek:n { Sigma } }
+ \def\Tau { \__mhchem_output_greek:n { Tau } }
+ \def\Upsilon { \__mhchem_output_greek:n { Upsilon } }
+ \def\Phi { \__mhchem_output_greek:n { Phi } }
+ \def\Chi { \__mhchem_output_greek:n { Chi } }
+ \def\Psi { \__mhchem_output_greek:n { Psi } }
+ \def\Omega { \__mhchem_output_greek:n { Omega } }
}
\tl_clear:N \l__mhchem_ce_result_tl
\tl_clear:N \l__mhchem_ce_part_tl
@@ -385,7 +379,15 @@
{
{ + }
{
- \tl_put_right:Nn \l__mhchem_ce_result_tl { \__mhchem_output_operatorPlus: }
+ \tl_put_right:Nn \l__mhchem_ce_result_tl
+ { \__mhchem_output_operatorPlus: }
+ \tl_clear:N \l__mhchem_ce_part_tl
+ \tl_set:Nn \l__mhchem_ce_state_tl { a-end }
+ }
+ { \pm }
+ {
+ \tl_put_right:Nn \l__mhchem_ce_result_tl
+ { \__mhchem_output_operatorPlusMinus: }
\tl_clear:N \l__mhchem_ce_part_tl
\tl_set:Nn \l__mhchem_ce_state_tl { a-end }
}
@@ -437,6 +439,26 @@
{
{ c }
{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendMathAAsGroup:NNw
+ \l__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }
+ {
+ \__mhchem_loopHelper_appendMathA:NNw
+ \l__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \l__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }{
\peek_charcode_remove:NTF \c_space_token
{
\int_compare:nTF { \l__mhchem_ce_distanceFromLastComma_int = 1 }
@@ -446,7 +468,7 @@
}
{
\__mhchem_ce_output:
- \bool_if:NTF \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_if:NTF \l__mhchem_ce_potentialSpacingAllowed_bool
{ \bool_set_true:N \l__mhchem_ce_potentialSpacing_bool }
{ \bool_set_false:N \l__mhchem_ce_potentialSpacing_bool }
}
@@ -458,26 +480,6 @@
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_ce_part_tl
\__mhchem_ce_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \peek_catcode:NTF \c_group_begin_token
- {
- \__mhchem_loopHelper_appendMathAAsGroup:NNw
- \l__mhchem_ce_part_tl
- \__mhchem_ce_loop:
- }
- {
- \__mhchem_loopHelper_appendMathA:NNw
- \l__mhchem_ce_part_tl
- \__mhchem_ce_loop:
- }
- }{
- \peek_catcode:NTF \c_group_begin_token
- {
- \__mhchem_loopHelper_appendNextGroup:NNn
- \l__mhchem_ce_part_tl
- \__mhchem_ce_loop:
}
% else
{
@@ -593,16 +595,6 @@
}
{ a-]1 }
{
- \peek_charcode_remove:NTF \c_space_token
- {
- \tl_put_right:Nn \l__mhchem_ce_arrowTextOne_tl { ~ }
- \__mhchem_ce_loop:
- }{
- \peek_charcode:NTF ]
- {
- \tl_set:Nn \l__mhchem_ce_state_tl { a-t2 }
- \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
- }{
\peek_catcode:NTF \c_group_begin_token
{
\__mhchem_loopHelper_appendNextGroup:NNn
@@ -611,9 +603,19 @@
}{
\peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathB:nn
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
{ l__mhchem_ce_arrowTextOne_tl }
{ __mhchem_ce_loop: }
+ }{
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \tl_put_right:Nn \l__mhchem_ce_arrowTextOne_tl { ~ }
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF ]
+ {
+ \tl_set:Nn \l__mhchem_ce_state_tl { a-t2 }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
}
% else
{
@@ -680,17 +682,6 @@
}
{ a-]2 }
{
- \peek_charcode_remove:NTF \c_space_token
- {
- \tl_put_right:Nn \l__mhchem_ce_arrowTextTwo_tl { ~ }
- \__mhchem_ce_loop:
- }{
- \peek_charcode:NTF ]
- {
- \__mhchem_ce_output:
- \tl_set:Nn \l__mhchem_ce_state_tl { a-end }
- \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
- }{
\peek_catcode:NTF \c_group_begin_token
{
\__mhchem_loopHelper_appendNextGroup:NNn
@@ -699,9 +690,20 @@
}{
\peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathB:nn
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
{ l__mhchem_ce_arrowTextTwo_tl }
{ __mhchem_ce_loop: }
+ }{
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \tl_put_right:Nn \l__mhchem_ce_arrowTextTwo_tl { ~ }
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF ]
+ {
+ \__mhchem_ce_output:
+ \tl_set:Nn \l__mhchem_ce_state_tl { a-end }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
}
% else
{
@@ -736,7 +738,7 @@
}
\cs_new_protected:Npn \__mhchem_ce_output:
{
- \bool_set_true:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_true:N \l__mhchem_ce_potentialSpacingAllowed_bool
\str_case:Vnn \l__mhchem_ce_state_tl
{
{ c }
@@ -745,50 +747,63 @@
{
{ - }
{
- \tl_put_right:Nn \l__mhchem_ce_result_tl { \ensuremath{{}-{}} }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \tl_put_right:Nn \l__mhchem_ce_result_tl
+ { \__mhchem_output_operatorMinus: }
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
+ }
+ { = }
+ {
+ \tl_put_right:Nn \l__mhchem_ce_result_tl
+ { \__mhchem_output_operatorEquals: }
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
+ }
+ { +- }
+ {
+ \tl_put_right:Nn \l__mhchem_ce_result_tl
+ { \__mhchem_output_operatorPlusMinus: }
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
+ }
+ { $\pm$ }
+ {
+ \tl_put_right:Nn \l__mhchem_ce_result_tl
+ { \__mhchem_output_operatorPlusMinus: }
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ (v) }
{
\tl_put_right:Nn \l__mhchem_ce_result_tl
{ \ensuremath{{}\mathop{\downarrow}{}} }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ v }
{
\tl_put_right:Nn \l__mhchem_ce_result_tl
{ \ensuremath{{}\mathop{\downarrow}{}} }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ (^) }
{
\tl_put_right:Nn \l__mhchem_ce_result_tl
{ \ensuremath{{}\mathop{\uparrow}{}} }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ ^ }
{
\tl_put_right:Nn \l__mhchem_ce_result_tl
{ \ensuremath{{}\mathop{\uparrow}{}} }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
- }
- { = }
- {
- \tl_put_right:Nn \l__mhchem_ce_result_tl
- { \__mhchem_output_operatorEquals: }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ . }
{
\tl_put_right:Nn \l__mhchem_ce_result_tl
{ \__mhchem_output_additionCompound: }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ * }
{
\tl_put_right:Nn \l__mhchem_ce_result_tl
{ \__mhchem_output_additionCompound: }
- \bool_set_false:N \__mhchem_ce_potentialSpacingAllowed_bool
+ \bool_set_false:N \l__mhchem_ce_potentialSpacingAllowed_bool
}
{ }
{
@@ -796,16 +811,41 @@
}
% else
{
- \bool_if:NT \l__mhchem_ce_potentialSpacing_bool
+ \int_compare:nTF { \l__mhchem_option_version_int > 3 }
{
- \int_compare:nT { \l__mhchem_option_version_int > 3 }
- { \tl_put_right:Nn \l__mhchem_ce_result_tl { \mhchem@option@skipAfterAmount } }
+ \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 }
+ \l__mhchem_ce_part_tl
+ {
+ \regex_replace_once:nnN
+ { \A (.+) (\([a-z]{1,3}\)) \Z }
+ {
+ \c{__mhchem_cf:nn}\cB[\cE]\cB[ \1 \cE]
+ \c{__mhchem_output_skipBeforeStateOfAggregation:}
+ \c{__mhchem_cf:nn}\cB[\cE]\cB[ \2 \cE]
+ }
+ \l__mhchem_ce_part_tl
+ \tl_put_right:Nx \l__mhchem_ce_result_tl
+ { \exp_not:V \l__mhchem_ce_part_tl }
+ }
+ {
+ \tl_put_right:Nx \l__mhchem_ce_result_tl
+ {
+ \exp_not:N \__mhchem_cf:nn
+ {}
+ { \exp_not:V \l__mhchem_ce_part_tl }
+ }
+ }
}
- \tl_put_right:Nx \l__mhchem_ce_result_tl
{
- \exp_not:N \__mhchem_cf:nn
- {}
- { \exp_not:V \l__mhchem_ce_part_tl }
+ \tl_put_right:Nx \l__mhchem_ce_result_tl
+ {
+ \exp_not:N \__mhchem_cf:nn
+ {}
+ { \exp_not:V \l__mhchem_ce_part_tl }
+ }
}
}
}
@@ -920,8 +960,8 @@
\ExplSyntaxOn
\msg_new:nnn { mhchem } { unexpected-arrow-type }
{
- Assertion~failed:~Unexpected~arrow~type~'#1'.~You~found~a~bug.~
- Please~contact~the~package~author.
+ Assertion~failed:~Unexpected~arrow~type~'#1'.~
+ You~found~a~bug.~Please~contact~the~package~author.
}
\cs_new_protected:Npn \__mhchem_arrow_deploy:nnnnn #1#2#3#4#5
{
@@ -1319,13 +1359,14 @@
\msg_new:nnn { mhchem } { cf / unexpected-input }
{
- Assertion~failed:~Unexpected~input~character.~You~found~a~bug.~
- Please~contact~the~package~author.
+ Assertion~failed:~Unexpected~input~character.~
+ In~case~you~think~this~is~a~bug,~
+ lease~contact~the~package~author.
}
\msg_new:nnn { mhchem } { cf / unexpected-state }
{
- Assertion~failed:~Unexpected~internal~state~'#1' (cf).~You~found~a~bug.~
- Please~contact~the~package~author.
+ Assertion~failed:~Unexpected~internal~state~'#1' (cf).~
+ You~found~a~bug.~Please~contact~the~package~author.
}
\msg_new:nnn { mhchem } { cf / unexpected-two-superscripts }
{
@@ -1382,6 +1423,7 @@
\tl_new:N \l__mhchem_cf_supState_tl
\tl_new:N \l__mhchem_cf_subState_tl
\tl_new:N \l__mhchem_cf_lastElement_tl
+\bool_new:N \g__mhchem_cf_lastElementWithScript_bool
\cs_new_protected:Npn \__mhchem_cf_resetOutput:
{
\tl_clear:N \l__mhchem_cf_presup_tl
@@ -1403,10 +1445,7 @@
\group_begin:
\let\sbond\__mhchem_output_sbond:
\int_compare:nTF { 2 = \l__mhchem_option_version_int }
- {
- \let\bond\sbond
- }
- % else
+ { \let\bond\sbond }
{
\int_compare:nT { \l__mhchem_option_version_int > 2 }
{
@@ -1475,7 +1514,7 @@
{
\__mhchem_cf_outputAndReset:
\regex_match:nVTF
- { \A (n|\c{eta}|\c{mu}|\c{kappa}|\c{__mhchem_cg_withinMathTokens:n}\cB.n\cE.|\d+|\(\+\)) \Z }
+ { \A ([nmpx]|\c{eta}|\c{mu}|\c{kappa}|\c{__mhchem_cg_withinMathTokens:n}\cB.[nmpx]\cE.|\d+) \Z }
\l__mhchem_cf_lastElement_tl
{
\__mhchem_cf_outputRawElementAndReset:n
@@ -1484,7 +1523,7 @@
{
\__mhchem_cf_outputRawElementAndReset:n { \sbond }
}
- \tl_set:Nn \l__mhchem_cf_state_tl { a }
+ \tl_set:Nn \l__mhchem_cf_state_tl { s }
\__mhchem_cf_loop:
}
{ ( }
@@ -1503,8 +1542,66 @@
\__mhchem_cf_loop:
}
}
+ { ps }
+ {
+ \__mhchem_cf_outputAndReset:
+ \__mhchem_regex_peek:nTF { [ A-Z ] }
+ {
+ \regex_match:nVTF
+ { \A \c{__mhchem_cg_withinMathTokens:n}\cB. (([0-9nmpx]+ [\+\-])? [nmpx] ([\+\-] [0-9nmpx]+)?) \cE. \Z }
+ \l__mhchem_cf_lastElement_tl
+ {
+ \tl_put_right:Nn
+ \l__mhchem_cf_result_tl
+ { \__mhchem_output_skipAfterAmount: }
+ }
+ {}
+ \tl_set:Nn \l__mhchem_cf_state_tl { a }
+ \__mhchem_cf_loop:
+ }
+ {
+ \tl_set:Nn \l__mhchem_cf_state_tl { a }
+ \__mhchem_cf_loop:
+ }
+ }
{ s }
{
+ \peek_catcode:NTF \mhchem@macro
+ {
+ \__mhchem_cf_outputAndReset:
+ \tl_set:Nn \l__mhchem_cf_state_tl { c }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \l__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_cf_outputAndReset:
+ \int_compare:nTF { \l__mhchem_option_version_int < 4 }
+ {
+ \__mhchem_loopHelper_outputAndReset_append_appendNextGroupToResult:nNnn
+ {}
+ \__mhchem_cf_loop:
+ }
+ % else
+ {
+ \tl_set:Nn \l__mhchem_cf_state_tl { a }
+ \__mhchem_loopHelper_appendNextGroup_prefix_ifEmpty:NnnNn
+ \l__mhchem_cf_element_tl
+ { \__mhchem_cg_escapeFromMathToTextOrFaketext:n }
+ { \tl_set:Nn \l__mhchem_cf_state_tl { s } }
+ \__mhchem_cf_loop:
+ }
+ }{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \int_compare:nTF { \l__mhchem_option_version_int > 3 }
+ { \tl_set:Nn \l__mhchem_cf_state_tl { ps } }
+ { \tl_set:Nn \l__mhchem_cf_state_tl { a } }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cf_element_tl }
+ { __mhchem_cf_loop: }
+ }{
\peek_charcode:NTF -
{
\__mhchem_cf_outputAndReset:
@@ -1623,15 +1720,7 @@
{ a }
\__mhchem_cf_loop:
}{
- \peek_catcode:NTF \mhchem@macro
- {
- \__mhchem_cf_outputAndReset:
- \tl_set:Nn \l__mhchem_cf_state_tl { c }
- \__mhchem_loopHelper_appendNextToken:NNn
- \l__mhchem_cf_element_tl
- \__mhchem_cf_loop:
- }{
- \peek_catcode:NTF a
+ \__mhchem_regex_peek:nTF { [ a-zA-Z ] }
{
\tl_set:Nn \l__mhchem_cf_state_tl { a }
\__mhchem_loopHelper_appendNextToken:NNn
@@ -1643,32 +1732,6 @@
\__mhchem_cf_outputAndReset:
\tl_set:Nn \l__mhchem_cf_state_tl { 1 }
\__mhchem_cf_loop:
- }{
- \peek_catcode:NTF \c_group_begin_token
- {
- \__mhchem_cf_outputAndReset:
- \int_compare:nTF { \l__mhchem_option_version_int < 4 }
- {
- \__mhchem_loopHelper_outputAndReset_append_appendNextGroupToResult:nNnn
- {}
- \__mhchem_cf_loop:
- }
- % else
- {
- \tl_set:Nn \l__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextGroup_prefix_ifEmpty:NnnNn
- \l__mhchem_cf_element_tl
- { \__mhchem_cg_escapeFromMathToTextOrFaketext:n }
- { \tl_set:Nn \l__mhchem_cf_state_tl { s } }
- \__mhchem_cf_loop:
- }
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \tl_set:Nn \l__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cf_element_tl }
- { __mhchem_cf_loop: }
}
% else
{ \msg_error:nnn { mhchem } { cf / unexpected-input } }
@@ -1726,6 +1789,42 @@
}
{ a }
{
+ \peek_catcode:NTF \mhchem@macro
+ {
+ \__mhchem_cf_outputAndReset:
+ \tl_set:Nn \l__mhchem_cf_state_tl { c }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \l__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_cf_outputAndReset:
+ \int_compare:nTF { \l__mhchem_option_version_int < 4 }
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \l__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
+ }
+ % else
+ {
+ \__mhchem_loopHelper_appendNextGroup_prefix_ifEmpty:NnnNn
+ \l__mhchem_cf_element_tl
+ { \__mhchem_cg_escapeFromMathToTextOrFaketext:n }
+ {}
+ \__mhchem_cf_loop:
+ }
+ }{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \str_if_eq:VnF \l__mhchem_cf_supState_tl { - }
+ { \__mhchem_cf_outputAndReset: }
+ \str_if_eq:VnF \l__mhchem_cf_subState_tl { - }
+ { \__mhchem_cf_outputAndReset: }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cf_element_tl }
+ { __mhchem_cf_loop: }
+ }{
\peek_charcode:NTF -
{
\tl_set:Nn \l__mhchem_cf_state_tl { - }
@@ -1827,15 +1926,7 @@
{ a }
\__mhchem_cf_loop:
}{
- \peek_catcode:NTF \mhchem@macro
- {
- \__mhchem_cf_outputAndReset:
- \tl_set:Nn \l__mhchem_cf_state_tl { c }
- \__mhchem_loopHelper_appendNextToken:NNn
- \l__mhchem_cf_element_tl
- \__mhchem_cf_loop:
- }{
- \peek_catcode:NTF a % letter
+ \__mhchem_regex_peek:nTF { [ a-zA-Z ] }
{
\str_if_eq:VnTF \l__mhchem_cf_supState_tl { - }
{
@@ -1874,34 +1965,6 @@
\tl_set:Nn \l__mhchem_cf_subState_tl { d }
\tl_set:Nn \l__mhchem_cf_state_tl { f }
\__mhchem_cf_loop:
- }{
- \peek_catcode:NTF \c_group_begin_token
- {
- \__mhchem_cf_outputAndReset:
- \int_compare:nTF { \l__mhchem_option_version_int < 4 }
- {
- \__mhchem_loopHelper_appendNextGroup:NNn
- \l__mhchem_cf_result_tl
- \__mhchem_cf_loop:
- }
- % else
- {
- \__mhchem_loopHelper_appendNextGroup_prefix_ifEmpty:NnnNn
- \l__mhchem_cf_element_tl
- { \__mhchem_cg_escapeFromMathToTextOrFaketext:n }
- {}
- \__mhchem_cf_loop:
- }
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \str_if_eq:VnF \l__mhchem_cf_supState_tl { - }
- { \__mhchem_cf_outputAndReset: }
- \str_if_eq:VnF \l__mhchem_cf_subState_tl { - }
- { \__mhchem_cf_outputAndReset: }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cf_element_tl }
- { __mhchem_cf_loop: }
}
% else
{
@@ -1915,19 +1978,19 @@
}
{ e }
{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \tl_set:Nn \l__mhchem_cf_state_tl { a }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cf_sup_tl }
+ { __mhchem_cf_loop: }
+ }{
\__mhchem_regex_peek:nTF { [0-9] }
{
\tl_set:Nn \l__mhchem_cf_state_tl { e+ }
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_sup_tl
\__mhchem_cf_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \tl_set:Nn \l__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cf_sup_tl }
- { __mhchem_cf_loop: }
}
% else
{
@@ -1971,19 +2034,19 @@
}
{ f }
{
- \__mhchem_regex_peek:nTF { [0-9] }
- {
- \tl_set:Nn \l__mhchem_cf_state_tl { f+ }
- \__mhchem_loopHelper_appendNextToken:NNn
- \l__mhchem_cf_sub_tl
- \__mhchem_cf_loop:
- }{
\peek_catcode_remove:NTF \c_math_toggle_token
{
\tl_set:Nn \l__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendMathB:nn
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
{ l__mhchem_cf_sub_tl }
{ __mhchem_cf_loop: }
+ }{
+ \__mhchem_regex_peek:nTF { [ 0-9 \/ ] }
+ {
+ \tl_set:Nn \l__mhchem_cf_state_tl { f+ }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \l__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
% else
{
@@ -1996,7 +2059,7 @@
}
{ f+ }
{
- \__mhchem_regex_peek:nTF { [0-9] }
+ \__mhchem_regex_peek:nTF { [ 0-9 \/ ] }
{
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_sub_tl
@@ -2010,19 +2073,19 @@
}
{ p }
{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \tl_set:Nn \l__mhchem_cf_state_tl { s }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cf_presup_tl }
+ { __mhchem_cf_loop: }
+ }{
\__mhchem_regex_peek:nTF { [0-9] }
{
\tl_set:Nn \l__mhchem_cf_state_tl { p+ }
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_presup_tl
\__mhchem_cf_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \tl_set:Nn \l__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cf_presup_tl }
- { __mhchem_cf_loop: }
}
% else
{
@@ -2049,19 +2112,19 @@
}
{ q }
{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \tl_set:Nn \l__mhchem_cf_state_tl { s }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cf_presub_tl }
+ { __mhchem_cf_loop: }
+ }{
\__mhchem_regex_peek:nTF { [0-9] }
{
\tl_set:Nn \l__mhchem_cf_state_tl { q+ }
\__mhchem_loopHelper_appendNextToken:NNn
\l__mhchem_cf_presub_tl
\__mhchem_cf_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \tl_set:Nn \l__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cf_presub_tl }
- { __mhchem_cf_loop: }
}
% else
{
@@ -2111,6 +2174,11 @@
}
{
\tl_set:NV \l__mhchem_cf_lastElement_tl \l__mhchem_cf_element_tl
+ \bool_gset:Nn \g__mhchem_cf_lastElementWithScript_bool
+ {
+ ! \tl_if_empty_p:N \l__mhchem_cf_sub_tl ||
+ ! \tl_if_empty_p:N \l__mhchem_cf_sup_tl
+ }
\str_case:Vnn \l__mhchem_cf_state_tl
{
{ 1 }
@@ -2121,7 +2189,7 @@
\exp_not:N \__mhchem_output_withFont:n {
\exp_not:V \l__mhchem_cf_element_tl
}
- \exp_not:N \mhchem@option@skipAfterAmount
+ \exp_not:N \__mhchem_output_skipAfterAmount:
}
}
{ 9 }
@@ -2149,6 +2217,11 @@
\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 }
+ \l__mhchem_cf_sup_tl
+ { \tl_set:Nn \l__mhchem_cf_supState_tl { ox } }
+ {}
\bool_if:nT
{
\str_if_eq_p:Vn \l__mhchem_cf_supState_tl { kv } &&
@@ -2161,11 +2234,26 @@
{
\tl_put_right:Nx \l__mhchem_cf_result_tl
{
- \exp_not:N \__mhchem_output_coreFive:nnnnnn
+ \exp_not:N \__mhchem_output_coreFive:nnnnnnn
+ { \exp_not:V \l__mhchem_cf_presup_tl }
+ { \exp_not:V \l__mhchem_cf_presub_tl }
+ { \exp_not:V \l__mhchem_cf_element_tl }
+ {}
+ { \exp_not:V \l__mhchem_cf_sup_tl }
+ { \exp_not:V \l__mhchem_cf_sub_tl }
+ {}
+ }
+ }
+ { ox }
+ {
+ \tl_put_right:Nx \l__mhchem_cf_result_tl
+ {
+ \exp_not:N \__mhchem_output_coreFive:nnnnnnn
{ \exp_not:V \l__mhchem_cf_presup_tl }
{ \exp_not:V \l__mhchem_cf_presub_tl }
{ \exp_not:V \l__mhchem_cf_element_tl }
{ \exp_not:V \l__mhchem_cf_sup_tl }
+ {}
{ \exp_not:V \l__mhchem_cf_sub_tl }
{}
}
@@ -2174,11 +2262,12 @@
{
\tl_put_right:Nx \l__mhchem_cf_result_tl
{
- \exp_not:N \__mhchem_output_coreFive:nnnnnn
+ \exp_not:N \__mhchem_output_coreFive:nnnnnnn
{ \exp_not:V \l__mhchem_cf_presup_tl }
{ \exp_not:V \l__mhchem_cf_presub_tl }
{ \exp_not:V \l__mhchem_cf_element_tl }
{}
+ {}
{ \exp_not:V \l__mhchem_cf_sub_tl }
{ \exp_not:V \l__mhchem_cf_sup_tl }
}
@@ -2210,6 +2299,8 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% cg %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\tl_new:N \l__mhchem_cg_withinMathTokens_tmpa_tl
\cs_new_protected:Npn \__mhchem_cg_withinMathTokens:n #1
{
\int_compare:nTF { \l__mhchem_option_version_int > 3 }
@@ -2217,7 +2308,7 @@
\regex_match:nnTF
{ \A \cB. [^\cE.]* \cE. \Z } {#1}
{
- \__mhchem_output_escapeFromMathToItalicMath:n { #1 }
+ \__mhchem_output_escapeFromMathToItalicMath:n {#1}
}
% else
{
@@ -2225,35 +2316,31 @@
{ \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 }
{#1}
{
- {
- \bool_if:NTF \l__mhchem_output_isMathMode_bool
- {
- \int_compare:nT
- { \l__mhchem_option_version_int > 3 }
- {
- \thinmuskip=0mu
- \medmuskip=0mu
- \thickmuskip=0mu
- }
- \__mhchem_output_escapeFromMathToItalicMath:n {#1}
- }
- {
- \tl_set:Nn \l_tmpa_tl { #1 }
- \regex_replace_all:nnN
- { [a-zA-Z]+ }
- { \c{__mhchem_output_escapeFromTextToItalicText:n} \cB[ \0 \cE] }
- \l_tmpa_tl
- \regex_replace_all:nnN
- { [\ ]+ }
- {}
- \l_tmpa_tl
- \regex_replace_all:nnN
- { - }
- { \c{mhchem@option@textminus} }
- \l_tmpa_tl
- \tl_use:N \l_tmpa_tl
- }
- }
+ \group_begin:
+ \bool_if:NTF \l__mhchem_output_isMathMode_bool
+ {
+ \thinmuskip=0mu
+ \medmuskip=0mu
+ \thickmuskip=0mu
+ \__mhchem_output_escapeFromMathToItalicMath:n {#1}
+ }
+ {
+ \tl_set:Nn \l__mhchem_cg_withinMathTokens_tmpa_tl { #1 }
+ \regex_replace_all:nnN
+ { [a-zA-Z]+ }
+ { \c{__mhchem_output_escapeFromTextToItalicText:n} \cB[ \0 \cE] }
+ \l__mhchem_cg_withinMathTokens_tmpa_tl
+ \regex_replace_all:nnN
+ { [\ ]+ }
+ {}
+ \l__mhchem_cg_withinMathTokens_tmpa_tl
+ \regex_replace_all:nnN
+ { - }
+ { \c{mhchem@option@textminus} }
+ \l__mhchem_cg_withinMathTokens_tmpa_tl
+ \tl_use:N \l__mhchem_cg_withinMathTokens_tmpa_tl
+ }
+ \group_end:
}
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
@@ -2267,6 +2354,12 @@
\__mhchem_output_escapeFromMathToItalicMath:n {#1}
}
}
+\tl_new:N \g__mhchem_cg_potentialSpaceAfterWithinMath_tl
+\cs_new_protected:Npn \__mhchem_cg_potentialSpaceAfterWithinMath:
+ {
+ \tl_use:N \g__mhchem_cg_potentialSpaceAfterWithinMath_tl
+ \tl_gclear:N \g__mhchem_cg_potentialSpaceAfterWithinMath_tl
+ }
\cs_new_protected:Npn \__mhchem_cg_itshape:n #1
{
\int_compare:nTF { \l__mhchem_option_version_int > 3 }
@@ -2295,6 +2388,19 @@
\peek_meaning:NTF \q_recursion_stop
{ \use_none:n }
{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cg_escapeFromMathToFakeText_result_tl }
+ { __mhchem_cg_escapeFromMathToFakeText_loop: }
+ }
+ {
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \l__mhchem_cg_escapeFromMathToFakeText_result_tl
+ \__mhchem_cg_escapeFromMathToFakeText_loop:
+ }{
\peek_charcode_remove:NTF \c_space_token
{
\tl_put_right:Nn
@@ -2308,19 +2414,6 @@
\l__mhchem_cg_escapeFromMathToFakeText_result_tl
{ \mhchem@hyphen }
\__mhchem_cg_escapeFromMathToFakeText_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cg_escapeFromMathToFakeText_result_tl }
- { __mhchem_cg_escapeFromMathToFakeText_loop: }
- }
- {
- \peek_catcode:NTF \c_group_begin_token
- {
- \__mhchem_loopHelper_appendNextGroup:NNn
- \l__mhchem_cg_escapeFromMathToFakeText_result_tl
- \__mhchem_cg_escapeFromMathToFakeText_loop:
}
% else
{
@@ -2390,6 +2483,21 @@
\peek_meaning:NTF \q_recursion_stop
{ \use_none:n }
{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { s }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cg_replaceForSubscript_result_tl }
+ { __mhchem_cg_replaceForSubscript_loop: }
+ }
+ {
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { s }
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \l__mhchem_cg_replaceForSubscript_result_tl
+ \__mhchem_cg_replaceForSubscript_loop:
+ }{
\__mhchem_regex_peek:nTF { [0-9] }
{
\tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { 9 }
@@ -2423,21 +2531,6 @@
}
\tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { s }
\__mhchem_cg_replaceForSubscript_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { s }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cg_replaceForSubscript_result_tl }
- { __mhchem_cg_replaceForSubscript_loop: }
- }
- {
- \peek_catcode:NTF \c_group_begin_token
- {
- \tl_set:Nn \l__mhchem_cg_replaceForSubscript_state_tl { s }
- \__mhchem_loopHelper_appendNextGroup:NNn
- \l__mhchem_cg_replaceForSubscript_result_tl
- \__mhchem_cg_replaceForSubscript_loop:
}
% else
{
@@ -2469,6 +2562,30 @@
}
\use_none:n
}{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
+ {
+ \tl_put_right:Nn \l__mhchem_cg_replaceForSuperscript_result_tl
+ { \__mhchem_output_electronDot: }
+ }
+ \tl_set:Nn \l__mhchem_cg_replaceForSuperscript_state_tl { s }
+ \__mhchem_loopHelper_appendWithinMathTokens:nn
+ { l__mhchem_cg_replaceForSuperscript_result_tl }
+ { __mhchem_cg_replaceForSuperscript_loop: }
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
+ {
+ \tl_put_right:Nn \l__mhchem_cg_replaceForSuperscript_result_tl
+ { \__mhchem_output_electronDot: }
+ }
+ \tl_set:Nn \l__mhchem_cg_replaceForSuperscript_state_tl { s }
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \l__mhchem_cg_replaceForSuperscript_result_tl
+ \__mhchem_cg_replaceForSuperscript_loop:
+ }{
\peek_charcode_remove:NTF -
{
\str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
@@ -2556,30 +2673,6 @@
}
\tl_set:Nn \l__mhchem_cg_replaceForSuperscript_state_tl { s }
\__mhchem_cg_replaceForSuperscript_loop:
- }{
- \peek_catcode_remove:NTF \c_math_toggle_token
- {
- \str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
- {
- \tl_put_right:Nn \l__mhchem_cg_replaceForSuperscript_result_tl
- { \__mhchem_output_electronDot: }
- }
- \tl_set:Nn \l__mhchem_cg_replaceForSuperscript_state_tl { s }
- \__mhchem_loopHelper_appendMathB:nn
- { l__mhchem_cg_replaceForSuperscript_result_tl }
- { __mhchem_cg_replaceForSuperscript_loop: }
- }{
- \peek_catcode:NTF \c_group_begin_token
- {
- \str_if_eq:VnT \l__mhchem_cg_replaceForSuperscript_state_tl { 9. }
- {
- \tl_put_right:Nn \l__mhchem_cg_replaceForSuperscript_result_tl
- { \__mhchem_output_electronDot: }
- }
- \tl_set:Nn \l__mhchem_cg_replaceForSuperscript_state_tl { s }
- \__mhchem_loopHelper_appendNextGroup:NNn
- \l__mhchem_cg_replaceForSuperscript_result_tl
- \__mhchem_cg_replaceForSuperscript_loop:
}
% else
{
@@ -2615,11 +2708,11 @@
\mhchem@option@textFont
}
}
-\cs_new_protected:Npn \__mhchem_output_coreFive:nnnnnn #1#2#3#4#5#6
+\cs_new_protected:Npn \__mhchem_output_coreFive:nnnnnnn #1#2#3#4#5#6#7
{
\group_begin:
\bool_if:nT
- { \str_if_eq_p:nn {#6} {} && ! \str_if_eq_p:nn {#4} {} }
+ { \str_if_eq_p:nn {#7} {} && ! \str_if_eq_p:nn {#5} {} }
{ \bool_set_true:N \l__mhchem_option_superscriptsStacked_bool }
\m@th
\ensuremath
@@ -2647,66 +2740,80 @@
\mhchem@minispace
}
\__mhchem_output_withFont:n {#3}
- \str_if_eq:nnF {#4#6#5} {}
+ \str_if_eq:nnF {#4#5#6#7} {}
{
\bool_if:NTF \l__mhchem_option_superscriptsStacked_bool
{
{ \vphantom { \__mhchem_output_withFont:n { X } } }
- \str_if_eq:nnF {#5} {}
+ \str_if_eq:nnF {#6} {}
{
\c_math_subscript_token
{
\vphantom { \__mhchem_output_scriptWithFont:n { 2 } }
- \smash[t] { \__mhchem_output_scriptWithFont:n {#5} }
+ \smash[t] { \__mhchem_output_scriptWithFont:n {#6} }
}
}
^ {
\vphantom { \smash[t] { \__mhchem_output_scriptWithFont:n { 2+ } } }
- \__mhchem_output_scriptWithFont:n {#4#6}
+ \__mhchem_output_scriptWithFont:n {#4#5#7}
}
}
% else
{
\bool_if:NTF \l__mhchem_option_subscriptsDeep_bool
{
- { \vphantom { \__mhchem_output_withFont:n { X } } }
- \str_if_eq:nnF {#5} {}
+ \str_if_eq:nnF {#4} {}
{
+ { \vphantom { \__mhchem_output_withFont:n { X } } }
+ ^ {
+ \vphantom { \smash[t] { \__mhchem_output_scriptWithFont:n { 2+ } } }
+ \__mhchem_output_scriptWithFont:n {#4}
+ }
\c_math_subscript_token
{
\vphantom { \__mhchem_output_scriptWithFont:n { 2 } }
- \smash[t] { \__mhchem_output_scriptWithFont:n {#5} }
}
}
- \str_if_eq:nnTF {#4#6} {}
+ \str_if_eq:nnF {#5#6#7} {}
{
+ { \vphantom { \__mhchem_output_withFont:n { X } } }
+ \str_if_eq:nnF {#6} {}
+ {
+ \c_math_subscript_token
+ {
+ \vphantom { \__mhchem_output_scriptWithFont:n { 2 } }
+ \smash[t] { \__mhchem_output_scriptWithFont:n {#6} }
+ }
+ }
^ {
\vphantom { \smash[t] { \__mhchem_output_scriptWithFont:n { 2+ } } }
+ \hphantom { \__mhchem_output_scriptWithFont:n {#6} }
+ \__mhchem_output_scriptWithFont:n {#5#7}
}
}
+ }
+ {
+ \str_if_eq:nnF {#4} {}
{
+ { \vphantom { \__mhchem_output_withFont:n { X } } }
^ {
- \vphantom { \smash[t] { \__mhchem_output_scriptWithFont:n { 2+ } } }
- \hphantom { \__mhchem_output_scriptWithFont:n {#5} }
- \__mhchem_output_scriptWithFont:n {#4#6}
+ \__mhchem_output_scriptWithFont:n {#4}
}
}
- }
- {
- \str_if_eq:nnF {#5} {}
+ \str_if_eq:nnF {#6} {}
{
{ \vphantom { \__mhchem_output_withFont:n { X } } }
\c_math_subscript_token
{
\vphantom { \__mhchem_output_scriptWithFont:n { 2 } }
- \smash[t] { \__mhchem_output_scriptWithFont:n {#5} }
+ \smash[t] { \__mhchem_output_scriptWithFont:n {#6} }
}
}
- \str_if_eq:nnF {#4#6} {}
+ \str_if_eq:nnF {#5#7} {}
{
{ \vphantom { \__mhchem_output_withFont:n { X } } }
^ {
- \__mhchem_output_scriptWithFont:n {#4#6}
+ \__mhchem_output_scriptWithFont:n {#5#7}
}
}
}
@@ -2766,15 +2873,14 @@
\ensuremath
{
\mhchem@hook@beforeItalicMath
- \bool_if:NT \l__mhchem_cg_isScript_bool
- {
- \medmuskip=0mu
- \thinmuskip=0mu
- \thickmuskip=0mu
- }
#1
}
}
+
+\cs_new_protected:Npn \__mhchem_output_skipAfterAmount:
+ { \, }
+\cs_new_protected:Npn \__mhchem_output_skipBeforeStateOfAggregation:
+ { \bool_if:NF \g__mhchem_cf_lastElementWithScript_bool { \hspace{0.2ex} } }
\cs_new_protected:Npn \__mhchem_output_minus:
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
@@ -2785,13 +2891,27 @@
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
{ {}+{} }
- { \hspace{0.5ex} + \hspace{0.5ex} }
+ { \hspace{0.5ex minus 0.5ex} + \hspace{0.5ex minus 0.5ex} }
}
\cs_new_protected:Npn \__mhchem_output_operatorPlus:
{
\int_compare:nTF { \l__mhchem_option_version_int < 4 }
{ \ensuremath { {}+{} } }
- { \__mhchem_output_plus: }
+ {
+ \bool_if:NTF \l__mhchem_output_isMathMode_bool
+ { {}+{} }
+ { \nobreak \hspace{0.5ex plus 0.3ex minus 0.3ex} + \hspace{0.5ex plus 0.3ex minus 0.3ex} }
+ }
+ }
+\cs_new_protected:Npn \__mhchem_output_operatorMinus:
+ {
+ \int_compare:nTF { \l__mhchem_option_version_int < 4 }
+ { \ensuremath { {}-{} } }
+ {
+ \bool_if:NTF \l__mhchem_output_isMathMode_bool
+ { \nobreak \hspace{0.5ex plus 0.3ex minus 0.1ex} {-} \hspace{0.5ex plus 0.3ex minus 0.1ex} }
+ { \nobreak \hspace{0.6ex plus 0.3ex minus 0.1ex} -- \hspace{0.6ex plus 0.3ex minus 0.1ex} }
+ }
}
\cs_new_protected:Npn \__mhchem_output_operatorEquals:
{
@@ -2799,10 +2919,16 @@
{ {}={} }
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
- { {}={} }
- { \hspace{0.5ex} = \hspace{0.5ex} }
+ { \nobreak \hspace{0.5ex plus 0.3ex minus 0.1ex} {=} \hspace{0.5ex plus 0.3ex minus 0.1ex} }
+ { \nobreak \hspace{0.6ex plus 0.3ex minus 0.1ex} = \hspace{0.6ex plus 0.3ex minus 0.1ex} }
}
}
+\cs_new_protected:Npn \__mhchem_output_operatorPlusMinus:
+ {
+ \bool_if:NTF \l__mhchem_output_isMathMode_bool
+ { {}\pm{} }
+ { \nobreak \ensuremath { {}\pm{} } }
+ }
\cs_new_protected:Npn \__mhchem_output_electronDot:
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
@@ -2838,6 +2964,63 @@
{ \__mhchem_output_commaEnumerationSmall: }
}
+\cs_new_protected:Npn \__mhchem_output_greek:n #1
+ {
+ \group_begin:
+ \cs_set_eq:NN \alpha \__mhchem_output_greek_orig_alpha
+ \cs_set_eq:NN \beta \__mhchem_output_greek_orig_beta
+ \cs_set_eq:NN \gamma \__mhchem_output_greek_orig_gamma
+ \cs_set_eq:NN \delta \__mhchem_output_greek_orig_delta
+ \cs_set_eq:NN \epsilon \__mhchem_output_greek_orig_epsilon
+ \cs_set_eq:NN \zeta \__mhchem_output_greek_orig_zeta
+ \cs_set_eq:NN \eta \__mhchem_output_greek_orig_eta
+ \cs_set_eq:NN \theta \__mhchem_output_greek_orig_theta
+ \cs_set_eq:NN \iota \__mhchem_output_greek_orig_iota
+ \cs_set_eq:NN \kappa \__mhchem_output_greek_orig_kappa
+ \cs_set_eq:NN \lambda \__mhchem_output_greek_orig_lambda
+ \cs_set_eq:NN \mu \__mhchem_output_greek_orig_mu
+ \cs_set_eq:NN \nu \__mhchem_output_greek_orig_nu
+ \cs_set_eq:NN \xi \__mhchem_output_greek_orig_xi
+ \cs_set_eq:NN \omicron \__mhchem_output_greek_orig_omicron
+ \cs_set_eq:NN \pi \__mhchem_output_greek_orig_pi
+ \cs_set_eq:NN \rho \__mhchem_output_greek_orig_rho
+ \cs_set_eq:NN \sigma \__mhchem_output_greek_orig_sigma
+ \cs_set_eq:NN \tau \__mhchem_output_greek_orig_tau
+ \cs_set_eq:NN \upsilon \__mhchem_output_greek_orig_upsilon
+ \cs_set_eq:NN \phi \__mhchem_output_greek_orig_phi
+ \cs_set_eq:NN \chi \__mhchem_output_greek_orig_chi
+ \cs_set_eq:NN \psi \__mhchem_output_greek_orig_psi
+ \cs_set_eq:NN \omega \__mhchem_output_greek_orig_omega
+ \cs_set_eq:NN \Alpha \__mhchem_output_greek_orig_Alpha
+ \cs_set_eq:NN \Beta \__mhchem_output_greek_orig_Beta
+ \cs_set_eq:NN \Gamma \__mhchem_output_greek_orig_Gamma
+ \cs_set_eq:NN \Delta \__mhchem_output_greek_orig_Delta
+ \cs_set_eq:NN \Epsilon \__mhchem_output_greek_orig_Epsilon
+ \cs_set_eq:NN \Zeta \__mhchem_output_greek_orig_Zeta
+ \cs_set_eq:NN \Eta \__mhchem_output_greek_orig_Eta
+ \cs_set_eq:NN \Theta \__mhchem_output_greek_orig_Theta
+ \cs_set_eq:NN \Iota \__mhchem_output_greek_orig_Iota
+ \cs_set_eq:NN \Kappa \__mhchem_output_greek_orig_Kappa
+ \cs_set_eq:NN \Lambda \__mhchem_output_greek_orig_Lambda
+ \cs_set_eq:NN \Mu \__mhchem_output_greek_orig_Mu
+ \cs_set_eq:NN \Nu \__mhchem_output_greek_orig_Nu
+ \cs_set_eq:NN \Xi \__mhchem_output_greek_orig_Xi
+ \cs_set_eq:NN \Omicron \__mhchem_output_greek_orig_Omicron
+ \cs_set_eq:NN \Pi \__mhchem_output_greek_orig_Pi
+ \cs_set_eq:NN \Rho \__mhchem_output_greek_orig_Rho
+ \cs_set_eq:NN \Sigma \__mhchem_output_greek_orig_Sigma
+ \cs_set_eq:NN \Tau \__mhchem_output_greek_orig_Tau
+ \cs_set_eq:NN \Upsilon \__mhchem_output_greek_orig_Upsilon
+ \cs_set_eq:NN \Phi \__mhchem_output_greek_orig_Phi
+ \cs_set_eq:NN \Chi \__mhchem_output_greek_orig_Chi
+ \cs_set_eq:NN \Psi \__mhchem_output_greek_orig_Psi
+ \cs_set_eq:NN \Omega \__mhchem_output_greek_orig_Omega
+ \mode_if_math:TF
+ { \chemgreek_get_from_mapping:nn { mhchem-math } {#1} }
+ { \chemgreek_get_from_mapping:nn { mhchem-text } {#1} }
+ \group_end:
+ }
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% bonds %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2991,12 +3174,14 @@
{
You~did~not~specify~a~'version'~option~for~the~mhchem~package.~
Please~write~
- \string\usepackage[version=3]{mhchem}~in~your~preamble~
- (or~any~lower~number~for~compatibility~mode).
+ \string\usepackage[version=4]{mhchem}~in~your~preamble~
+ (or~any~lower~number~for~compatibility~mode),~
+ because~you~might~get~different~output~with~the~same~input~
+ in~future~versions.
}
\msg_new:nnn { mhchem } { options / version-too-high }
{
- You~are~using~version~3.xx~of~mhchem,
+ You~are~using~version~4.xx~of~mhchem,
but~you~entered~a~higher~version~number.~
This~means,~you~are~using~some~beta~features~of~mhchem~
that~are~subject~to~change~without~notice.
@@ -3016,8 +3201,10 @@
\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_greekSelectedByUser
-\bool_set_false:N \l__mhchem_option_greekSelectedByUser
+\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
\keys_define:nn {mhchem}
{
@@ -3042,6 +3229,17 @@
\def\mhchem@option@mathFont{\mathrm}
},
+ text-greek .code:n =
+ {
+ \chemgreek_declare_mapping_alias:nn { mhchem-text } {#1}
+ \bool_set_true:N \l__mhchem_option_textgreekSelectedByUser
+ },
+ math-greek .code:n =
+ {
+ \chemgreek_declare_mapping_alias:nn { mhchem-math } {#1}
+ \bool_set_true:N \l__mhchem_option_mathgreekSelectedByUser
+ },
+
layout .choice:,
layout / stacked .code:n =
{
@@ -3094,12 +3292,6 @@
},
arrows .initial:n = { font },
- skip-after-amount .code:n =
- {
- \def\mhchem@option@skipAfterAmount{#1}
- },
- skip-after-amount .initial:n = { \, },
-
textminus .code:n = { \def\mhchem@option@textminus{#1} },
textminus .initial:n = { \hspace{0.3ex} -- \hspace{0.3ex} },
@@ -3125,7 +3317,7 @@
\int_compare:nT { -1 = \l__mhchem_option_version_int }
{
- \msg_error:nn { mhchem } { options / no-version }
+ \msg_warning:nn { mhchem } { options / no-version }
\int_set:Nn \l__mhchem_option_version_int { 4 }
}
% else
@@ -3142,6 +3334,18 @@
{ \mhchemoptions{layout=staggered-flat} }
}
+\AtBeginDocument
+ {
+ \bool_if:nF \l__mhchem_option_textgreekSelectedByUser
+ {
+ \chemgreek_declare_mapping_alias:nn { mhchem-text } { \l_chemgreek_active_mapping_tl }
+ }
+ \bool_if:nF \l__mhchem_option_mathgreekSelectedByUser
+ {
+ \chemgreek_declare_mapping_alias:nn { mhchem-math } { \l_chemgreek_active_mapping_tl }
+ }
+ }
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% legacy %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -3153,4 +3357,3 @@
\DeclareRobustCommand\cf[2][]{\mhchem@cf[#1]{#2}}
\DeclareRobustCommand\cee[1]{\mhchem@cee{#1}}
}
-