diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/mhchem/mhchem.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/mhchem/mhchem.sty | 1815 |
1 files changed, 900 insertions, 915 deletions
diff --git a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty index 831a8cf29a6..9f8d8f2fc34 100644 --- a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty +++ b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty @@ -1,13 +1,12 @@ %% mhchem.sty -%% Copyright 2004-2011 M.a-r.t-i.n H.e-n.s-e.l +%% Copyright 2004-2013 Martin Hensel % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License version 1.3c -% which can be found at -% http://www.latex-project.org/lppl/lppl-1-3c.txt +% which is included as lppl-1-3c.txt. % % This work has the LPPL maintenance status "maintained". -% The Current Maintainer of this work is M.a-r.t-i.n H.e-n.s-e.l. +% The Current Maintainer of this work is Martin Hensel. % % ( In order to fight spam, the maintainer's contact ) % ( information is "encrypted" with ROT13. ) @@ -25,319 +24,636 @@ % | Treznal % `---------- % -% This work consists of the files mhchem.sty, rsphrase.sty, -% mhchem.pdf and legal.txt. +% This work consists of all files listed in manifest.txt. % % -\ProvidesPackage{mhchem}[2011/06/03 v3.11 for typesetting chemical formulae] +\ProvidesPackage{mhchem}[2013/06/17 v3.12 for typesetting chemical formulae] \RequirePackage{ifthen} \RequirePackage{calc}[1998/07/07] \RequirePackage{twoopt} \RequirePackage{amsmath} \RequirePackage{keyval} \RequirePackage{graphics} +\RequirePackage{pdftexcmds} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% misc %%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \DeclareMathSymbol{\mhchem@hyphen}{0}{operators}{45} +\def\mhchem@END{\mhchem@END} +\def\mhchem@macro{} +\def\mhchem@empty{} +\def\mhchem@gobble#1{} %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% \cee %%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newcommand*{\cee}[1]{% - \ifnum 1<\mhchem@option@version% - \def\mhchem@ce@out{}% - {\mhchem@ce@v#1\mhchem@empty\\\mhchem@END\mhchem@ENDEND}% - \ensuremath{% - \mhchem@ce@out% - }% - \else% - \PackageWarningNoLine{mhchem}{% - The \string\cee{} command of mhchem is only available\MessageBreak - when you secify [version=2] or greater}% - \fi% + \def\mhchem@ce@out{}% + {\mhchem@cee@i#1\mhchem@empty\\\mhchem@END\mhchem@ENDEND}% + \ensuremath{% + \mhchem@ce@out% + }% }% -\def\mhchem@ce@v#1\\#2#3\mhchem@ENDEND{% +\def\mhchem@cee@i#1\\#2#3\mhchem@ENDEND{% \ifx\mhchem@END#2% - \mhchem@ce@vii#1&\mhchem@END\mhchem@ENDEND% + \mhchem@cee@ii#1&\mhchem@END\mhchem@ENDEND% \else% - \mhchem@ce@vii#1&\mhchem@END\mhchem@ENDEND% + \mhchem@cee@ii#1&\mhchem@END\mhchem@ENDEND% \g@addto@macro\mhchem@ce@out{\\}% - \mhchem@ce@v#2#3\mhchem@ENDEND% + \mhchem@cee@i#2#3\mhchem@ENDEND% \fi% } -\long\def\mhchem@ce@vii#1#3\mhchem@ENDEND{% +\long\def\mhchem@cee@ii#1#3\mhchem@ENDEND{% \ifx\mhchem@END#2% - \g@addto@macro\mhchem@ce@out{\ce@main{#1}}% + \g@addto@macro\mhchem@ce@out{\ce{#1}}% \else% - \g@addto@macro\mhchem@ce@out{\ce@main{#1}}% + \g@addto@macro\mhchem@ce@out{\ce{#1}}% \g@addto@macro\mhchem@ce@out{&}% - \mhchem@ce@vii#2#3\mhchem@ENDEND% - \fi% + \mhchem@cee@ii#2#3\mhchem@ENDEND% + \fi% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% global helpers %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\mhchem@appendToks#1#2{% + #1=\expandafter{\the#1#2}% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%% \ce %%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% - -\def\mhchem@protect{\protect\noexpand\protect}% - -\newcommand\ce[1]{\mhchem@ce@xiii{\mhchem@ce@viii#1 \mhchem@END\mhchem@ENDEND}}% -% -% -\def\mhchem@ce@viii#1 #2\mhchem@ENDEND{% - \ifx\mhchem@END#2% - \ifx\@empty#1\@empty - \else - \mhchem@ce@x#1\mhchem@END\mhchem@ENDEND% - \fi - \else% - \mhchem@ce@x#1\mhchem@END\mhchem@ENDEND% - \space\mhchem@ce@viii#2\mhchem@ENDEND% - \fi -} -\def\mhchem@ce@x#1#2\mhchem@ENDEND{% - \ifx\@empty#1\@empty% - \mhchem@ce@xi{}\mhchem@END\mhchem@ENDEND% - \else%\ifx\mhchem@END#1\else - \mhchem@ce@xi#1\mhchem@END\mhchem@ENDEND% - \fi%\fi% - \ifx\mhchem@END#2% +\DeclareRobustCommand\ce[1]{\mhchem@ce{#1}} + +\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% + +\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% - \mhchem@ce@x#2\mhchem@ENDEND% + \ensuremath{\the\mhchem@ce@result}% \fi% + \egroup% } -\def\mhchem@ce@xi#1#2\mhchem@ENDEND{% - \ifx\mhchem@END#2% - \ifx\@empty#1\@empty% - {}% - \else\if\noexpand#1##% - \mhchem@protect\tbond% +\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@protect#1% - \fi\fi% + \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% - {\mhchem@ce@xii#1#2}% - \fi% + \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@xii#1\mhchem@END{\mhchem@ce@viii#1 \mhchem@END\mhchem@ENDEND}% -\DeclareRobustCommand\mhchem@ce@xiii[1]{% - \bgroup% - \ifnum 4>\mhchem@option@version% - \def\hyphen{\mhchem@hyphen}% +\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% - \def\mhchem@protect{\noexpand}% - \edef\mhchem@tmp{#1}% - % - \expandafter\ce@main\expandafter{\mhchem@tmp}% - \egroup } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% arrows %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%% - -\DeclareRobustCommand*{\ce@main}[1]{% - \bgroup% - \ifnum 1<\mhchem@option@version% - \ifmmode\else\def\mhchem@option@alwaystextmode{1}\fi% - \fi% - \def\bond{}\def\sbond{}\def\dbond{}\def\tbond{}% - \ifx\@empty#1\@empty\else% - \ifmmode\else\mhchem@option@textFont\fi% - \ensuremath{% - \mhchem@ce@xx#1 \mhchem@END\mhchem@ENDEND% - }% - \fi% - \egroup% -}% +\def\mhchem@arrow@minlength{{2em}}% -\def\mhchem@ce@xx#1 #2\mhchem@ENDEND{% - \mhchem@ce@i#1\mhchem@empty\mhchem@ENDEND% - \ifx\mhchem@END#2% - \else% - \mhchem@ce@xx#2 \mhchem@ENDEND% - \fi% -} -\def\mhchem@ce@i#1#2\mhchem@ENDEND{% - \ifcat a#1 {\mhchem@ce@ii{#1#2}}% - \else\ifx 1#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 2#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 3#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 4#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 5#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 6#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 7#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 8#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 9#1{\mhchem@ce@ii{#1#2}}% - \else\ifx 0#1{\mhchem@ce@ii{#1#2}}% - \else\ifx (#1{\mhchem@ce@ii{#1#2}}% - \else\ifx [#1{\mhchem@ce@ii{#1#2}}% - \else\ifx \{#1{\mhchem@ce@ii{#1#2}}% - \else\ifx ^#1{\mhchem@ce@ii{#1#2}}% - \else\if ^#1{\mhchem@ce@ii{#1#2}}% - \else\ifx _#1{\mhchem@ce@ii{#1#2}}% - \else\ifx $#1{\mhchem@ce@ii{#1#2}}% - \else\ifx -#1{\ifx\@empty#2\@empty#1\else\mhchem@ce@dash#2\mhchem@END\fi}% - \else\if\noexpand#1<{\ifx\@empty#2\@empty#1\else\mhchem@ce@lt#2\mhchem@END\fi}% - \else\ifx +#1+ \mhchem@ce@ii{#2}% - \else\ifx \protect#1{\mhchem@ce@ii{#1#2}}% - % - \else\ifx\ce#1 \mhchem@ce@i #2 \mhchem@END% - \else\ifx\cf#1 \mhchem@cf{#2}% - \else\ifx\cmath#1 \mhchem@ce@cmath#2\mhchem@END% - \else\ifx\bond#1{\mhchem@ce@ii{#1#2}}% - \else\ifx\sbond#1{\mhchem@ce@ii{#1#2}}% - \else\ifx\dbond#1{\mhchem@ce@ii{#1#2}}% - \else\ifx\tond#1{\mhchem@ce@ii{#1#2}}% - \else\ifx\label#1 \mhchem@ce@label#2\mhchem@END% - \else\ifx\tag#1 \mhchem@ce@tag#2\mhchem@END% - % - \else #1#2% - \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\fi\fi\fi\fi% -} - -% -\def\mhchem@ce@dash#1#2\mhchem@END{% - \if\noexpand#1>% - {}\ifx\@empty#2\@empty\mhchem@gives#2% - \else\mhchem@ce@deploycommand{mhchem@gives}#2{}\mhchem@END\fi{}% - \else% - -#1#2% - \fi% -}% -\def\mhchem@ce@lt#1#2\mhchem@END{% - \ifx =#1\mhchem@ce@equal#2\mhchem@END% - \else\if\noexpand#1<\mhchem@ce@equiL#2\mhchem@END% - \else\ifx-#1% - \ifx\@empty#2\@empty% - {}\mhchem@givesleft#2{}% +%%% 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% - \mhchem@ce@dashtwo#2\mhchem@END% + \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% - <#1#2% + \def\mhchem@arrow@deploy@action{}% + \PackageError{mhchem}{Arrow type not supported}% \fi\fi\fi% + \mhchem@arrow@deploy@action% } -\def\mhchem@ce@equal#1#2\mhchem@END{% - \if\noexpand#1>% (<=)>... - \ifx\@empty#2\@empty{}\mhchem@equilibrium#2{}% - \else% - \mhchem@ce@equi#2\mhchem@END% - \fi% - \else% - <=#1#2% - \fi% +\def\mhchem@arrow@yields{% + \mhchem@arrow@deployType={yields}% + \futurelet\lookahead\mhchem@arrow@deploy% } -\def\mhchem@ce@equi#1#2\mhchem@END{% - \if\noexpand#1>% - {}\ifx\@empty#2\@empty\mhchem@equilibriumRight#2% - \else\mhchem@ce@deploycommand{mhchem@equilibriumRight}#2{}\mhchem@END\fi{}% - \else% - {}\mhchem@ce@deploycommand{mhchem@equilibrium}#1#2{}\mhchem@END{}% - \fi% +\def\mhchem@arrow@yieldsLeft{% + \mhchem@arrow@deployType={yieldsLeft}% + \futurelet\lookahead\mhchem@arrow@deploy% } -\def\mhchem@ce@equiL#1#2\mhchem@END{% - \ifx =#1\mhchem@ce@equiLi#2\mhchem@END% - \else<=#1#2% - \fi% +\def\mhchem@arrow@yieldsLeftRight{% + \mhchem@arrow@deployType={yieldsLeftRight}% + \futurelet\lookahead\mhchem@arrow@deploy% } -\def\mhchem@ce@equiLi#1#2\mhchem@END{% - \if\noexpand#1>% (<<=)> - {}\ifx\@empty#2\@empty\mhchem@equilibriumLeft#2% - \else\mhchem@ce@deploycommand{mhchem@equilibriumLeft}#2{}\mhchem@END\fi{}% - \else% - <<=#1#2% - \fi% +\def\mhchem@arrow@mesomerism{% + \mhchem@arrow@deployType={mesomerism}% + \futurelet\lookahead\mhchem@arrow@deploy% } -\def\mhchem@ce@dashtwo#1#2\mhchem@END{% - \if\noexpand#1>% - {}\ifx\@empty#2\@empty\mhchem@mesomeric#2% - \else\mhchem@ce@deploycommand{mhchem@mesomeric}#2{}\mhchem@END\fi{}% - \else% - {}\mhchem@ce@deploycommand{mhchem@givesleft}#1#2{}\mhchem@END{}% - \fi% +\def\mhchem@arrow@equilibrium{% + \mhchem@arrow@deployType={equilibrium}% + \futurelet\lookahead\mhchem@arrow@deploy% } -\def\mhchem@ce@deploycommand#1#2#3\mhchem@END{% - \ifx T#2\csname#1T\endcsname#3% - \else\ifx C#2\csname#1C\endcsname#3% - \else\csname#1\endcsname#2#3\fi\fi% +\def\mhchem@arrow@equilibriumRight{% + \mhchem@arrow@deployType={equilibriumRight}% + \futurelet\lookahead\mhchem@arrow@deploy% } - -\def\mhchem@ce@ii#1{% - \mhchem@ce@iii#1% +\def\mhchem@arrow@equilibriumLeft{% + \mhchem@arrow@deployType={equilibriumLeft}% + \futurelet\lookahead\mhchem@arrow@deploy% } -\newtoks\tok@mhchem@ce@iii% -\def\mhchem@ce@iii@tmp@i{}% -\def\mhchem@ce@iii@tmp@ii{}% -\def\mhchem@ce@iii#1\mhchem@empty{% - \tok@mhchem@ce@iii{#1}% - \edef\mhchem@ce@iii@tmp@i{\the\tok@mhchem@ce@iii}% - % - \def\mhchem@ce@iii@tmp@ii{(^)}% - \ifx\mhchem@ce@iii@tmp@i\mhchem@ce@iii@tmp@ii% - {}\mathop{\uparrow}{}% - \else\def\mhchem@ce@iii@tmp@ii{^}% - \ifx\mhchem@ce@iii@tmp@i\mhchem@ce@iii@tmp@ii% - {}\mathop{\uparrow}{}% - \else\def\mhchem@ce@iii@tmp@ii{(v)}% - \ifx\mhchem@ce@iii@tmp@i\mhchem@ce@iii@tmp@ii% - {}\mathop{\downarrow}{}% - \else\def\mhchem@ce@iii@tmp@ii{v}% - \ifx\mhchem@ce@iii@tmp@i\mhchem@ce@iii@tmp@ii% - {}\mathop{\downarrow}{}% - \else% - \mhchem@cf{#1}% - \fi\fi\fi\fi% -}% - -\def\mhchem@ce@cmath#1#2\mhchem@END{\mhchem@cmath{#1}\mhchem@cf{#2}} -\def\mhchem@ce@label#1#2\mhchem@END{\label{#1}\mhchem@cf{#2}} -\def\mhchem@ce@tag#1#2\mhchem@END{\tag{#1}\mhchem@cf{#2}} -%%%%%%%%%%%%% -%%% arrows - -\newlength{\mhchem@arrowminlength} -\setlength{\mhchem@arrowminlength}{1em} -%TODO: adapt min length to each of the math modes +%%% 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@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][][]{% + \ensuremath{{}\mhchem@ext@arrow{9}{5}{##1}{9}{5}{##2}{\mhchem@arrow@minlength}{\leftarrowfill@}{}}}% + \renewcommandtwoopt*\mhchem@arrow@yieldsLeftRightM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##2}% + {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\rightarrowfill@}$}}}% + {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{\hphantom{##2}}{\mhchem@arrow@minlength}{\rightarrowfill@}$}}}% + \@ifempty{##1}% + {\raisebox{-.44ex}{$\mhchem@ext@arrow{9}{9}{}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftarrowfill@}$}}% + {\raisebox{-.44ex}{$\mhchem@ext@arrow{9}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftarrowfill@}$}}% + }{}}}% + \renewcommandtwoopt*\mhchem@arrow@mesomerismM[2][][]{% + \ensuremath{{}\mhchem@ext@arrow{9}{9}{##1}{9}{9}{##2}{\mhchem@arrow@minlength}{\leftrightarrowfill@}{}}}% + \renewcommandtwoopt*\mhchem@arrow@equilibriumM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##2}% + {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow{5}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}}% + {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{5}{\hphantom{##2}}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}}% + \@ifempty{##1}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow{9}{9}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow{5}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}% + }{}}}% + \renewcommandtwoopt*\mhchem@arrow@equilibriumRightM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##1}{% if only above, center optically; if above AND below, center exactly to avoid misalignment + \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondownfill@}$}}% + \@ifempty{##2}% + {\raisebox{.22ex}{$\mhchem@ext@arrow{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}% + {\raisebox{.22ex}{$\mhchem@ext@arrow{0}{0}{}{9}{5}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}% + }{% + \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow{5}{9}{\hphantom{##1}\kern-1em}{9}{9}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondownfill@}$}}% + \@ifempty{##2}% + {\raisebox{.22ex}{$\mhchem@ext@arrow{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}% + {\raisebox{.22ex}{$\mhchem@ext@arrow{9}{9}{##1}{9}{9}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonupfill@}$}}% + }% + }{}}}% + \renewcommandtwoopt*\mhchem@arrow@equilibriumLeftM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##2}{% + \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonupfill@}$}}% + \@ifempty{##1}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow{5}{9}{\hphantom{##1}\kern1em}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}% + }{% + \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow{9}{9}{##1}{5}{9}{\hphantom{##2}\kern-1em}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonupfill@}$}}% + \@ifempty{##1}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow{9}{9}{\hphantom{##1}\kern1em}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondownfill@}$}}% + }% + }{}}}% + %%% pgf + }{\ifthenelse{\equal{#1}{pgf} \or \equal{#1}{pgf-filled}}{% + \renewcommandtwoopt*\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][][]{% + \ensuremath{{}\mhchem@ext@arrow@pgf{9}{5}{##1}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}{}}}% + \renewcommandtwoopt*\mhchem@arrow@yieldsLeftRightM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##2}% + {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\mhchem@rightarrow@pgf}$}}}% + {\rlap{\raisebox{.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{\hphantom{##2}}{\mhchem@arrow@minlength}{\mhchem@rightarrow@pgf}$}}}% + \@ifempty{##1}% + {\raisebox{-.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}$}}% + {\raisebox{-.44ex}{$\mhchem@ext@arrow@pgf{9}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftarrow@pgf}$}}% + }{}}}% + \renewcommandtwoopt*\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][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##2}% + {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{##1}{9}{9}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}}% + {\rlap{\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{5}{\hphantom{##2}}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}}% + \@ifempty{##1}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{\hphantom{##1}}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}% + }{}}}% + \renewcommandtwoopt*\mhchem@arrow@equilibriumRightM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##1}{% if only above, center optically; if above AND below, center exactly to avoid misalignment + \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondown@pgf}$}}% + \@ifempty{##2}% + {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}% + {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{9}{5}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}% + }{% + \rlap{\raisebox{-.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{5}{9}{\hphantom{##1}\kern-1em}{9}{9}{##2}{\mhchem@arrow@minlength-1em}{\mhchem@leftharpoondown@pgf}$}}% + \@ifempty{##2}% + {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}% + {\raisebox{.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{##1}{9}{9}{\hphantom{##2}\kern1em}{\mhchem@arrow@minlength}{\mhchem@rightharpoonup@pgf}$}}% + }% + }{}}}% + \renewcommandtwoopt*\mhchem@arrow@equilibriumLeftM[2][][]{% + \ensuremath{{}\mathrel{% + \@ifempty{##2}{% + \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{5}{9}{##1}{0}{0}{}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonup@pgf}$}}% + \@ifempty{##1}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{5}{9}{\hphantom{##1}\kern1em}{0}{0}{}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}% + }{% + \rlap{\raisebox{.22ex}{$\kern0.5em\mhchem@ext@arrow@pgf{9}{9}{##1}{5}{9}{\hphantom{##2}\kern-1em}{\mhchem@arrow@minlength-1em}{\mhchem@rightharpoonup@pgf}$}}% + \@ifempty{##1}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{0}{0}{}{9}{5}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}% + {\raisebox{-.22ex}{$\mhchem@ext@arrow@pgf{9}{9}{\hphantom{##1}\kern1em}{9}{9}{##2}{\mhchem@arrow@minlength}{\mhchem@leftharpoondown@pgf}$}}% + }% + }{}}}% + \ifthenelse{\equal{#1}{pgf}}{% + \let\mhchem@rightarrow@pgf\mhchem@rightarrow@pgfopen% + \let\mhchem@leftarrow@pgf\mhchem@leftarrow@pgfopen% + \let\mhchem@leftrightarrow@pgf\mhchem@leftrightarrow@pgfopen% + \let\mhchem@rightharpoonup@pgf\mhchem@rightharpoonup@pgfopen% + \let\mhchem@leftharpoondown@pgf\mhchem@leftharpoondown@pgfopen% + }{% + \let\mhchem@rightarrow@pgf\mhchem@rightarrow@pgffilled% + \let\mhchem@leftarrow@pgf\mhchem@leftarrow@pgffilled% + \let\mhchem@leftrightarrow@pgf\mhchem@leftrightarrow@pgffilled% + \let\mhchem@rightharpoonup@pgf\mhchem@rightharpoonup@pgffilled% + \let\mhchem@leftharpoondown@pgf\mhchem@leftharpoondown@pgffilled% + }% + }{% + \PackageError{mhchem}{The option font=#1 is not supported}% + }}% +} -%%% for font arrows -%%%%% idea taken from http://www.texnik.de/misc/harpoon.phtml +%%% Arrow compositions with text or chemistry +\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}]}}% +}% +\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}]}}% +}% +\newcommandtwoopt*\mhchem@arrow@yieldsT[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@yieldsC[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@yieldsM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@yieldsLeftT[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@yieldsLeftC[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@yieldsLeftM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@yieldsLeftRightT[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@yieldsLeftRightC[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@yieldsLeftRightM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@mesomerismT[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}% +\newcommandtwoopt*\mhchem@arrow@mesomerismC[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@mesomerismM\the\mhchem@arrow@params}% +\newcommandtwoopt*{\mhchem@arrow@equilibriumT}[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}% +\newcommandtwoopt*{\mhchem@arrow@equilibriumC}[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@equilibriumM\the\mhchem@arrow@params}% +\newcommandtwoopt*{\mhchem@arrow@equilibriumRightT}[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}% +\newcommandtwoopt*{\mhchem@arrow@equilibriumRightC}[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@equilibriumRightM\the\mhchem@arrow@params}% +\newcommandtwoopt*{\mhchem@arrow@equilibriumLeftT}[2][][]{% + \mhchem@arrow@setParamsT{#1}{#2}% + \expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}% +\newcommandtwoopt*{\mhchem@arrow@equilibriumLeftC}[2][][]{% + \mhchem@arrow@setParamsC{#1}{#2}% + \expandafter\mhchem@arrow@equilibriumLeftM\the\mhchem@arrow@params}% + +%%% Font arrows +\def\mhchem@ext@arrow#1#2#3#4#5#6#7#8{% adaption of amsmath's ext@arrow + \mathrel{% + \mathop{\makebox[#7]{#8\displaystyle}}% + \limits% + \@ifnotempty{#3}{^{\mkern#1mu#3\mkern#2mu}}% + \@ifnotempty{#6}{_{\mkern#4mu#6\mkern#5mu}}% + }% +} \def\mhchem@rightharpoonupfill@{\arrowfill@\relbar\relbar\rightharpoonup} \def\mhchem@leftharpoondownfill@{\arrowfill@\leftharpoondown\relbar\relbar} -\newcommand*\mhchem@xrightleftharpoons[2][]{% + +%%% pgf arrows +\newlength{\mhchem@arrowlength@pgf} +\def\mhchem@ext@arrow@pgf#1#2#3#4#5#6#7#8{% + \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{% + \mhchem@ext@arrow{#1}{#2}{#3}{#4}{#5}{#6}{#7}{\rightarrowfill@}% + }}}% \mathrel{% - \rlap{\protect\raisebox{.22ex}{$\ext@arrow 3399\mhchem@rightharpoonupfill@{}{\mhchem@mathbox[#1]{#2}}$}}% - \raisebox{-.22ex}{$\ext@arrow 3399\mhchem@leftharpoondownfill@{#1}{\hphantom{#2}}$}}}% -\newsavebox\mhchem@arrows@box% -\newcommand*\mhchem@xlongrightshortleftharpoons[2][]{\mathrel{% - \sbox{\mhchem@arrows@box}% - {$\mkern9mu\ext@arrow 3399\mhchem@leftharpoondownfill@% - {#1}{\hphantom{#2}\mkern-6mu\mkern-12mu}$}% - \rlap{\protect\raisebox{-.22ex}{\usebox{\mhchem@arrows@box}}}% - \protect\raisebox{.22ex}{$\ext@arrow 3399\mhchem@rightharpoonupfill@% - {\hphantom{\usebox{\mhchem@arrows@box}}\mkern-6mu}{#2}$}% - }} -\newcommand*\mhchem@xshortrightlongleftharpoons[2][]{\mathrel{% - \sbox{\mhchem@arrows@box}% - {$\mkern9mu\ext@arrow 3399\mhchem@rightharpoonupfill@% - {\hphantom{#1}\mkern-6mu\mkern-12mu}{#2}$}% - \rlap{\protect\raisebox{.22ex}{\usebox{\mhchem@arrows@box}}}% - \protect\raisebox{-.22ex}{$\ext@arrow 3399\mhchem@leftharpoondownfill@% - {#1}{\hphantom{\usebox{\mhchem@arrows@box}}\mkern-6mu}$}% - }} -%\newcommand*\mhchem@xleftrightarrow[2][]{\ext@arrow 3095\leftrightarrowfill@{#1}{#2}} - - -%%% for pgf arrows -\newcommand*\mhchem@rightarrow@pgf[1]{% + \mathop{\kern0.7pt#8{\mhchem@arrowlength@pgf-1.8pt}\kern0.7pt}% + \limits% + \@ifnotempty{#3}{^{\mkern#1mu#3\mkern#2mu}}% + \@ifnotempty{#6}{_{\mkern#4mu#6\mkern#5mu}}% + }% +}% +\newcommand*\mhchem@rightarrow@pgfopen[1]{% \begin{tikzpicture}[baseline]% \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex] @@ -346,7 +662,7 @@ arc (110:162:0.6ex); \end{tikzpicture}% }% -\newcommand*\mhchem@leftarrow@pgf[1]{% +\newcommand*\mhchem@leftarrow@pgfopen[1]{% \begin{tikzpicture}[baseline]% \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex] @@ -355,47 +671,34 @@ arc (-70:-18:0.6ex); \end{tikzpicture}% }% -\newcommand*\mhchem@leftrightarrow@pgf[1]{% +\newcommand*\mhchem@leftrightarrow@pgfopen[1]{% \begin{tikzpicture}[baseline]% \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex] - (0cm,0.575ex) - arc (70:18:0.6ex) arc (18:70:0.6ex) - arc (-70:-18:0.6ex) arc (-18:-70:0.6ex) - -- ++(#1,0cm) - arc (250:198:0.6ex) arc (198:250:0.6ex) - arc (110:162:0.6ex); + (0cm,0.575ex) + arc (70:18:0.6ex) arc (18:70:0.6ex) + arc (-70:-18:0.6ex) arc (-18:-70:0.6ex) + -- ++(#1,0cm) + arc (250:198:0.6ex) arc (198:250:0.6ex) + arc (110:162:0.6ex); \end{tikzpicture}% }% -\newcommand*\mhchem@leftrightharpoon@pgf[1]{% +\newcommand*\mhchem@rightharpoonup@pgfopen[1]{% \begin{tikzpicture}[baseline]% - \draw[use as bounding box] (0,0) (#1,1ex); - \draw[cap=round, join=round, line width=0.09ex] - (0cm,0.575ex+0.22ex) -- ++(#1,0cm) arc (250:198:0.9ex); - \draw[cap=round, join=round, line width=0.09ex] - (#1,0.575ex-0.22ex) -- ++(-#1,0cm) arc (70:18:0.9ex); - \end{tikzpicture}% -}% -\newcommand*\mhchem@longrightshortleftharpoons@pgf[1]{% - \begin{tikzpicture}[baseline]% - \draw[use as bounding box] (0,0) (#1,1ex); - \draw[cap=round, join=round, line width=0.09ex] - (0.0cm,0.575ex+0.22ex) -- ++(#1,0cm) arc (250:198:0.9ex); + \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex] - (#1+0.5em-1em,0.575ex-0.22ex) -- (0.5em,0.575ex-0.22ex) arc (70:18:0.9ex); + (0cm,0.575ex) -- ++(#1,0cm) arc (250:198:0.6ex); \end{tikzpicture}% -}% -\newcommand*\mhchem@shortrightlongleftharpoons@pgf[1]{% +}% +\newcommand*\mhchem@leftharpoondown@pgfopen[1]{% \begin{tikzpicture}[baseline]% - \draw[use as bounding box] (0,0) (#1,1ex); - \draw[cap=round, join=round, line width=0.09ex] - (0.5em,0.575ex+0.22ex) -- ++(#1-1em,0cm) arc (250:198:0.9ex); + \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex] - (#1,0.575ex-0.22ex) -- ++(-#1,0cm) arc (70:18:0.9ex); + (0cm,0.575ex) arc (70:18:0.6ex) arc (18:70:0.6ex) + -- ++(#1,0cm); \end{tikzpicture}% }% -%%% for pgf-filled arrows \newcommand*\mhchem@rightarrow@pgffilled[1]{% \begin{tikzpicture}[baseline]% \draw[use as bounding box] (0,0) (#1,0.85ex); @@ -426,253 +729,45 @@ \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] (0cm,0.575ex) -- ++(#1,0cm); \filldraw[cap=round, join=round, line width=0.09ex] - (#1,0.575ex) - -- ++(-0.6ex,0.2ex) -- ++(0.15ex,-0.2ex) - -- ++(-0.15ex,-0.2ex) - -- cycle; - \filldraw[cap=round, join=round, line width=0.09ex] (0cm,0.575ex) -- ++(0.6ex,0.2ex) -- ++(-0.15ex,-0.2ex) -- ++(+0.15ex,-0.2ex) - -- cycle; - \end{tikzpicture}% -}% -\newcommand*\mhchem@leftrightharpoon@pgffilled[1]{% - \begin{tikzpicture}[baseline]% - \draw[use as bounding box] (0,0) (#1,1ex); - \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] - (0cm,0.575ex+0.22ex) -- ++(#1,0cm); - \filldraw[cap=round, join=round, line width=0.09ex] - (#1,0.575ex+0.22ex) - -- ++(-0.6ex,0.25ex) -- ++(0.15ex,-0.25ex) -- cycle; - \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] - (0cm,0.575ex-0.22ex) -- ++(#1,0cm); \filldraw[cap=round, join=round, line width=0.09ex] - (0cm,0.575ex-0.22ex) - -- ++(0.6ex,-0.25ex) -- ++(-0.15ex,0.25ex) + (#1,0.575ex) + -- ++(-0.6ex,0.2ex) -- ++(0.15ex,-0.2ex) + -- ++(-0.15ex,-0.2ex) -- cycle; \end{tikzpicture}% -}% -\newcommand*\mhchem@longrightshortleftharpoons@pgffilled[1]{% +}% +\newcommand*\mhchem@rightharpoonup@pgffilled[1]{% \begin{tikzpicture}[baseline]% - \draw[use as bounding box] (0,0) (#1,1ex); + \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] - (0cm,0.575ex+0.22ex) -- ++(#1,0cm); + (0cm,0.575ex) -- ++(#1,0cm); \filldraw[cap=round, join=round, line width=0.09ex] - (#1,0.575ex+0.22ex) + (#1,0.575ex) -- ++(-0.6ex,0.25ex) -- ++(0.15ex,-0.25ex) -- cycle; - \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] - (0.5em,0.575ex-0.22ex) -- ++(#1-1em,0cm); - \filldraw[cap=round, join=round, line width=0.09ex] - (0.5em,0.575ex-0.22ex) - -- ++(0.6ex,-0.25ex) -- ++(-0.15ex,0.25ex) - -- cycle; \end{tikzpicture}% -}% -\newcommand*\mhchem@shortrightlongleftharpoons@pgffilled[1]{% +}% +\newcommand*\mhchem@leftharpoondown@pgffilled[1]{% \begin{tikzpicture}[baseline]% - \draw[use as bounding box] (0,0) (#1,1ex); - \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] - (0.5em,0.575ex+0.22ex) -- ++(#1-1em,0cm); - \filldraw[cap=round, join=round, line width=0.09ex] - (#1-0.5em,0.575ex+0.22ex) - -- ++(-0.6ex,0.25ex) -- ++(0.15ex,-0.25ex) - -- cycle; + \draw[use as bounding box] (0,0) (#1,0.85ex); \draw[cap=round, join=round, line width=0.09ex, shorten >=0.01ex] - (0cm,0.575ex-0.22ex) -- ++(#1,0cm); + (0cm,0.575ex) -- ++(#1,0cm); \filldraw[cap=round, join=round, line width=0.09ex] - (0cm,0.575ex-0.22ex) + (0cm,0.575ex) -- ++(0.6ex,-0.25ex) -- ++(-0.15ex,0.25ex) -- cycle; \end{tikzpicture}% }% -\newlength{\mhchem@arrowlength@pgf} -\newlength{\mhchem@arrowminlength@pgf} -%TODO: use \mhchem@arrowminlength -\def\mhchem@labeledarrow@pgf#1#2#3#4#5#6#7{% 1-4 muskips 5 arrow 6 text above 7 below - \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{% - \mkern#3mu% - \mathop{}% - \limits% - \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi% - #7\if0#2\else\mkern#2mu\fi}}% - \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi% - #6\if0#2\else\mkern#2mu\fi}}% - \mkern#4mu% - }}}% - % - \setlength\mhchem@arrowminlength@pgf{10pt+0.5em}% - \ifthenelse{\equal{mhchem@longrightshortleftharpoons@pgf}{#5}}{ - \setlength\mhchem@arrowminlength@pgf{1.85em}% - \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{% - \mkern#3mu% - \mathop{}% - \limits% - \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi% - #7\if0#2\else\mkern#2mu\fi}}% - \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi% - \hspace{1em}% %% - #6\if0#2\else\mkern#2mu\fi}}% - \mkern#4mu% - }}}% - }{}% - \ifthenelse{\equal{mhchem@shortrightlongleftharpoons@pgf}{#5}}{ - \setlength\mhchem@arrowminlength@pgf{1.85em}% - \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{% - \mkern#3mu% - \mathop{}% - \limits% - \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi% - \hspace{1em}% %% - #7\if0#2\else\mkern#2mu\fi}}% - \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi% - #6\if0#2\else\mkern#2mu\fi}}% - \mkern#4mu% - }}}% - }{}% - \ifthenelse{\equal{mhchem@longrightshortleftharpoons@pgffilled}{#5}}{ - \setlength\mhchem@arrowminlength@pgf{1.85em}% - \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{% - \mkern#3mu% - \mathop{}% - \limits% - \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi% - #7\if0#2\else\mkern#2mu\fi}}% - \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi% - \hspace{1em}% %% - #6\if0#2\else\mkern#2mu\fi}}% - \mkern#4mu% - }}}% - }{}% - \ifthenelse{\equal{mhchem@shortrightlongleftharpoons@pgffilled}{#5}}{ - \setlength\mhchem@arrowminlength@pgf{1.85em}% - \setlength\mhchem@arrowlength@pgf{\widthof{\ensuremath{% - \mkern#3mu% - \mathop{}% - \limits% - \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi% - \hspace{1em}% %% - #7\if0#2\else\mkern#2mu\fi}}% - \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi% - #6\if0#2\else\mkern#2mu\fi}}% - \mkern#4mu% - }}}% - }{}% - % - \ifdim\mhchem@arrowlength@pgf<\mhchem@arrowminlength@pgf% - \setlength\mhchem@arrowlength@pgf{\mhchem@arrowminlength@pgf}% - \fi% - \mathrel{\mkern#3mu\mathop{\csname#5\endcsname{\mhchem@arrowlength@pgf}% - }% - \limits - \@ifnotempty{#7}{^{\if0#1\else\mkern#1mu\fi% - #7\if0#2\else\mkern#2mu\fi}}% - \@ifnotempty{#6}{_{\if0#1\else\mkern#1mu\fi% - #6\if0#2\else\mkern#2mu\fi}}% - \mkern#4mu% - }%} -}% - -\newcommandtwoopt*\mhchem@gives[2][][]{} -\newcommandtwoopt*\mhchem@givesleft[2][][]{} -\newcommandtwoopt*\mhchem@mesomeric[2][][]{} -\newcommandtwoopt*\mhchem@equilibrium[2][][]{} -\newcommandtwoopt*\mhchem@equilibriumRight[2][][]{} -\newcommandtwoopt*\mhchem@equilibriumLeft[2][][]{} - -\newcommand\mhchem@definearrows[1]{% - %%% font - \ifthenelse{\equal{#1}{font}}{% - \renewcommandtwoopt*\mhchem@gives[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% - \xrightarrow% - [{##2}]% - {##1}}}% - \renewcommandtwoopt*\mhchem@givesleft[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% - \xleftarrow% - [{##2}]% - {##1}}}% - \renewcommandtwoopt*\mhchem@mesomeric[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% - \ext@arrow 3399\leftrightarrowfill@% - {##2}% - {##1}}}% - \renewcommandtwoopt*{\mhchem@equilibrium}[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% - \mhchem@xrightleftharpoons% - [{##2}]% - {##1}}}% - \renewcommandtwoopt*{\mhchem@equilibriumRight}[2][\hphantom{\makebox[\mhchem@arrowminlength]{}}][]{\ensuremath{% - \mhchem@xlongrightshortleftharpoons% - [{##2}]% - {##1}}}% - \renewcommandtwoopt*{\mhchem@equilibriumLeft}[2][][\hspace{\mhchem@arrowminlength}]{\ensuremath{% - \mhchem@xshortrightlongleftharpoons% - [{##2}]% - {##1}}}% - }{%%% pgf - \ifthenelse{\equal{#1}{pgf}}{% - \renewcommandtwoopt*\mhchem@gives[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{1.5}{5}{1.5}{1}{mhchem@rightarrow@pgf}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@givesleft[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{5}{1.5}{1}{1.5}{mhchem@leftarrow@pgf}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@mesomeric[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{5}{5}{1}{1}{mhchem@leftrightarrow@pgf}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@equilibrium[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{6}{6}{1}{1}{mhchem@leftrightharpoon@pgf}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@equilibriumRight[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{6}{6}{1}{1}{mhchem@longrightshortleftharpoons@pgf}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@equilibriumLeft[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{6}{6}{1}{1}{mhchem@shortrightlongleftharpoons@pgf}{##2}{##1}}}% - }{%%% pgf-filled - \ifthenelse{\equal{#1}{pgf-filled}}{% - \renewcommandtwoopt*\mhchem@gives[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{1.5}{7}{1.5}{1}{mhchem@rightarrow@pgffilled}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@givesleft[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{7}{1.5}{1}{1.5}{mhchem@leftarrow@pgffilled}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@mesomeric[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{7}{7}{1}{1}{mhchem@leftrightarrow@pgffilled}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@equilibrium[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{7}{7}{1}{1}{mhchem@leftrightharpoon@pgffilled}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@equilibriumRight[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{7}{7}{1}{1}{mhchem@longrightshortleftharpoons@pgffilled}{##2}{##1}}}% - \renewcommandtwoopt*\mhchem@equilibriumLeft[2][][]% - {\ensuremath{\mhchem@labeledarrow@pgf{7}{7}{1}{1}{mhchem@shortrightlongleftharpoons@pgffilled}{##2}{##1}}}% - }{% - \PackageError{mhchem}{The option font=#1 is not supported}% - }% - }}% -} - -\newcommandtwoopt*\mhchem@givesT[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@gives[\text{#1}][\text{#2}]}% -\newcommandtwoopt*\mhchem@givesC[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@gives[\ce@main{#1}][\ce@main{#2}]}% -\newcommandtwoopt*\mhchem@givesleftT[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@givesleft[\text{#1}][\text{#2}]}% -\newcommandtwoopt*\mhchem@givesleftC[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@givesleft[\ce@main{#1}][\ce@main{#2}]}% -\newcommandtwoopt*\mhchem@mesomericT[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@mesomeric[\text{#1}][\text{#2}]}% -\newcommandtwoopt*\mhchem@mesomericC[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@mesomeric[\ce@main{#1}][\ce@main{#2}]}% -\newcommandtwoopt*{\mhchem@equilibriumT}[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@equilibrium[\text{#1}][\text{#2}]} -\newcommandtwoopt*{\mhchem@equilibriumC}[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@equilibrium[\ce@main{#1}][\ce@main{#2}]} -\newcommandtwoopt*{\mhchem@equilibriumRightT}[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@equilibriumRight[\text{#1}][\text{#2}]} -\newcommandtwoopt*{\mhchem@equilibriumRightC}[2][\hspace{\mhchem@arrowminlength}][]% - {\mhchem@equilibriumRight[\ce@main{#1}][\ce@main{#2}]} -\newcommandtwoopt*{\mhchem@equilibriumLeftT}[2][][\hspace{\mhchem@arrowminlength}]% - {\mhchem@equilibriumLeft[\text{#1}][\text{#2}]} -\newcommandtwoopt*{\mhchem@equilibriumLeftC}[2][][\hspace{\mhchem@arrowminlength}]% - {\mhchem@equilibriumLeft[\ce@main{#1}][\ce@main{#2}]} +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% bonds %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%% -%%% bonds %%% -% \newlength\mhchem@bondwidth% \newlength\mhchem@bondheight% \newlength\mhchem@smallbondwidth@tmpA% @@ -694,46 +789,47 @@ \resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}\unskip% \resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}% \resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}}% - \phantom{\sbond}} + \phantom{\sbond}}% \def\mhchem@bond#1{% - % - \if ##\noexpand#1% - \tbond% - \else\ifx \tbond#1% + \ifnum\pdf@strcmp{#1}{-}=0% + \sbond% + \else\ifnum\pdf@strcmp{#1}{=}=0% + \dbond% + \else\ifnum\pdf@strcmp{#1}{##}=0% \tbond% - \else% - \ifthenelse{\equal{#1}{-}}{\sbond}{% - \ifthenelse{\equal{#1}{=}}{\dbond}{% - \ifthenelse{\equal{#1}{~}}{% + \else\ifnum\pdf@strcmp{#1}{~}=0% \mhchem@setbondwidth% - \mhchem@halfbond}{% - \ifthenelse{\equal{#1}{~-}}{% + \mhchem@halfbond% + \else\ifnum\pdf@strcmp{#1}{~-}=0% \mhchem@setbondwidth% \rlap{\protect\raisebox{.2ex}{\mhchem@halfbond}}% - \protect\raisebox{-.2ex}{\sbond}}{% - \ifthenelse{\equal{#1}{~--}}{% + \protect\raisebox{-.2ex}{\sbond}% + \else\ifnum\pdf@strcmp{#1}{~--}=0% \mhchem@setbondwidth% \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}% \rlap{\sbond}% - \protect\raisebox{-.4ex}{\sbond}}{% - \ifthenelse{\equal{#1}{~=}}{% + \protect\raisebox{-.4ex}{\sbond}% + \else\ifnum\pdf@strcmp{#1}{~=}=0% \mhchem@setbondwidth% \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}% \rlap{\sbond}% - \protect\raisebox{-.4ex}{\sbond}}{% - \ifthenelse{\equal{#1}{-~-}}{% + \protect\raisebox{-.4ex}{\sbond}% + \else\ifnum\pdf@strcmp{#1}{-~-}=0% \mhchem@setbondwidth% \rlap{\protect\raisebox{.4ex}{\sbond}}% \rlap{\mhchem@halfbond}% - \protect\raisebox{-.4ex}{\sbond}}{% - \ifthenelse{\equal{#1}{...}}{{\cdot}{\cdot}{\cdot}}{% - \ifthenelse{\equal{#1}{....}}{{\cdot}{\cdot}{\cdot}{\cdot}}{% - \ifthenelse{\equal{#1}{->}}{{\rightarrow}}{% - \ifthenelse{\equal{#1}{<-}}{{\leftarrow}}{% - % - \PackageError{mhchem}{unknown bond type in \string\bond (#1)}% - }}}}}}}}}}}% - \fi\fi% + \protect\raisebox{-.4ex}{\sbond}% + \else\ifnum\pdf@strcmp{#1}{...}=0% + {\cdot}{\cdot}{\cdot}% + \else\ifnum\pdf@strcmp{#1}{....}=0% + {\cdot}{\cdot}{\cdot}{\cdot}% + \else\ifnum\pdf@strcmp{#1}{->}=0% + {\rightarrow}% + \else\ifnum\pdf@strcmp{#1}{<-}=0% + {\leftarrow}% + \else + \PackageError{mhchem}{Unknown bond type in \string\bond (#1)}% + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% } %%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -742,7 +838,6 @@ \newtoks\mhchem@cf@result% \newcommand*\mhchem@cf[2][]{% \bgroup% - %%% \def\sbond{{\ensuremath{-}}}% \ifnum 2=\mhchem@option@version% \let\bond\sbond% @@ -753,7 +848,6 @@ \DeclareRobustCommand\tbond{\rlap{\protect\raisebox{.4ex}{\sbond}}% \rlap{\sbond}\protect\raisebox{-.4ex}{\sbond}}% \def\hyphen{\mhchem@hyphen}% - %%% \ifmmode\else\def\mhchem@option@alwaystextmode{1}\fi% \if 1\mhchem@option@alwaystextmode% \edef\mhchem@mathOrText##1{\noexpand\text{##1}}% @@ -768,70 +862,45 @@ \fi% \fi% \ifmmode\else\mhchem@option@textFont\fi% - %%% \def\mhchem@cf@state{s}% - % - % - % - % - % - % - % - % - % - % \def\mhchem@cf@startedWithBond{0}% - %%% \mhchem@cf@outputReset% \mhchem@cf@result={}% - %%% \mhchem@cf@continue#2\mhchem@END% - %%% - % - % \ifthenelse{\equal{#1}{}}% {% - \ensuremath{\the\mhchem@cf@result}% + \ensuremath{\the\mhchem@cf@result}% }{% \ensuremath{\overset{#1}{\the\mhchem@cf@result}}% }% - %TODO: insert kerning if full stop (or similar) follows superscript - %\@ifnextchar,{\kern-0.2em}{} ??% \egroup% }% \def\mhchem@cf@i{% - % - % - %%% \ifx\mhchem@END\mhchem@cf@lookahead% \if -\mhchem@cf@state% \ifnum 4>\mhchem@option@version% - \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup -}% + \mhchem@appendToks{\mhchem@cf@sup}{-}% \else% \if 0\mhchem@cf@startedWithBond% - \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup -}% + \mhchem@appendToks{\mhchem@cf@sup}{-}% \else% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\sbond}% + \mhchem@appendToks{\mhchem@cf@result}{\sbond}% \fi% \fi% - \fi% + \else\if 1\mhchem@cf@state% + \def\mhchem@cf@state{9}% + \fi\fi% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \let\mhchem@cf@action\mhchem@gobble% \else\ifx\relax\mhchem@cf@lookahead% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% \else\ifx\protect\mhchem@cf@lookahead% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - %%% \else% -% -% -% -% \if -\mhchem@cf@state% - % \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\sbond}% + \mhchem@appendToks{\mhchem@cf@result}{\sbond}% \def\mhchem@cf@state{+}% \fi% \if s\mhchem@cf@state% @@ -841,25 +910,22 @@ \else\ifx \}\mhchem@cf@lookahead% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% - \else\ifx\bond\mhchem@cf@lookahead% - \ifnum 2=\mhchem@option@version% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else% - \def\mhchem@cf@state{C}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \fi% - \else\if =\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\dbond}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\if ##\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\tbond}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% - \def\mhchem@cf@state{c}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\if ^\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@equal@other\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@equal@active\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\if ##\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\tbond}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@super\mhchem@cf@lookahead% + \def\mhchem@cf@state{p}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@active\mhchem@cf@lookahead% \def\mhchem@cf@state{p}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% \else\if _\mhchem@cf@lookahead% @@ -894,7 +960,16 @@ \else\if +\mhchem@cf@lookahead% \def\mhchem@cf@state{+}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@sup}}% - \else\if -\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@hyphen@other\mhchem@cf@lookahead% + \ifnum 1<\mhchem@option@version% + \def\mhchem@cf@state{-}% + \def\mhchem@cf@startedWithBond{1}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else% + \def\mhchem@cf@state{+}% + \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@sup}{-}}% + \fi% + \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@cf@lookahead% \ifnum 1<\mhchem@option@version% \def\mhchem@cf@state{-}% \def\mhchem@cf@startedWithBond{1}% @@ -920,13 +995,16 @@ \else\if *\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% + \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \def\mhchem@cf@state{c}% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \else\ifcat a\mhchem@cf@lookahead% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifcat 1\mhchem@cf@lookahead% \def\mhchem@cf@state{1}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% - \else\if\mhchem@lbracechar\mhchem@cf@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@lookahead% \ifnum 4>\mhchem@option@version% \def\mhchem@cf@action{\mhchem@cf@appendNextGroup{\mhchem@cf@result}}% \else% @@ -943,16 +1021,16 @@ \fi% \else% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \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\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \else\if C\mhchem@cf@state% - \if\mhchem@lbracechar\mhchem@cf@lookahead% + \if\mhchem@char@lbrace\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextGroup{\mhchem@cf@result}}% \else% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \fi% \def\mhchem@cf@state{c}% \else\if c\mhchem@cf@state% - \if\mhchem@lbracechar\mhchem@cf@lookahead% + \if\mhchem@char@lbrace\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextGroup{\mhchem@cf@result}}% \else% \def\mhchem@cf@state{s}% @@ -967,29 +1045,26 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% - \else\ifx\bond\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@equal@other\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \ifnum 2=\mhchem@option@version% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else% - \def\mhchem@cf@state{C}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \fi% - \else\if =\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\dbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\if ##\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\tbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@equal@active\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{c}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\if ^\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\if ##\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\tbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@super\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \def\mhchem@cf@state{p}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@active\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{p}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% @@ -1006,22 +1081,9 @@ \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% \fi% \else\if ,\mhchem@cf@lookahead% - \ifnum 4>\mhchem@option@version% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{F}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else% - \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@amount}{{,}}}% - \fi% + \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@amount}{{,}}}% \else\if .\mhchem@cf@lookahead% - \ifnum 4>\mhchem@option@version% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{s}% - \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% - {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% - \else% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% - \fi% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% \else\if |\mhchem@cf@lookahead% \PackageWarning{mhchem}{The symbol | is not allowed here}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% @@ -1046,13 +1108,17 @@ \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% + \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \def\mhchem@cf@state{c}% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \else\ifcat a\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifcat 1\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% - \else\if\mhchem@lbracechar\mhchem@cf@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@lookahead% \ifnum 4>\mhchem@option@version% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% @@ -1066,38 +1132,37 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \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\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \else\if a\mhchem@cf@state% \ifx \{\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifx \}\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% - \else\ifx\bond\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@equal@other\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \ifnum 2=\mhchem@option@version% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else% - \def\mhchem@cf@state{C}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@equal@active\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\if ##\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\tbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@super\mhchem@cf@lookahead% + \def\mhchem@cf@state{e}% + \expandafter\ifx\expandafter\@empty\the\mhchem@cf@sup\@empty\else% + \mhchem@appendToks{\mhchem@cf@sup}{,}% \fi% - \else\if =\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\dbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\if ##\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\tbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{c}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\if ^\mhchem@cf@lookahead% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@active\mhchem@cf@lookahead% \def\mhchem@cf@state{e}% \expandafter\ifx\expandafter\@empty\the\mhchem@cf@sup\@empty\else% - \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup ,}% + \mhchem@appendToks{\mhchem@cf@sup}{,}% \fi% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% \else\if _\mhchem@cf@lookahead% @@ -1128,7 +1193,15 @@ \else\if +\mhchem@cf@lookahead% \def\mhchem@cf@state{+}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@sup}}% - \else\if -\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@hyphen@other\mhchem@cf@lookahead% + \ifnum 1<\mhchem@option@version% + \def\mhchem@cf@state{-}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else% + \def\mhchem@cf@state{+}% + \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@sup}{-}}% + \fi% + \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@cf@lookahead% \ifnum 1<\mhchem@option@version% \def\mhchem@cf@state{-}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% @@ -1152,12 +1225,16 @@ \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% + \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \def\mhchem@cf@state{c}% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \else\ifcat a\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifcat 1\mhchem@cf@lookahead% \def\mhchem@cf@state{2}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% - \else\if\mhchem@lbracechar\mhchem@cf@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@lookahead% \ifnum 4>\mhchem@option@version% \def\mhchem@cf@action{\mhchem@cf@appendNextGroupAsMath{% \mhchem@cf@element}}% @@ -1170,7 +1247,7 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \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\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \else\if 2\mhchem@cf@state% \ifx \{\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% @@ -1180,32 +1257,31 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% - \else\ifx\bond\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@equal@other\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \ifnum 2=\mhchem@option@version% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else% - \def\mhchem@cf@state{C}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \fi% - \else\if =\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\dbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\if ##\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\tbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@equal@active\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{c}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\if ^\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\if ##\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\tbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@super\mhchem@cf@lookahead% \def\mhchem@cf@state{e}% \expandafter\ifx\expandafter\@empty\the\mhchem@cf@sup\@empty\else% - \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup ,}% + \mhchem@appendToks{\mhchem@cf@sup}{,}% + \fi% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@active\mhchem@cf@lookahead% + \def\mhchem@cf@state{e}% + \expandafter\ifx\expandafter\@empty\the\mhchem@cf@sup\@empty\else% + \mhchem@appendToks{\mhchem@cf@sup}{,}% \fi% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% \else\if _\mhchem@cf@lookahead% @@ -1237,7 +1313,15 @@ \else\if +\mhchem@cf@lookahead% \def\mhchem@cf@state{+}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@sup}}% - \else\if -\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@hyphen@other\mhchem@cf@lookahead% + \ifnum 1<\mhchem@option@version% + \def\mhchem@cf@state{-}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else% + \def\mhchem@cf@state{+}% + \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@sup}{-}}% + \fi% + \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@cf@lookahead% \ifnum 1<\mhchem@option@version% \def\mhchem@cf@state{-}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% @@ -1269,13 +1353,17 @@ \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% + \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \def\mhchem@cf@state{c}% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \else\ifcat a\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifcat 1\mhchem@cf@lookahead% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% - \else\if\mhchem@lbracechar\mhchem@cf@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@lookahead% \ifnum 4>\mhchem@option@version% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% @@ -1293,7 +1381,7 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \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\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \else\if e\mhchem@cf@state% \def\mhchem@cf@state{+}% \if $\mhchem@cf@lookahead% @@ -1347,32 +1435,31 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% - \else\ifx\bond\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@equal@other\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \ifnum 2=\mhchem@option@version% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else% - \def\mhchem@cf@state{C}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \fi% - \else\if =\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\dbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\if ##\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\tbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@equal@active\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{c}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\if ^\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\if ##\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\tbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@super\mhchem@cf@lookahead% \def\mhchem@cf@state{e}% \expandafter\ifx\expandafter\@empty\the\mhchem@cf@sup\@empty\else% - \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup ,}% + \mhchem@appendToks{\mhchem@cf@sup}{,}% + \fi% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@active\mhchem@cf@lookahead% + \def\mhchem@cf@state{e}% + \expandafter\ifx\expandafter\@empty\the\mhchem@cf@sup\@empty\else% + \mhchem@appendToks{\mhchem@cf@sup}{,}% \fi% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% \else\if _\mhchem@cf@lookahead% @@ -1410,7 +1497,15 @@ \else\if +\mhchem@cf@lookahead% \def\mhchem@cf@state{+}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@sup}}% - \else\if -\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@hyphen@other\mhchem@cf@lookahead% + \ifnum 1<\mhchem@option@version% + \def\mhchem@cf@state{-}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else% + \def\mhchem@cf@state{+}% + \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@sup}{-}}% + \fi% + \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@cf@lookahead% \ifnum 1<\mhchem@option@version% \def\mhchem@cf@state{-}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% @@ -1442,16 +1537,19 @@ \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% + \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \def\mhchem@cf@state{c}% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \else\ifcat a\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifcat 1\mhchem@cf@lookahead% - % \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% - \else\if\mhchem@lbracechar\mhchem@cf@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@lookahead% \ifnum 4>\mhchem@option@version% \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% @@ -1469,7 +1567,7 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \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\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \else\if *\mhchem@cf@state% \ifx \{\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% @@ -1479,29 +1577,25 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\ifx\bond\mhchem@cf@lookahead% + \else\expandafter\ifx\mhchem@char@equal@other\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \ifnum 2=\mhchem@option@version% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else% - \def\mhchem@cf@state{C}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \fi% - \else\if =\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\dbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\if ##\mhchem@cf@lookahead% - \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \mhchem@cf@result=\expandafter{\the\mhchem@cf@result\tbond}% - \def\mhchem@cf@state{+}% - \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% - \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@equal@active\mhchem@cf@lookahead% \mhchem@cf@outputAndReset{\mhchem@cf@result}% - \def\mhchem@cf@state{c}% - \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \else\if ^\mhchem@cf@lookahead% + \mhchem@appendToks{\mhchem@cf@result}{\dbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\if ##\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \mhchem@appendToks{\mhchem@cf@result}{\tbond}% + \def\mhchem@cf@state{+}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@super\mhchem@cf@lookahead% + \def\mhchem@cf@state{p}% + \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% + \else\expandafter\ifx\mhchem@char@caret@active\mhchem@cf@lookahead% \def\mhchem@cf@state{p}% \let\mhchem@cf@action\mhchem@cf@gobbleNextToken% \else\if _\mhchem@cf@lookahead% @@ -1557,15 +1651,18 @@ \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@append{\mhchem@cf@result}% {\mhchem@mathOrText@ii{{}\cdot{}}{\mhchem@option@textcdot}}}% + \else\ifcat\noexpand\mhchem@macro\noexpand\mhchem@cf@lookahead% + \mhchem@cf@outputAndReset{\mhchem@cf@result}% + \def\mhchem@cf@state{c}% + \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% \else\ifcat a\mhchem@cf@lookahead% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@element}}% \else\ifcat 1\mhchem@cf@lookahead% - % \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{1}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@amount}}% - \else\if\mhchem@lbracechar\mhchem@cf@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@lookahead% \def\mhchem@cf@state{a}% \def\mhchem@cf@action{\mhchem@cf@appendNextGroup{\mhchem@cf@element}}% \else\if $\mhchem@cf@lookahead% @@ -1575,86 +1672,67 @@ \mhchem@cf@outputAndReset{\mhchem@cf@result}% \def\mhchem@cf@state{s}% \def\mhchem@cf@action{\mhchem@cf@appendNextToken{\mhchem@cf@result}}% - \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\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \else% \PackageWarning{mhchem}{Assertion failed: unknown internal state \mhchem@cf@state}% \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi% \fi\fi\fi% \mhchem@cf@action% }% -%%% \def\mhchem@cf@continue{% \futurelet\mhchem@cf@lookahead\mhchem@cf@i% }% \def\mhchem@cf@gobbleNextToken#1{% \mhchem@cf@continue% }% -\def\mhchem@cf@append#1#2#3{% - %\showthe#1% - #1=\expandafter{\the#1#2}% - %\showthe#1% +\def\mhchem@cf@appendNextToken#1#2{% + \mhchem@appendToks{#1}{#2}% \mhchem@cf@continue% -}% -\def\mhchem@cf@appendExpand#1#2#3{% - \edef\mhchem@cf@appendExpand@i{\noexpand\mhchem@cf@append\noexpand{#1}{#2}}% - \mhchem@cf@appendExpand@i% -}% -\def\mhchem@cf@appendAndExecute#1#2#3#4{% - #1=\expandafter{\the#1#2}% - #3% +} +\def\mhchem@cf@appendNextTokenAsMathrm#1#2{% + \mhchem@appendToks{#1}{\ensuremath{\mathrm{#2}}}% \mhchem@cf@continue% -}% -\def\mhchem@cf@appendAndExecuteExpand#1#2#3#4{% - \edef\mhchem@cf@appendExpand@i{\noexpand\mhchem@cf@appendAndExecute\noexpand{#1}{#2}{#3}}% - \mhchem@cf@appendExpand@i% -}% +} \def\mhchem@cf@appendNextGroup#1#2{% - #1=\expandafter{\the#1{#2}}% + \mhchem@appendToks{#1}{{#2}}% \mhchem@cf@continue% } \def\mhchem@cf@appendNextGroupAsMath#1#2{% - #1=\expandafter{\the#1{\text{\ensuremath{#2}}}}% - \mhchem@cf@continue% -} -\def\mhchem@cf@appendNextToken#1#2{% - %\showthe#1% - #1=\expandafter{\the#1#2}% - %\showthe#1% + \mhchem@appendToks{#1}{\text{\ensuremath{#2}}}% \mhchem@cf@continue% } -\def\mhchem@cf@appendNextTokenAsMathrm#1#2{% - #1=\expandafter{\the#1{\ensuremath{\mathrm{#2}}}}% +\def\mhchem@cf@append#1#2#3{% + \mhchem@appendToks{#1}{#2}% \mhchem@cf@continue% -} +}% \def\mhchem@cf@appendMath#1#2#3${% - #1=\expandafter{\the#1\text{\ensuremath{#3}}}% + \mhchem@appendToks{#1}{\text{\ensuremath{#3}}}% \mhchem@cf@continue% }% \def\mhchem@cf@appendMathAsGroup#1#2#3${% - #1=\expandafter{\the#1{\text{\ensuremath{#3}}}}% + \mhchem@appendToks{#1}{{\text{\ensuremath{#3}}}}% \mhchem@cf@continue% }% \def\mhchem@cf@switchState#1#2|{% - \ifthenelse{\equal{1}{#2}}{% if 1 - \def\mhchem@cf@state{a}% switch to [a]element + \ifthenelse{\equal{1}{#2}}{% + \def\mhchem@cf@state{a}% }{% \PackageWarning{mhchem}{Command |#2| unknown}% }% \mhchem@cf@continue% }% -%%%%% \newtoks\mhchem@cf@element% \newtoks\mhchem@cf@amount% -%\newtoks\mhchem@cf@sub% \newtoks\mhchem@cf@sup% \newtoks\mhchem@cf@presub% \newtoks\mhchem@cf@presup% \def\mhchem@cf@output{% - % - \if\mhchem@cf@state s% - \else\if\mhchem@cf@state 1% - \noexpand\mhchem@mathOrText{\noexpand\mhchem@cf@frac\the\mhchem@cf@amount/\noexpand\mhchem@END}% + \if s\mhchem@cf@state% + \else\if 1\mhchem@cf@state% + \noexpand\mhchem@mathOrText{\noexpand\mhchem@cf@frac\the\mhchem@cf@amount/\noexpand\mhchem@END{\mhchem@option@skipAfterFracAmount}}% + \else\if 9\mhchem@cf@state% + \noexpand\mhchem@mathOrText{\noexpand\mhchem@cf@frac\the\mhchem@cf@amount/\noexpand\mhchem@END{}}% \else% \if\mhchem@option@usenonsimultaneoussubsuperscripts 0\relax% \noexpand\mhchem@chemfive% @@ -1673,12 +1751,9 @@ {}% {\noexpand\mhchem@cf@replaceMathMinusDot{\the\mhchem@cf@sup}}% \fi% - \fi\fi%\fi% + \fi\fi\fi% } \def\mhchem@cf@outputReset{% - %\showthe\mhchem@cf@element% - %\showthe\mhchem@cf@sup% - % \mhchem@cf@element={}% \mhchem@cf@amount={}% \mhchem@cf@sup={}% @@ -1688,23 +1763,22 @@ \def\mhchem@cf@outputAndReset#1{% \edef\mhchem@cf@outputAndReset@i{#1={\the#1\mhchem@cf@output}}% \mhchem@cf@outputAndReset@i% - %\showthe#1% \mhchem@cf@outputReset% } %%% frac -\def\mhchem@cf@frac#1/#2\mhchem@END{% +\def\mhchem@cf@frac#1/#2\mhchem@END#3{% \ifthenelse{\equal{#2}{}}{% - #1\mhchem@option@skipAfterAmount% + #1#3% }{% \ensuremath{\mathchoice% {\textstyle% - \frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mhchem@option@skipAfterFracAmount}% - {\frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mhchem@option@skipAfterFracAmount}% - {\frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mhchem@option@skipAfterFracAmount}% - {\frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mhchem@option@skipAfterFracAmount}% + \frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}#3}% + {\frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}#3}% + {\frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}#3}% + {\frac{\mhchem@mathOrText{#1}}{\mhchem@mathOrText{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}#3}% }% }% }% @@ -1712,20 +1786,16 @@ \def\mhchem@getlastchars#1#2\mhchem@ENDgetlastchars{#2} %%% replaceMath - % - % - % \newtoks\mhchem@cf@replaceMath@result \newcommand\mhchem@cf@replaceMath[1]{% \mhchem@cf@replaceMath@result={}% \mhchem@cf@replaceMath@continue#1\mhchem@END% - % \the\mhchem@cf@replaceMath@result% } \def\mhchem@cf@replaceMath@i{% \ifx\mhchem@END\mhchem@cf@replaceMath@lookahead% \let\mhchem@cf@replaceMath@action\mhchem@gobble% - \else\if\mhchem@lbracechar\mhchem@cf@replaceMath@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@replaceMath@lookahead% \let\mhchem@cf@replaceMath@action\mhchem@cf@replaceMath@appendNextGroup% \else\if $\mhchem@cf@replaceMath@lookahead% \let\mhchem@cf@replaceMath@action\mhchem@cf@replaceMath@appendMath% @@ -1734,69 +1804,63 @@ \fi\fi\fi% \mhchem@cf@replaceMath@action% } -%%% \def\mhchem@cf@replaceMath@continue{% \futurelet\mhchem@cf@replaceMath@lookahead\mhchem@cf@replaceMath@i% } \def\mhchem@cf@replaceMath@appendNextGroup#1{% - \mhchem@cf@replaceMath@result=\expandafter{\the\mhchem@cf@replaceMath@result{#1}}% + \mhchem@appendToks{\mhchem@cf@replaceMath@result}{{#1}}% \mhchem@cf@replaceMath@continue% } \def\mhchem@cf@replaceMath@appendNextToken#1{% - \mhchem@cf@replaceMath@result=\expandafter{\the\mhchem@cf@replaceMath@result#1}% + \mhchem@appendToks{\mhchem@cf@replaceMath@result}{#1}% \mhchem@cf@replaceMath@continue% } \def\mhchem@cf@replaceMath@appendMath#1#2${% - \mhchem@cf@replaceMath@result=\expandafter{\the\mhchem@cf@replaceMath@result\text{\ensuremath{#2}}}% + \mhchem@appendToks{\mhchem@cf@replaceMath@result}{\text{\ensuremath{#2}}}% \mhchem@cf@replaceMath@continue% -}% +} %%% replaceMathMinusDot -%%% -%%% -%%% -%%% -%%% \newtoks\mhchem@cf@replaceMathMinusDot@result \newcommand\mhchem@cf@replaceMathMinusDot[1]{% \mhchem@cf@replaceMathMinusDot@result={}% \mhchem@cf@replaceMathMinusDot@continue#1\mhchem@END% - % \the\mhchem@cf@replaceMathMinusDot@result% } \def\mhchem@cf@replaceMathMinusDot@i{% \ifx\mhchem@END\mhchem@cf@replaceMathMinusDot@lookahead% \let\mhchem@cf@replaceMathMinusDot@action\mhchem@gobble% - \else\if -\mhchem@cf@replaceMathMinusDot@lookahead\relax% + \else\expandafter\ifx\mhchem@char@hyphen@other\mhchem@cf@replaceMathMinusDot@lookahead\relax% + \def\mhchem@cf@replaceMathMinusDot@action{\mhchem@cf@replaceMathMinusDot@append{\mhchem@mathOrText@ii{-}{\mhchem@option@textminus}}}% + \else\expandafter\ifx\mhchem@char@hyphen@active\mhchem@cf@replaceMathMinusDot@lookahead\relax% \def\mhchem@cf@replaceMathMinusDot@action{\mhchem@cf@replaceMathMinusDot@append{\mhchem@mathOrText@ii{-}{\mhchem@option@textminus}}}% \else\if .\mhchem@cf@replaceMathMinusDot@lookahead\relax% \def\mhchem@cf@replaceMathMinusDot@action{\mhchem@cf@replaceMathMinusDot@append{\ensuremath{\textbf{\fontfamily{cmr}\selectfont\textperiodcentered}}}}% - \else\if\mhchem@lbracechar\mhchem@cf@replaceMathMinusDot@lookahead% + \else\if\mhchem@char@lbrace\mhchem@cf@replaceMathMinusDot@lookahead% \let\mhchem@cf@replaceMathMinusDot@action\mhchem@cf@replaceMathMinusDot@appendNextGroup% \else\if $\mhchem@cf@replaceMathMinusDot@lookahead% \let\mhchem@cf@replaceMathMinusDot@action\mhchem@cf@replaceMathMinusDot@appendMath% \else% \let\mhchem@cf@replaceMathMinusDot@action\mhchem@cf@replaceMathMinusDot@appendNextToken% - \fi\fi\fi\fi\fi% + \fi\fi\fi\fi\fi\fi% \mhchem@cf@replaceMathMinusDot@action% } -%%% \def\mhchem@cf@replaceMathMinusDot@continue{% \futurelet\mhchem@cf@replaceMathMinusDot@lookahead\mhchem@cf@replaceMathMinusDot@i% } \def\mhchem@cf@replaceMathMinusDot@append#1#2{% - \mhchem@cf@replaceMathMinusDot@result=\expandafter{\the\mhchem@cf@replaceMathMinusDot@result#1}% + \mhchem@appendToks{\mhchem@cf@replaceMathMinusDot@result}{#1}% \mhchem@cf@replaceMathMinusDot@continue% } \def\mhchem@cf@replaceMathMinusDot@appendNextGroup#1{% - \mhchem@cf@replaceMathMinusDot@result=\expandafter{\the\mhchem@cf@replaceMathMinusDot@result{#1}}% + \mhchem@appendToks{\mhchem@cf@replaceMathMinusDot@result}{{#1}}% \mhchem@cf@replaceMathMinusDot@continue% } \def\mhchem@cf@replaceMathMinusDot@appendNextToken#1{% - \mhchem@cf@replaceMathMinusDot@result=\expandafter{\the\mhchem@cf@replaceMathMinusDot@result#1}% + \mhchem@appendToks{\mhchem@cf@replaceMathMinusDot@result}{#1}% \mhchem@cf@replaceMathMinusDot@continue% } \def\mhchem@cf@replaceMathMinusDot@appendMath#1#2${% - \mhchem@cf@replaceMathMinusDot@result=\expandafter{\the\mhchem@cf@replaceMathMinusDot@result\text{\ensuremath{#2}}}% + \mhchem@appendToks{\mhchem@cf@replaceMathMinusDot@result}{\text{\ensuremath{#2}}}% \mhchem@cf@replaceMathMinusDot@continue% }% @@ -1804,13 +1868,6 @@ %%%%%%%%%%%%%%%%%%%%% %%% @chemfive %%% %%%%%%%%%%%%%%%%%%%%% -%%% -%%% -%%% -%%% -%%% -%%% -%%% \newcommand*\mhchem@chemfive[6]{% {% \mhchem@prepostscript% @@ -1825,13 +1882,6 @@ } %%% @prepostscript -%%% -%%% -%%% -%%% -%%% -%%% -%%% \newlength\mhchem@prepostscript@tmp@i% \newlength\mhchem@prepostscript@tmp@ii% \newcommand*\mhchem@prepostscript[7][]{% @@ -1839,64 +1889,55 @@ \ensuremath{% \setlength{\mhchem@prepostscript@tmp@i}{\widthof{$#2#3$}}% \ifdim\mhchem@prepostscript@tmp@i>0pt% - \setlength{\mhchem@prepostscript@tmp@i}{\widthof{${}^{#2}$}}% [1] - \setlength{\mhchem@prepostscript@tmp@ii}{\widthof{${}_{#3}$}}% [1] + \setlength{\mhchem@prepostscript@tmp@i}{\widthof{${}^{#2}$}}% + \setlength{\mhchem@prepostscript@tmp@ii}{\widthof{${}_{#3}$}}% \ifdim\mhchem@prepostscript@tmp@i<\mhchem@prepostscript@tmp@ii% - \setlength{\mhchem@prepostscript@tmp@i}{\mhchem@prepostscript@tmp@ii}\fi% [1] - \vphantom{#4}% [2] + \setlength{\mhchem@prepostscript@tmp@i}{\mhchem@prepostscript@tmp@ii}\fi% + \vphantom{#4}% {}% ^{% - \mhchem@mathboxright{\mhchem@prepostscript@tmp@i}{% [1] - \vphantom{#6#7}% [2] - \vphantom{#1}% [4] + \mhchem@mathboxright{\mhchem@prepostscript@tmp@i}{% + \vphantom{#6#7}% + \vphantom{#1}% #2% - }% [1] + }% }% _{% - \mhchem@mathboxright{\mhchem@prepostscript@tmp@i}{% [1] - \vphantom{#5}% [2] + \mhchem@mathboxright{\mhchem@prepostscript@tmp@i}{% + \vphantom{#5}% #3% - }% [1] + }% }% - \mhchem@minispace% [3] + \mhchem@minispace% \fi% #4% \setlength{\mhchem@prepostscript@tmp@i}{\widthof{$#5#6$}}% - \ifdim\mhchem@prepostscript@tmp@i>0pt% + \ifdim\mhchem@prepostscript@tmp@i>0pt% _{% - \vphantom{#3}% [2] + \vphantom{#3}% #5% }% ^{% - \vphantom{#2#7}% [2] - \vphantom{#1}% [4] - #6 + \vphantom{#2#7}% + \vphantom{#1}% + #6% }% \fi% \setlength{\mhchem@prepostscript@tmp@i}{\widthof{$#7$}}% - \ifdim\mhchem@prepostscript@tmp@i>0pt% - \mhchem@minispace% [3] + \ifdim\mhchem@prepostscript@tmp@i>0pt% + \mhchem@minispace% {}% - _{\vphantom{#3#5}}% [2] + _{\vphantom{#3#5}}% ^{% - \vphantom{#2#6}% [2] - \vphantom{#1}% [4] + \vphantom{#2#6}% + \vphantom{#1}% #7% }% \fi% }% -% -% -% -% -% -% -% } %%% @mathbox -%%% -%%% \newcommand*\mhchem@mathbox[2][]{% \mathchoice% {\mhchem@mathbox@ii{\displaystyle}{#1}{#2}}% @@ -1905,7 +1946,7 @@ {\mhchem@mathbox@ii{\scriptscriptstyle}{#1}{#2}}}% \newlength\mhchem@mathbox@tmp@i \newlength\mhchem@mathbox@tmp@ii -\newcommand*\mhchem@mathbox@ii[3]{% +\newcommand*\mhchem@mathbox@ii[3]{% \setlength{\mhchem@mathbox@tmp@i}{\widthof{\ensuremath{#1#2}}}% \setlength{\mhchem@mathbox@tmp@ii}{\widthof{\ensuremath{#1#3}}}% \ifdim\mhchem@mathbox@tmp@i<\mhchem@mathbox@tmp@ii% @@ -1919,7 +1960,7 @@ {\mbox{\ensuremath{\scriptstyle#1}}}% {\mbox{\ensuremath{\scriptscriptstyle#1}}}} -%%% @mathboxright +%%% @mathboxright \newcommand*\mhchem@mathboxright[2]{\mathchoice% {\makebox[#1][r]{\ensuremath{\displaystyle#2}}}% {\makebox[#1][r]{\ensuremath{\textstyle#2}}}% @@ -1927,12 +1968,10 @@ {\makebox[#1][r]{\ensuremath{\scriptscriptstyle#2}}}} %%% @minispace -%%% -%%% \newlength\mhchem@minispace@tmp \newcommand*\mhchem@minispace{% \setlength{\mhchem@minispace@tmp}{0pt-\widthof{${}^8_8$}+% - \widthof{$\text{C}^8_8$}-\widthof{$\text{C}^{}_{}$}}% [3] + \widthof{$\text{C}^8_8$}-\widthof{$\text{C}^{}_{}$}}% \kern\mhchem@minispace@tmp% } @@ -1960,7 +1999,6 @@ }{\PackageError{mhchem}{Font option `#1' unknown}}}% } -% \def\mhchem@option@alwaystextmode{0}% \newlength\mhchem@option@minussidebearingleft @@ -1970,22 +2008,6 @@ \define@key{mhchem}{minus-sidebearing-left}{\setlength\mhchem@option@minussidebearingleft{#1}} \define@key{mhchem}{minus-sidebearing-right}{\setlength\mhchem@option@minussidebearingright{#1}} -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% % Replicate layout of MS Word (superscript after subscript, not over) \def\mhchem@option@usenonsimultaneoussubsuperscripts{0}% @@ -1993,7 +2015,7 @@ \mhchem@definearrows{font} \define@key{mhchem}{arrows}{% - \ifthenelse{\equal{pgf}{#1} \or \equal{pgf-filled}{#1}}{% + \ifthenelse{\equal{pgf}{#1} \or \equal{pgf-filled}{#1}}{% \RequirePackage{pgf}% for finding the tikz package more easily \RequirePackage{tikz}% }{}% @@ -2004,17 +2026,14 @@ \define@key{mhchem}{skip-after-amount}{\def\mhchem@option@skipAfterAmount{#1}\def\mhchem@option@skipAfterFracAmount{#1}} \def\mhchem@option@skipAfterFracAmount{\,} \define@key{mhchem}{skip-after-frac-amount}{\def\mhchem@option@skipAfterFracAmount{#1}} -% \def\mhchem@option@textminus{--} \define@key{mhchem}{textminus}{\def\mhchem@option@textminus{#1}} -% \def\mhchem@option@textcdot{\cdot} \define@key{mhchem}{textcdot}{\def\mhchem@option@textcdot{#1}} -% -%%% begin: standard keyval handling as in many other packages +%%% begin: standard keyval handling as in many other packages \def\ProcessOptionsWithKV#1{% \let\@tempc\relax% \let\mhchem@tempa\@empty% @@ -2047,8 +2066,9 @@ \PackageWarningNoLine{mhchem}{% You did not specify a 'version' option for the mhchem\MessageBreak package. If you are about to create a new document,\MessageBreak - please write \string\usepackage[version=3]{mhchem} in your preamble in\MessageBreak - order to use the most recent version of mhchem}% + please write \string\usepackage[version=3]{mhchem} in your\MessageBreak + preamble in order to use the most recent version of\MessageBreak + mhchem}% \def\mhchem@option@version{3}% \else\ifnum 4=\mhchem@option@version% \PackageWarningNoLine{mhchem}{% @@ -2058,47 +2078,12 @@ to change without notice}% \fi\fi% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%% misc %%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% legacy %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ifnum 4>\mhchem@option@version \newcommand*\mhchem@cmath[1]{\ensuremath{\text{\ensuremath{#1}}}}% \newcommand*\cmath[1]{\mhchem@cmath{#1}} - \newcommand*\cf[2][]{\mhchem@cf[#1]{#2}} + \DeclareRobustCommand\cf[2][]{\mhchem@cf[#1]{#2}} \fi - - - - - - - - - -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% -% - -% -\def\mhchem@END{} -\def\mhchem@macro{} -\def\mhchem@empty{} -% -\edef\mhchem@lbracechar{\string{} %} -\def\mhchem@gobble#1{}% -% -%
\ No newline at end of file |