diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemformula.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemformula.sty | 95 |
1 files changed, 72 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty index a509e2772a1..30f254f9039 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty +++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty @@ -5,7 +5,7 @@ % - macros and commands for chemists - % % --------------------------------------------------------------------------- % % - Clemens Niederberger - % -% - 2012/03/20 - % +% - 2012/05/07 - % % --------------------------------------------------------------------------- % % - https://bitbucket.org/cgnieder/chemmacros/ - % % - contact@mychemistry.eu - % @@ -30,8 +30,8 @@ \RequirePackage{ expl3 } \ProvidesExplPackage {chemformula} - {2012/03/20} - {3.2} + {2012/05/07} + {3.3} {typeset chemical compounds and reactions} %-----------------------------------------------------------------------------% @@ -488,7 +488,7 @@ %-----------------------------------------------------------------------------% % MAIN COMMAND -\NewDocumentCommand \chemformula_ch_aux_iii:w { > { \SplitList { ~ } } m } +\NewDocumentCommand \chemformula_ch_main:w { > { \SplitList { ~ } } m } { \group_begin: \cs_set_eq:NN \xspace \scan_stop: @@ -504,7 +504,7 @@ \chemformula_generate_arrows:V \l_chemformula_input_tl \chemformula_generate_name:V \l_chemformula_output_tl \tl_set_rescan:Nno \l_chemformula_output_tl - { \ExplSyntaxOn } + { \ExplSyntaxOn \makeatletter } { \l_chemformula_output_tl } \chemformula_write:V \l_chemformula_output_tl \group_end: @@ -523,6 +523,8 @@ \tl_gclear:N \g_chemformula_output_tl } +% Trickery to use \ch inside align environment: +% bypass \\: \cs_new:Npn \chemformula_ch_aux_i:w #1 \\ #2 \q_stop { \chemformula_ch_aux_ii:w #1 & \q_no_value \q_stop @@ -533,10 +535,10 @@ } } +% bypass &: \cs_new:Npn \chemformula_ch_aux_ii:w #1 & #2 \q_stop { - \tl_gput_right:Nn \g_chemformula_output_tl - { \chemformula_ch_aux_iii:w { #1 } } + \chemformula_ch_aux_iii:w #1 \label{} \q_no_value \q_stop \quark_if_no_value:nF { #2 } { \tl_gput_right:Nn \g_chemformula_output_tl { & } @@ -544,6 +546,40 @@ } } +% bypass \label: +\cs_new:Npn \chemformula_ch_aux_iii:w #1 \label#2 #3 \q_stop + { + \chemformula_ch_aux_iv:w #1 \tag{} \q_no_value \q_stop + \quark_if_no_value:nF { #3 } + { + \tl_gput_right:Nn \g_chemformula_output_tl { \label{#2} } + \chemformula_ch_aux_iii:w #3 \q_stop + } + } + +% bypass \tag: +\cs_new:Npn \chemformula_ch_aux_iv:w #1 \tag#2 #3 \q_stop + { + \chemformula_ch_aux_v:w #1 \intertext{} \q_no_value \q_stop + \quark_if_no_value:nF { #3 } + { + \tl_gput_right:Nn \g_chemformula_output_tl { \tag{#2} } + \chemformula_ch_aux_iv:w #3 \q_stop + } + } + +% bypass \intertext: +\cs_new:Npn \chemformula_ch_aux_v:w #1 \intertext#2 #3 \q_stop + { + \tl_gput_right:Nn \g_chemformula_output_tl + { \chemformula_ch_main:w { #1 } } + \quark_if_no_value:nF { #3 } + { + \tl_gput_right:Nn \g_chemformula_output_tl { \intertext{#2} } + \chemformula_ch_aux_v:w #3 \q_stop + } + } + % user command: \NewDocumentCommand \ch { om } { \chemformula_ch:nn { #1 } { #2 } } @@ -807,23 +843,29 @@ %-----------------------------------------------------------------------------% % bonds: +\dim_new:N \l_chemformula_bond_space_dim +\dim_zero:N \l_chemformula_bond_space_dim + \cs_new:Npn \chemformula_single_bond: { \bool_if:NTF \l_chemformula_sup_bool { \chemformula_minus: } { - \chemformula_tikz:nn { inner~sep=0, outer~sep=0 } - { - \draw node[draw=none,minimum~height=1em,minimum~width=0] - (chemformula-single-bond) at (0,0) {} ; - \draw[butt~cap-butt~cap] (chemformula-single-bond) ++ (0,-.1716em) - -- ++( \l_chemformula_bond_dim ,0) ; - } - } + \skip_horizontal:N \l_chemformula_bond_space_dim + \chemformula_tikz:nn { inner~sep=0, outer~sep=0 } + { + \draw node[draw=none,minimum~height=1em,minimum~width=0] + (chemformula-single-bond) at (0,0) {} ; + \draw[butt~cap-butt~cap] (chemformula-single-bond) ++ (0,-.1716em) + -- ++( \l_chemformula_bond_dim ,0) ; + } + \skip_horizontal:N \l_chemformula_bond_space_dim + } } \cs_new:Npn \chemformula_double_bond: { + \skip_horizontal:N \l_chemformula_bond_space_dim \chemformula_tikz:nn { inner~sep=0, outer~sep=0 } { \draw node[draw=none,minimum~height=1em,minimum~width=0] @@ -835,10 +877,12 @@ (chemformula-double-bond) ++ (0,-.2574em) -- ++ (\l_chemformula_bond_dim ,0) ; } + \skip_horizontal:N \l_chemformula_bond_space_dim } \cs_new:Npn \chemformula_triple_bond: { + \skip_horizontal:N \l_chemformula_bond_space_dim \chemformula_tikz:nn { inner~sep=0, outer~sep=0 } { \draw node[draw=none,minimum~height=1em,minimum~width=0] @@ -853,6 +897,7 @@ (chemformula-triple-bond) ++ (0,-.3003em) -- ++ (\l_chemformula_bond_dim ,0) ; } + \skip_horizontal:N \l_chemformula_bond_space_dim } %-----------------------------------------------------------------------------% @@ -1146,8 +1191,6 @@ %-----------------------------------------------------------------------------% % set options for next compound: -% TODO: this is not working: -% - applies to first instead of the next cmpd \cs_new:Npn \chemformula_input_options:n #1 { \makeatother @@ -1345,10 +1388,10 @@ \char_set_catcode_letter:N \{ \char_set_catcode_letter:N \} \char_set_catcode_letter:N \\ + \char_set_catcode_letter:N \# } { #1 } % let's see if the compound starts with a sub- or superscript: -% \exp_args:Nx \tl_show:n { \tl_head:V \l_tmpa_tl } \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_tmpa_tl } { ^ } { \bool_set_true:N \l_chemformula_is_isotope_bool } \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_tmpa_tl } { _ } @@ -1356,8 +1399,6 @@ \exp_args:NNx \prop_if_in:NnT \l_chemformula_numbers_prop { \tl_head:V \l_tmpa_tl } { \bool_set_true:N \l_chemformula_is_isotope_bool } -% \bool_if:NT \l_chemformula_is_isotope_bool -% { \exp_args:Nx \tl_show:n { \tl_head:V \l_tmpa_tl } } \tl_if_in:VnT \l_tmpa_tl { ^ } { \tl_replace_all:Nnn \l_tmpa_tl { ^ } @@ -1502,7 +1543,7 @@ { \ExplSyntaxNamesOn \char_set_catcode_other:N \: } { { #1 } } \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } + \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token \tl_replace_all:Nnn \l_tmpa_tl { chemformulaplaceholder } { \_ } \tl_set_rescan:Nno \l_tmpa_tl { \ExplSyntaxOff } { \l_tmpa_tl } \tl_put_right:NV \l_chemformula_input_tl \l_tmpa_tl @@ -1514,7 +1555,7 @@ { \ExplSyntaxNamesOn \char_set_catcode_other:N \: } { { #1 } } \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } + \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token \tl_replace_all:Nnn \l_tmpa_tl { chemformulaplaceholder } { \_ } \tl_set_rescan:Nno \l_tmpa_tl { \ExplSyntaxOff } { \l_tmpa_tl } \tl_put_right:NV \l_chemformula_input_tl \l_tmpa_tl @@ -1580,7 +1621,7 @@ } { \mbox { \( #1 \) } } \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } + \tl_replace_all:Nnn \l_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token \tl_replace_all:Nnn \l_tmpa_tl { chemformulaplaceholder } { \_ } \tl_set_rescan:Nno \l_tmpa_tl { \ExplSyntaxOff } { \l_tmpa_tl } \tl_put_right:NV \l_chemformula_input_tl \l_tmpa_tl @@ -1680,6 +1721,7 @@ } } , bond-length .dim_set:N = \l_chemformula_bond_dim , + bond-offset .dim_set:N = \l_chemformula_bond_space_dim , font-family .code:n = \bool_set_true:N \l_chemformula_fss_bool \bool_set_false:N \l_chemformula_fontspec_bool @@ -1742,9 +1784,16 @@ VERSION HISTORY - improved arrow labels 2012/03/20 - version 3.2 - new: option input via @{<options>} - a few changes in chemmacros.sty +2012/05/07 - version 3.3 - \ch now bypasses \ref{}, \label{}, and \intertext{} + - new features in chemmacros.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO +- Bindungen nach einem Mechanismus ähnlich der Pfeile konstruieren + => Möglichkeit, eigene Bindungen hinzuzufügen, Bindungen leichter um weitere + Typen erweitern + => Problem: bislang nur ein Token pro Bindung möglich + => Makro \bond{<type>}? - Addukte: Zahlen nach * und . automatisch erkennen? - allow fractions in subscripts: _{$\frac{1}{2}$} ? - optionale argumente von \\ nach außen weiterreichen? |