diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-12 23:59:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-12 23:59:09 +0000 |
commit | 071534301ccf5f0717cc236bb7eb49e7dc2cdaa0 (patch) | |
tree | d5c59284d1d4e407094c6f8f42bfe16e7dd5ace5 /Master/texmf-dist/tex/latex/mhchem/mhchem.sty | |
parent | d625e47ffd1453f40c42192234fa3ac1c234e835 (diff) |
mhchem
git-svn-id: svn://tug.org/texlive/trunk@1091 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/mhchem/mhchem.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/mhchem/mhchem.sty | 906 |
1 files changed, 906 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/mhchem/mhchem.sty b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty new file mode 100644 index 00000000000..b3eec4f0670 --- /dev/null +++ b/Master/texmf-dist/tex/latex/mhchem/mhchem.sty @@ -0,0 +1,906 @@ +%% mhchem.sty +%% Copyright 2004-2005 M.a-r.t-i.n H.e-n.s-e.l +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License version 1.3 +% which can be found at +% http://www.latex-project.org/lppl/lppl-1-3.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. +% +% ( In order to fight spam, the maintainer's contact ) +% ( information is "encrypted" with ROT13. ) +% ( If you do not know ROT13 yet and have no tool for ) +% ( decryption, simply do an Internet search for "ROT13". ) +% +% ,---[ ROT 13 ]--- +% | Gur Pheerag Znvagnvare bs guvf jbex vf Znegva Urafry +% | jub pna or pbagnpgrq ivn +% | zupurz@ZnegvaUrafry.qr +% | be ivn znvy +% | Znegva Urafry +% | Cbfgfge. 20 +% | 09232 Unegznaafqbes +% | Treznal +% `---------- +% +% This work consists of the files mhchem.sty, rsphrase.sty, +% mhchem.pdf, legal.txt and whatsnew.txt. +% +% +\ProvidesPackage{mhchem}[2005/07/15 v3.00 for typesetting chemical formulae] +\RequirePackage{ifthen} +\RequirePackage{calc}[1998/07/07] +\RequirePackage{twoopt} +\RequirePackage{amsmath} +\RequirePackage{keyval} +\RequirePackage{graphics} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% Options %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\mhchem@option@version{0} +\define@key{mhchem}{version}{\def\mhchem@option@version{#1}} +\def\mhchem@option@mathfont{\mathrm} +\def\mhchem@option@textfont{} +\define@key{mhchem}{textfontcommand}{\def\mhchem@option@textfont{#1}} +\define@key{mhchem}{textfontname}{\def\mhchem@option@textfont{\csname#1\endcsname}} +\define@key{mhchem}{mathfontcommand}{\def\mhchem@option@mathfont{#1}} +\define@key{mhchem}{mathfontname}{\def\mhchem@option@mathfont{\csname#1\endcsname}} +\define@key{mhchem}{font}{% + \ifthenelse{\equal{sf}{#1}}{% + \def\mhchem@option@textfont{\sffamily}% + \def\mhchem@option@mathfont{\mathsf}% + }{\ifthenelse{\equal{}{#1}}{% + \def\mhchem@option@textfont{}% + \def\mhchem@option@mathfont{\mathrm}% + }{\PackageError{mhchem}{Font option `#1' unknown}}}% +} +\newlength\mhchem@option@minussidebearingleft +\newlength\mhchem@option@minussidebearingright +\setlength\mhchem@option@minussidebearingleft{0.06em} +\setlength\mhchem@option@minussidebearingright{0.11em} +\define@key{mhchem}{minus-sidebearing-left}{\setlength\mhchem@option@minussidebearingleft{#1}} +\define@key{mhchem}{minus-sidebearing-right}{\setlength\mhchem@option@minussidebearingright{#1}} + +\providecommand\mhchemoptions[1]{\setkeys{mhchem}{#1}} + +%%% begin: standard keyval handling as in many other packages +\def\ProcessOptionsWithKV#1{% + \let\@tempc\relax + \let\mhchem@tempa\@empty + \@for\CurrentOption:=\@classoptionslist\do{% + \@ifundefined{KV@#1@\CurrentOption}% + {}% + {% + \edef\mhchem@tempa{\mhchem@tempa,\CurrentOption,}% + \@expandtwoargs\@removeelement\CurrentOption + \@unusedoptionlist\@unusedoptionlist + }% + }% + \edef\mhchem@tempa{% + \noexpand\setkeys{#1}{% + \mhchem@tempa\@ptionlist{\@currname.\@currext}% + }% + }% + \mhchem@tempa + \let\CurrentOption\@empty + \AtEndOfPackage{\let\@unprocessedoptions\relax} +} +\ProcessOptionsWithKV{mhchem}\relax +%%% end: + +\ifnum0=\mhchem@option@version% + \PackageWarningNoLine{mhchem}{% + You did not specify a 'version' option for the mhchem\MessageBreak + package. This means you EITHER have an existing\MessageBreak + document and mhchem was updated to a newer version.\MessageBreak + Please check the mhchem manual in that case! OR, you\MessageBreak + are about to create a new document, in this case,\MessageBreak + please write \string\usepackage[version=2] in your preamble in\MessageBreak + order to use the most recent version of mhchem}% + \def\mhchem@option@version{1}% +\else% +\fi% + +% +% +% +% +% +% +% +% +% +% +% +% +% +% +% + +\def\mhchem@option@usenonsimultaneoussubsuperscripts{0}% +\def\mhchem@option@alwaystextmode{0}% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\providecommand\cmath[1]{\ensuremath{#1}}% + +\DeclareMathSymbol{\mhchem@hyphen}{0}{operators}{45} + +\def\mhchem@empty{} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% \ce %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\ifnum1<\mhchem@option@version% + \newtoks\tok@mhchem@ce@i% + \newtoks\tok@mhchem@ce@ii% + \providecommand*{\cee}[1]{% + \def\mhchem@ce@out{}% + %\ifx\mhchem@END#1\mhchem@END\else% + {\mhchem@ce@v#1\mhchem@empty\\\mhchem@END\mhchem@ENDEND}% + %\fi% + \ensuremath{% + \mhchem@ce@out% + }% + }% +\fi% +\providecommand*{\ce}[1]{% + \def\hyphen{\mhchem@hyphen}% + \bgroup% + \ifnum1<\mhchem@option@version% + \ifmmode\else\def\mhchem@option@alwaystextmode{1}\fi% + \fi% + \ifx\mhchem@END#1\mhchem@END\else% + \ifmmode\else\mhchem@option@textfont\fi% + \ensuremath{% + \mhchem@ce@i#1 \mhchem@END\mhchem@ENDEND% + }% + \fi% + \egroup% +}% + +\def\mhchem@ce@v#1\\#2#3\mhchem@ENDEND{% + \ifx\mhchem@END#2% + %\ifx\mhchem@END#1\mhchem@END\else% + \mhchem@ce@vii#1&\mhchem@END\mhchem@ENDEND% + %\fi% + \else% + \mhchem@ce@vii#1&\mhchem@END\mhchem@ENDEND% + \g@addto@macro\mhchem@ce@out{\\}% + \mhchem@ce@v#2#3\mhchem@ENDEND% + \fi% +} +% +\long\def\mhchem@ce@vii#1#3\mhchem@ENDEND{% + \ifx\mhchem@END#2% + \g@addto@macro\mhchem@ce@out{\ce{#1}}% + \else% + \g@addto@macro\mhchem@ce@out{\ce{#1}}% + \g@addto@macro\mhchem@ce@out{&}% + \mhchem@ce@vii#2#3\mhchem@ENDEND% + \fi% +} + +%%% + +\def\mhchem@ce@i#1#2 #3\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{\ifx\mhchem@END#2\mhchem@END#1\else\mhchem@ce@dash#2\mhchem@END\fi}% + \else\if\noexpand#1<{\ifx\mhchem@END#2\mhchem@END#1\else\mhchem@ce@lt#2\mhchem@END\fi}% + \else\ifx +#1+ \mhchem@ce@ii{#2}% + % + \else\ifx\ce#1 \mhchem@ce@i #2 \mhchem@END% + \else\ifx\cf#1 \cf{#2}% + \else\ifx\cmath#1 \mhchem@ce@cmath #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% + % + \ifx\mhchem@END#3\mhchem@END% + \else% + \ifx\mhchem@END#1\else% + \mhchem@ce@i#3 \mhchem@ENDEND% + \fi% + \fi% +} + +% +\def\mhchem@ce@dash#1#2\mhchem@END{% + \if\noexpand#1>% + {}\ifx \mhchem@END#2\mhchem@END\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 \mhchem@END#2\mhchem@END% + {}\mhchem@givesleft#2{}% + \else% + \mhchem@ce@dashtwo#2\mhchem@END% + \fi% + \else% + <#1#2% + \fi\fi\fi% +} +\def\mhchem@ce@equal#1#2\mhchem@END{% + \if\noexpand#1>% (<=)>... + \ifx \mhchem@END#2\mhchem@END{}\mhchem@equilibrium#2{}% + \else% + \mhchem@ce@equi#2\mhchem@END% + \fi% + \else% + <=#1#2% + \fi% +} +\def\mhchem@ce@equi#1#2\mhchem@END{% + \if\noexpand#1>% + {}\ifx \mhchem@END#2\mhchem@END\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@ce@equiL#1#2\mhchem@END{% + \ifx =#1\mhchem@ce@equiLi#2\mhchem@END% + \else<=#1#2% + \fi% +} +\def\mhchem@ce@equiLi#1#2\mhchem@END{% + \if\noexpand#1>% (<<=)> + {}\ifx \mhchem@END#2\mhchem@END\mhchem@equilibriumLeft#2% + \else\mhchem@ce@deploycommand{mhchem@equilibriumLeft}#2\mhchem@END\fi{}% + \else% + <<=#1#2% + \fi% +} +\def\mhchem@ce@dashtwo#1#2\mhchem@END{% + \if\noexpand#1>% + {}\ifx \mhchem@END#2\mhchem@END\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@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@ce@ii@tmp@i{} +\def\mhchem@ce@ii@tmp@ii{} +\def\mhchem@ce@ii#1{% + \tok@mhchem@ce@ii{#1}% + \edef\mhchem@ce@ii@tmp@i{\the\tok@mhchem@ce@ii}% + % + \def\mhchem@ce@ii@tmp@ii{(^)}% + \ifx\mhchem@ce@ii@tmp@i\mhchem@ce@ii@tmp@ii% + {}\mathop{\uparrow}{}% + \else\def\mhchem@ce@ii@tmp@ii{^}% + \ifx\mhchem@ce@ii@tmp@i\mhchem@ce@ii@tmp@ii% + {}\mathop{\uparrow}{}% + \else\def\mhchem@ce@ii@tmp@ii{(v)}% + \ifx\mhchem@ce@ii@tmp@i\mhchem@ce@ii@tmp@ii% + {}\mathop{\downarrow}{}% + \else\def\mhchem@ce@ii@tmp@ii{v}% + \ifx\mhchem@ce@ii@tmp@i\mhchem@ce@ii@tmp@ii% + {}\mathop{\downarrow}{}% + \else% + \cf{#1}% + \fi\fi\fi\fi% +% \ifthenelse{\equal{{{#1}}}{{{(^)}}}}{{}\mathop{\uparrow}{}}{% +% \ifthenelse{\equal{#1}{^}}{{}\mathop{\uparrow}{}}{% +% \ifthenelse{\equal{#1}{(v)}}{{}\mathop{\downarrow}{}}{% +% \ifthenelse{\equal{#1}{v}}{{}\mathop{\downarrow}{}}{% +% \cf{#1}% +% }%}}}% +}% + +\def\mhchem@ce@cmath#1#2\mhchem@END{\cmath{#1}\cf{#2}} + +%%%%%%%%%%%%% +%%% arrows + +\newlength{\mhchem@arrowminlength} +\setlength{\mhchem@arrowminlength}{1em} +%TODO: adapt min length to each of the math modes + +\newcommandtwoopt*{\mhchem@gives}[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% + \xrightarrow% + [{#2}]% + {{#1}}}} +\newcommandtwoopt*{\mhchem@givesT}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@gives[\text{#1}][\text{#2}]} +\newcommandtwoopt*{\mhchem@givesC}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@gives[\ce{#1}][\ce{#2}]} + +\newcommandtwoopt*{\mhchem@givesleft}[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% + \xleftarrow% + [{#2}]% + {{#1}}}} +\newcommandtwoopt*{\mhchem@givesleftT}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@givesleft[\text{#1}][\text{#2}]} +\newcommandtwoopt*{\mhchem@givesleftC}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@givesleft[\ce{#1}][\ce{#2}]} + +\newcommandtwoopt*{\mhchem@mesomeric}[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% + \ext@arrow 3399\leftrightarrowfill@% + {{#2}}% + {{#1}}}} +\newcommandtwoopt*{\mhchem@mesomericT}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@mesomeric[\text{#1}][\text{#2}]} +\newcommandtwoopt*{\mhchem@mesomericC}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@mesomeric[\ce{#1}][\ce{#2}]} + +%%% idea taken from http://www.texnik.de/misc/harpoon.phtml +\def\mhchem@rightharpoonupfill@{\arrowfill@\relbar\relbar\rightharpoonup} +\def\mhchem@leftharpoondownfill@{\arrowfill@\leftharpoondown\relbar\relbar} +\newcommand*{\mhchem@xrightleftharpoons}[2][]{\mathrel{% + \rlap{\protect\raisebox{.22ex}{$\ext@arrow 3399\mhchem@rightharpoonupfill@{\hphantom{#1}}{#2}$}}% + \raisebox{-.22ex}{$\ext@arrow 3399\mhchem@leftharpoondownfill@{#1}{\hphantom{#2}}$}}} +\newcommandtwoopt*{\mhchem@equilibrium}[2][\hspace{\mhchem@arrowminlength}][]{\ensuremath{% + \mhchem@xrightleftharpoons% + [{#2}]% + {{#1}}}} +\newcommandtwoopt*{\mhchem@equilibriumT}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@equilibrium[\text{#1}][\text{#2}]} +\newcommandtwoopt*{\mhchem@equilibriumC}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@equilibrium[\ce{#1}][\ce{#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}$}% + }} +\newcommandtwoopt*{\mhchem@equilibriumRight}[2][\hphantom{\makebox[\mhchem@arrowminlength]{}}][]{\ensuremath{% + \mhchem@xlongrightshortleftharpoons% + [{#2}]% + {{#1}}}} +\newcommandtwoopt*{\mhchem@equilibriumRightT}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@equilibriumRight[\text{#1}][\text{#2}]} +\newcommandtwoopt*{\mhchem@equilibriumRightC}[2][\hspace{\mhchem@arrowminlength}][]% + {\mhchem@equilibriumRight[\ce{#1}][\ce{#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}$}% + }} +\newcommandtwoopt*{\mhchem@equilibriumLeft}[2][][\hspace{\mhchem@arrowminlength}]{\ensuremath{% + \mhchem@xshortrightlongleftharpoons% + [{#2}]% + {{#1}}}} +\newcommandtwoopt*{\mhchem@equilibriumLeftT}[2][][\hspace{\mhchem@arrowminlength}]% + {\mhchem@equilibriumLeft[\text{#1}][\text{#2}]} +\newcommandtwoopt*{\mhchem@equilibriumLeftC}[2][][\hspace{\mhchem@arrowminlength}]% + {\mhchem@equilibriumLeft[\ce{#1}][\ce{#2}]} + +%%%%%%%%%% +% bonds - basic definition see in \cf +\newlength\mhchem@bondwidth% +\newlength\mhchem@bondheight% +\newlength\mhchem@smallbondwidth@tmpA% +\newlength\mhchem@smallbondwidth@tmpB% +\newlength\mhchem@smallbondwidth% + +\def\mhchem@setbondwidth{% + \setlength\mhchem@bondwidth{\widthof{\sbond}}% + \setlength\mhchem@bondheight{\heightof{\sbond}}% + \setlength\mhchem@smallbondwidth@tmpA{% + \mhchem@bondwidth-\mhchem@option@minussidebearingleft-\mhchem@option@minussidebearingright}% + \setlength\mhchem@smallbondwidth@tmpB{% + \widthof{\sbond\sbond\sbond}-\mhchem@option@minussidebearingleft-% + \mhchem@option@minussidebearingright}% + \setlength\mhchem@smallbondwidth{\mhchem@bondwidth*% + \ratio{\mhchem@smallbondwidth@tmpA}{\mhchem@smallbondwidth@tmpB}}% +} +\def\mhchem@halfbond{\rlap{\hspace{\mhchem@option@minussidebearingleft}% + \resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}\unskip% + \resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}% + \resizebox{\mhchem@smallbondwidth}{\mhchem@bondheight}{\sbond}}% + \phantom{\sbond}} +\def\mhchem@bond#1{% + \mhchem@cf@length{#1}% + {}% + \ifnum\count@>1\relax% + \ifthenelse{\equal{#1}{~-}}{% + \mhchem@setbondwidth% + \rlap{\protect\raisebox{.2ex}{\mhchem@halfbond}}% + \protect\raisebox{-.2ex}{\sbond}}{% + \ifthenelse{\equal{#1}{~--}}{% + \mhchem@setbondwidth% + \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}% + \rlap{\sbond}% + \protect\raisebox{-.4ex}{\sbond}}{% + \ifthenelse{\equal{#1}{~=}}{% + \mhchem@setbondwidth% + \rlap{\protect\raisebox{.4ex}{\mhchem@halfbond}}% + \rlap{\sbond}% + \protect\raisebox{-.4ex}{\sbond}}{% + \ifthenelse{\equal{#1}{-~-}}{% + \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}% + }}}}}}}}% + \else% + \if\noexpand#1##% + \tbond% + \else% + \ifthenelse{\equal{#1}{-}}{\sbond}{% + \ifthenelse{\equal{#1}{=}}{\dbond}{% + \ifthenelse{\equal{#1}{~}}{% + \mhchem@setbondwidth% + \mhchem@halfbond}{% + % + \PackageError{mhchem}{unknown bond type in \string\bond}% + }}}% + \fi% + \fi% +} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% \cf %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newtoks\mhchem@cf@sup% +\newtoks\tok@mhchem@cf@i% + +\providecommand*{\cf}[2][]{% + \bgroup% + \def\sbond{{\ensuremath{-}}}% + \def\dbond{\rlap{\protect\raisebox{.2ex}{\sbond}}\protect\raisebox{-.2ex}{\sbond}}% + \def\tbond{\rlap{\protect\raisebox{.4ex}{\sbond}}% + \rlap{\sbond}\protect\raisebox{-.4ex}{\sbond}}% + \def\hyphen{\mhchem@hyphen}% + \ifmmode\else\def\mhchem@option@alwaystextmode{1}\fi% + \if 1\mhchem@option@alwaystextmode% + \edef\mhchem@mathortext##1{\noexpand\text{##1}}% + \edef\mhchem@mathortext@ii##1##2{##2}% + \else% + \edef\mhchem@mathortext##1{\ifmmode\noexpand\mhchem@option@mathfont{##1}\else\noexpand\text{##1}\fi}% + \edef\mhchem@mathortext@ii##1##2{\ifmmode\noexpand\mhchem@option@mathfont{##1}\else ##2\fi}% + \fi% + \ifmmode\else\mhchem@option@textfont\fi% + \ensuremath{% + \def\mhchem@cf@element{}% + \def\mhchem@cf@number{}% + %\def\mhchem@cf@sup{}% + \def\mhchem@cf@presub{}% + \def\mhchem@cf@presup{}% + \def\mhchem@cf@others{}% + \def\mhchem@cf@state{s}% +% +% +% +% +% +% + \ifthenelse{\equal{#1}{}}% + {\mhchem@cf@i #2\mhchem@END\mhchem@ENDEND}% + {\ensuremath{\overset{#1}{\mhchem@cf@i #2\mhchem@END\mhchem@ENDEND}}}% + %TODO: insert kerning if full stop (or similar) follows superscript + %\@ifnextchar,{\kern-0.2em}{} ??% + }\egroup% +} +\def\mhchem@cf@output{% + \if\mhchem@cf@state s% + % + \else\if\mhchem@cf@state 1% + {\mhchem@mathortext{\expandafter\mhchem@cf@frac\mhchem@cf@number/\mhchem@END}}% + \else\if\mhchem@cf@state n% + {\mhchem@mathortext{\expandafter\mhchem@cf@frac\mhchem@cf@number/\mhchem@END}}% + \else% + \if\mhchem@option@usenonsimultaneoussubsuperscripts 0% + \mhchem@chemfive{\mhchem@cf@presup}{\mhchem@cf@presub}% + {\mhchem@cf@element}{\mhchem@cf@number}{\the\mhchem@cf@sup}{}% + \else% + \mhchem@chemfive{\mhchem@cf@presup}{\mhchem@cf@presub}% + {\mhchem@cf@element}{\mhchem@cf@number}{}{\the\mhchem@cf@sup}% + \fi% + \fi\fi\fi% + \def\mhchem@cf@element{}% + \def\mhchem@cf@number{}% + % + \mhchem@cf@sup{}% + \def\mhchem@cf@presub{}% + \def\mhchem@cf@presup{}% + \def\mhchem@cf@others{}% +} +\def\mhchem@cf@output@o#1{% + \mhchem@cf@output% + \if\mhchem@cf@state s\else\nolinebreak\fi% + {#1}% +} +\def\mhchem@cf@length#1{% +% +% +% +% +% +% +% +% + \count@=0% + \ifx\mhchem@END#1\mhchem@END% + \else% + \count@=1% + \mhchem@cf@length@i#1\mhchem@END% + \fi% +} +% +% +\def\mhchem@cf@length@i#1#2\mhchem@END{% + \ifx\mhchem@END#2\mhchem@END% + \else% + \count@=2% + \fi% +} + +\def\mhchem@cf@frac#1/#2\mhchem@END{\ifthenelse{\equal{#2}{}}{#1\,}{% + \ensuremath{\mathchoice% + {\textstyle\frac{\mhchem@mathortext{#1}}{\mhchem@mathortext{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mskip1mu}% + {\frac{\mhchem@mathortext{#1}}{\mhchem@mathortext{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mskip1mu}% + {\frac{\mhchem@mathortext{#1}}{\mhchem@mathortext{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mskip1mu}% + {\frac{\mhchem@mathortext{#1}}{\mhchem@mathortext{\mhchem@getfirstchar#2\mhchem@ENDgetfirstchar}}\mskip1mu}}}} +\def\mhchem@getfirstchar#1#2\mhchem@ENDgetfirstchar{#1} +\def\mhchem@getlastchars#1#2\mhchem@ENDgetlastchars{#2} + +\newtoks\mhchem@cf@replaceminus@tok +\def\mhchem@cf@replaceminus#1{% + \mhchem@cf@replaceminus@tok{}% + \mhchem@cf@replaceminus@i#1-\mhchem@END\mhchem@ENDEND% + \the\mhchem@cf@replaceminus@tok} +\def\mhchem@cf@replaceminus@i#1-#2\mhchem@ENDEND{% + \ifx\mhchem@END#2% + \mhchem@cf@replaceminus@tok=\expandafter{\the\mhchem@cf@replaceminus@tok#1}% + \else% + \mhchem@cf@replaceminus@tok=\expandafter{#1\mhchem@mathortext@ii{-}{$\,$--$\,$}}%\ensuremath{-}% + \mhchem@cf@replaceminus@i#2\mhchem@ENDEND% + \fi% +} + +\def\mhchem@cf@replacedot#1{\mhchem@cf@replacedot@i#1.\mhchem@END\mhchem@ENDEND} +\def\mhchem@cf@replacedot@i#1.#2\mhchem@ENDEND{% + \ifx\mhchem@END#2% + #1% + \else% + #1%{\noexpand\textbf{\noexpand\fontfamily{cmr}\noexpand\selectfont\noexpand\textperiodcentered}}% + {\textbf{\fontfamily{cmr}\selectfont\textperiodcentered}}% + \mhchem@cf@replacedot@i#2\mhchem@ENDEND% + \fi% +} + +\def\mhchem@END{} +\def\mhchem@ENDEND{} +\def\mhchem@cf@i#1#2\mhchem@ENDEND{% + \ifx\mhchem@END#1% + \mhchem@cf@output% + \else% + \if\mhchem@cf@state e% + \tok@mhchem@cf@i=\expandafter{\mhchem@cf@replaceminus{#1}}% + \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup% + \expandafter\mhchem@cf@replacedot\expandafter{\the\tok@mhchem@cf@i}}% + \def\mhchem@cf@state{+}% + \else\if\mhchem@cf@state E% + \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup% + \mhchem@mathortext@ii{\mhchem@option@mathfont{#1}}{#1}}% + \def\mhchem@cf@state{+}% + \else\if\mhchem@cf@state p% + \edef\mhchem@cf@presup{\mhchem@cf@presup% + %\mhchem@cf@replaceminus{ + #1}% + %}% + \def\mhchem@cf@state{*}% + \else\if\mhchem@cf@state P% + \edef\mhchem@cf@presup{\mhchem@cf@presup% + \mhchem@mathortext@ii{\mhchem@option@mathfont{#1}}{#1}}% + \def\mhchem@cf@state{*}% + \else\if\mhchem@cf@state f% + \g@addto@macro\mhchem@cf@number{#1}% + \def\mhchem@cf@state{+}% + \else\if\mhchem@cf@state F% + \if\mhchem@END\mhchem@cf@number\mhchem@END% + \else\edef\mhchem@cf@number{\mhchem@cf@number\,}\fi% + \edef\mhchem@cf@number{\mhchem@cf@number% + \mhchem@mathortext@ii{\mhchem@option@mathfont{#1}}{#1}}% + \def\mhchem@cf@state{+}% + \else\if\mhchem@cf@state q% + \edef\mhchem@cf@presub{\mhchem@cf@presub #1}% + \def\mhchem@cf@state{*}% + \else\if\mhchem@cf@state Q% + \edef\mhchem@cf@presub{\mhchem@cf@presub% + \mhchem@mathortext@ii{\mhchem@option@mathfont{#1}}{#1}}% + \def\mhchem@cf@state{*}% + \else\if\mhchem@cf@state m% math + \cmath{#1}% + \def\mhchem@cf@state{+}% + \else\if\mhchem@cf@state b% + \mhchem@bond{#1}% + \def\mhchem@cf@state{+}% + \else% + \mhchem@cf@length{#1}% + \ifnum\count@>1% + \mhchem@cf@output@o{#1}% + % + \else% + \ifx\mhchem@END#1\mhchem@END% + \mhchem@cf@output% + \def\mhchem@cf@state{s}% + \else\ifx\ #1\mhchem@cf@output% + \else\ifx#1\cmath% + \mhchem@cf@output% + \def\mhchem@cf@state{m}% + \else\ifx#1\bond% + \ifnum2<\mhchem@option@version% + \mhchem@cf@output% + \def\mhchem@cf@state{b}% + \else% + \mhchem@cf@output% + \sbond% + \fi% + \else\if\noexpand#1`% + \if\mhchem@cf@state s\def\mhchem@cf@state{P}% + \else\if\mhchem@cf@state 1\mhchem@cf@output\def\mhchem@cf@state{P}% + \else\if\mhchem@cf@state *\def\mhchem@cf@state{P}% + \else\def\mhchem@cf@state{E}% + \fi\fi\fi% + \else\if\noexpand#1,% + \if\mhchem@cf@state s\def\mhchem@cf@state{Q}% + \else\if\mhchem@cf@state 1\mhchem@cf@output\def\mhchem@cf@state{Q}% + \else\if\mhchem@cf@state *\def\mhchem@cf@state{Q}% + \else\def\mhchem@cf@state{F}% + \fi\fi\fi% + \else\ifx#1(% + \mhchem@cf@output@o{#1}% + \else\ifx#1)% + \mhchem@cf@output@o{#1}% + \else\ifx#1[% + \mhchem@cf@output@o{#1}% + \else\ifx#1]% + \mhchem@cf@output@o{#1}% + \else\ifx#1+% + \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup #1}% + \def\mhchem@cf@state{+}% + \else\ifx#1-% + \ifnum1<\mhchem@option@version% + \ifx\mhchem@END#2% + \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup \mhchem@cf@replaceminus{#1}}% + \def\mhchem@cf@state{+}% + \else% + \mhchem@cf@output% + \sbond% + \fi% + \else% + \mhchem@cf@sup=\expandafter{\the\mhchem@cf@sup \mhchem@cf@replaceminus{#1}}% + \def\mhchem@cf@state{+}% + \fi% + \else\ifx#1=% + \ifnum1<\mhchem@option@version% + \mhchem@cf@output% + \dbond% + \else% + \mhchem@cf@output@o{#1}% + \fi% + \else\if\noexpand#1##% + \ifnum1<\mhchem@option@version% + \mhchem@cf@output% + \tbond% + \else% + \mhchem@cf@output@o{\#}% + \fi% + \else\ifx#1.% + \mhchem@cf@output% + \mhchem@mathortext@ii{\cdot}{\,\ensuremath{{\cdot}}\,}% + \def\mhchem@cf@state{s}% + \else\ifx#1*% + \mhchem@cf@output% + \mhchem@mathortext@ii{\cdot}{\,\ensuremath{{\cdot}}\,}% + \def\mhchem@cf@state{s}% + \else\ifcat 1\noexpand#1% + \if\mhchem@cf@state 2% + \else% + \if\mhchem@cf@state s% + \def\mhchem@cf@state{1}% + \else\if\mhchem@cf@state 1% + \else% + \def\mhchem@cf@state{2}% + \fi\fi% + \fi% + \edef\mhchem@cf@number{\mhchem@cf@number #1}% + \else\ifcat a\noexpand#1% + \if\mhchem@cf@state a% + \else% + \if\mhchem@cf@state *\else\mhchem@cf@output% + \if\mhchem@cf@state s\else% + \nolinebreak% + \fi% + \fi% + \def\mhchem@cf@state{a}% + \fi% + \edef\mhchem@cf@element{\mhchem@cf@element #1}% + \else% + \ifcat ^\noexpand#1% + \if\mhchem@cf@state s\def\mhchem@cf@state{p}% + \else\if\mhchem@cf@state 1\mhchem@cf@output\def\mhchem@cf@state{p}% + \else\if\mhchem@cf@state *\def\mhchem@cf@state{p}% + \else\def\mhchem@cf@state{e}% + \fi\fi\fi% + \else\if^\noexpand#1% + \if\mhchem@cf@state s\def\mhchem@cf@state{p}% + \else\if\mhchem@cf@state 1\mhchem@cf@output\def\mhchem@cf@state{p}% + \else\if\mhchem@cf@state *\def\mhchem@cf@state{p}% + \else\def\mhchem@cf@state{e}% + \fi\fi\fi% + \else\ifcat _\noexpand#1% + \if\mhchem@cf@state s\def\mhchem@cf@state{q}% + \else\if\mhchem@cf@state 1\mhchem@cf@output\def\mhchem@cf@state{q}% + \else\if\mhchem@cf@state *\def\mhchem@cf@state{q}% + \else\def\mhchem@cf@state{f}% + \fi\fi\fi% + \else% + \mhchem@cf@output@o{#1}% + \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% + \mhchem@cf@length{#2}% + \mhchem@cf@i #2\mhchem@ENDEND% + \fi% +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%% \mhchem@chemfive %%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcommand*{\mhchem@chemfive}[6]{% +% + \def\mhchem@largest@superscript{\smash[t]{2+}}% [4] + \def\mhchem@vphantommathortext##1{\vphantom{\mhchem@mathortext{##1}}}% [2][5] + \m@th% + \ensuremath{% + \ifthenelse{\equal{#1#2}{}}{}{% + \setlength{\dimen0}{\widthof{${}^{% + \mhchem@mathortext{% [5] + #1% [1] + }% [5] + }$}}% [1] + \setlength{\dimen1}{\widthof{${}_{#2}$}}% [1] + \ifdim\dimen0<\dimen1\setlength{\dimen0}{\dimen1}\fi% [1] + \makebox{\vphantom{\text{#3}}}% [2] + {}% + ^{% + \mhchem@mathboxright{\dimen0}{% [1] + \mhchem@vphantommathortext{#5#6}% [2][5] + \mhchem@vphantommathortext{\mhchem@largest@superscript}% [4][5] + \mhchem@mathortext{% [5] + #1% + }% [5] + }% [1] + }% + _{% + \mhchem@mathboxright{\dimen0}{% [1] + \mhchem@vphantommathortext{#4}% [2][5] + \mhchem@mathortext{% [5] + #2% + }% [5] + }% [1] + }% + \mhchem@minispace% [3] + }% + \mhchem@mathortext@ii{% [5] + \mhchem@option@mathfont{#3}% + }{\text{#3}}% [5] + \ifthenelse{\equal{#4#5}{}}{}{% + _{% + \mhchem@vphantommathortext{#2}% [2][5] + \mhchem@mathortext{% [5] + #4% + }% [5] + }% + ^{% + \mhchem@vphantommathortext{#1#6}% [2][5] + \mhchem@vphantommathortext{\mhchem@largest@superscript}% [4][5] + \mhchem@mathortext{% [5] + #5% + }% [5] + }% + }% + \ifthenelse{\equal{#6}{}}{}{% + \mhchem@minispace% [3] + {}% + _{\mhchem@vphantommathortext{#2#4}}% [2][5] + ^{% + \mhchem@vphantommathortext{#1#5}% [2][5] + \mhchem@vphantommathortext{\mhchem@largest@superscript}% [4][5] + \mhchem@mathortext{% [5] + #6% + }% [5] + }% + }% + }% +% +% +% +% +% +% +% +% +} + +\newcommand*{\mhchem@mathbox}[1]{\mathchoice% + {\mbox{\ensuremath{\displaystyle#1}}}% + {\mbox{\ensuremath{\textstyle#1}}}% + {\mbox{\ensuremath{\scriptstyle#1}}}% + {\mbox{\ensuremath{\scriptscriptstyle#1}}}} + +\newcommand*{\mhchem@mathboxright}[2]{\mathchoice% + {\makebox[#1][r]{\ensuremath{\displaystyle#2}}}% + {\makebox[#1][r]{\ensuremath{\textstyle#2}}}% + {\makebox[#1][r]{\ensuremath{\scriptstyle#2}}}% + {\makebox[#1][r]{\ensuremath{\scriptscriptstyle#2}}}} + +\def\mhchem@minispace{% + \setlength{\dimen2}{0pt-\widthof{${}^8_8$}+ + \widthof{$\text{C}^8_8$}-\widthof{$\text{C}^{}_{}$}}% [3] + \kern\dimen2% + % + % +} + +%TODO: option for CrO_4{}^{2-} instead of CrO_4^{2-} - proper switch option [wordstyle] and documentation +%TODO: option to use nicefrac +%TODO: option for automatically using nicefrac im text mode +%TODO: kerning if superscript is followed by arrow (inside ce), comma (outside) etc. +%TODO: make sure a \cf in a (uppercase) heading retains its mixed case +% from fancyhdr.sty version 3.0: +% \def\nouppercase##1{{\let\uppercase\relax\let\MakeUppercase\relax +% \expandafter\let\csname MakeUppercase \endcsname\relax##1}}% +%TODO: bold Parts of formulae? +%TODO: Option for longer arrows +%TODO: spacing? X2 Y ^2- before ^ +%TODO: always minimum length of arrows? override? +%TODO: count0 und dimen@ eliminieren +% +%- ? option for labels on arrows in \scriptstyle? \textstyle?
\ No newline at end of file |