diff options
author | Karl Berry <karl@freefriends.org> | 2012-03-21 23:09:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2012-03-21 23:09:51 +0000 |
commit | a1cc0e0ea92d774194ebc156455ec9f3771998f2 (patch) | |
tree | 2d515f65bffdd27648ca6e2a563834b4a43f66da /Master/texmf-dist/tex/latex/chemmacros/chemformula.sty | |
parent | 09ea5e9ef5909ec8198759710d1a292dea755378 (diff) |
chemmacros (21mar12)
git-svn-id: svn://tug.org/texlive/trunk@25721 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemformula.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/chemmacros/chemformula.sty | 78 |
1 files changed, 63 insertions, 15 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty index 11b5e014f7f..a509e2772a1 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/14 - % +% - 2012/03/20 - % % --------------------------------------------------------------------------- % % - https://bitbucket.org/cgnieder/chemmacros/ - % % - contact@mychemistry.eu - % @@ -30,8 +30,8 @@ \RequirePackage{ expl3 } \ProvidesExplPackage {chemformula} - {2012/03/14} - {3.1c} + {2012/03/20} + {3.2} {typeset chemical compounds and reactions} %-----------------------------------------------------------------------------% @@ -81,7 +81,7 @@ % pass options to the `chemmacros' package \DeclareOption* { \PassOptionsToPackage { \CurrentOption } { chemmacros } } -\ProcessOptions\relax +\ProcessOptions \scan_stop: \RequirePackage { chemmacros , nicefrac } @@ -228,6 +228,13 @@ \pgfusepathqfillstroke } +% a possibility to overwrite the arrow tips: +\providecommand*\pgfarrowsrenewalias[4]{% + \let\savedef\pgf@arrows@check@already + \def\pgf@arrows@check@already##1##2##3{##3}% + \pgfarrowsdeclarealias{#1}{#2}{#3}{#4}% + \let\pgf@arrows@check@already\savedef} + %-----------------------------------------------------------------------------% % dimension variables \dim_new:N \l_chemformula_arrow_length_dim @@ -494,12 +501,12 @@ { \g_chemformula_options_tl } } \tl_map_function:nN { #1 } \chemformula_input:n - \chemformula_generate_arrows:N \l_chemformula_input_tl - \chemformula_generate_name:N \l_chemformula_output_tl + \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 } { \l_chemformula_output_tl } - \chemformula_write:n { \l_chemformula_output_tl } + \chemformula_write:V \l_chemformula_output_tl \group_end: } @@ -541,7 +548,7 @@ \NewDocumentCommand \ch { om } { \chemformula_ch:nn { #1 } { #2 } } -\cs_new:Npn \chemformula_write:n #1 +\cs_new:Nn \chemformula_write:V { \mode_if_math:TF { @@ -556,7 +563,7 @@ %-----------------------------------------------------------------------------% % arrow generation & detection -\cs_set:Npn \chemformula_generate_arrows:n #1 +\cs_set:Nn \chemformula_generate_arrows:V { \tl_set:No \l_tmpa_tl { #1 } \seq_map_inline:Nn \l_chemformula_arrows_type_seq @@ -566,7 +573,6 @@ } \tl_set_eq:NN \l_chemformula_output_tl \l_tmpa_tl } -\cs_generate_variant:Nn \chemformula_generate_arrows:n { N } \cs_new:Npn \chemformula_detect_arrows:n #1 { @@ -612,14 +618,13 @@ } \cs_generate_variant:Nn \width_to_dim:nn { Nn } -\cs_new:Npn \chemformula_generate_name:n #1 +\cs_new:Nn \chemformula_generate_name:V { \tl_set:No \l_tmpa_tl { #1 } \tl_if_in:onT { \l_tmpa_tl } { ! } { \tl_replace_all:Nnn \l_tmpa_tl { ! } { \chemformula_name_cmpd:w } } \tl_set_eq:NN \l_chemformula_output_tl \l_tmpa_tl } -\cs_generate_variant:Nn \chemformula_generate_name:n { N } \cs_new:Npn \chemformula_detect_name:n #1 { @@ -633,6 +638,8 @@ % parsing input % booleans: \bool_new:N \l_chemformula_inside_ch_bool +\bool_new:N \l_chemformula_options_bool +\bool_new:N \l_chemformula_is_option_bool \bool_new:N \l_chemformula_stoich_bool \bool_new:N \l_chemformula_is_plus_bool \bool_new:N \l_chemformula_is_up_bool @@ -1128,8 +1135,8 @@ \chemformula_input_escape_math:n { #1 } \chemformula_input_stoich:n { #1 } \chemformula_clean_chem_macros:o { \l_chemformula_tmpa_tl } - \chemformula_input_cmpd:oN - { \l_chemformula_tmpa_tl } \l_chemformula_input_tl + \chemformula_input_cmpd:VN + \l_chemformula_tmpa_tl \l_chemformula_input_tl \chemformula_input_arrow:n { #1 } \chemformula_input_name:n { #1 } \chemformula_input_plus:n { #1 } @@ -1138,6 +1145,25 @@ } %-----------------------------------------------------------------------------% +% 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 + \tl_set_rescan:Nnn \l_tmpa_tl { \makeatletter } { #1 } + \tl_if_in:VnTF \l_tmpa_tl { @ } + { + \bool_set_true:N \l_chemformula_options_bool + \bool_set_true:N \l_chemformula_is_option_bool + \tl_remove_all:Nn \l_tmpa_tl { @ } + \exp_last_unbraced:Nno \tl_set:Nn \l_chemformula_internal_options_tl + { \l_tmpa_tl } + } + { \bool_set_false:N \l_chemformula_is_option_bool } + } + +%-----------------------------------------------------------------------------% % input stoichiometric factors \cs_new:Npn \chemformula_input_stoich:n #1 { @@ -1236,8 +1262,19 @@ { \bool_set_true:N \l_chemformula_is_up_bool } \chemformula_detect_arrows:n { #1 } \chemformula_detect_name:n { #1 } + \chemformula_input_options:n { #1 } + \bool_if:NT \l_chemformula_is_option_bool + { + \tl_put_right:Nn #2 + { + \group_begin: + \keys_set:nV { chemmacros / chemformula } + \l_chemformula_internal_options_tl + } + } \bool_if:nT { + !\l_chemformula_is_option_bool && !\l_chemformula_is_plus_bool && !\l_chemformula_is_down_bool && !\l_chemformula_is_up_bool && @@ -1250,6 +1287,15 @@ \tl_put_right:Nn #2 { \chemformula_font_inner: } \chemformula_handle_sub_and_superscripts:nN { #1 } #2 + \bool_if:NT \l_chemformula_options_bool + { + \tl_put_right:Nn #2 + { + \group_end: + \tl_clear:N \l_chemformula_internal_options_tl + } + \bool_set_false:N \l_chemformula_options_bool + } } } { @@ -1258,7 +1304,7 @@ \tl_clear:N \l_chemformula_stoich_tl } } -\cs_generate_variant:Nn \chemformula_input_cmpd:nN { oN , fN , xN } +\cs_generate_variant:Nn \chemformula_input_cmpd:nN { VN } \cs_new:Nn \chemformula_font_inner: { @@ -1694,6 +1740,8 @@ VERSION HISTORY - new option charge-vshift 2012/03/14 - version 3.1c - a few changes in chemmacros.sty - improved arrow labels +2012/03/20 - version 3.2 - new: option input via @{<options>} + - a few changes in chemmacros.sty %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TODO |