summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorManuel Pégourié-Gonnard <mpg@elzevir.fr>2011-08-02 19:36:55 +0000
committerManuel Pégourié-Gonnard <mpg@elzevir.fr>2011-08-02 19:36:55 +0000
commit6891ff595999bc063deca4970de4edeb3db9368f (patch)
tree148d67e9d333abedba93096aa2f7245e5d0335bf /Master/texmf-dist/tex
parentf2d6ed458a41ef939424ba4a5727efd53812544e (diff)
chemmacros 1.1 2011/06/22
git-svn-id: svn://tug.org/texlive/trunk@23352 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty843
1 files changed, 532 insertions, 311 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
index d789aef77ce..dcf361df406 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
@@ -4,7 +4,7 @@
% - a collection of macros to make typesetting chemistry documents more convenient ---- %
% ------------------------------------------------------------------------------------- %
% - Clemens Niederberger -------------------------------------------------------------- %
-% - 2011/05/15 ------------------------------------------------------------------------ %
+% - 2011/06/22 ------------------------------------------------------------------------ %
% ------------------------------------------------------------------------------------- %
% - http://www.mychemistry.eu/ -------------------------------------------------------- %
% - contact@mychemistry.eu ------------------------------------------------------------ %
@@ -28,385 +28,606 @@
% - - %
% - This work consists of the files chemmacros.sty, chemmacros_doc_de.tex, - %
% - chemmacros_doc_de.tex, README - %
-% ------------------------------------------------------------------------------------- %
-% - Version history: ------------------------------------------------------------------ %
-% 2011/05/15 version 1.0 CTAN release %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\def\CM@version{1.0}
-\def\CM@date{2011/05/15}
-\def\CM@name{chemmacros}
-\ProvidesPackage{chemmacros}[\CM@date]
-\typeout{\CM@name\space v\CM@version, \CM@date\space Clemens Niederberger}
-\RequirePackage{xkeyval,amsmath,tikz}
+\newcommand*\CM@version{1.1}%
+\newcommand*\CM@date{2011/06/22}%
+\newcommand*\CM@name{chemmacros}%
+\NeedsTeXFormat{LaTeX2e}[2009/09/24]%
+\ProvidesPackage{chemmacros}[2011/06/22 v1.1 chemistry macros]%
+\RequirePackage{amsmath,tikz,xparse,ifthen,siunitx}%
+\usetikzlibrary{calc}%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - package options ------------------------------------------------------------------- %
+% - ifs ------------------------------------------------------------------------------- %
+\newif\if@CM@circled\@CM@circledfalse%
+\newif\if@CM@german\@CM@germanfalse%
+\newif\if@CM@xspace\@CM@xspacefalse%
+\newif\if@CM@mhchemloaded\@CM@mhchemloadedfalse%
+\newif\if@CM@chemstyleloaded\@CM@chemstyleloadedfalse%
+\newif\if@CM@bpchemloaded\@CM@bpchemloadedfalse%
+\newif\if@CM@bpchem\@CM@bpchemfalse%
+\newif\if@CM@mychemistryloaded\@CM@mychemistryloadedfalse%
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\newif\if@circled\@circledtrue
-\newif\if@mhchemloaded\@mhchemloadedfalse
-\newif\if@xspaceloaded\@xspaceloadedfalse
-\newif\if@siunitxloaded\@siunitxloadedfalse
-\newif\if@chemstyleloaded\@chemstyleloadedfalse
-
-\define@boolkey+[CM]{chemmacros.sty}[CM@]{circled}{
- \ifCM@circled
- \@circledtrue
- \else
- \@circledfalse
- \fi
-}{
- \PackageWarning{chemmacros}{option `circled' is not boolean}
+% - package options ------------------------------------------------------------------- %
+% circled:
+\DeclareOption{circled}{%
+ \@CM@circledtrue%
}
-\define@key[CM]{chemmacros.sty}{xspace}{
- \def\CM@xspace@value{#1}%
+% xspace:
+\newcommand*\CM@xspace{}
+\DeclareOption{xspace}{%
+ \@CM@xspacetrue%
}
-\ProcessOptionsX[CM]
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - tools ----------------------------------------------------------------------------- %
-\def\CM@false{false}%
-\def\CM@true{true}%
-\def\CM@off{off}%
-\def\CM@on{on}%
-\def\CM@right{right}%
-% Optional Argument Analysis ---------------------------------------------------------- %
-% Prüfen ob #2 in #1 enthalten ist
-% (das Makro ist eine Kopie von \CF@if@instr in chemfig.tex von Christian Tellechea)
-\def\CM@if@instr#1#2{%
- \def\CM@if@instr@i##1#2##2\@nil{\ifx\@empty##2\@empty\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}%
- \CM@if@instr@i#1\@@nil#2\@nil%
+% german:
+\DeclareOption{german}{%
+ \@CM@germantrue%
}
-% Am ersten , splitten, #1 in #3 speichern, #2 in \CM@remainargs
-% (das Makro ist eine Kopie von \CF@analyze@movearg in chemfig.tex von Christian Tellechea)
-\def\CM@splitfirst#1,#2\@nil#3{%
- \def#3{#1}\def\CM@remainargs{#2}%
+
+% bpchem:
+\DeclareOption{bpchem}{
+ \@CM@bpchemtrue
}
-% ein durch , in 3 Teile getrenntes Argument splitten
-% (das Makro ist eine Abwandlung von \CF@analyze@movearg in chemfig.tex von Christian Tellechea)
-\def\CM@splitarg#1{%
- \CM@if@instr{#1}{,}{\expandafter\CM@splitfirst#1\@nil\CM@firstarg}{\def\CM@firstarg{#1}}%
- \expandafter\CM@if@instr\expandafter{\CM@remainargs}{,}{\expandafter\CM@splitfirst\CM@remainargs\@nil\CM@secondarg}{\expandafter\def\expandafter\CM@secondarg\expandafter{\CM@remainargs}}%
- \ifx\CM@remainargs\CM@secondarg\let\CM@thirdarg\@empty\else\expandafter\def\expandafter\CM@thirdarg\expandafter{\CM@remainargs}\fi%
+
+% unknown options:
+\DeclareOption*{%
+ \PackageWarning{chemmacros}{Unknown option `\CurrentOption'}%
}
+\ProcessOptions\relax
-\let\CM@xspace\empty%
-\ifx\CM@xspace@value\CM@false\def\CM@xspace{}\fi%
-\ifx\CM@xspace@value\CM@true%
- \@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}
- \def\CM@xspace{\xspace}%
+\if@CM@bpchem
+ \RequirePackage{bpchem}
\fi
-\ifx\CM@xspace@value\CM@off\def\CM@xspace{}\fi%
-\ifx\CM@xspace@value\CM@on%
- \@ifpackageloaded{xspace}{}{\RequirePackage{xspace}}%
- \def\CM@xspace{\xspace}%
+
+\if@CM@xspace
+ \RequirePackage{xspace}%
+ \let\CM@xspace\xspace%
\fi
-\@ifpackageloaded{mhchem}{\@mhchemloadedtrue}{\@mhchemloadedfalse}
-\@ifpackageloaded{siunitx}{\@siunitxloadedtrue}{\@siunitxloadedfalse}
-\@ifpackageloaded{chemstyle}{\@chemstyleloadedtrue}{\@chemstyleloadedfalse}
+\AtBeginDocument{%
+ \@ifpackageloaded{mhchem}{\@CM@mhchemloadedtrue}{\@CM@mhchemloadedfalse}
+ \@ifpackageloaded{chemstyle}{\@CM@chemstyleloadedtrue}{\@CM@chemstyleloadedfalse}
+ \@ifpackageloaded{bpchem}{\@CM@bpchemloadedtrue}{\@CM@bpchemloadedfalse}
+ \@ifpackageloaded{mychemistry}{\@CM@mychemistryloadedtrue}{\@CM@mychemistryloadedfalse}
-\if@mhchemloaded%
- \def\CM@atom#1{\cf{#1}}%
-\else%
- \def\CM@atom#1{\ensuremath{\text{#1}}}%
-\fi
+ \if@CM@mhchemloaded
+ \newcommand*\CM@atom[1]{\cf{#1}}%
+ \else
+ \newcommand*\CM@atom[1]{\mbox{#1}}%
+ \fi
+
+ \if@CM@circled
+ \let\CM@plus\oplus
+ \let\CM@minus\ominus
+ \else
+ \newcommand*\CM@plus{+}%
+ \newcommand*\CM@minus{-}%
+ \fi
+}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - tools ----------------------------------------------------------------------------- %
+% Test if #2 is part of #1
+% (the macro is a copy of chemfig's \CF@if@instr by Christian Tellechea)
+\newcommand*\CM@ifinstr[2]{%
+ \def\CM@ifinstr@i##1#2##2\@nil{\ifx\@empty##2\@empty\expandafter\@secondoftwo\else\expandafter\@firstoftwo\fi}%
+ \CM@ifinstr@i#1#2\@nil%
+}
+
+% split at comma, save part before in #3, save part after in \CM@RemainStr
+% (the macro is a copy of chemfig's \CF@analyze@movearg by Christian Tellechea)
+\def\CM@split#1,#2\@nil#3{%
+ \def#3{#1}\def\CM@RemainStr{#2}%
+}
+
+% Optional Argument Analysis ---------------------------------------------------------- %
+\newcounter{CM@tmp@cnt}
+\setcounter{CM@tmp@cnt}{0}
+\newcounter{CM@splitting@cnt}
+% empty \CM@arg@<num>
+\newcommand*\CM@ClearArgs[1]{%
+ \whiledo{\value{CM@tmp@cnt}<#1}{%
+ \stepcounter{CM@tmp@cnt}%
+ \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\@empty%
+ }%
+ \setcounter{CM@tmp@cnt}{0}%
+}
+% split a list separated by commas into \CM@arg@<num>, number of arguments chosen by #2
+\newcommand*\CM@splitting[2]{%
+ \CM@ClearArgs{#2}%
+ \setcounter{CM@splitting@cnt}{#2-1}%
+ \def\CM@RemainStr{#1}%
+ \whiledo{\value{CM@tmp@cnt}<\value{CM@splitting@cnt}}{%
+ \expandafter\CM@ifinstr\expandafter{\CM@RemainStr}{,}{%
+ \stepcounter{CM@tmp@cnt}%
+ \expandafter\CM@split\CM@RemainStr\@nil\CM@tmp@name%
+ \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\CM@tmp@name%
+ }{%
+ \stepcounter{CM@tmp@cnt}%
+ \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\CM@RemainStr%
+ \let\CM@RemainStr\@empty%
+ \setcounter{CM@tmp@cnt}{\value{CM@splitting@cnt}}%
+ }%
+ }%
+ \stepcounter{CM@tmp@cnt}%
+ \expandafter\let\csname CM@arg@\roman{CM@tmp@cnt}\endcsname\CM@RemainStr%
+ \setcounter{CM@tmp@cnt}{0}%
+}
+
+% check commands for equality --------------------------------------------------------- %
+\newcommand*\CM@compareCs[2]{%
+ \expandafter\let\expandafter\CM@cs@one\csname#1\endcsname%
+ \expandafter\let\expandafter\CM@cs@two\csname#2\endcsname%
+ \ifx\CM@cs@one\CM@cs@two\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
+}
+
+% check strings for equality ---------------------------------------------------------- %
+\newcommand*\CM@compareStr[2]{%
+ \edef\CM@cs@one{#1}%
+ \edef\CM@cs@two{#2}%
+ \ifx\CM@cs@one\CM@cs@two\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi
+}
-\if@circled%
- \def\CM@plus{\oplus}%
- \def\CM@minus{\ominus}%
-\else%
- \def\CM@plus{+}%
- \def\CM@minus{-}%
-\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - particles, charges, other helpers ------------------------------------------------- %
+% - particles, charges ---------------------------------------------------------------- %
% electron
-\def\el{\ensuremath{e^\CM@minus}\CM@xspace}%
+\newcommand*\el{\ensuremath{e^\CM@minus}\CM@xspace}
% proton
-\def\prt{\ensuremath{p^\CM@plus}\CM@xspace}%
+\newcommand*\prt{\ensuremath{p^\CM@plus}\CM@xspace}
% charges
-\def\mch{\@ifnextchar[{\mch@ii}{\mch@i}}%
- \def\mch@i{\ensuremath{{}^{\CM@minus}}}%
- \def\mch@ii[#1]{\ensuremath{{}^{#1\CM@minus}}}%
-\def\pch{\@ifnextchar[{\pch@ii}{\pch@i}}%
- \def\pch@i{\ensuremath{{}^{\CM@plus}}}%
- \def\pch@ii[#1]{\ensuremath{{}^{#1\CM@plus}}}%
-\def\delm{\ensuremath{\text{\tiny$\delta\CM@minus$}}\CM@xspace}%
-\def\delp{\ensuremath{\text{\tiny$\delta\CM@plus$}}\CM@xspace}%
-\def\scrm{\ensuremath{\scriptstyle\CM@minus}}%
-\def\scrp{\ensuremath{\scriptstyle\CM@plus}}%
+\newcommand*\mch[1][]{\ensuremath{{}^{#1\CM@minus}}}
+\newcommand*\pch[1][]{\ensuremath{{}^{#1\CM@plus}}}
+\newcommand*\delm{\mbox{\tiny$\delta\CM@minus$}\CM@xspace}
+\newcommand*\delp{\mbox{\tiny$\delta\CM@plus$}\CM@xspace}
+\newcommand*\scrm{\ensuremath{\scriptstyle\CM@minus}}
+\newcommand*\scrp{\ensuremath{\scriptstyle\CM@plus}}
% neutron
-\def\ntr{\ensuremath{n^0}\CM@xspace}%
+\newcommand*\ntr{\ensuremath{n^0}\CM@xspace}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - stereo descriptors ---------------------------------------------------------------- %
+% - stereo descriptors and sim. ------------------------------------------------------- %
% Cahn-Ingold-Prelog
-\def\Rcip{\textit{(R)}}%
-\def\Scip{\textit{(S)}}%
-\def\cip#1{\textit{(#1)}}%
-\def\Sconf{\@ifnextchar[{\sconf@ii}{\sconf@i}}% S-Konfiguration
- \def\sconf@ii[#1]{\tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]{\draw node(a) at (0,0) {#1};\draw[->,thick,rotate=90] (20:.3cm) arc (20:340:.3cm);}}%
- \def\sconf@i{\tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]{\draw node(a) at (0,0) {S};\draw[->,thick,rotate=90] (20:.3cm) arc (20:340:.3cm);}}%
-\def\Rconf{\@ifnextchar[{\rconf@ii}{\rconf@i}}% R-Konfiguration
- \def\rconf@ii[#1]{\tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]{\draw node(a) at (0,0) {#1};\draw[<-,thick,rotate=90] (20:.3cm) arc (20:340:.3cm);}}%
- \def\rconf@i{\tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]{\draw node(a) at (0,0) {R};\draw[<-,thick,rotate=90] (20:.3cm) arc (20:340:.3cm);}}%
-% E/Z
-\def\E{\textit{(E)}}%
-\def\Z{\textit{(Z)}}%
-\def\cis{\textit{cis}}%
-\def\trans{\textit{trans}}%
+\newcommand*\Rcip{\textit{(R)}}
+\newcommand*\Scip{\textit{(S)}}
+\newcommand*\cip[1]{\textit{(#1)}}
+\newcommand*\Sconf[1][S]{\tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]{\draw node(a) {#1};\draw[->,thick,rotate=90] ($(a.center)+(20:.8em)$) arc (20:340:.8em);}}
+\newcommand*\Rconf[1][R]{\tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]{\draw node(a) {#1};\draw[<-,thick,rotate=90] ($(a.center)+(20:.8em)$) arc (20:340:.8em);}}
+% E(ntgegen)/Z(usammen)
+\newcommand*\E{\textit{(E)}}
+\newcommand*\Z{\textit{(Z)}}
+\AtBeginDocument{\if@CM@bpchemloaded
+ \renewcommand*\cis{\textit{cis}\CM@xspace}
+ \renewcommand*\trans{\textit{trans}\CM@xspace}
+ \else
+ \newcommand*\cis{\textit{cis}\CM@xspace}
+ \newcommand*\trans{\textit{trans}\CM@xspace}
+\fi}
+\newcommand*\tert{\textit{tert}\CM@xspace}
% Fischer
-\def\Dfi{\textsc{d}}%
-\def\Lfi{\textsc{l}}%
+\newcommand*\Dfi{\textsc{d}}
+\newcommand*\Lfi{\textsc{l}}
% ortho/meta/para
-\def\ortho{\textsl{o}}%
-\def\meta{\textsl{m}}%
-\def\para{\textsl{p}}%
+\newcommand*\ortho{\textsl{o}}
+\newcommand*\meta{\textsl{m}}
+\newcommand*\para{\textsl{p}}
+
+% latin phrases
+\AtBeginDocument{\if@CM@chemstyleloaded
+ \newcommand*\insitu{\latin{in situ}\CM@xspace}
+ \newcommand*\abinitio{\latin{ab initio}\CM@xspace}
+\else
+ \newcommand*\insitu{\textit{in situ}\CM@xspace}
+ \newcommand*\abinitio{\textit{ab initio}\CM@xspace}
+\fi}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - ions, molecules ------------------------------------------------------------------- %
+% Proton, Hydroxide, Hydronium/Oxonium, water, nucleophile, electrophile
+\newcommand*\Hpl{\CM@atom{H\pch}\CM@xspace}
+\newcommand*\Hyd{\CM@atom{OH\mch}\CM@xspace}
+\newcommand*\HtO{\CM@atom{H$_3$O\pch}\CM@xspace}
+\newcommand*\water{\CM@atom{H$_2$O}\CM@xspace}
+\newcommand*\Nu{\CM@atom{Nu\mch}\CM@xspace}
+\newcommand*\El{\CM@atom{E\pch}\CM@xspace}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - acid/base ------------------------------------------------------------------------- %
+\newcommand*\pH{\mbox{\textsl{p}H}\CM@xspace}
+\newcommand*\pOH{\mbox{\textsl{p}OH}\CM@xspace}
+\newcommand*\pKa[1][]{\mbox{\textsl{p}$K_\mathrm{\if@CM@german S\else A\fi#1}$}\CM@xspace}
+\newcommand*\pKb[1][]{\mbox{\textsl{p}$K_\mathrm{B#1}$}\CM@xspace}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - substituents ---------------------------------------------------------------------- %
+% \R[<sign>]{<subscript>}
+\newcommand*\R[2][]{\CM@atom{R$_{\mathrm{#2}}^{\ifx#1+\CM@plus\else\ifx#1-\CM@minus\fi\fi}$}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - ions ------------------------------------------------------------------------------ %
-% Proton, Hydroxid, Hydronium
-\def\Hpl{\CM@atom{H$^\CM@plus$}\CM@xspace}%
-\def\Hyd{\CM@atom{OH$^\CM@minus$}\CM@xspace}%
-\def\HtO{\CM@atom{H$_3$O$^\CM@plus$}\CM@xspace}%
+% - units ----------------------------------------------------------------------------- %
+\DeclareSIUnit{\atm}{atm}
+\DeclareSIUnit{\atmosphere}{atm}
+\DeclareSIUnit{\calory}{cal}
+\DeclareSIUnit{\cal}{cal}
+\AtBeginDocument{\if@CM@chemstyleloaded\else
+ \DeclareSIUnit{\cmc}{\cubic\centi\metre}
+ \DeclareSIUnit{\molar}{\mole\per\cubic\deci\metre}
+ \DeclareSIUnit{\Molar}{\textsc{m}}
+\fi}
+\DeclareSIUnit{\moLar}{\mole\per\liter}
+\DeclareSIUnit{\MolMass}{\gram\per\mole}
+\DeclareSIUnit{\normal}{\textsc{n}}
+\DeclareSIUnit{\torr}{torr}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - reaction mechanisms --------------------------------------------------------------- %
+% \mech[<type>]
+% <type> - substitutions: {}, 1, 2, se, 1e, 2e, ar
+% - eliminations: e, e1, e2, cb
+\newcommand*\CM@Substitution[1][]{%
+ \CM@compareStr{#1}{se}{\def\CM@subst@mol{_\mathrm{E}}\let\CM@subst@ar\@empty}{%
+ \CM@compareStr{#1}{1e}{\def\CM@subst@mol{_\mathrm{E}1}\let\CM@subst@ar\@empty}{%
+ \CM@compareStr{#1}{2e}{\def\CM@subst@mol{_\mathrm{E}2}\let\CM@subst@ar\@empty}{%
+ \CM@compareStr{#1}{ar}{\def\CM@subst@mol{_\mathrm{E}}\def\CM@subst@ar{Ar-}}{%
+ \def\CM@subst@mol{_\mathrm{N}#1}\let\CM@subst@ar\@empty}}}}%
+ \CM@atom{\mbox{\CM@subst@ar S}$\CM@subst@mol$}\CM@xspace%
+}
+\newcommand*\CM@Elimination[1][]{%
+ \CM@compareStr{#1}{cb}{\def\CM@elim@mol{1_\mathrm{cb}}}{\def\CM@elim@mol{#1}}%
+ \CM@atom{E$\CM@elim@mol$}\CM@xspace%
+}
+\newcommand*\mech[1][]{%
+ \CM@compareStr{#1}{se}{\def\CM@mech@type{S}\def\CM@mech@mol{_\mathrm{E}}\let\CM@mech@ar\@empty}{%
+ \CM@compareStr{#1}{1e}{\def\CM@mech@type{S}\def\CM@mech@mol{_\mathrm{E}1}\let\CM@mech@ar\@empty}{%
+ \CM@compareStr{#1}{2e}{\def\CM@mech@type{S}\def\CM@mech@mol{_\mathrm{E}2}\let\CM@mech@ar\@empty}{%
+ \CM@compareStr{#1}{ar}{\def\CM@mech@type{S}\def\CM@mech@mol{_\mathrm{E}}\def\CM@mech@ar{Ar-}}{%
+ \CM@compareStr{#1}{e}{\def\CM@mech@type{E}\def\CM@mech@mol{}\let\CM@mech@ar\@empty}{%
+ \CM@compareStr{#1}{e1}{\def\CM@mech@type{E}\def\CM@mech@mol{1}\let\CM@mech@ar\@empty}{%
+ \CM@compareStr{#1}{e2}{\def\CM@mech@type{E}\def\CM@mech@mol{2}\let\CM@mech@ar\@empty}{%
+ \CM@compareStr{#1}{cb}{\def\CM@mech@type{E}\def\CM@mech@mol{1_\mathrm{cb}}\let\CM@mech@ar\@empty}{%
+ \def\CM@mech@type{S}\def\CM@mech@mol{_\mathrm{N}#1}\let\CM@mech@ar\@empty}}}}}}}}%
+ \CM@atom{\mbox{\CM@mech@ar\CM@mech@type}$\CM@mech@mol$}\CM@xspace%
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - oxidation numbers ----------------------------------------------------------------- %
% \ox{<number>,<atom>}
-\def\CM@ox@sign#1{%
- \ifx -#1{$-$}%
- \else \ifx +#1{$+$}%
+\newcommand*\CM@ox@sign[1]{%
+ \ifx -#1{$-$}% TODO: bad method here, do you see what happens if #1 is more than 1 token??? Use \@car to avoid the bug!
+ \else \ifx +#1{$+$}% TODO: bad method here, do you see what happens if #1 is more than 1 token??? Use \@car to avoid the bug!
\else #1%
\fi\fi%
}
-\def\ox#1{%
- \let\CM@remainargs\@empty\CM@splitarg{#1}%
- \ifx\CM@firstarg\@empty\PackageError{chemmacros}{\string\ox: oxidation number missing}\fi%
- \ifx\CM@secondarg\@empty\PackageError{chemmacros}{\string\ox: atom missing}\fi%
- \let\CM@thirdarg\@empty%
- \ensuremath{\overset{\text{\tiny\expandafter\CM@ox@sign\CM@firstarg}}{\expandafter\CM@atom\expandafter{\CM@secondarg}}}%
-}%
+% I don't quite understand the problem: that macro is used ONLY in \ox (lines 286-291) where no other input than arabic or (more often) roman numbers with a sign make any sense at all (chemically speaking*). In these cases everything happens as it is supposed to: the signs are changed into the math ones but the letters/numbers stay as they are. I must confess I didn't test senseless cases...
+%* And I would like to think that users who use a macro for oxidation numbers know what oxidation numbers are
+\DeclareRobustCommand\ox[1]{% needs to be robust in order to be used in mhchem's \ce macro
+ \CM@splitting{#1}{2}%
+ \CM@compareCs{CM@arg@i}{@empty}{\PackageError{chemmacros}{\string\ox: oxidation number missing}{}}{}%
+ \CM@compareCs{CM@arg@ii}{@empty}{\PackageError{chemmacros}{\string\ox: atom missing}{}}{}%
+ \ensuremath{\overset{\mbox{\tiny\expandafter\CM@ox@sign\CM@arg@i}}{\expandafter\CM@atom\expandafter{\CM@arg@ii}}}%
+}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - oxidation arrows ------------------------------------------------------------------ %
+% place and name nodes:
% \OX{<name>,<atom>}
-% \redox(<name1>,<name2>)[<tikz>][<dim>]{<text>}
-% node setzen und benennen:
-\def\OX#1{%
- \let\CM@remainargs\@empty\CM@splitarg{#1}%
- \ifx\CM@firstarg\@empty\PackageError{chemmacros}{\string\OX: node name missing}\fi%
- \ifx\CM@secondarg\@empty\PackageError{chemmacros}{\string\OX: atom missing}\fi%
- \let\CM@thirdarg\@empty%
- \tikz[baseline=(\CM@firstarg.base),remember picture]{\node[inner sep=0](\CM@firstarg){\expandafter\CM@atom\expandafter{\CM@secondarg}};}%
+\DeclareRobustCommand*\OX[1]{% needs to be robust in order to be used in mhchem's \ce macro
+ \CM@splitting{#1}{2}%
+ \CM@compareCs{CM@arg@i}{@empty}{\PackageError{chemmacros}{\string\OX: node name missing}{}}{}%
+ \CM@compareCs{CM@arg@i}{@empty}{\PackageError{chemmacros}{\string\OX: atom missing}{}}{}%
+ \tikz[baseline=(\CM@arg@i.base),remember picture]{\node[inner sep=0](\CM@arg@i){\expandafter\CM@atom\expandafter{\CM@arg@ii}};}%
}
-% nodes mit Linie verbinden:
-\def\redox(#1){%
- \let\CM@redox@tikz\@empty%
- \let\CM@remainargs\@empty\CM@splitarg{#1}%
- \ifx\CM@firstarg\@empty\PackageError{chemmacros}{\string\redox: you must specify coordinates}\fi%
- \ifx\CM@secondarg\@empty\PackageError{chemmacros}{\string\redox: you must specify coordinates}\fi%
- \let\CM@thirdarg\@empty%
- \let\CM@redox@begin\CM@firstarg%
- \let\CM@redox@end\CM@secondarg%
- \redox@i%
-}
-\def\redox@i{\@ifnextchar[{\redox@ii}{\def\CM@redox@shift{.6em}\def\CM@redox@anchor{above}\def\CM@redox@side{north}\def\CM@redox@dist{.2em}\redox@v}}
-\def\redox@ii[#1]{%
- \ifx\@empty#1\@empty
- \let\CM@redox@tikz\@empty%
- \else%
- \def\CM@redox@tikz{#1}%
- \fi
- \redox@iii%
-}
-\def\redox@iii{\@ifnextchar[{\redox@iv}{\def\CM@redox@shift{.6em}\def\CM@redox@anchor{above}\def\CM@redox@side{north}\def\CM@redox@dist{.2em}\redox@v}}
-\def\redox@iv[#1]{%
- \ifx\@empty#1\@empty%
- \let\CM@redox@shift\@empty%
- \else%
- \pgfmathparse{#1<0}
- \ifnum\pgfmathresult=1%
- \def\CM@redox@anchor{below}\def\CM@redox@side{south}\def\CM@redox@dist{-.2em}%
+% connect nodes with "redox"-line
+% \redox(<name1>,<name2>)[<tikz>][<dim>]{<text>}
+\newcommand*\CM@redox@dist{.6em}
+\newcommand*\setredoxdist[1]{\ifx\@empty#1\@empty\renewcommand*\CM@redox@dist{.6em}\else\renewcommand*\CM@redox@dist{#1}\fi}
+\NewDocumentCommand\redox{d()oom}{%
+ \IfNoValueTF{#1}{%
+ \PackageError{chemmacros}{\string\redox: You need to specify coordinates}{}
+ }{%
+ \CM@splitting{#1}{2}%
+ \let\CM@redox@begin\CM@arg@i%
+ \let\CM@redox@end\CM@arg@ii%
+ }
+ \IfNoValueTF{#2}{\def\CM@redox@tikz{}}{\def\CM@redox@tikz{#2}}
+ \IfNoValueTF{#3}{%
+ \def\CM@redox@shift{1}%
+ \def\CM@redox@anchor{above}%
+ \def\CM@redox@side{north}%
+ \def\CM@redox@sep{.2em}%
+ }{%
+ \pgfmathparse{#3<0}% TODO : You should learn to test if an integer is less than 0: \ifnum#1<\z@
+% #3 is not necessarily an integer. It is more likely real; if you know a way to test if '-.5' is less than 0 that's easier than \pgfmathparse, please let me know.
+ \ifnum\pgfmathresult=1 %
+ \def\CM@redox@anchor{below}\def\CM@redox@side{south}\def\CM@redox@sep{-.2em}%
\else%
- \def\CM@redox@anchor{above}\def\CM@redox@side{north}\def\CM@redox@dist{.2em}%
+ \def\CM@redox@anchor{above}\def\CM@redox@side{north}\def\CM@redox@sep{.2em}%
\fi%
- \def\CM@redox@shift{#1}%
- \fi%
- \redox@v%
+ \def\CM@redox@shift{#3}%
+ }
+ \tikz[remember picture,overlay]{\expandafter\draw\expandafter[\CM@redox@tikz] ($(\CM@redox@begin.\CM@redox@side)+(0,\CM@redox@sep)$) -- ++(0,\CM@redox@shift*\CM@redox@dist) -| node[pos=.25,\CM@redox@anchor]{#4} ($(\CM@redox@end.\CM@redox@side)+(0,\CM@redox@sep)$);}%
}
-\def\redox@v#1{%
- \ifx\CM@redox@tikz\@empty\def\CM@redox@tikz{}\fi%
- \ifx\CM@redox@shift\@empty\def\CM@redox@shift{.6em}\def\CM@redox@anchor{above}\fi%
- \tikz[remember picture,overlay]{\expandafter\draw\expandafter[\CM@redox@tikz] ($(\CM@redox@begin.\CM@redox@side)+(0,\CM@redox@dist)$) -- ++(0,\CM@redox@shift) -| node[pos=.25,\CM@redox@anchor]{#1} ($(\CM@redox@end.\CM@redox@side)+(0,\CM@redox@dist)$);}%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - spectroscopy ---------------------------------------------------------------------- %
+% \NMR(<num>,<elem>)[<num>,<unit>]{<solvent>} ALL arguments are optional
+% \NMR* same but without ": $\delta$" at end
+\AtBeginDocument{
+ \NewDocumentCommand\NMR{sG{1,H}d()o}{%
+ \IfBooleanTF{#1}{\let\CM@nmr@delta\@empty}{\ifmmode\def\CM@nmr@delta{\mbox{: }\delta}\else\def\CM@nmr@delta{: $\delta$}\fi}%
+ \CM@splitting{#2}{2}%
+ \let\CM@nmr@istp\CM@arg@i
+ \let\CM@nmr@elem\CM@arg@ii
+ \IfNoValueTF{#3}{%
+ \let\CM@nmr@spec\@empty
+ \let\CM@nmr@freq\@empty
+ }{%
+ \let\CM@nmr@spec\relax
+ \CM@splitting{#3}{2}%
+ \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@nmr@unit{\mega\hertz}}{\def\CM@nmr@unit{\CM@arg@ii}}%
+ \def\CM@nmr@freq{\expandafter\SI\expandafter{\CM@arg@i}{\CM@nmr@unit}}%
+ }%
+ \IfNoValueTF{#4}{%
+ \let\CM@nmr@lm\@empty
+ \let\CM@nmr@comma\@empty
+ }{%
+ \let\CM@nmr@spec\relax
+ \def\CM@nmr@lm{\CM@atom{#4}}%
+ \CM@compareCs{CM@nmr@freq}{@empty}{\let\CM@nmr@comma\@empty}{\def\CM@nmr@comma{,\ifmmode\medspace\else\hspace{\smallskipamount}\fi}}%
+ }%
+ \CM@compareCs{CM@nmr@spec}{@empty}{}{%
+ \def\CM@nmr@spec{\hspace{\smallskipamount}(\CM@nmr@freq\CM@nmr@comma\CM@nmr@lm)}%
+ }%
+ \if@CM@bpchem
+ \ifmmode
+ \expandafter\text\expandafter{\IUPAC{\^{\CM@nmr@istp}\CM@nmr@elem-NMR}\CM@nmr@spec}\CM@nmr@delta
+ \else
+ \IUPAC{\^{\CM@nmr@istp}\CM@nmr@elem-NMR}\CM@nmr@spec\CM@nmr@delta\CM@xspace
+ \fi
+ \else
+ \ifmmode
+ ^{\CM@nmr@istp}\expandafter\CM@atom\expandafter{\CM@nmr@elem}\mbox{-}\text{NMR}\CM@nmr@spec\CM@nmr@delta
+ \else
+ $^{\CM@nmr@istp}$\expandafter\CM@atom\expandafter{\CM@nmr@elem}-NMR\CM@nmr@spec\CM@nmr@delta\CM@xspace
+ \fi
+ \fi
+ }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - reaction environments for mhchem -------------------------------------------------- %
-\if@mhchemloaded
- \RequirePackage{mathtools,environ}
- \newtagform{CMreaction}{\{}{\}}
- \newcounter{save@reaction}%
- \newcounter{reaction}%
- \def\CM@AtBeginReaction{\setcounter{save@reaction}{\value{equation}}\setcounter{equation}{\value{reaction}}\usetagform{CMreaction}}%
- \def\CM@AtEndReaction{\setcounter{reaction}{\value{equation}}\setcounter{equation}{\value{save@reaction}}\usetagform{default}}%
- %
- \NewEnviron{reaction}{\CM@AtBeginReaction\begin{equation}\expandafter\ce\expandafter{\BODY}\end{equation}\CM@AtEndReaction}
- \NewEnviron{reaction*}{\begin{equation*}\expandafter\ce\expandafter{\BODY}\end{equation*}}
- %
- \NewEnviron{reactions}{\CM@AtBeginReaction\begin{align}\expandafter\cee\expandafter{\BODY}\end{align}\CM@AtEndReaction}
- \NewEnviron{reactions*}{\begin{align*}\expandafter\cee\expandafter{\BODY}\end{align*}}
-\fi
+% - for use with mhchem --------------------------------------------------------------- %
+\AtBeginDocument{\if@CM@mhchemloaded
+% placing text below atom/molecule
+ \newcommand*\CM@mhName@textattr@default{\centering\tiny}%
+% \setmhName{<commands>}
+ \newcommand*\setmhName[1]{%
+ \ifx\@empty#1\@empty
+ \renewcommand*\CM@mhName@textattr@default{\centering\tiny}%
+ \else
+ \renewcommand*\CM@mhName@textattr@default{#1}%
+ \fi
+ }
+% \mhName[<width>][<textattr>]{<formula>}{<text>}
+ \newlength{\CM@mhName@boxlength}%
+ \NewDocumentCommand\mhName{oomm}{%
+ \IfNoValueTF{#1}{%
+ \settowidth{\CM@mhName@boxlength}{#3}%
+ }{%
+ \ifx\@empty#1\@empty
+ \settowidth{\CM@mhName@boxlength}{#3}%
+ \else
+ \setlength{\CM@mhName@boxlength}{#1}%
+ \fi
+ }%
+ \IfNoValueTF{#2}{%
+ \let\CM@mhName@textattr\CM@mhName@textattr@default
+ }{%
+ \def\CM@mhName@textattr{#2}
+ }
+ \def\CM@mhName@formula{#3}
+ \ensuremath{\underset{\parbox{\CM@mhName@boxlength}{\CM@mhName@textattr#4}}{\expandafter\ce\expandafter{\CM@mhName@formula}}}%
+ }
+% reaction environments for mhchem
+ \RequirePackage{mathtools,environ}
+ \newtagform{CMreaction}{\{}{\}}
+ \newcounter{save@reaction}%
+ \newcounter{reaction}%
+ \newcommand*\CM@AtBeginReaction{\setcounter{save@reaction}{\value{equation}}\setcounter{equation}{\value{reaction}}\usetagform{CMreaction}}%
+ \newcommand*\CM@AtEndReaction{\setcounter{reaction}{\value{equation}}\setcounter{equation}{\value{save@reaction}}\usetagform{default}}%
+% \newreaction*+{<name>}{<type>}
+% * and + are optional
+ \NewDocumentCommand\newreaction{st+mm}{%
+ \@ifundefined{#3}{%
+ \IfBooleanTF{#2}{%
+ \NewEnviron{#3}[1]{\CM@AtBeginReaction\begin{#4}{##1}\expandafter\cee\expandafter{\BODY}\end{#4}\CM@AtEndReaction}
+ \IfBooleanTF{#1}{%
+ \NewEnviron{#3*}[1]{\begin{#4*}{##1}\expandafter\cee\expandafter{\BODY}\end{#4*}}%
+ }{}%
+ }{%
+ \NewEnviron{#3}{\CM@AtBeginReaction\begin{#4}\expandafter\cee\expandafter{\BODY}\end{#4}\CM@AtEndReaction}
+ \IfBooleanTF{#1}{%
+ \NewEnviron{#3*}{\begin{#4*}\expandafter\cee\expandafter{\BODY}\end{#4*}}%
+ }{}%
+ }%
+ }{\PackageError{chemmacros}{The environment/command #3 is already defined}{}}%
+ }
+% predefined:
+ \newreaction*{reaction}{equation}%
+ \newreaction*{reactions}{align}%
+\fi}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% - phases ---------------------------------------------------------------------------- %
+\newcommand*\solid[1][]{\ensuremath{_\mathrm{(\ifx\@empty#1\@empty\if@CM@german f\else s\fi\else#1\fi)}}}
+\newcommand*\gas{\ensuremath{_\mathrm{(g)}}}
+\newcommand*\liquid[1][]{\ensuremath{_\mathrm{(\ifx\@empty#1\@empty\if@CM@german f\/l\else l\fi\else#1\fi)}}}
+\newcommand*\aq{\ensuremath{_\mathrm{(aq)}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - transition state symbol ----------------------------------------------------------- %
-\def\transitionstatesymbol{\tikz[inner sep=0,outer sep=0,minimum size=0]{%
- \coordinate (@TSa) at (0,0);%
- \coordinate (@TSb) at (0,.6em);%
- \draw(@TSa)--node[pos=.3333](@TSx){}node[pos=.6667](@TSy){}(@TSb);%
+\AtBeginDocument{%
+\newcommand*\CM@transition@state@symbol{\tikz[inner sep=0,outer sep=0,minimum size=0]{%
+ \draw(0,0)--node[pos=.3333](@TSx){}node[pos=.6667](@TSy){}(0,.6em);%
\draw(@TSx)++(-.3em,0)--++(.6em,0);%
\draw(@TSy)++(-.3em,0)--++(.6em,0);}%
}
+% make sure symbol scales correctly:
+\if@CM@mychemistryloaded
+ \renewcommand*\transitionstatesymbol{\ifmmode\text{\CM@transition@state@symbol}\else\CM@transition@state@symbol\fi}
+\else
+ \newcommand*\transitionstatesymbol{\ifmmode\text{\CM@transition@state@symbol}\else\CM@transition@state@symbol\fi}
+\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% - enthalpy, entropy ----------------------------------------------------------------- %
-% \State[<exp>,<Delta>,right]{<Symbol>}{<Index>}
-\def\State{\@ifnextchar[{\CM@state@ii}{\CM@state@i}}%
- \def\CM@state@i#1#2{\ensuremath{\Delta_\mathrm{#2}#1\if@chemstyleloaded^\standardstate\fi}}%
- \def\CM@state@ii[#1]#2#3{%
- \let\CM@remainargs\@empty\CM@splitarg{#1}%
- \ensuremath{\ifx\CM@secondarg\@empty\Delta\else\CM@secondarg\fi\ifx\CM@thirdarg\CM@right\else_\mathrm{#3}\fi#2\ifx\CM@thirdarg\CM@right_\mathrm{#3}\fi\ifx\CM@firstarg\@empty\if@chemstyleloaded^{\standardstate}\fi\else^{\CM@firstarg}\fi}%
- }%
+% - thermodynamics et.al. ------------------------------------------------------------- %
+\AtBeginDocument{\if@CM@chemstyleloaded\else\newcommand*\standardstate{\circ}\fi
-\if@siunitxloaded
- \if@chemstyleloaded\else\def\standardstate{}\fi
- \let\CM@standard@state@symbol\standardstate%
- \def\setnewstate{\@ifnextchar[{\CM@setnewstate@ii}{\let\CM@current@standard@state@symbol\@empty\def\CM@state@delta{\Delta}\def\CM@state@kind@right{}\CM@setnewstate@i}}%
- \def\CM@setnewstate@ii[#1]{%
- \let\CM@remainargs\@empty\CM@splitarg{#1}% exp,Delta,right
- \ifx\CM@firstarg\@empty\let\CM@current@standard@state@symbol\@empty\else\let\CM@current@standard@state@symbol\CM@firstarg\fi%
- \ifx\CM@secondarg\@empty\def\CM@state@delta{\Delta}\else\let\CM@state@delta\CM@secondarg\fi%
- \ifx\CM@thirdarg\CM@right\let\CM@state@kind@right\CM@right\else\def\CM@state@kind@right{}\fi%
- \CM@setnewstate@i%
- }
- \def\CM@setnewstate@i#1#2#3{%
- \ifx\CM@current@standard@state@symbol\@empty\let\CM@current@standard@state@symbol\standardstate\fi%
- \expandafter\let\csname CM@#1@symbol\endcsname\CM@current@standard@state@symbol%
- \expandafter\let\csname CM@#1@delta\endcsname\CM@state@delta%
- \expandafter\def\csname#1\endcsname{\@ifnextchar[{\csname CM@#1@ii\endcsname}{\csname CM@#1@i\endcsname}}%
- \expandafter\def\csname CM@#1@i\endcsname##1{\ensuremath{\State[\csname CM@#1@symbol\endcsname,\csname CM@#1@delta\endcsname]{#2}{}=\SI{##1}{#3}}}%
- \expandafter\def\csname CM@#1@ii\endcsname[##1]##2{%
- \let\CM@remainargs\@empty\CM@splitarg{##1}% index,exp,einheit
- \let\CM@state@index\CM@firstarg%
- \let\CM@state@symbol\CM@secondarg%
- \let\CM@state@unit\CM@thirdarg%
- \ensuremath{\State[\CM@state@symbol,\csname CM@#1@delta\endcsname]{#2}{\CM@state@index} = \SI{##2}{\ifx\CM@state@unit\@empty#3\else\CM@state@unit\fi}}%
+% \setstatesubscript{right/left}
+\newcommand*\CM@State@subscript{left}
+\newcommand*\setstatesubscript[1]{%
+ \renewcommand*\CM@State@subscript{\ifx\relax#1\relax left\else#1\fi}
+}
+
+% \State[<exp>,<Delta>,<subscript pos>]{<Symbol>}{<Index>}
+% {<Index>} is an optional argument!
+\NewDocumentCommand\State{omG{}}{%
+ \IfNoValueTF{#1}{\CM@splitting{}{3}}{\CM@splitting{#1}{3}}%
+ \ensuremath{%
+ \CM@compareCs{CM@arg@iii}{@empty}{%
+ \CM@compareStr{\CM@State@subscript}{right}{\let\CM@State@sub@left\@empty\def\CM@State@sub@right{_\mathrm{#3}}}{\let\CM@State@sub@right\@empty\def\CM@State@sub@left{_\mathrm{#3}}}%
+ }{
+ \CM@compareStr{\CM@arg@iii}{right}{\let\CM@State@sub@left\@empty\def\CM@State@sub@right{_\mathrm{#3}}}{%
+ \CM@compareStr{\CM@arg@iii}{left}{\let\CM@State@sub@right\@empty\def\CM@State@sub@left{_\mathrm{#3}}}{%
+ \PackageWarning{chemmacros}{\string\State: <subscript pos> can only have the values 'left' or 'right'}{}%
+ }
}%
- }%
- \setnewstate{Enthalpy}{H}{\kilo\joule\per\mole}%
- \setnewstate[, ]{Entropy}{S}{\joule\per\kelvin\per\mole}%
- \setnewstate{Gibbs}{G}{\kilo\joule\per\mole}%
-\fi%
+ }%
+ \CM@compareCs{CM@arg@ii}{@empty}{\Delta}{\CM@arg@ii}\CM@State@sub@left#2\CM@State@sub@right%
+ \CM@compareCs{CM@arg@i}{@empty}{^{\standardstate}}{^{\CM@arg@i}}}%
+}
+
+% \setnewstate[<exp>,<Delta>,<subscript pos>]{<command>}{<letter>}{<unit>}
+% \renewstate[<exp>,<Delta>,<subscript pos>]{<command>}{<letter>}{<unit>}
+\newcommand*\CM@setnewstate[4][]{%
+ \CM@splitting{#1}{3}% [<exp>,<Delta>,<subscript pos>]
+ \CM@compareCs{CM@arg@i}{@empty}{\expandafter\let\csname CM@#2@supscript\endcsname\standardstate}{\expandafter\let\csname CM@#2@supscript\endcsname\CM@arg@i}%
+ \CM@compareCs{CM@arg@ii}{@empty}{\expandafter\let\csname CM@#2@delta\endcsname\Delta}{\expandafter\let\csname CM@#2@delta\endcsname\CM@arg@ii}
+ \CM@compareCs{CM@arg@iii}{@empty}{\@namedef{CM@#2@right}{left}}{\expandafter\let\csname CM@#2@right\endcsname\CM@arg@iii}%
+ \@namedef{#2}{\@ifnextchar[{\@nameuse{CM@#2@ii}}{\@nameuse{CM@#2@i}}}%
+ \@namedef{CM@#2@i}##1{\ensuremath{\State[\@nameuse{CM@#2@supscript},\@nameuse{CM@#2@delta},\@nameuse{CM@#2@right}]{#3}{}=\SI{##1}{#4}}}%
+ \@namedef{CM@#2@ii}[##1]##2{%
+ \CM@splitting{##1}{4}% [<index>,<exp>,<unit>,<subscript pos>]
+ \let\CM@State@index\CM@arg@i
+ \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@State@supscript{\@nameuse{CM@#2@supscript}}}{\let\CM@State@supscript\CM@arg@ii}%
+ \CM@compareCs{CM@arg@iii}{@empty}{\def\CM@State@unit{#4}}{\let\CM@State@unit\CM@arg@iii}%
+ \CM@compareCs{CM@arg@iv}{@empty}{\def\CM@State@right{\@nameuse{CM@#2@right}}}{\let\CM@State@right\CM@arg@iv}%
+ \ensuremath{\State[\CM@State@supscript,\@nameuse{CM@#2@delta},\CM@State@right]{#3}{\CM@State@index} = \SI{##2}{\CM@State@unit}}%
+ }%
+}
+\newcommand*\setnewstate[4][]{%
+ \@ifundefined{#2}{\CM@setnewstate[#1]{#2}{#3}{#4}}{\PackageError{chemmacros}{\string\setnewstate: state #2 is already defined}{}}%
+}
+\newcommand*\renewstate[4][]{%
+ \@ifundefined{#2}{\PackageError{chemmacros}{\string\renewstate: state #2 is not defined}{}}{\CM@setnewstate[#1]{#2}{#3}{#4}}%
+}
+\setnewstate{Enthalpy}{H}{\kilo\joule\per\mole}%
+\setnewstate[, ]{Entropy}{S}{\joule\per\kelvin\per\mole}%
+\setnewstate{Gibbs}{G}{\kilo\joule\per\mole}%
+}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - p-orbitals ------------------------------------------------------------------------ %
-% \phorb[<size factor>,<color>,<angle>]
-\def\CM@phorb{\@ifnextchar[{\CM@phorb@ii}{\let\CM@firstarg\@empty\let\CM@secondarg\@empty\let\CM@thirdarg\@empty\CM@phorb@i}}
-\def\CM@phorb@ii[#1]{\let\CM@remainargs\@empty\CM@splitarg{#1}\CM@phorb@i}
-\def\CM@phorb@i{
- \ifx\CM@firstarg\@empty\def\CM@orb@flip{1.5*\CM@orb@height}\else\def\CM@orb@flip{\CM@firstarg*1.5*\CM@orb@height}\fi
- \ifx\CM@secondarg\@empty\def\CM@orb@color{black}\else\def\CM@orb@color{\CM@secondarg}\fi
- \ifx\CM@thirdarg\@empty\def\CM@orb@ang{0}\else\def\CM@orb@ang{\CM@thirdarg}\fi
- \tikzpicture[overlay,rotate={\CM@orb@ang-90},opacity=.5,inner sep=0pt,outer sep=0pt,text height=0pt,text depth=0pt]
- \pgfsetfillopacity{.5}
- \node(\CM@orb@node){};
- \draw[draw=\CM@orb@color,fill=\CM@orb@color] (\CM@orb@node) .. controls ++(-.9*\CM@orb@height,\CM@orb@flip) and ++(.9*\CM@orb@height,\CM@orb@flip) .. (\CM@orb@node);
- \endtikzpicture
+\newcommand*\CM@porb[1][]{%
+ \CM@splitting{#1}{3}%
+ \CM@compareCs{CM@arg@i}{@empty}{\let\CM@orbital@height\CM@orb@height}{\def\CM@orbital@height{\CM@arg@i*\CM@orb@height}}%
+ \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@orb@color{black}}{\let\CM@orb@color\CM@arg@ii}%
+ \CM@compareStr{\CM@orb@color}{white}{\def\CM@orb@color@draw{black}}{\let\CM@orb@color@draw\CM@orb@color}%
+ \CM@compareCs{CM@arg@iii}{@empty}{\def\CM@orb@ang{0}}{\let\CM@orb@ang\CM@arg@iii}%
+ \tikzpicture[overlay,rotate={\CM@orb@ang-90},opacity=.5,inner sep=0pt,outer sep=0pt,text height=0pt,text depth=0pt]%
+ \pgfsetfillopacity{.5}%
+ \CM@compareStr{\CM@orb@half}{false}{%
+ \draw[draw=black] (0,0) .. controls ++(-.9*\CM@orbital@height,-1.5*\CM@orbital@height) and ++(.9*\CM@orbital@height,-1.5*\CM@orbital@height) .. (0,0);%
+ }{}%
+ \draw[draw=\CM@orb@color@draw,fill=\CM@orb@color] (0,0) .. controls ++(-.9*\CM@orbital@height,1.5*\CM@orbital@height) and ++(.9*\CM@orbital@height,1.5*\CM@orbital@height) .. (0,0);%
+ \endtikzpicture%
}
-\def\phorb{\CM@phorb}
-
+% full orbital:
% \porb[<size factor>,<color>,<angle>]
-\def\CM@porb{\@ifnextchar[{\CM@porb@ii}{\let\CM@firstarg\@empty\let\CM@secondarg\@empty\let\CM@thirdarg\@empty\CM@porb@i}}
-\def\CM@porb@ii[#1]{\let\CM@remainargs\@empty\CM@splitarg{#1}\CM@porb@i}
-\def\CM@porb@i{
- \ifx\CM@firstarg\@empty\def\CM@orb@flip{1.5*\CM@orb@height}\else\def\CM@orb@flip{\CM@firstarg*1.5*\CM@orb@height}\fi
- \ifx\CM@secondarg\@empty\def\CM@orb@color{black}\else\def\CM@orb@color{\CM@secondarg}\fi
- \ifx\CM@thirdarg\@empty\def\CM@orb@ang{0}\else\def\CM@orb@ang{\CM@thirdarg}\fi
- \tikzpicture[overlay,rotate={\CM@orb@ang-90},opacity=.5,inner sep=0pt,outer sep=0pt,text height=0pt,text depth=0pt]
- \pgfsetfillopacity{.5}
- \node(\CM@orb@node){};
- \draw[draw=black] (\CM@orb@node) .. controls ++(-.9*\CM@orb@height,\CM@orb@flip) and ++(.9*\CM@orb@height,\CM@orb@flip) .. (\CM@orb@node);
- \draw[draw=\CM@orb@color,fill=\CM@orb@color] (\CM@orb@node) .. controls ++(-.9*\CM@orb@height,-\CM@orb@flip) and ++(.9*\CM@orb@height,-\CM@orb@flip) .. (\CM@orb@node);
- \endtikzpicture
-}
-\def\porb{\CM@porb}
+\newcommand*\porb{\def\CM@orb@half{false}\CM@porb}%
+% half of an orbital:
+% \phorb[<size factor>,<color>,<angle>]
+\newcommand*\phorb{\def\CM@orb@half{true}\CM@porb}%
-\def\CM@orb@node{x}
-\def\CM@orb@height{1em}
-\def\setorbheight#1{
+% predefined orbitals:
+\newcommand*\pzorb{\porb[,,90]}%
+\newcommand*\pyorb{\porb[,,0]}%
+\newcommand*\pxorb{\porb[,,-135]}%
+
+% change orbital settings:
+\newcommand*\CM@orb@height{1em}%
+\newcommand*\setorbheight[1]{%
\ifx\@empty#1\@empty
- \def\CM@orb@height{1em}
+ \renewcommand*\CM@orb@height{1em}%
\else
- \def\CM@orb@height{#1}
+ \renewcommand*\CM@orb@height{#1}%
\fi
}
-\def\pzorb{\porb[,,90]}
-\def\pyorb{\porb[,,0]}
-\def\pxorb{\porb[,,-135]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% - Newman projections ---------------------------------------------------------------- %
-\let\CM@newman@tikz@ring\@empty%
-\let\CM@newman@tikz@one\@empty%
-\let\CM@newman@tikz@two\@empty%
-\def\newman{\@ifnextchar[{\CM@newman@ii}{\def\CM@newman@angle{0}\def\CM@newman@scale{1}\let\CM@newman@tikz@ring\@empty\let\CM@newman@tikz@one\@empty\let\CM@newman@tikz@two\@empty\CM@newman@i}}%
-\def\CM@newman@ii[#1]{%
- \let\CM@remainargs\@empty\CM@splitarg{#1}%
- \ifx\CM@firstarg\@empty\def\CM@newman@angle{0}\else\let\CM@newman@angle\CM@firstarg\fi%
- \ifx\CM@secondarg\@empty\def\CM@newman@scale{1}\else\let\CM@newman@scale\CM@secondarg\fi%
- \ifx\CM@thirdarg\@empty\let\CM@newman@tikz@ring\else\let\CM@newman@tikz@ring\CM@thirdarg\fi%
- \CM@newman@iii%
-}
-\def\CM@newman@iii{\@ifnextchar[{\CM@newman@iv}{\CM@newman@i}}
-\def\CM@newman@iv[#1]{%
- \ifx\@empty#1\@empty\let\CM@newman@tikz@one\@empty\else\edef\CM@newman@tikz@one{#1}\fi%
- \let\CM@newman@tikz@two\CM@newman@tikz@one%
- \CM@newman@v%
-}
-\def\CM@newman@v{\@ifnextchar[{\CM@newman@vi}{\CM@newman@i}}
-\def\CM@newman@vi[#1]{%
- \ifx\@empty#1\@empty\else\edef\CM@newman@tikz@two{#1}\fi%
- \CM@newman@i%
-}
-\def\CM@newman@i#1{%
- \let\CM@remainargs\@empty\CM@splitarg{#1}%
- \ifx\CM@firstarg\@empty\let\CM@newman@node@one\@empty\else\let\CM@newman@node@one\CM@firstarg\fi%
- \ifx\CM@secondarg\@empty\let\CM@newman@node@two\CM@newman@tikz@one\else\let\CM@newman@node@two\CM@secondarg\fi%
- \let\CM@remainargs\@empty%
- \expandafter\CM@splitarg\expandafter{\CM@thirdarg}%
- \ifx\CM@firstarg\@empty\let\CM@newman@node@three\@empty\else\let\CM@newman@node@three\CM@firstarg\fi%
- \ifx\CM@secondarg\@empty\let\CM@newman@node@four\@empty\else\let\CM@newman@node@four\CM@secondarg\fi%
- \let\CM@remainargs\@empty%
- \expandafter\CM@splitarg\expandafter{\CM@thirdarg}%
- \ifx\CM@firstarg\@empty\let\CM@newman@node@five\@empty\else\let\CM@newman@node@five\CM@firstarg\fi%
- \ifx\CM@secondarg\@empty\let\CM@newman@node@six\@empty\else\let\CM@newman@node@six\CM@secondarg\fi%
- \let\CM@thirdarg\@empty%
- \edef\CM@newman@tikz{scale=\CM@newman@scale,atomF/.style={inner sep=0,outer sep=0,\CM@newman@tikz@one},atomB/.style={inner sep=0,outer sep=0,\CM@newman@tikz@two}}
- \expandafter\tikz\expandafter[\CM@newman@tikz]{%
- \coordinate (a) at (0,0);
- \expandafter\draw\expandafter[\CM@newman@tikz@ring] (a) circle (.5);
- \foreach\i in{30+\CM@newman@angle,150+\CM@newman@angle,270+\CM@newman@angle}
- {\expandafter\draw\expandafter[\CM@newman@tikz@ring] ($(a)+(\i:0.5)$) --++(\i:.5);}
- \node[atomB,anchor=-150+\CM@newman@angle] at ($(a)+(30+\CM@newman@angle:1.05)$) {\CM@newman@node@five};
- \node[atomB,anchor=-30+\CM@newman@angle] at ($(a)+(150+\CM@newman@angle:1.05)$){\CM@newman@node@six};
- \node[atomB,anchor=90+\CM@newman@angle] at ($(a)+(270+\CM@newman@angle:1.05)$){\CM@newman@node@four};
- \foreach\i in{90,210,330}
- {\expandafter\draw\expandafter[\CM@newman@tikz@ring] (a) --++(\i:1);}
- \node[atomF,anchor=-90] at ($(a)+(90:1.05)$) {\CM@newman@node@one};
- \node[atomF,anchor=30] at ($(a)+(210:1.05)$){\CM@newman@node@two};
- \node[atomF,anchor=150] at ($(a)+(330:1.05)$){\CM@newman@node@three};
+% \newman[<angle>,<scale>,<tikz ring>][<tikz (front) nodes>][<tikz back nodes>]{<1>,<2>,<3>,<4>,<5>,<6>}
+\NewDocumentCommand\newman{ooom}{%
+ \IfNoValueTF{#1}{%
+ \def\CM@newman@angle{0}%
+ \def\CM@newman@scale{1}%
+ \def\CM@newman@tikz@ring{}%
+ }{%
+ \CM@splitting{#1}{3}%
+ \CM@compareCs{CM@arg@i}{@empty}{\def\CM@newman@angle{0}}{\let\CM@newman@angle\CM@arg@i}%
+ \CM@compareCs{CM@arg@ii}{@empty}{\def\CM@newman@scale{1}}{\let\CM@newman@scale\CM@arg@ii}%
+ \expandafter\def\expandafter\CM@newman@tikz@ring\expandafter{\CM@arg@iii}%
+ }
+ \IfNoValueTF{#2}{%
+ \let\CM@newman@tikz@one\@empty%
+ }{%
+ \def\CM@newman@tikz@one{#2}%
}
+ \IfNoValueTF{#3}{%
+ \let\CM@newman@tikz@two\CM@newman@tikz@one%
+ }{%
+ \def\CM@newman@tikz@two{#3}%
+ }
+ \CM@splitting{#4}{6}%
+ \edef\CM@newman@tikz{scale=\CM@newman@scale,CMatomFront/.style={inner sep=0,outer sep=0,\CM@newman@tikz@one},CMatomBack/.style={inner sep=0,outer sep=0,\CM@newman@tikz@two}}
+ \expandafter\tikz\expandafter[\CM@newman@tikz]{%
+ \expandafter\draw\expandafter[\CM@newman@tikz@ring] (0,0) circle (.5);%
+ \foreach\i in{30+\CM@newman@angle,150+\CM@newman@angle,270+\CM@newman@angle}{%
+ \expandafter\draw\expandafter[\CM@newman@tikz@ring] (\i:0.5) --++(\i:.5);%
+ }%
+ \node[CMatomBack,anchor=-150+\CM@newman@angle] at (30+\CM@newman@angle:1.05) {\CM@arg@v};%
+ \node[CMatomBack,anchor=-30+\CM@newman@angle] at (150+\CM@newman@angle:1.05) {\CM@arg@vi};%
+ \node[CMatomBack,anchor=90+\CM@newman@angle] at (270+\CM@newman@angle:1.05) {\CM@arg@iv};%
+ \foreach\i in{90,210,330}{%
+ \expandafter\draw\expandafter[\CM@newman@tikz@ring] (0,0) --++(\i:1);%
+ }%
+ \node[CMatomFront,anchor=-90] at (90:1.05) {\CM@arg@i};%
+ \node[CMatomFront,anchor=30] at (210:1.05) {\CM@arg@ii};%
+ \node[CMatomFront,anchor=150] at (330:1.05) {\CM@arg@iii};%
+ }%
}
-
-\endinput \ No newline at end of file
+\endinput
+% - Version history: ------------------------------------------------------------------ %
+% 2011/05/15 version 1.0 CTAN release %
+% 2011/06/22 version 1.1 "LaTeXified" whole package for safer usage %
+% less user work required (like loading package after another) %
+% more particle macros %
+% latin phrases %
+% extra units %
+% acid/base commands %
+% \mech %
+% \NMR %
+% \mhName, \setmhName, \newreaction, phases %
+% \renewstate, \setstatesubscript %
+% improved orbitals %
+% simpler package options, option german, bpchem %
+% bug fixes % \ No newline at end of file