%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % --------------------------------------------------------------------------- % % - the CHEMMACROS bundle - % % - chemmacros-version1.cfg - % % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % % - 2012/01/28 - % % --------------------------------------------------------------------------- % % - http://www.mychemistry.eu/ - % % - contact@mychemistry.eu - % % --------------------------------------------------------------------------- % % - If you have any ideas, questions, suggestions or bugs to report, please - % % - feel free to contact me. - % % --------------------------------------------------------------------------- % % - Copyright 2011-2012 Clemens Niederberger - % % - - % % - This work may be distributed and/or modified under the - % % - conditions of the LaTeX Project Public License, either version 1.3 - % % - of this license or (at your option) any later version. - % % - The latest version of this license is in - % % - http://www.latex-project.org/lppl.txt - % % - and version 1.3 or later is part of all distributions of LaTeX - % % - version 2005/12/01 or later. - % % - - % % - This work has the LPPL maintenance status `maintained'. - % % - - % % - The Current Maintainer of this work is Clemens Niederberger. - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % old definitions of some commands, deprecated commands \RequirePackage { ifthen } % first copy old tools: % --------------------------------------------------------------------------- % \ExplSyntaxOff % 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@ \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@, 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 } % --------------------------------------------------------------------------- % % \setnewstate, \renewstate \State % copy of definitions in v1.1 % \setstatesubscript{right/left} \newcommand*\CM@State@subscript{left} \newcommand*\setstatesubscript[1]{% \renewcommand*\CM@State@subscript{\ifx\relax#1\relax left\else#1\fi} } % \State[,,]{}{} % {} 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: can only have the values 'left' or 'right'}{}% } }% }% \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[,,]{}{}{} % \renewstate[,,]{}{}{} \newcommand*\CM@setnewstate[4][]{% \CM@splitting{#1}{3}% [,,] \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}% [,,,] \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}% \ExplSyntaxOn % --------------------------------------------------------------------------- % % \newreaction \NewDocumentCommand \newreaction { s t+ m m } { \cs_if_exist:cTF { #3 } { \msg_error:nnx { chemmacros } { already-defined } { #3 } } { \IfBooleanTF { #1 } { \bool_set_true:N \l_chemmacros_reactions_star_bool } { \bool_set_false:N \l_chemmacros_reactions_star_bool } \IfBooleanTF { #2 } { \bool_set_true:N \l_chemmacros_reactions_args_bool } { \bool_set_false:N \l_chemmacros_reactions_args_bool } \bool_if:NTF \l_chemmacros_reactions_args_bool { \NewEnviron { #3 } [ 1 ] { \chemmacros_begin_reaction: \begin { #4 } { ##1 } \chemmacros_cee:f { \BODY } \end{ #4 } \chemmacros_end_reaction: } \bool_if:NT \l_chemmacros_reactions_star_bool { \NewEnviron { #3* } [ 1 ] { \begin { #4* } { ##1 } \chemmacros_cee:f { \BODY } \end { #4* } } } } { \NewEnviron { #3 } { \chemmacros_begin_reaction: \begin { #4 } \chemmacros_cee:f { \BODY } \end { #4 } \chemmacros_end_reaction: } \bool_if:NT \l_chemmacros_reactions_star_bool { \NewEnviron { #3* } { \begin { #4* } \chemmacros_cee:f { \BODY } \end { #4* } } } } } } \newreaction* { reaction } { equation } \newreaction* { reactions } { align } % --------------------------------------------------------------------------- % % \mhName % copy of definition in v1.1 % placing text below atom/molecule \newcommand*\CM@mhName@textattr@default{\centering\tiny} % \setmhName{} \newcommand*\setmhName[1]{ \ifx\@empty#1\@empty \renewcommand*\CM@mhName@textattr@default{\centering\tiny} \else \renewcommand*\CM@mhName@textattr@default{#1} \fi } % \mhName[][]{}{} \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}}} } \ExplSyntaxOff % --------------------------------------------------------------------------- % % \newman % copy of definition in v1.1 \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};% }% } % --------------------------------------------------------------------------- % % - p-orbitals -------------------------------------------------------------- % % copy of definition in v1.1 \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% } % full orbital: % \porb[,,] \newcommand*\porb{\def\CM@orb@half{false}\CM@porb}% % half of an orbital: % \phorb[,,] \newcommand*\phorb{\def\CM@orb@half{true}\CM@porb}% % 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 \renewcommand*\CM@orb@height{1em}% \else \renewcommand*\CM@orb@height{#1}% \fi } \ExplSyntaxOn \tex_endinput:D