summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty230
1 files changed, 126 insertions, 104 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
index 26cb76ea4ab..3b99d33eb9b 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.sty
@@ -26,8 +26,8 @@
% - The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\RequirePackage{ expl3 , xparse , l3keys2e }
-\def\chemmacros@version{4.1}
-\def\chemmacros@date{2013/08/24}
+\def\chemmacros@version{4.2}
+\def\chemmacros@date{2013/10/28}
\ProvidesExplPackage
{chemmacros}
@@ -55,6 +55,8 @@
\cs_generate_variant:Nn \prop_put:Nnn { NV , NVx }
\cs_generate_variant:Nn \prop_get:NnNTF { NV }
\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV }
+\cs_generate_variant:Nn \tl_if_eq:nnTF { V }
+\cs_generate_variant:Nn \tl_const:cn { cV }
% --------------------------------------------------------------------------
% load required packages
@@ -127,6 +129,13 @@
{ \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } }
}
+\cs_new_protected:Npn \chemmacros_msg:nn #1#2
+ {
+ \bool_if:NTF \l_chemmacros_strict_bool
+ { \msg_error:nn { #1 } { #2 } }
+ { \msg_warning:nn { #1 } { #2 } }
+ }
+
\cs_new_protected:Npn \chemmacros_warning:nnxx #1#2#3#4
{
\bool_if:NTF \l_chemmacros_strict_bool
@@ -296,28 +305,35 @@
properly~ \msg_line_context: .
}
-\msg_new:nnnn { chemmacros } { DeclareChemState }
+\msg_new:nnnn { chemmacros } { declare-state }
{
The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl
already~ exists.~ You~ need~ to~ use~ \token_to_str:N \RenewChemState
- \c_space_tl to~ alter~ it.
+ \c_space_tl to~ alter~ it~ \msg_line_context: .
}
{
The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl
already~ exists.~ You~ need~ to~ use~ \token_to_str:N \RenewChemState
- \c_space_tl to~ alter~ it.
+ \c_space_tl to~ alter~ it~ \msg_line_context: .
}
-\msg_new:nnnn { chemmacros } { RenewChemState }
+\msg_new:nnnn { chemmacros } { renew-state }
{
The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl
isn't~ set~ up~ yet.~ You~ need~ to~ use~ \token_to_str:N
- \DeclareChemState \c_space_tl to~ create~ it.
+ \DeclareChemState \c_space_tl to~ create~ it~ \msg_line_context: .
}
{
The~ state~ \exp_after:wN \token_to_str:N \cs:w #1 \cs_end: \c_space_tl
isn't~ set~ up~ yet.~ You~ need~ to~ use~ \token_to_str:N
- \DeclareChemState \c_space_tl to~ create ~it.
+ \DeclareChemState \c_space_tl to~ create ~it~ \msg_line_context: .
+ }
+
+\msg_new:nnn { chemmacros } { state-syntax }
+ {
+ You're~ using~ a~ no~ longer~ recommended~ syntax~ to~ (re-)define~ a~
+ state~ variable~ \msg_line_context: .~ This~ syntax~ may~ deprecate~ and~
+ be~ removed~ in~ the~ future.
}
% declare an option as deprecated:
@@ -614,6 +630,13 @@
\cs_new:Npn \chemmacros_remove_backslash:N #1
{ \exp_after:wN \use_none:n \token_to_str:N #1 }
+\prg_new_conditional:Npnn \chemmacros_if_is_cs:n #1 { T,F,TF }
+ {
+ \tl_set:Nx \l__chemmacros_tmpa_tl { \token_if_cs:NTF #1 { } { x } }
+ \tl_if_blank:VTF \l__chemmacros_tmpa_tl
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
% detection and handling of bold face:
\prg_new_conditional:Npnn \chemmacros_if_bold: { T,F,TF }
@@ -909,10 +932,9 @@
\bool_if:NTF \l__chemmacros_chemfig_bool
{
\bool_if:NTF \l__chemmacros_elpair_dots_bool
- {
- { \chemmacros_inner_font: #1 \Lewis { 0: , { \vphantom { #1 } } } }
- }
- { { \chemmacros_inner_font: #1 \Lewis { 0 , \vphantom { #1 } } } }
+ { \chlewis { 0: } { #1 } }
+ { \chlewis { 0| } { #1 } }
+% { { \chemmacros_inner_font: #1 \chlewis { 0=| } { \vphantom { #1 } } } }
}
{
\chemmacros_msg:nnxx { chemmacros } { chemfig } { #1 } {}
@@ -1038,10 +1060,11 @@
\protected\def\chemmacros@sconf#1%
{%
\begingroup
- \tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]
+ \tikz[baseline,text height=1.5ex,text depth=.25ex]
{
- \node(a) {#1} ;
- \draw[->,thick,rotate=90] ($(a.center)+(20:.8em)$) arc (20:340:.8em);
+ \node[anchor=base] (chemmacros@@Sconf) {#1} ;
+ \draw[->,thick,rotate=90]
+ ($(chemmacros@@Sconf.center)+(20:.8em)$) arc (20:340:.8em);
}%
\endgroup
}
@@ -1049,10 +1072,11 @@
\protected\def\chemmacros@rconf#1%
{%
\begingroup
- \tikz[baseline=(a.base),text height=1.5ex,text depth=.25ex]
+ \tikz[baseline,text height=1.5ex,text depth=.25ex]
{
- \node(a) {#1} ;
- \draw[<-,thick,rotate=90] ($(a.center)+(20:.8em)$) arc (20:340:.8em) ;
+ \node[anchor=base] (chemmacros@@Rconf) {#1} ;
+ \draw[<-,thick,rotate=90]
+ ($(chemmacros@@Rconf.center)+(20:.8em)$) arc (20:340:.8em) ;
}%
\endgroup
}
@@ -2337,18 +2361,10 @@
}
\NewDocumentCommand \DeclareChemPhase { mom }
- {
- \IfNoValueTF { #2 }
- { \chemmacros_declare_phase:Nn #1 { #3 } }
- { \chemmacros_declare_phase:Nn #1 { #3 } }
- }
+ { \chemmacros_declare_phase:Nn #1 { #3 } }
\NewDocumentCommand \RenewChemPhase { mom }
- {
- \IfNoValueTF { #2 }
- { \chemmacros_renew_phase:Nn #1 { #3 } }
- { \chemmacros_renew_phase:Nn #1 { #3 } }
- }
+ { \chemmacros_renew_phase:Nn #1 { #3 } }
\cs_new_protected:Npn \__chemmacros_define_phase:Nn #1#2
{
@@ -2620,10 +2636,13 @@
}
}
+\cs_new_protected:Npn \changestate
+ { \mathop{} \! \ChemDelta }
+
% --------------------------------------------------------------------------
% \State
\tl_new:N \l__chemmacros_State_delta_tl
-\tl_set:Nn \l__chemmacros_State_delta_tl { \Delta }
+\tl_set:Nn \l__chemmacros_State_delta_tl { \changestate }
\tl_new:N \l__chemmacros_State_exponent_tl
\tl_set:Nn \l__chemmacros_State_exponent_tl { \standardstate }
@@ -2667,8 +2686,7 @@
\cs_new_protected:Npn \chemmacros_state:nnn #1#2#3
{
\group_begin:
- \IfNoValueF { #1 }
- { \keys_set:nn { chemmacros / state } { #1 } }
+ \keys_set:nn { chemmacros / state } { #1 }
\ensuremath
{
\bool_if:NT \l__chemmacros_State_delta_bool
@@ -2683,11 +2701,11 @@
}
\group_end:
}
-\cs_generate_variant:Nn \chemmacros_state:nnn { fnn,xnn }
+\cs_generate_variant:Nn \chemmacros_state:nnn { xnV }
\bool_if:NF \l__chemmacros_version_one_bool
{
- \NewDocumentCommand \State { s o m G{} }
+ \NewDocumentCommand \State { s O{} m G{} }
{
\group_begin:
\IfBooleanT { #1 }
@@ -2711,7 +2729,7 @@
\tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate }
\tl_new:N \l__chemmacros_thermod_delta_tl
\tl_new:N \l__chemmacros_thermod_delta_default_tl
-\tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \Delta }
+\tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \changestate }
\bool_new:N \l__chemmacros_renewstate_bool
@@ -2738,25 +2756,31 @@
\l__chemmacros_thermod_delta_default_tl
}
-% \DeclareChemState[<keyval>]{<name>}{<symbol>}{<unit>}
\bool_if:NF \l__chemmacros_version_one_bool
{
- \cs_new_protected:Npn \DeclareChemState
+ % \DeclareChemState{<name>}[<keyval>]{<symbol>}{<unit>}
+ \NewDocumentCommand \DeclareChemState { omO{}mm }
{
\bool_set_false:N \l__chemmacros_renewstate_bool
\__chemmacros_setnewstate_reset:
- \peek_meaning:NTF [
- { \__chemmacros_setnewstate:n }
- { \__chemmacros_setnewstate_aux:nnn }
+ \IfNoValueTF { #1 }
+ { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } }
+ {
+ \chemmacros_msg:nn { chemmacros } { state-syntax }
+ \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 }
+ }
}
-% \RenewChemState[<keyval>]{<name>}{<symbol>}{<unit>}
- \cs_new_protected:Npn \RenewChemState
+ % \RenewChemState{<name>}[<keyval>]{<symbol>}{<unit>}
+ \NewDocumentCommand \RenewChemState { omO{}mm }
{
\bool_set_true:N \l__chemmacros_renewstate_bool
\__chemmacros_setnewstate_reset:
- \peek_meaning:NTF [
- { \__chemmacros_setnewstate:n }
- { \__chemmacros_setnewstate_aux:nnn }
+ \IfNoValueTF { #1 }
+ { \chemmacros_define_state:nnnn { #3 } { #2 } { #4 } { #5 } }
+ {
+ \chemmacros_msg:nn { chemmacros } { state-syntax }
+ \chemmacros_define_state:nnnn { #1#3 } { #2 } { #4 } { #5 }
+ }
}
\cs_set_protected:Npn \setnewstate
{
@@ -2777,27 +2801,32 @@
\tl_set:Nn \l__chemmacros_thermod_subscript_left_default_tl { true }
\tl_clear:N \l__chemmacros_thermod_subscript_default_tl
\tl_set:Nn \l__chemmacros_thermod_exponent_default_tl { \standardstate }
- \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \Delta }
+ \tl_set:Nn \l__chemmacros_thermod_delta_default_tl { \changestate }
}
-\cs_new_protected:Npn \__chemmacros_setnewstate:n [#1]
+\cs_new_protected:Npn \chemmacros_define_state:nnnn #1#2#3#4
{
\keys_set:nn { chemmacros / setnewstate } { #1 }
- \__chemmacros_setnewstate_aux:nnn
+ \chemmacros_if_is_cs:nTF { #2 }
+ { \__chemmacros_set_state:xnn { \cs_to_str:N #2 } { #3 } { #4 } }
+ {
+ \chemmacros_msg:nn { chemmacros } { state-syntax }
+ \__chemmacros_set_state:nnn { #2 } { #3 } { #4 }
+ }
}
-\cs_new_protected:Npn \__chemmacros_setnewstate_aux:nnn #1#2#3
+\cs_new_protected:Npn \__chemmacros_set_state:nnn #1#2#3
{
\bool_if:NTF \l__chemmacros_renewstate_bool
{
\cs_if_exist:cF { #1 }
- { \msg_error:nnx { chemmacros } { renewstate } { #1 } }
+ { \msg_error:nnx { chemmacros } { renew-state } { #1 } }
\cs_undefine:c {chemmacros_ #1 _reset: }
- \cs_undefine:c { l__chemmacros_ #1 _subscript_tl }
- \cs_undefine:c { l__chemmacros_ #1 _exponent_tl }
- \cs_undefine:c { l__chemmacros_ #1 _delta_tl }
- \cs_undefine:c { l__chemmacros_ #1 _left_tl }
- \cs_undefine:c { l__chemmacros_ #1 _unit_tl }
+ \cs_undefine:c { c__chemmacros_ #1 _subscript_tl }
+ \cs_undefine:c { c__chemmacros_ #1 _exponent_tl }
+ \cs_undefine:c { c__chemmacros_ #1 _delta_tl }
+ \cs_undefine:c { c__chemmacros_ #1 _left_tl }
+ \cs_undefine:c { c__chemmacros_ #1 _unit_tl }
\cs_undefine:c { #1 }
\cs_undefine:c { #1 _aux_i:n }
\cs_undefine:c { #1 _aux_ii:n }
@@ -2805,41 +2834,41 @@
}
{
\cs_if_exist:cT { #1 }
- { \msg_error:nnx { chemmacros } { setnewstate } { #1 } }
+ { \msg_error:nnx { chemmacros } { declare-state } { #1 } }
}
\group_begin:
- \exp_args:Nnf \tl_const:cn
- { l__chemmacros_ #1 _subscript_tl }
- { \tl_use:N \l__chemmacros_thermod_subscript_default_tl }
- \exp_args:Nnf \tl_const:cn
- { l__chemmacros_ #1 _exponent_tl }
- { \tl_use:N \l__chemmacros_thermod_exponent_default_tl }
- \exp_args:Nnf \tl_const:cn
- { l__chemmacros_ #1 _delta_tl }
- { \tl_use:N \l__chemmacros_thermod_delta_default_tl }
- \exp_args:Nnf \tl_const:cn
- { l__chemmacros_ #1 _left_tl }
- { \tl_use:N \l__chemmacros_thermod_subscript_left_default_tl }
+ \tl_const:cV
+ { c__chemmacros_ #1 _subscript_tl }
+ \l__chemmacros_thermod_subscript_default_tl
+ \tl_const:cV
+ { c__chemmacros_ #1 _exponent_tl }
+ \l__chemmacros_thermod_exponent_default_tl
+ \tl_const:cV
+ { c__chemmacros_ #1 _delta_tl }
+ \l__chemmacros_thermod_delta_default_tl
+ \tl_const:cV
+ { c__chemmacros_ #1 _left_tl }
+ \l__chemmacros_thermod_subscript_left_default_tl
\tl_const:cn
- { l__chemmacros_ #1 _unit_tl }
+ { c__chemmacros_ #1 _unit_tl }
{ #3 }
\cs_new_protected:cpn {chemmacros_ #1 _reset: }
{
\tl_set_eq:Nc
\l__chemmacros_thermod_subscript_tl
- { l__chemmacros_ #1 _subscript_tl }
+ { c__chemmacros_ #1 _subscript_tl }
\tl_set_eq:Nc
\l__chemmacros_thermod_exponent_tl
- { l__chemmacros_ #1 _exponent_tl }
+ { c__chemmacros_ #1 _exponent_tl }
\tl_set_eq:Nc
\l__chemmacros_thermod_delta_tl
- { l__chemmacros_ #1 _delta_tl }
+ { c__chemmacros_ #1 _delta_tl }
\tl_set_eq:Nc
\l__chemmacros_thermod_subscript_left_tl
- { l__chemmacros_ #1 _left_tl }
+ { c__chemmacros_ #1 _left_tl }
\tl_set_eq:Nc
\l__chemmacros_thermod_unit_tl
- { l__chemmacros_ #1 _unit_tl }
+ { c__chemmacros_ #1 _unit_tl }
}
\cs_new_protected:cpn { #1 }
{
@@ -2868,48 +2897,47 @@
{
\ensuremath
{
- \exp_args:Nf \tl_if_eq:nnTF
- { \tl_use:N \l__chemmacros_thermod_subscript_left_tl } { true }
+ \tl_if_eq:VnTF
+ \l__chemmacros_thermod_subscript_left_tl { true }
{
- \chemmacros_state:fnn
+ \chemmacros_state:xnV
{
subscript-left = true ,
exponent =
- { \tl_use:N \l__chemmacros_thermod_exponent_tl } ,
+ { \exp_not:V \l__chemmacros_thermod_exponent_tl } ,
delta =
- { \tl_use:N \l__chemmacros_thermod_delta_tl }
+ { \exp_not:V \l__chemmacros_thermod_delta_tl }
}
{ #2 }
}
{
- \chemmacros_state:fnn
+ \chemmacros_state:xnV
{
subscript-left = false ,
exponent =
- { \tl_use:N \l__chemmacros_thermod_exponent_tl } ,
+ { \exp_not:V \l__chemmacros_thermod_exponent_tl } ,
delta =
- { \tl_use:N \l__chemmacros_thermod_delta_tl }
+ { \exp_not:V \l__chemmacros_thermod_delta_tl }
}
{ #2 }
}
- { \tl_use:N \l__chemmacros_thermod_subscript_tl }
+ \l__chemmacros_thermod_subscript_tl
=
- \exp_args:Nno \SI { ##1 } { \l__chemmacros_thermod_unit_tl }
+ \exp_args:NnV \SI { ##1 } \l__chemmacros_thermod_unit_tl
}
}
\group_end:
\ignorespaces
}
+\cs_generate_variant:Nn \__chemmacros_set_state:nnn { x }
% predefined:
\bool_if:NF \l__chemmacros_version_one_bool
{
- \DeclareChemState {Enthalpy}
- {H} {\kilo\joule\per\mole}
- \DeclareChemState [ delta=false, subscript-left=false ] {Entropy}
+ \DeclareChemState \Enthalpy {H} {\kilo\joule\per\mole}
+ \DeclareChemState \Entropy [ delta=false, subscript-left=false ]
{S} {\joule\per\kelvin\per\mole}
- \DeclareChemState {Gibbs}
- {G} {\kilo\joule\per\mole}
+ \DeclareChemState \Gibbs {G} {\kilo\joule\per\mole}
}
% --------------------------------------------------------------------------
@@ -3732,7 +3760,7 @@
\NewDocumentCommand \chemsetup { o m }
{
\IfNoValueTF { #1 }
- { \keys_set:nn { chemmacros } { #2 } }
+ { \keys_set:nn { chemmacros } { #2 } }
{
\bool_if:NTF \l__chemmacros_version_four_bool
{
@@ -3757,29 +3785,15 @@
{
\pdfstringdefDisableCommands
{
- \cs_set:Npn \- { - }% myabe not a good idea...
+ % \cs_set:Npn \- { - } % maybe not a good idea...
\cs_set:Npn \| { }
\cs_set:Npn \pH { pH }
\cs_set:Npn \pOH { pOH }
\cs_set:Npn \iupac #1 { #1 }
- % \cs_set:Npn \a { alpha }
- % \cs_set:Npn \g { gamma }
- % \cs_set:Npn \d { delta }
- % \cs_set:Npn \m { mu }
- % \cs_set:Npn \n { eta }
- % \cs_set:Npn \w { omega }
- % \cs_set:Npn \N { N }
- % \cs_set:Npn \O { O }
- % \cs_set:Npn \Sf { S }
- % \cs_set:Npn \P { P }
- % \cs_set:Npn \R { (R) }
\cs_set:Npn \cip #1 { (#1) }
- % \cs_set:Npn \E { (E) }
- % \cs_set:Npn \Z { (Z) }
\cs_set:Npn \cis { cis }
\cs_set:Npn \trans { trans }
\cs_set:Npn \tert { tert }
- % \cs_set:Npn \D { D }
\cs_set:Npn \ortho { o }
\cs_set:Npn \meta { m }
\cs_set:Npn \para { p }
@@ -4020,6 +4034,14 @@ Version history
see http://tex.stackexchange.com/q/128792/5049 and
http://tex.stackexchange.com/q/118467/5049 for
reference
+2013/10/28 - version 4.2 - changed particles with electron pairs to use
+ \chlewis
+ - changed \Delta in thermodynamic state variables
+ into \ChemDelta for IUPAC compliance and defined
+ it as an operator
+ - change in the syntax of \DeclareChemState and
+ \RenewChemState and improved both internal
+ definition and user interface
% --------------------------------------------------------------------------- %
% TODO: