summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mhchem
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-01-05 23:21:43 +0000
committerKarl Berry <karl@freefriends.org>2015-01-05 23:21:43 +0000
commit43012178bfdaf77a45ba52aae3733dd0c3e93f25 (patch)
tree9491b5ef229d6c76d2de7ccb840d03f226b746c2 /Master/texmf-dist/tex/latex/mhchem
parent799587c8bece3420f45708d9435194a50a72cfa2 (diff)
mhchem (5jan15)
git-svn-id: svn://tug.org/texlive/trunk@35966 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mhchem')
-rw-r--r--Master/texmf-dist/tex/latex/mhchem/mhchem.sty1670
1 files changed, 1037 insertions, 633 deletions
diff --git a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
index 06670198f5c..50d11a60c0d 100644
--- a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
+++ b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
@@ -1,5 +1,5 @@
%% mhchem.sty
-%% Copyright 2004-2014 Martin Hensel
+%% Copyright 2004-2015 Martin Hensel
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c
@@ -27,14 +27,12 @@
% This work consists of all files listed in manifest.txt.
%
%
-\ProvidesPackage{mhchem}[2014/03/27 v3.17 for typesetting chemical formulae]
+\ProvidesPackage{mhchem}[2015/01/05 v3.18 for typesetting chemical formulae]
\RequirePackage{ifthen}
\RequirePackage{calc}[1998/07/07]
-\RequirePackage{twoopt}
\RequirePackage{amsmath}
\RequirePackage{keyval}
\RequirePackage{graphics}
-\RequirePackage{pdftexcmds}
\RequirePackage{expl3}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -44,8 +42,6 @@
\DeclareMathSymbol{\mhchem@hyphen}{0}{operators}{45}
\def\mhchem@END{\mhchem@END}
\def\mhchem@macro{}
-\def\mhchem@empty{}
-\def\mhchem@gobble#1{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% \cee %%%%%%%%%
@@ -92,11 +88,58 @@
#1=\expandafter{\the#1#2}%
}
+\ExplSyntaxOn
+
+\int_new:N \__mhchem_option_version_int
+\cs_generate_variant:Nn \str_if_eq:nnTF { Vn }
+\cs_generate_variant:Nn \peek_catcode_remove:NTF { oTF }
+\cs_generate_variant:Nn \peek_catcode:NTF { oTF }
+\cs_generate_variant:Nn \str_case:nnn { Vnn }
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% loop helpers %%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\cs_new_protected:Npn \__mhchem_loopHelper_appendNextToken:NNn #1#2#3
+ {
+ \tl_put_right:Nn #1 {#3}
+ #2
+ }
+\cs_new_protected:Npn \__mhchem_loopHelper_appendNextGroup:NNn #1#2#3
+ {
+ \tl_put_right:Nn #1 { { #3 } }
+ #2
+ }
+\cs_new_protected:Npn \__mhchem_loopHelper_appendMathA:NNw #1#2#3$
+ {
+ \tl_put_right:Nn #1 { $ #3 $ }
+ #2
+ }
+\cs_new_protected:Npn \__mhchem_loopHelper_appendMathB:NNw #1#2#3$
+ {
+ \tl_put_right:Nn #1 { \text { \ensuremath { #3 } } }
+ #2
+ }
+\cs_new_protected:Npn \__mhchem_loopHelper_appendMathAsGroup:NNw #1#2#3$
+ {
+ \tl_put_right:Nn #1 { \text { \ensuremath { #3 } } }
+ #2
+ }
+\cs_new_protected:Npn \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn #1#2#3
+ {
+ \tl_put_right:Nn #1 { \ensuremath { \mathrm { #3 } } }
+ #2
+ }
+\cs_new_protected:Npn \__mhchem_loopHelper_ignoreNextToken:Nn #1#2
+ {
+ #1
+ }
+\ExplSyntaxOff
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% \ce %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
%%% \/ %%% Prevent argument from expanding when written to .aux
%%%%%%%%%% Solution by Heiko Oberdiek
%%%%%%%%%% http://tex.stackexchange.com/questions/160306/prevent-caption-from-expanding-argument-too-early
@@ -142,297 +185,492 @@
%%%%%%%%%%
%%% /\ %%%
-\edef\mhchem@char@lbrace{\string{} %}
-\begingroup%
- \catcode`\-=12%
- \gdef\mhchem@char@hyphen@other{-}%
- \catcode`\-=\active%
- \gdef\mhchem@char@hyphen@active{-}%
- \catcode`\<=12%
- \gdef\mhchem@char@lt@other{<}%
- \catcode`\<=\active%
- \gdef\mhchem@char@lt@active{<}%
- \catcode`\>=12%
- \gdef\mhchem@char@gt@other{>}%
- \catcode`\>=\active%
- \gdef\mhchem@char@gt@active{>}%
- \catcode`\^=7%
- \gdef\mhchem@char@caret@super{^}%
- \catcode`\^=\active%
- \gdef\mhchem@char@caret@active{^}%
- \catcode`\==12%
- \gdef\mhchem@char@equal@other{=}%
- \catcode`\==\active%
- \gdef\mhchem@char@equal@active{=}%
-\endgroup%
+\ExplSyntaxOn
+\msg_new:nnn { mhchem } { ce/unexpected-state }
+ {
+ Assertion~failed:~Unexpected~internal~state~'#1' (ce).~You~found~a~bug.~
+ Please~contact~the~package~author.
+ }
+\tl_new:N \__mhchem_ce_state_tl
-\newtoks\mhchem@ce@result%
-\newtoks\mhchem@ce@part%
-\newcommand*\mhchem@ce[1]{%
- \bgroup%
- \def\mhchem@ce@state{s}%
- \chardef\mhchem@ce@substate=0\relax%
- \mhchem@ce@result={}%
- \mhchem@ce@part={}%
- \mhchem@ce@continue#1\mhchem@END%
- \ifnum 1<\mhchem@option@version%
- \the\mhchem@ce@result%
- \else%
- \ensuremath{\the\mhchem@ce@result}%
- \fi%
- \egroup%
-}
-\def\mhchem@ce@i{%
- \ifx\mhchem@END\mhchem@ce@lookahead%
- \mhchem@ce@output%
- \let\mhchem@ce@action\mhchem@gobble%
- \else\if\space\noexpand\mhchem@ce@lookahead%
- \if s\mhchem@ce@state%
- \else%
- \mhchem@ce@output%
- \mhchem@ce@part={}%
- \def\mhchem@ce@state{s}%
- \fi%
- \let\mhchem@ce@action\mhchem@ce@gobbleNextSpace%
- \else\if\mhchem@char@lbrace\noexpand\mhchem@ce@lookahead%
- \if s\mhchem@ce@state%
- \def\mhchem@ce@state{c}%
- \fi%
- \def\mhchem@ce@action{\mhchem@ce@appendNextGroup{\mhchem@ce@part}}%
- \else%
- \if s\mhchem@ce@state%
- \expandafter\ifx\mhchem@char@hyphen@other\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=1\relax%
- \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=1\relax%
- \else\expandafter\ifx\mhchem@char@lt@other\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=7\relax%
- \else\expandafter\ifx\mhchem@char@lt@active\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=7\relax%
- \else\if +\noexpand\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=50\relax%
- \else\if (\noexpand\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=101\relax%
- \else\if v\noexpand\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=106\relax%
- \else\expandafter\ifx\mhchem@char@caret@super\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=107\relax%
- \else\expandafter\ifx\mhchem@char@caret@active\mhchem@ce@lookahead%
- \def\mhchem@ce@state{a}%
- \chardef\mhchem@ce@substate=107\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi%
- \def\mhchem@ce@action{\mhchem@ce@appendNextToken{\mhchem@ce@part}}%
- \else\if c\mhchem@ce@state%
- \def\mhchem@ce@action{\mhchem@ce@appendNextToken{\mhchem@ce@part}}%
- \else\if a\mhchem@ce@state%
- \def\mhchem@ce@action{\mhchem@ce@appendNextToken{\mhchem@ce@part}}%
- \ifnum 1=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@gt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=2\relax%
- \else\expandafter\ifx\mhchem@char@gt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=2\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi%
- \else\ifnum 2=\mhchem@ce@substate\relax%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=3\relax%
- \else\ifnum 7=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@hyphen@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=8\relax%
- \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=8\relax%
- \else\expandafter\ifx\mhchem@char@equal@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=19\relax%
- \else\expandafter\ifx\mhchem@char@equal@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=19\relax%
- \else\expandafter\ifx\mhchem@char@lt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=24\relax%
- \else\expandafter\ifx\mhchem@char@lt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=24\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi\fi\fi\fi\fi%
- \else\ifnum 8=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@gt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=10\relax%
- \else\expandafter\ifx\mhchem@char@gt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=10\relax%
- \else\expandafter\ifx\mhchem@char@hyphen@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=12\relax%
- \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=12\relax%
- \else%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=9\relax%
- \fi\fi\fi\fi%
- \else\ifnum 10=\mhchem@ce@substate\relax%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=11\relax%
- \else\ifnum 12=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@gt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=13\relax%
- \else\expandafter\ifx\mhchem@char@gt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=13\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi%
- \else\ifnum 13=\mhchem@ce@substate\relax%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=14\relax%
- \else\ifnum 19=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@gt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=20\relax%
- \else\expandafter\ifx\mhchem@char@gt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=20\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi%
- \else\ifnum 20=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@gt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=22\relax%
- \else\expandafter\ifx\mhchem@char@gt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=22\relax%
- \else%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=21\relax%
- \fi\fi%
- \else\ifnum 22=\mhchem@ce@substate\relax%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=23\relax%
- \else\ifnum 24=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@equal@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=25\relax%
- \else\expandafter\ifx\mhchem@char@equal@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=25\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi%
- \else\ifnum 25=\mhchem@ce@substate\relax%
- \expandafter\ifx\mhchem@char@gt@other\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=26\relax%
- \else\expandafter\ifx\mhchem@char@gt@active\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=26\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi%
- \else\ifnum 26=\mhchem@ce@substate\relax%
- \mhchem@ce@part={}%
- \chardef\mhchem@ce@substate=27\relax%
- \else\ifnum 50=\mhchem@ce@substate\relax%
- \mhchem@ce@output%
- \mhchem@ce@part={}%
- \def\mhchem@ce@state{c}%
- \else\ifnum 101=\mhchem@ce@substate\relax%
- \if v\noexpand\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=102\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi%
- \else\ifnum 102=\mhchem@ce@substate\relax%
- \if )\noexpand\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=103\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi%
- \else\ifnum 103=\mhchem@ce@substate\relax%
- \def\mhchem@ce@state{c}%
- \else\ifnum 104=\mhchem@ce@substate\relax%
- \if )\noexpand\mhchem@ce@lookahead%
- \chardef\mhchem@ce@substate=105\relax%
- \else%
- \def\mhchem@ce@state{c}%
- \fi%
- \else\ifnum 105=\mhchem@ce@substate\relax%
- \def\mhchem@ce@state{c}%
- \else\ifnum 106=\mhchem@ce@substate\relax%
- \def\mhchem@ce@state{c}%
- \else\ifnum 107=\mhchem@ce@substate\relax%
- \def\mhchem@ce@state{c}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
- \fi\fi\fi%
- \fi\fi\fi%
- \mhchem@ce@action%
-}
-\def\mhchem@ce@continue{%
- \futurelet\mhchem@ce@lookahead\mhchem@ce@i%
-}%
-\def\mhchem@ce@gobbleNextToken#1{%
- \mhchem@ce@continue%
-}%
-\def\mhchem@ce@gobbleNextSpace{%
- % thanks to de.comp.text.tex
- \def\mhchem@ce@gobbleNextSpace@i{%
- \mhchem@ce@continue}%
- \afterassignment\mhchem@ce@gobbleNextSpace@i%
- \let\mhchem@ce@gobbleNextSpace@ii= % The space is the trick!
-}
-\def\mhchem@ce@appendNextToken#1#2{%
- \mhchem@appendToks{#1}{#2}%
- \mhchem@ce@continue%
-}
-\def\mhchem@ce@appendNextGroup#1#2{%
- \mhchem@appendToks{#1}{{#2}}%
- \mhchem@ce@continue%
-}
-\def\mhchem@ce@output{%
- \if a\mhchem@ce@state%
- \ifnum 2=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@yields[][]}%
- \else\ifnum 3=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@yields\the\mhchem@ce@part}%
- \else\ifnum 8=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@yieldsLeft[][]}%
- \else\ifnum 9=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@yieldsLeft\the\mhchem@ce@part}%
- \else\ifnum 10=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@mesomerism[][]}%
- \else\ifnum 11=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@mesomerism\the\mhchem@ce@part}%
- \else\ifnum 13=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@yieldsLeftRight[][]}%
- \else\ifnum 14=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@yieldsLeftRight\the\mhchem@ce@part}%
- \else\ifnum 20=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@equilibrium[][]}%
- \else\ifnum 21=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@equilibrium\the\mhchem@ce@part}%
- \else\ifnum 22=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@equilibriumRight[][]}%
- \else\ifnum 23=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@equilibriumRight\the\mhchem@ce@part}%
- \else\ifnum 26=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\mhchem@arrow@equilibriumLeft[][]}%
- \else\ifnum 27=\mhchem@ce@substate\relax%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@arrow@equilibriumLeft\the\mhchem@ce@part}%
- \else\ifnum 50=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\ensuremath{{}+{}}}%
- \else\ifnum 103=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\ensuremath{{}\mathop{\downarrow}{}}}%
- \else\ifnum 105=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\ensuremath{{}\mathop{\uparrow}{}}}%
- \else\ifnum 106=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\ensuremath{{}\mathop{\downarrow}{}}}%
- \else\ifnum 107=\mhchem@ce@substate\relax%
- \mhchem@appendToks{\mhchem@ce@result}{\ensuremath{{}\mathop{\uparrow}{}}}%
- \else%
- \def\mhchem@ce@state{c}%
- \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
- \fi%
- \if c\mhchem@ce@state%
- \expandafter\mhchem@appendToks\expandafter{\expandafter\mhchem@ce@result\expandafter}\expandafter{\expandafter\mhchem@cf\expandafter{\the\mhchem@ce@part}}%
- \fi%
+\tl_new:N \__mhchem_ce_arrowName_tl
+\tl_new:N \__mhchem_ce_arrowTypeOne_tl
+\tl_new:N \__mhchem_ce_arrowTextOne_tl
+\tl_new:N \__mhchem_ce_arrowTypeTwo_tl
+\tl_new:N \__mhchem_ce_arrowTextTwo_tl
+
+\newcommand*\mhchem@ce[1]{
+ \__mhchem_ce:n {#1}
}
+\cs_new_protected:Npn \__mhchem_ce:n #1
+ {
+ \group_begin:
+ \def\hyphen{\mhchem@hyphen}%
+ \tl_clear_new:N \__mhchem_ce_result_tl
+ \tl_clear_new:N \__mhchem_ce_part_tl
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ \__mhchem_ce_loop: #1 \q_recursion_stop
+ \int_set:Nn \__mhchem_option_version_int { \mhchem@option@version }
+ \int_compare:nTF { 1 < \__mhchem_option_version_int }
+ { \tl_use:N \__mhchem_ce_result_tl }
+ { \ensuremath{\tl_use:N \__mhchem_ce_result_tl} }
+ \group_end:
+ }
+\cs_new_protected:Npn \__mhchem_ce_loop:
+ {
+ \str_case:Vnn \__mhchem_ce_state_tl
+ {
+ { c }
+ {
+ \str_case:Vnn \__mhchem_ce_part_tl
+ {
+ { + }
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl { \ensuremath{{}+{}} }
+ \tl_clear:N \__mhchem_ce_part_tl
+ }
+ { -> }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { yields }
+ \__mhchem_ce_loop_startArrow:
+ }
+ { <- }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { yieldsLeft }
+ \__mhchem_ce_loop_startArrow:
+ }
+ { <--> }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { yieldsLeftRight }
+ \__mhchem_ce_loop_startArrow:
+ }
+ { <-> }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { mesomerism }
+ \__mhchem_ce_loop_startArrow:
+ }
+ { <=> }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { equilibrium }
+ \__mhchem_ce_loop_startArrow:
+ }
+ { <<=> }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { equilibriumLeft }
+ \__mhchem_ce_loop_startArrow:
+ }
+ { <=>> }
+ {
+ \tl_set:Nn \__mhchem_ce_arrowName_tl { equilibriumRight }
+ \__mhchem_ce_loop_startArrow:
+ }
+ }
+ {}
+ }
+ }
+ {}
+ \peek_meaning_remove:NTF \q_recursion_stop
+ {
+ \__mhchem_ce_output:
+ }{
+ \str_case:Vnn \__mhchem_ce_state_tl
+ {
+ { c }
+ {
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \__mhchem_loopHelper_appendMathA:NNw
+ \__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }
+ }}
+ }
+ { a-t1 }
+ {
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF T
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-[1 }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTypeOne_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF M
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-[1 }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTypeOne_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF C
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-[1 }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTypeOne_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF [
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-]1 }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \str_case:Vnn \__mhchem_ce_arrowName_tl
+ {
+ { yieldsLeft }
+ {
+ \peek_charcode:NTF -
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ \tl_set:Nn \__mhchem_ce_part_tl { <- }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF >
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ \tl_set:Nn \__mhchem_ce_part_tl { <- }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }
+ }
+ }
+ { equilibrium }
+ {
+ \peek_charcode:NTF >
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ \tl_set:Nn \__mhchem_ce_part_tl { <=> }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_part_tl
+ \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }
+ }
+ }
+ % else
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }
+ }
+ }}}}
+ }
+ { a-[1 }
+ {
+ \peek_charcode:NTF [
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-]1 }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }
+ }
+ { a-]1 }
+ {
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \tl_put_right:Nn \__mhchem_ce_arrowTextOne_tl { ~ }
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF ]
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-t2 }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_ce_arrowTextOne_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_ce_arrowTextOne_tl
+ \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTextOne_tl
+ \__mhchem_ce_loop:
+ }
+ }}}
+ }
+ { a-t2 }
+ {
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF T
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-[2 }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTypeTwo_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF M
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-[2 }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTypeTwo_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF C
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-[2 }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTypeTwo_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF [
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-]2 }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }
+ }}}}
+ }
+ { a-[2 }
+ {
+ \peek_charcode:NTF [
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-]2 }
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_ce_output:
+ \__mhchem_ce_loop:
+ }
+ }
+ { a-]2 }
+ {
+ \peek_charcode_remove:NTF \c_space_token
+ {
+ \tl_put_right:Nn \__mhchem_ce_arrowTextTwo_tl { ~ }
+ \__mhchem_ce_loop:
+ }{
+ \peek_charcode:NTF ]
+ {
+ \__mhchem_ce_output:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_ce_loop:
+ }{
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_ce_arrowTextTwo_tl
+ \__mhchem_ce_loop:
+ }{
+ \peek_catcode_remove:NTF \c_math_toggle_token
+ {
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_ce_arrowTextTwo_tl
+ \__mhchem_ce_loop:
+ }
+ % else
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_arrowTextTwo_tl
+ \__mhchem_ce_loop:
+ }
+ }}}
+ }
+ }
+ {
+ \msg_error:nnx { mhchem } { ce/unexpected-state }
+ { \__mhchem_ce_state_tl }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_ce_result_tl
+ \__mhchem_ce_loop:
+ }
+ }
+ }
+\cs_new_protected:Npn \__mhchem_ce_output:
+ {
+ \str_case:Vnn \__mhchem_ce_state_tl
+ {
+ { c }
+ {
+ \str_if_eq:VnTF \__mhchem_ce_part_tl { - }
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl { \ensuremath{{}-{}} }
+ }{
+ \str_if_eq:VnTF \__mhchem_ce_part_tl { (v) }
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl
+ { \ensuremath{{}\mathop{\downarrow}{}} }
+ }{
+ \str_if_eq:VnTF \__mhchem_ce_part_tl { v }
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl
+ { \ensuremath{{}\mathop{\downarrow}{}} }
+ }{
+ \str_if_eq:VnTF \__mhchem_ce_part_tl { (^) }
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl
+ { \ensuremath{{}\mathop{\uparrow}{}} }
+ }{
+ \str_if_eq:VnTF \__mhchem_ce_part_tl { ^ }
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl
+ { \ensuremath{{}\mathop{\uparrow}{}} }
+ }
+ % else
+ {
+ \tl_if_empty:NTF \__mhchem_ce_part_tl
+ {}
+ {
+ \tl_put_right:Nx \__mhchem_ce_result_tl
+ {
+ \exp_not:N \__mhchem_cf:nn
+ {}
+ { \exp_not:V \__mhchem_ce_part_tl }
+ }
+ }
+ }
+ }}}}
+ }
+ { a-t1 }
+ {
+ \__mhchem_ce_outputArrow:ooooo
+ { \__mhchem_ce_arrowName_tl }
+ {}
+ {}
+ {}
+ {}
+ }
+ { a-[1 }
+ {
+ \__mhchem_ce_outputArrow:ooooo
+ { \__mhchem_ce_arrowName_tl }
+ {}
+ {}
+ {}
+ {}
+ \tl_set:NV \__mhchem_ce_part_tl \__mhchem_ce_arrowTypeOne_tl
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ \__mhchem_ce_output:
+ }
+ { a-]1 }
+ {
+ \__mhchem_ce_outputArrow:ooooo
+ { \__mhchem_ce_arrowName_tl }
+ { \__mhchem_ce_arrowTypeOne_tl }
+ { \__mhchem_ce_arrowTextOne_tl }
+ {}
+ {}
+ }
+ { a-t2 }
+ {
+ \__mhchem_ce_outputArrow:ooooo
+ { \__mhchem_ce_arrowName_tl }
+ { \__mhchem_ce_arrowTypeOne_tl }
+ { \__mhchem_ce_arrowTextOne_tl }
+ {}
+ {}
+ }
+ { a-[2 }
+ {
+ \__mhchem_ce_outputArrow:ooooo
+ { \__mhchem_ce_arrowName_tl }
+ { \__mhchem_ce_arrowTypeOne_tl }
+ { \__mhchem_ce_arrowTextOne_tl }
+ {}
+ {}
+ \tl_set:NV \__mhchem_ce_part_tl \__mhchem_ce_arrowTypeTwo_tl
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ \__mhchem_ce_output:
+ }
+ { a-]2 }
+ {
+ \__mhchem_ce_outputArrow:ooooo
+ { \__mhchem_ce_arrowName_tl }
+ { \__mhchem_ce_arrowTypeOne_tl }
+ { \__mhchem_ce_arrowTextOne_tl }
+ { \__mhchem_ce_arrowTypeTwo_tl }
+ { \__mhchem_ce_arrowTextTwo_tl }
+ }
+ }
+ {}
+ \tl_clear:N \__mhchem_ce_part_tl
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ }
+\cs_new_protected:Npn \__mhchem_ce_outputArrow:nnnnn #1#2#3#4#5
+ {
+ \tl_put_right:Nn \__mhchem_ce_result_tl
+ {
+ \__mhchem_arrow_deploy:nnnnn {#1} {#2} {#3} {#4} {#5}
+ }
+ \tl_clear:N \__mhchem_ce_part_tl
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ }
+\cs_generate_variant:Nn \__mhchem_ce_outputArrow:nnnnn {ooooo}
+\cs_new_protected:Npn \__mhchem_ce_loop_startArrow:
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-t1 }
+ \tl_clear:N \__mhchem_ce_arrowTypeOne_tl
+ \tl_clear:N \__mhchem_ce_arrowTextOne_tl
+ \tl_clear:N \__mhchem_ce_arrowTypeTwo_tl
+ \tl_clear:N \__mhchem_ce_arrowTextTwo_tl
+ \tl_clear:N \__mhchem_ce_part_tl
+ }
+\cs_new_protected:Npn \__mhchem_ce_loop_abortArrow:
+ {
+ \tl_put_right:Nx \__mhchem_ce_part_tl
+ {
+ \tl_set:Nn \__mhchem_ce_state_tl { a-t1 }
+ \exp_not:V \__mhchem_ce_arrowTypeOne_tl
+ \exp_not:V \__mhchem_ce_arrowTextOne_tl
+ \exp_not:V \__mhchem_ce_arrowTypeTwo_tl
+ \exp_not:V \__mhchem_ce_arrowTextTwo_tl
+ }
+ \tl_set:Nn \__mhchem_ce_state_tl { c }
+ }
+\ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% arrows %%%%%%%%%%
@@ -441,69 +679,49 @@
\def\mhchem@arrow@minlength{{2em}}%
%%% Deployment of arrow macros
-\newtoks\mhchem@arrow@deployType
-\def\mhchem@arrow@deploy#1{%
- \if [#1%
- \ifnum 3<\mhchem@option@version%
- \edef\mhchem@arrow@deploy@action{\noexpand\csname mhchem@arrow@\the\mhchem@arrow@deployType T\endcsname[}%
- \else%
- \edef\mhchem@arrow@deploy@action{\noexpand\csname mhchem@arrow@\the\mhchem@arrow@deployType M\endcsname[}%
- \fi%
- \else\if T#1%
- \edef\mhchem@arrow@deploy@action{\noexpand\csname mhchem@arrow@\the\mhchem@arrow@deployType T\endcsname}%
- \else\if C#1%
- \edef\mhchem@arrow@deploy@action{\noexpand\csname mhchem@arrow@\the\mhchem@arrow@deployType C\endcsname}%
- \else%
- \def\mhchem@arrow@deploy@action{}%
- \PackageError{mhchem}{Arrow type not supported}%
- \fi\fi\fi%
- \mhchem@arrow@deploy@action%
-}
-\def\mhchem@arrow@yields{%
- \mhchem@arrow@deployType={yields}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
-\def\mhchem@arrow@yieldsLeft{%
- \mhchem@arrow@deployType={yieldsLeft}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
-\def\mhchem@arrow@yieldsLeftRight{%
- \mhchem@arrow@deployType={yieldsLeftRight}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
-\def\mhchem@arrow@mesomerism{%
- \mhchem@arrow@deployType={mesomerism}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
-\def\mhchem@arrow@equilibrium{%
- \mhchem@arrow@deployType={equilibrium}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
-\def\mhchem@arrow@equilibriumRight{%
- \mhchem@arrow@deployType={equilibriumRight}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
-\def\mhchem@arrow@equilibriumLeft{%
- \mhchem@arrow@deployType={equilibriumLeft}%
- \futurelet\lookahead\mhchem@arrow@deploy%
-}
+\ExplSyntaxOn
+\msg_new:nnn { mhchem } { unexpected-arrow-type }
+ {
+ 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
+ {
+ \str_case:nnn {#2}
+ {
+ { }
+ {
+ \int_compare:nTF { 3 < \__mhchem_option_version_int }
+ { \cs:w mhchem@arrow@#1T \cs_end: {#3}{#5} }
+ { \cs:w mhchem@arrow@#1M \cs_end: {#3}{#5} }
+ }
+ { M }
+ { \cs:w mhchem@arrow@#1M \cs_end: {#3}{#5} }
+ { T }
+ { \cs:w mhchem@arrow@#1T \cs_end: {#3}{#5} }
+ { C }
+ { \cs:w mhchem@arrow@#1C \cs_end: {#3}{#5} }
+ }
+ { \msg_error:nnn { mhchem } { unexpected-arrow-type } {#2} }
+ }
+\ExplSyntaxOff
%%% Definition of arrows (with math text) for font/pgf/pgf-filled
-\newcommandtwoopt*\mhchem@arrow@yieldsM[2][][]{}
-\newcommandtwoopt*\mhchem@arrow@yieldsLeftM[2][][]{}
-\newcommandtwoopt*\mhchem@arrow@yieldsLeftRightM[2][][]{}
-\newcommandtwoopt*\mhchem@arrow@mesomerismM[2][][]{}
-\newcommandtwoopt*\mhchem@arrow@equilibriumM[2][][]{}
-\newcommandtwoopt*\mhchem@arrow@equilibriumRightM[2][][]{}
-\newcommandtwoopt*\mhchem@arrow@equilibriumLeftM[2][][]{}
+\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}}{%
- \renewcommandtwoopt*\mhchem@arrow@yieldsM[2][][]{%
- \ensuremath{{}\mhchem@ext@arrow{5}{9}{##1}{5}{9}{##2}{\mhchem@arrow@minlength}{\rightarrowfill@}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@yieldsLeftM[2][][]{%
+ \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@}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@yieldsLeftRightM[2][][]{%
+ \renewcommand*\mhchem@arrow@yieldsLeftRightM[2]{%
\ensuremath{{}\mathrel{%
\@ifempty{##2}%
{\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\rightarrowfill@}$}}}%
@@ -512,9 +730,9 @@
{\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@}$}}%
}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@mesomerismM[2][][]{%
+ \renewcommand*\mhchem@arrow@mesomerismM[2]{%
\ensuremath{{}\mhchem@ext@arrow{9}{9}{##1}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftrightarrowfill@}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@equilibriumM[2][][]{%
+ \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@}$}}}%
@@ -523,7 +741,7 @@
{\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@}$}}%
}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@equilibriumRightM[2][][]{%
+ \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@}$}}%
@@ -537,7 +755,7 @@
{\raisebox{.22ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}%
}%
}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@equilibriumLeftM[2][][]{%
+ \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@}$}}%
@@ -553,11 +771,11 @@
}{}}}%
%%% pgf
}{\ifthenelse{\equal{#1}{pgf} \or \equal{#1}{pgf-filled}}{%
- \renewcommandtwoopt*\mhchem@arrow@yieldsM[2][][]{%
+ \renewcommand*\mhchem@arrow@yieldsM[2]{%
\ensuremath{{}\mhchem@ext@arrow@pgf{5}{9}{##1}{5}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@rightarrow@pgf}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@yieldsLeftM[2][][]{%
+ \renewcommand*\mhchem@arrow@yieldsLeftM[2]{%
\ensuremath{{}\mhchem@ext@arrow@pgf{9}{5}{##1}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@yieldsLeftRightM[2][][]{%
+ \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}$}}}%
@@ -566,9 +784,9 @@
{\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}$}}%
}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@mesomerismM[2][][]{%
+ \renewcommand*\mhchem@arrow@mesomerismM[2]{%
\ensuremath{{}\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftrightarrow@pgf}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@equilibriumM[2][][]{%
+ \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}$}}}%
@@ -577,7 +795,7 @@
{\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}$}}%
}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@equilibriumRightM[2][][]{%
+ \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}$}}%
@@ -591,7 +809,7 @@
{\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}%
}%
}{}}}%
- \renewcommandtwoopt*\mhchem@arrow@equilibriumLeftM[2][][]{%
+ \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}$}}%
@@ -627,54 +845,62 @@
\newtoks\mhchem@arrow@params%
\def\mhchem@arrow@setParamsT#1#2{%
\mhchem@arrow@params={}%
- \@ifnotempty{#1}{\mhchem@appendToks{\mhchem@arrow@params}{[\text{#1}]}}%
- \@ifnotempty{#2}{\mhchem@appendToks{\mhchem@arrow@params}{[\text{#2}]}}%
+ \@ifempty{#1}%
+ {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
+ {\mhchem@appendToks{\mhchem@arrow@params}{{\text{#1}}}}%
+ \@ifempty{#2}%
+ {\mhchem@appendToks{\mhchem@arrow@params}{{}}}%
+ {\mhchem@appendToks{\mhchem@arrow@params}{{\text{#2}}}}%
}%
\def\mhchem@arrow@setParamsC#1#2{%
\mhchem@arrow@params={}%
- \@ifnotempty{#1}{\mhchem@appendToks{\mhchem@arrow@params}{[\ce{#1}]}}%
- \@ifnotempty{#2}{\mhchem@appendToks{\mhchem@arrow@params}{[\ce{#2}]}}%
+ \@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}}}}%
}%
-\newcommandtwoopt*\mhchem@arrow@yieldsT[2][][]{%
+\newcommand*\mhchem@arrow@yieldsT[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@yieldsC[2][][]{%
+\newcommand*\mhchem@arrow@yieldsC[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@yieldsLeftT[2][][]{%
+\newcommand*\mhchem@arrow@yieldsLeftT[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@yieldsLeftC[2][][]{%
+\newcommand*\mhchem@arrow@yieldsLeftC[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@yieldsLeftRightT[2][][]{%
+\newcommand*\mhchem@arrow@yieldsLeftRightT[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@yieldsLeftRightC[2][][]{%
+\newcommand*\mhchem@arrow@yieldsLeftRightC[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@mesomerismT[2][][]{%
+\newcommand*\mhchem@arrow@mesomerismT[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}%
-\newcommandtwoopt*\mhchem@arrow@mesomerismC[2][][]{%
+\newcommand*\mhchem@arrow@mesomerismC[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}%
-\newcommandtwoopt*{\mhchem@arrow@equilibriumT}[2][][]{%
+\newcommand*{\mhchem@arrow@equilibriumT}[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}%
-\newcommandtwoopt*{\mhchem@arrow@equilibriumC}[2][][]{%
+\newcommand*{\mhchem@arrow@equilibriumC}[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}%
-\newcommandtwoopt*{\mhchem@arrow@equilibriumRightT}[2][][]{%
+\newcommand*{\mhchem@arrow@equilibriumRightT}[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}%
-\newcommandtwoopt*{\mhchem@arrow@equilibriumRightC}[2][][]{%
+\newcommand*{\mhchem@arrow@equilibriumRightC}[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}%
-\newcommandtwoopt*{\mhchem@arrow@equilibriumLeftT}[2][][]{%
+\newcommand*{\mhchem@arrow@equilibriumLeftT}[2]{%
\mhchem@arrow@setParamsT{#1}{#2}%
\expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}%
-\newcommandtwoopt*{\mhchem@arrow@equilibriumLeftC}[2][][]{%
+\newcommand*{\mhchem@arrow@equilibriumLeftC}[2]{%
\mhchem@arrow@setParamsC{#1}{#2}%
\expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}%
@@ -813,7 +1039,6 @@
\end{tikzpicture}%
}%
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% bonds %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -888,88 +1113,69 @@
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi%
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%% loop helper %%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%% loop helpers %%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn
-\msg_new:nnn { mhchem } { cf / unexpected-input } { Assertion~failed:~Unexpected~input~character.~You~found~a~bug.~Please~contact~the~author. }
-\msg_new:nnn { mhchem } { cf / unexpected-state } { Assertion~failed:~Unexpected~internal~state~'#1'.~You~found~a~bug.~Please~contact~the~author. }
-\msg_new:nnn { mhchem } { cf / unexpected-two-superscripts } { Assertion~failed:~Two~superscripts.~You~entered~an~invalid~formula.~Or~you~found~a~bug,~in~which~case~you~should~contact~the~author. }
-
-\cs_generate_variant:Nn \peek_catcode_remove:NTF { oTF }
-\cs_generate_variant:Nn \peek_catcode:NTF { oTF }
-\cs_generate_variant:Nn \str_case:nnn { Vnn }
-
-\cs_new:Npn \__mhchem_loopHelper_appendNextToken:NNn #1#2#3
+\msg_new:nnn { mhchem } { cf/unexpected-input }
{
- \tl_put_right:Nn #1 { #3 }
- #2
+ Assertion~failed:~Unexpected~input~character.~You~found~a~bug.~
+ Please~contact~the~package~author.
}
-\cs_new:Npn \__mhchem_loopHelper_appendNextGroup:NNn #1#2#3
+\msg_new:nnn { mhchem } { cf/unexpected-state }
{
- \tl_put_right:Nn #1 { { #3 } }
- #2
+ Assertion~failed:~Unexpected~internal~state~'#1' (cf).~You~found~a~bug.~
+ Please~contact~the~package~author.
}
-\cs_new:Npn \__mhchem_loopHelper_appendMath:NNw #1#2#3$
+\msg_new:nnn { mhchem } { cf/unexpected-two-superscripts }
{
- \tl_put_right:Nn #1 { \text { \ensuremath { #3 } } }
- #2
+ Assertion~failed:~Two~superscripts.~You~entered~an~invalid~formula.~
+ Or~you~found~a~bug,~in~which~case~you~should~contact~the~package~author.
}
-\cs_new:Npn \__mhchem_loopHelper_appendMathAsGroup:NNw #1#2#3$
- {
- \tl_put_right:Nn #1 { \text { \ensuremath { #3 } } }
- #2
- }
-\cs_new:Npn \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn #1#2#3
- {
- \tl_put_right:Nn #1 { \ensuremath { \mathrm{ #3 } } }
- #2
- }
-\cs_new:Npn \__mhchem_loopHelper_useNone:Nn #1#2
- {
- #1
- }
-\cs_new:Npn \__mhchem_loopHelper_outputAndReset_appendNextTokenToResult_setState:NNn #1#2#3
+
+\cs_new_protected:Npn
+ \__mhchem_loopHelper_outputAndReset_appendNextTokenToResult_setState:NNn #1#2#3
{
\__mhchem_cf_outputAndReset:
\tl_put_right:Nn \__mhchem_cf_result_tl { \mhchem@mathOrText{#3} }
- \tl_set:Nn \__mhchem_cf_state_tl { #1 }
+ \tl_set:Nn \__mhchem_cf_state_tl {#1}
#2
}
-\cs_new:Npn \__mhchem_loopHelper_outputAndReset_appendToResult_setState_useNone:NNn #1#2#3#4
+\cs_new_protected:Npn
+ \__mhchem_loopHelper_outputAndReset_appendToResult_setState_useNone:NNn #1#2#3#4
{
\__mhchem_cf_outputAndReset:
- \tl_put_right:Nn \__mhchem_cf_result_tl { #1 }
- \tl_set:Nn \__mhchem_cf_state_tl { #2 }
+ \tl_put_right:Nn \__mhchem_cf_result_tl {#1}
+ \tl_set:Nn \__mhchem_cf_state_tl {#2}
#3
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% \cf %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\newcommand*\mhchem@cf[2][]{%
- \__mhchem_cf{#1}{#2}%
+
+\newcommand*\mhchem@cf[2][]{
+ \__mhchem_cf:nn {#1} {#2}
}
\tl_new:N \__mhchem_cf_state_tl
\bool_new:N \__mhchem_cf_startedWithBond_bool
\bool_new:N \__mhchem_cf_cfActive_bool
\bool_set_false:N \__mhchem_cf_cfActive_bool
-\int_new:N \__mhchem_option_version_int
-\cs_new:Npn \__mhchem_cf #1#2
+\cs_new_protected:Npn \__mhchem_cf:nn #1#2
{
\group_begin:
\int_set:Nn \__mhchem_option_version_int { \mhchem@option@version }
- \def\sbond{{\ensuremath{-}}}%
- \ifnum 2=\mhchem@option@version%
- \let\bond\sbond%
- \else\ifnum 2<\mhchem@option@version%
- \def\bond{\mhchem@bond}%
- \fi\fi%
- \def\dbond{\rlap{\protect\raisebox{.2ex}{\sbond}}\protect\raisebox{-.2ex}{\sbond}}%
- \def\tbond{\rlap{\protect\raisebox{.4ex}{\sbond}}%
- \rlap{\sbond}\protect\raisebox{-.4ex}{\sbond}}%
- \def\hyphen{\mhchem@hyphen}%
+ \def\sbond{{\ensuremath{-}}}
+ \ifnum 2=\mhchem@option@version
+ \let\bond\sbond
+ \else\ifnum 2<\mhchem@option@version
+ \def\bond{\mhchem@bond}
+ \fi\fi
+ \def\dbond{\rlap{\protect\raisebox{.2ex}{\sbond}}\protect\raisebox{-.2ex}{\sbond}}
+ \def\tbond{\rlap{\protect\raisebox{.4ex}{\sbond}}
+ \rlap{\sbond}\protect\raisebox{-.4ex}{\sbond}}
+ \def\hyphen{\mhchem@hyphen}
\bool_if:NF \__mhchem_cf_cfActive_bool
{
\bool_set_true:N \__mhchem_cf_cfActive_bool
@@ -984,15 +1190,19 @@
\cs_set:Npx \mhchem@mathOrText@ii ##1##2 { ##2 }
}
{
- \int_compare:nTF { 1 < \mhchem@option@version }
+ \int_compare:nTF { 1 < \__mhchem_option_version_int }
{
\cs_set:Npx \mhchem@mathOrText ##1
{
- \mode_if_math:TF { \exp_not:N \mhchem@option@mathFont{##1} } { \exp_not:N \text{##1} }
+ \mode_if_math:TF
+ { \exp_not:N \mhchem@option@mathFont{##1} }
+ { \exp_not:N \text{##1} }
}
\cs_set:Npx \mhchem@mathOrText@ii ##1##2
{
- \mode_if_math:TF { \exp_not:N \mhchem@option@mathFont{##1} } { ##2 }
+ \mode_if_math:TF
+ { \exp_not:N \mhchem@option@mathFont{##1} }
+ { ##2 }
}
}
{
@@ -1018,11 +1228,11 @@
\bool_set_false:N \__mhchem_cf_cfActive_bool
\group_end:
}
-\cs_new:Nn \__mhchem_cf_loop:
+\cs_new_protected:Npn \__mhchem_cf_loop:
{
\peek_meaning_remove:NTF \q_recursion_stop
{
- \str_case:Vnn { \__mhchem_cf_state_tl }
+ \str_case:Vnn \__mhchem_cf_state_tl
{
{ - }
{
@@ -1040,10 +1250,10 @@
\__mhchem_cf_outputAndReset:
}{
\peek_meaning:NTF \relax
- { \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop: }{
+ { \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop: }{
\peek_meaning:NTF \protect
- { \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop: }{
- \str_case:Vnn { \__mhchem_cf_state_tl }
+ { \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop: }{
+ \str_case:Vnn \__mhchem_cf_state_tl
{
{ - }
{
@@ -1060,12 +1270,12 @@
{
\tl_set:Nn \__mhchem_cf_state_tl { - }
\bool_set_true:N \__mhchem_cf_startedWithBond_bool
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
\tl_put_right:Nn \__mhchem_cf_sup_tl { - }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF =
@@ -1085,36 +1295,38 @@
\peek_charcode:NTF ^
{
\tl_set:Nn \__mhchem_cf_state_tl { p }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF _
{
\tl_set:Nn \__mhchem_cf_state_tl { q }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF `
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { P }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF ,
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { Q }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { 1 }
\tl_put_right:Nn \__mhchem_cf_sub_tl { {,} }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF .
@@ -1134,7 +1346,9 @@
\peek_charcode:NTF +
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}{
\peek_charcode:NTF |
{
@@ -1167,63 +1381,66 @@
\peek_catcode:NTF \mhchem@macro
{
\tl_set:Nn \__mhchem_cf_state_tl { c }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF a
{
\tl_set:Nn \__mhchem_cf_state_tl { a }
\__mhchem_loopHelper_appendNextToken:NNn
- \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF 1
{
\tl_set:Nn \__mhchem_cf_state_tl { 1 }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}{
- \peek_catcode:oTF \c_group_begin_token
+ \peek_catcode:NTF \c_group_begin_token
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { 1 }
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
}{
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { 1 }
- \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}
- {
- \msg_error:nnn { mhchem } { cf/unexpected-input }
- }
+ % else
+ { \msg_error:nnn { mhchem } { cf/unexpected-input } }
}}}}}}}}}}}}}}}}}}}
}
- { C }
- {
- \peek_catcode:oTF \c_group_begin_token
- {
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
- }
- {
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
- }
- \tl_set:Nn \__mhchem_cf_state_tl { c }
- }
{ c }
{
- \peek_catcode:oTF \c_group_begin_token
+ \peek_catcode:NTF \c_group_begin_token
{
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { a }
@@ -1233,58 +1450,108 @@
{ 1 }
{
\peek_charcode:NTF 1
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 2
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 3
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 4
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 5
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 6
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 7
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 8
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 9
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF 0
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF .
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
{
\peek_charcode:NTF ,
{
\tl_put_right:Nn \__mhchem_cf_element_tl { {,} }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\peek_charcode:NTF /
- { \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop: }
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
+ % else
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { s }
\__mhchem_cf_loop:
- }}}}}}}}}}}}}
+ }
+ }}}}}}}}}}}}
}
{ a }
{
\peek_charcode:NTF -
{
\tl_set:Nn \__mhchem_cf_state_tl { - }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF =
{
@@ -1303,35 +1570,37 @@
\peek_charcode:NTF ^
{
\tl_set:Nn \__mhchem_cf_state_tl { k }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF _
{
\tl_set:Nn \__mhchem_cf_state_tl { f }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF `
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { E }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF ,
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { F }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { 1 }
\tl_put_right:Nn \__mhchem_cf_sub_tl { , }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF .
@@ -1351,12 +1620,14 @@
\peek_charcode:NTF +
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}{
\peek_charcode:NTF |
{
\PackageWarning{mhchem}{The symbol | is not allowed here}
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF (
{
@@ -1386,86 +1657,99 @@
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { c }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF a
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF 1
{
\tl_set:Nn \__mhchem_cf_state_tl { 2 }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}{
- \peek_catcode:oTF \c_group_begin_token
+ \peek_catcode:NTF \c_group_begin_token
{
\__mhchem_cf_outputAndReset:
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}{
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_element_tl \__mhchem_cf_loop:
- }{
- \msg_error:nnn { mhchem } { cf/unexpected-input }
- }}}}}}}}}}}}}}}}}}}}
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
+ }
+ % else
+ { \msg_error:nnn { mhchem } { cf/unexpected-input } }
+ }}}}}}}}}}}}}}}}}}}
}
{ 2 }
{
\peek_charcode:NTF -
{
\tl_set:Nn \__mhchem_cf_state_tl { - }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF =
{
\__mhchem_cf_outputAndReset:
\tl_put_right:Nn \__mhchem_cf_result_tl {\dbond}
\tl_set:Nn \__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF ##
{
\__mhchem_cf_outputAndReset:
\tl_put_right:Nn \__mhchem_cf_result_tl {\tbond}
\tl_set:Nn \__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF ^
{
\tl_set:Nn \__mhchem_cf_state_tl { e }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF _
{
\tl_set:Nn \__mhchem_cf_state_tl { f }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF `
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { E }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF ,
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { F }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_put_right:Nn \__mhchem_cf_sub_tl { , }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF .
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\__mhchem_loopHelper_outputAndReset_appendToResult_setState_useNone:NNn
{ \mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot} }
@@ -1473,7 +1757,9 @@
\__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF *
@@ -1486,12 +1772,14 @@
\peek_charcode:NTF +
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}{
\peek_charcode:NTF |
{
\PackageWarning{mhchem}{The symbol | is not allowed here}
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF (
{
@@ -1521,125 +1809,169 @@
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { c }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF a
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF 1
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}{
- \peek_catcode:oTF \c_group_begin_token
+ \peek_catcode:NTF \c_group_begin_token
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
+ % else
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
- }}}}}}}}}}}}}}}}}}}}
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
+ }
+ }}}}}}}}}}}}}}}}}}}
}
{ e }
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathAsGroup:NNw \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathAsGroup:NNw
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}
}
{ k }
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathAsGroup:NNw \__mhchem_cf_supA_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathAsGroup:NNw
+ \__mhchem_cf_supA_tl
+ \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_supA_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_supA_tl
+ \__mhchem_cf_loop:
}
}
{ f }
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathAsGroup:NNw \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathAsGroup:NNw
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
}
{ p }
{
\tl_set:Nn \__mhchem_cf_state_tl { * }
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathAsGroup:NNw \__mhchem_cf_presup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathAsGroup:NNw
+ \__mhchem_cf_presup_tl
+ \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_presup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_presup_tl
+ \__mhchem_cf_loop:
}
}
{ q }
{
\tl_set:Nn \__mhchem_cf_state_tl { * }
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
- \__mhchem_loopHelper_appendMathAsGroup:NNw \__mhchem_cf_presub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathAsGroup:NNw
+ \__mhchem_cf_presub_tl
+ \__mhchem_cf_loop:
}
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_presub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_presub_tl
+ \__mhchem_cf_loop:
}
}
{ E }
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}
{ F }
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn \__mhchem_cf_sub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn
+ \__mhchem_cf_sub_tl
+ \__mhchem_cf_loop:
}
{ P }
{
\tl_set:Nn \__mhchem_cf_state_tl { * }
- \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn \__mhchem_cf_presup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn
+ \__mhchem_cf_presup_tl
+ \__mhchem_cf_loop:
}
{ Q }
{
\tl_set:Nn \__mhchem_cf_state_tl { * }
- \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn \__mhchem_cf_presub_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextTokenAsMathrm:NNn
+ \__mhchem_cf_presub_tl
+ \__mhchem_cf_loop:
}
{ + }
{
\peek_charcode:NTF -
{
\tl_set:Nn \__mhchem_cf_state_tl { - }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF =
{
@@ -1658,43 +1990,45 @@
\peek_charcode:NTF ^
{
\tl_set:Nn \__mhchem_cf_state_tl { e }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF _
{
\tl_set:Nn \__mhchem_cf_state_tl { f }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF `
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { E }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF ,
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { F }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
\tl_put_right:Nn \__mhchem_cf_element_tl { , }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF .
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\__mhchem_loopHelper_outputAndReset_appendToResult_setState_useNone:NNn
{ \mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot} }
@@ -1704,7 +2038,9 @@
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF *
@@ -1717,12 +2053,14 @@
\peek_charcode:NTF +
{
\tl_set:Nn \__mhchem_cf_state_tl { + }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_sup_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_sup_tl
+ \__mhchem_cf_loop:
}{
\peek_charcode:NTF |
{
\PackageWarning{mhchem}{The symbol | is not allowed here}
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF (
{
@@ -1752,93 +2090,116 @@
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { c }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF a
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}{
\peek_catcode:NTF 1
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}{
- \peek_catcode:oTF \c_group_begin_token
+ \peek_catcode:NTF \c_group_begin_token
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
- \peek_catcode_remove:oTF \c_math_toggle_token
+ \peek_catcode_remove:NTF \c_math_toggle_token
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
+ % else
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { s }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
- }}}}}}}}}}}}}}}}}}}}
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
+ }
+ }}}}}}}}}}}}}}}}}}}
}
{ * }
{
\peek_charcode:NTF ^
{
\tl_set:Nn \__mhchem_cf_state_tl { p }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF _
{
\tl_set:Nn \__mhchem_cf_state_tl { q }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}{
\peek_charcode:NTF `
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { P }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { a }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_element_tl \__mhchem_cf_loop:
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_element_tl
+ \__mhchem_cf_loop:
}
}{
\peek_charcode:NTF ,
{
- \int_compare:nTF { 4 > \mhchem@option@version }
+ \int_compare:nTF { 4 > \__mhchem_option_version_int }
{
\tl_set:Nn \__mhchem_cf_state_tl { Q }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
{
\tl_set:Nn \__mhchem_cf_state_tl { a }
\tl_put_right:Nn \__mhchem_cf_element_tl { , }
- \__mhchem_loopHelper_useNone:Nn \__mhchem_cf_loop:
+ \__mhchem_loopHelper_ignoreNextToken:Nn \__mhchem_cf_loop:
}
}
+ % else
{
\__mhchem_cf_outputAndReset:
\tl_set:Nn \__mhchem_cf_state_tl { s }
\__mhchem_cf_loop:
- }}}}
+ }
+ }}}
}
}
{
- \msg_error:nnx { mhchem } { cf / unexpected-state } { \__mhchem_cf_state_tl }
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_result_tl \__mhchem_cf_loop:
+ \msg_error:nnx { mhchem } { cf/unexpected-state }
+ { \__mhchem_cf_state_tl }
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_result_tl
+ \__mhchem_cf_loop:
}
}}}
}
@@ -1857,20 +2218,31 @@
\tl_new:N \__mhchem_cf_supA_tl
\tl_new:N \__mhchem_cf_sub_tl
\tl_new:N \__mhchem_cf_sup_tl
-\cs_new:Nn \__mhchem_cf_output:
+\cs_new_protected:Npn \__mhchem_cf_output:
{
- \str_case:Vnn { \__mhchem_cf_state_tl }
+ \str_case:Vnn \__mhchem_cf_state_tl
{
{ s } { }
{ 1 }
{
\tl_put_right:Nx \__mhchem_cf_result_tl
- { \exp_not:N \mhchem@mathOrText { \exp_not:N \mhchem@cf@frac \exp_not:V \__mhchem_cf_element_tl / \exp_not:N \mhchem@END { \mhchem@option@skipAfterFracAmount } } }
+ {
+ \exp_not:N \mhchem@mathOrText {
+ \exp_not:N \mhchem@cf@frac
+ \exp_not:V \__mhchem_cf_element_tl / \exp_not:N \mhchem@END
+ { \mhchem@option@skipAfterFracAmount } }
+ }
}
{ 9 }
{
\tl_put_right:Nx \__mhchem_cf_result_tl
- { \exp_not:N \mhchem@mathOrText { \exp_not:N \mhchem@cf@frac \exp_not:V \__mhchem_cf_element_tl / \exp_not:N \mhchem@END {} } }
+ {
+ \exp_not:N \mhchem@mathOrText {
+ \exp_not:N \mhchem@cf@frac
+ \exp_not:V \__mhchem_cf_element_tl /
+ \exp_not:N \mhchem@END
+ {} }
+ }
}
}
{
@@ -1893,19 +2265,31 @@
\tl_put_right:Nx \__mhchem_cf_result_tl
{
\exp_not:N \__mhchem_chemfive:nnnnnn
- { \exp_not:N \__mhchem_cf_replaceMath:n { \exp_not:V \__mhchem_cf_presup_tl } }
- { \exp_not:N \__mhchem_cf_replaceMath:n { \exp_not:V \__mhchem_cf_presub_tl } }
+ {
+ \exp_not:N \__mhchem_cf_replaceMath:n
+ { \exp_not:V \__mhchem_cf_presup_tl }
+ }
+ {
+ \exp_not:N \__mhchem_cf_replaceMath:n
+ { \exp_not:V \__mhchem_cf_presub_tl }
+ }
{ \exp_not:V \__mhchem_cf_element_tl }
- { \exp_not:N \__mhchem_cf_replaceMathMinusDot:n { \exp_not:V \__mhchem_cf_supA_tl } }
- { \exp_not:N \__mhchem_cf_replaceMath:n { \exp_not:V \__mhchem_cf_sub_tl } }
- { \exp_not:N \__mhchem_cf_replaceMathMinusDot:n { \exp_not:V \__mhchem_cf_sup_tl } }
+ {
+ \exp_not:N \__mhchem_cf_replaceMathMinusDot:n
+ { \exp_not:V \__mhchem_cf_supA_tl }
+ }
+ {
+ \exp_not:N \__mhchem_cf_replaceMath:n
+ { \exp_not:V \__mhchem_cf_sub_tl }
+ }
+ {
+ \exp_not:N \__mhchem_cf_replaceMathMinusDot:n
+ { \exp_not:V \__mhchem_cf_sup_tl }
+ }
}
}
}
-\cs_new:Npn \__mhchem_cf_output_aux:NV #1#2 {
- #1 { #2 }
-}
-\cs_new:Nn \__mhchem_cf_resetOutput:
+\cs_new_protected:Npn \__mhchem_cf_resetOutput:
{
\tl_clear:N \__mhchem_cf_presup_tl
\tl_clear:N \__mhchem_cf_presub_tl
@@ -1914,7 +2298,7 @@
\tl_clear:N \__mhchem_cf_sub_tl
\tl_clear:N \__mhchem_cf_sup_tl
}
-\cs_new:Nn \__mhchem_cf_outputAndReset:
+\cs_new_protected:Npn \__mhchem_cf_outputAndReset:
{
\__mhchem_cf_output:
\__mhchem_cf_resetOutput:
@@ -1939,35 +2323,47 @@
%%% replaceMath
\tl_new:N \__mhchem_cf_replaceMath_result_tl
-\cs_new:Npn \__mhchem_cf_replaceMath:n #1
+\cs_new_protected:Npn \__mhchem_cf_replaceMath:n #1
{
\tl_clear:N \__mhchem_cf_replaceMath_result_tl
\__mhchem_cf_replaceMath_loop: #1 \q_recursion_stop
\__mhchem_cf_replaceMath_result_tl
}
-\cs_new:Nn \__mhchem_cf_replaceMath_loop:
+\cs_new_protected:Npn \__mhchem_cf_replaceMath_loop:
{
\peek_meaning:NTF \q_recursion_stop
{ \use_none:n }
{
- \peek_catcode_remove:oTF \c_math_toggle_token % math $
- { \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_replaceMath_result_tl \__mhchem_cf_replaceMath_loop: }
+ \peek_catcode_remove:NTF \c_math_toggle_token % math $
{
- \peek_catcode:oTF \c_group_begin_token
- { \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_replaceMath_result_tl \__mhchem_cf_replaceMath_loop: }
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_replaceMath_result_tl
+ \__mhchem_cf_replaceMath_loop:
+ }
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_replaceMath_result_tl \__mhchem_cf_replaceMath_loop:
- }}}
+ \peek_catcode:NTF \c_group_begin_token
+ {
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_replaceMath_result_tl
+ \__mhchem_cf_replaceMath_loop:
+ }
+ % else
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_replaceMath_result_tl
+ \__mhchem_cf_replaceMath_loop:
+ }
+ }}
}
%%% replaceMathMinusDot
\tl_new:N \__mhchem_cf_replaceMathMinusDot_result_tl
-\cs_new:Npn \__mhchem_cf_replaceMathMinusDot:n #1
+\cs_new_protected:Npn \__mhchem_cf_replaceMathMinusDot:n #1
{
\tl_clear:N \__mhchem_cf_replaceMathMinusDot_result_tl
\__mhchem_cf_replaceMathMinusDot_loop: #1 \q_recursion_stop
\__mhchem_cf_replaceMathMinusDot_result_tl
}
-\cs_new:Nn \__mhchem_cf_replaceMathMinusDot_loop:
+\cs_new_protected:Npn \__mhchem_cf_replaceMathMinusDot_loop:
{
\peek_meaning:NTF \q_recursion_stop
{ \use_none:n }
@@ -1984,21 +2380,32 @@
{ \ensuremath{\textbf{\fontfamily{cmr}\selectfont\textperiodcentered}} }
\__mhchem_cf_replaceMathMinusDot_loop:
}{
- \peek_catcode_remove:oTF \c_math_toggle_token % math $
- { \__mhchem_loopHelper_appendMath:NNw \__mhchem_cf_replaceMathMinusDot_result_tl \__mhchem_cf_replaceMathMinusDot_loop: }
+ \peek_catcode_remove:NTF \c_math_toggle_token % math $
{
- \peek_catcode:oTF \c_group_begin_token
- { \__mhchem_loopHelper_appendNextGroup:NNn \__mhchem_cf_replaceMathMinusDot_result_tl \__mhchem_cf_replaceMathMinusDot_loop: }
+ \__mhchem_loopHelper_appendMathB:NNw
+ \__mhchem_cf_replaceMathMinusDot_result_tl
+ \__mhchem_cf_replaceMathMinusDot_loop:
+ }
+ {
+ \peek_catcode:NTF \c_group_begin_token
{
- \__mhchem_loopHelper_appendNextToken:NNn \__mhchem_cf_replaceMathMinusDot_result_tl \__mhchem_cf_replaceMathMinusDot_loop:
- }}}}}
+ \__mhchem_loopHelper_appendNextGroup:NNn
+ \__mhchem_cf_replaceMathMinusDot_result_tl
+ \__mhchem_cf_replaceMathMinusDot_loop:
+ }
+ % else
+ {
+ \__mhchem_loopHelper_appendNextToken:NNn
+ \__mhchem_cf_replaceMathMinusDot_result_tl
+ \__mhchem_cf_replaceMathMinusDot_loop:
+ }
+ }}}}
}
-
%%%%%%%%%%%%%%%%%%%%%
%%% @chemfive %%%
%%%%%%%%%%%%%%%%%%%%%
-\cs_new:Npn \__mhchem_chemfive:nnnnnn #1#2#3#4#5#6
+\cs_new_protected:Npn \__mhchem_chemfive:nnnnnn #1#2#3#4#5#6
{
\mhchem@prepostscript%
{\mhchem@mathOrText{\smash[t]{2+}}}%
@@ -2012,7 +2419,6 @@
}
\ExplSyntaxOff
-
%%% @prepostscript
\newlength\mhchem@prepostscript@tmp@i%
\newlength\mhchem@prepostscript@tmp@ii%
@@ -2112,7 +2518,6 @@
\kern\mhchem@minispace@tmp%
}
-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% Package Options %%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -2145,7 +2550,6 @@
\define@key{mhchem}{minus-sidebearing-left}{\setlength\mhchem@option@minussidebearingleft{#1}}
\define@key{mhchem}{minus-sidebearing-right}{\setlength\mhchem@option@minussidebearingright{#1}}
-
\mhchem@definearrows{font}
\define@key{mhchem}{arrows}{%
\ifthenelse{\equal{pgf}{#1} \or \equal{pgf-filled}{#1}}{%
@@ -2219,4 +2623,4 @@
\newcommand*\mhchem@cmath[1]{\ensuremath{\text{\ensuremath{#1}}}}%
\newcommand*\cmath[1]{\mhchem@cmath{#1}}
\DeclareRobustCommand\cf[2][]{\mhchem@cf[#1]{#2}}
-\fi \ No newline at end of file
+\fi