summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/mhchem
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-02-11 00:08:52 +0000
committerKarl Berry <karl@freefriends.org>2015-02-11 00:08:52 +0000
commit594384c2eaf02fe0d0e5aae153c6d5db8e30666f (patch)
tree651ef828bc76190d71fb533951a2efdd5b3bfb81 /Master/texmf-dist/tex/latex/mhchem
parent20bb32deefaa3ad8f476dd80e6b082cf7d6a6e6a (diff)
mhchem (9feb15)
git-svn-id: svn://tug.org/texlive/trunk@36253 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mhchem')
-rw-r--r--Master/texmf-dist/tex/latex/mhchem/mhchem.sty139
1 files changed, 82 insertions, 57 deletions
diff --git a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
index 50d11a60c0d..aba1aec977d 100644
--- a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
+++ b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty
@@ -27,7 +27,7 @@
% This work consists of all files listed in manifest.txt.
%
%
-\ProvidesPackage{mhchem}[2015/01/05 v3.18 for typesetting chemical formulae]
+\ProvidesPackage{mhchem}[2015/02/09 v3.19 for typesetting chemical formulae]
\RequirePackage{ifthen}
\RequirePackage{calc}[1998/07/07]
\RequirePackage{amsmath}
@@ -1065,53 +1065,61 @@
\resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}%
\resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}}%
\phantom{\sbond}}%
-\def\mhchem@bond#1{%
- \ifnum\pdf@strcmp{#1}{-}=0%
- \sbond%
- \else\ifnum\pdf@strcmp{#1}{1}=0%
- \sbond%
- \else\ifnum\pdf@strcmp{#1}{=}=0%
- \dbond%
- \else\ifnum\pdf@strcmp{#1}{2}=0%
- \dbond%
- \else\ifnum\pdf@strcmp{#1}{##}=0%
- \tbond%
- \else\ifnum\pdf@strcmp{#1}{3}=0%
- \tbond%
- \else\ifnum\pdf@strcmp{#1}{~}=0%
- \mhchem@setbondwidth%
- \mhchem@halfbond%
- \else\ifnum\pdf@strcmp{#1}{~-}=0%
- \mhchem@setbondwidth%
- \rlap{\protect\raisebox{.2ex}{\mhchem@halfbond}}%
- \protect\raisebox{-.2ex}{\sbond}%
- \else\ifnum\pdf@strcmp{#1}{~--}=0%
- \mhchem@setbondwidth%
- \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}%
- \rlap{\sbond}%
- \protect\raisebox{-.4ex}{\sbond}%
- \else\ifnum\pdf@strcmp{#1}{~=}=0%
- \mhchem@setbondwidth%
- \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}%
- \rlap{\sbond}%
- \protect\raisebox{-.4ex}{\sbond}%
- \else\ifnum\pdf@strcmp{#1}{-~-}=0%
- \mhchem@setbondwidth%
- \rlap{\protect\raisebox{.4ex}{\sbond}}%
- \rlap{\mhchem@halfbond}%
- \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\fi\fi\fi%
-}
+\ExplSyntaxOn
+\char_set_catcode_letter:n { 126 } % tilde
+\cs_new_protected:Npn \mhchem@bond #1
+ {
+ \str_case:nnn {#1}
+ {
+ { - } { \sbond }
+ { 1 } { \sbond }
+ { = } { \dbond }
+ { 2 } { \dbond }
+ { ## } { \tbond }
+ { 3 } { \tbond }
+ { ~ }
+ {
+ \mhchem@setbondwidth
+ \mhchem@halfbond
+ }
+ { ~- }
+ {
+ \mhchem@setbondwidth
+ \rlap{\protect\raisebox{.2ex}{\mhchem@halfbond}}
+ \protect\raisebox{-.2ex}{\sbond}
+ }
+ { ~-- }
+ {
+ \mhchem@setbondwidth
+ \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}
+ \rlap{\sbond}
+ \protect\raisebox{-.4ex}{\sbond}
+ }
+ { ~= }
+ {
+ \mhchem@setbondwidth
+ \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}
+ \rlap{\sbond}
+ \protect\raisebox{-.4ex}{\sbond}
+ }
+ { -~- }
+ {
+ \mhchem@setbondwidth
+ \rlap{\protect\raisebox{.4ex}{\sbond}}
+ \rlap{\mhchem@halfbond}
+ \protect\raisebox{-.4ex}{\sbond}
+ }
+ { ... } { {\cdot}{\cdot}{\cdot} }
+ { .... } { {\cdot}{\cdot}{\cdot}{\cdot} }
+ { -> } { {\rightarrow} }
+ { <- } { {\leftarrow} }
+ }
+ {
+ %todo Tilde is not a space anymore, here
+ \PackageError{mhchem}{Unknown~bond~type~in~\string\bond~(#1)}%
+ }
+ }
+\ExplSyntaxOff % end of Expl with tilde
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%% loop helpers %%%%%%%%%%
@@ -2407,15 +2415,29 @@
%%%%%%%%%%%%%%%%%%%%%
\cs_new_protected:Npn \__mhchem_chemfive:nnnnnn #1#2#3#4#5#6
{
- \mhchem@prepostscript%
- {\mhchem@mathOrText{\smash[t]{2+}}}%
- {\mhchem@mathOrText{\smash[t]{2}}}%
- {\mhchem@mathOrText{#1}}%
- {\mhchem@mathOrText{#2}}%
- {\mhchem@mathOrText@ii{\mhchem@option@mathFont{#3}}{\text{#3}}}%
- {\mhchem@mathOrText{#4}}%
- {\mhchem@mathOrText{#5}}%
- {\mhchem@mathOrText{#6}}%
+ \str_if_eq:VnTF \mhchem@option@superscriptstacked { true }
+ {
+ \mhchem@prepostscript%
+ {\mhchem@mathOrText{\smash[t]{2+}}}%
+ {\mhchem@mathOrText{\smash[t]{2}}}%
+ {\mhchem@mathOrText{#1}}%
+ {\mhchem@mathOrText{#2}}%
+ {\mhchem@mathOrText@ii{\mhchem@option@mathFont{#3}}{\text{#3}}}%
+ {\mhchem@mathOrText{#4#6}}%
+ {\mhchem@mathOrText{#5}}%
+ {}%
+ }
+ {
+ \mhchem@prepostscript%
+ {\mhchem@mathOrText{\smash[t]{2+}}}%
+ {\mhchem@mathOrText{\smash[t]{2}}}%
+ {\mhchem@mathOrText{#1}}%
+ {\mhchem@mathOrText{#2}}%
+ {\mhchem@mathOrText@ii{\mhchem@option@mathFont{#3}}{\text{#3}}}%
+ {\mhchem@mathOrText{#4}}%
+ {\mhchem@mathOrText{#5}}%
+ {\mhchem@mathOrText{#6}}%
+ }
}
\ExplSyntaxOff
@@ -2570,6 +2592,9 @@
\def\mhchem@option@textcdot{\cdot}
\define@key{mhchem}{textcdot}{\def\mhchem@option@textcdot{#1}}
+\def\mhchem@option@superscriptstacked{0}
+\define@key{mhchem}{superscriptstacked}[true]{\def\mhchem@option@superscriptstacked{#1}}%
+
%%% begin: standard keyval handling as in many other packages
\def\ProcessOptionsWithKV#1{%
\let\@tempc\relax%