summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemformula.sty')
-rw-r--r--Master/texmf-dist/tex/latex/chemmacros/chemformula.sty1116
1 files changed, 714 insertions, 402 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
index 12344325e7d..b29047b1e3d 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
@@ -1,41 +1,86 @@
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% --------------------------------------------------------------------------- %
-% - the CHEMMACROS bundle - %
-% - chemformula.sty - %
-% - macros and commands for chemists - %
-% --------------------------------------------------------------------------- %
-% - Clemens Niederberger - %
-% --------------------------------------------------------------------------- %
-% - https://bitbucket.org/cgnieder/chemmacros/ - %
-% - contact@mychemistry.eu - %
-% --------------------------------------------------------------------------- %
-% - If you have any ideas, questions, suggestions or bugs to report, please - %
-% - feel free to contact me. - %
-% --------------------------------------------------------------------------- %
-% - Copyright 2011-2013 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. - %
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\RequirePackage{ chemmacros }
+% --------------------------------------------------------------------------
+% the CHEMMACROS bundle
+% chemformula.sty
+% macros and commands for chemists
+% --------------------------------------------------------------------------
+% Clemens Niederberger
+% --------------------------------------------------------------------------
+% https://bitbucket.org/cgnieder/chemmacros/
+% contact@mychemistry.eu
+% --------------------------------------------------------------------------
+% If you have any ideas, questions, suggestions or bugs to report, please
+% feel free to contact me.
+% --------------------------------------------------------------------------
+% Copyright 2011-2013 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.
+% --------------------------------------------------------------------------
+\RequirePackage{ expl3 , xparse , l3keys2e , tikz , amsmath , xfrac , nicefrac , scrlfile }
+\usetikzlibrary{arrows}
+\def\chemformula@version{4.0}
+\def\chemformula@date{2013/07/06}
+
\ProvidesExplPackage
{chemformula}
- {\chemmacros@date}
- {\chemmacros@version}
+ {\chemformula@date}
+ {\chemformula@version}
{typeset chemical compounds and reactions}
-%-----------------------------------------------------------------------------%
-% WARNING AND ERROR MESSAGES
-\msg_set:nnnn { chemformula } { missing-argument }
+% --------------------------------------------------------------------------
+% check expl3 version:
+\@ifpackagelater { expl3 } { 2012/11/21 }
+ { }
+ {
+ \PackageError { chemformula } { Support~package~expl3~too~old }
+ {
+ You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
+ 'l3packages'.\MessageBreak
+ Loading~chemformula~will~abort!
+ }
+ \tex_endinput:D
+ }
+
+% --------------------------------------------------------------------------
+% warning and erroe messages:
+\cs_new_protected:Npn \chemformula_error:nnxx #1#2#3#4
+ {
+ \bool_if:NTF \l__chemformula_strict_bool
+ { \msg_error:nnxx { #1 } { #2 } { #3 } { #4 } }
+ { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } }
+ }
+
+\cs_new_protected:Npn \chemformula_error:nn #1#2
+ {
+ \bool_if:NTF \l__chemformula_strict_bool
+ { \msg_error:nnxx { #1 } { #2 } }
+ { \msg_warning:nnxx { #1 } { #2 } }
+ }
+
+\cs_new_protected:Npn \chemformula_warning:nnxx #1#2#3#4
+ {
+ \bool_if:NTF \l__chemformula_strict_bool
+ { \msg_warning:nnxx { #1 } { #2 } { #3 } { #4 } }
+ { \msg_info:nnxx { #1 } { #2 } { #3 } { #4 } }
+ }
+
+\cs_new_protected:Npn \chemformula_warning:nn #1#2
+ {
+ \bool_if:NTF \l__chemformula_strict_bool
+ { \msg_warning:nn { #1 } { #2 } }
+ { \msg_info:nn { #1 } { #2 } }
+ }
+
+\msg_new:nnnn { chemformula } { missing-argument }
{
Wrong~name~input~ \msg_line_context: .
}
@@ -47,15 +92,7 @@
Either~way~-~I~don't~know~what~to~do~ \msg_line_context: .
}
-\msg_set:nnnn { chemformula } { explicit }
- { It~seems~you've~loaded~`chemformula'~explicitly. }
- {
- It~seems~you've loaded~`chemformula'~explicitly.~This~should~work~but~the~
- recommended~way~is~to~load~it~via~the~bundle,~i.e.~by~using~
- \token_to_str:N \usepackage \{ chemmacros \}.
- }
-
-\msg_set:nnnn { chemformula } { declare-arrow }
+\msg_new:nnnn { chemformula } { declare-arrow }
{
The~arrow~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined.
}
@@ -65,14 +102,14 @@
~Choose~another~name.
}
-\msg_set:nnnn { chemformula } { renew-arrow }
+\msg_new:nnnn { chemformula } { renew-arrow }
{ The~arrow~type~ \tl_to_str:n { #1 } \c_space_tl is~not~defined. }
{
You've~tried~to~renew~the~arrow~type~\tl_to_str:n { #1 } ~but~it~doesn't~
exist.
}
-\msg_set:nnnn { chemformula } { declare-bond }
+\msg_new:nnnn { chemformula } { declare-bond }
{
The~bond~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined.
}
@@ -82,34 +119,248 @@
~Choose~another~name.
}
-\msg_set:nnnn { chemformula } { renew-bond }
+\msg_new:nnnn { chemformula } { renew-bond }
{ The~bond~type~ \tl_to_str:n { #1 } \c_space_tl is~not~defined. }
{
You've~tried~to~renew~the~bond~type~\tl_to_str:n { #1 } ~but~it~doesn't~
exist.
}
-% --------------------------------------------------------------------------- %
-% scratch variables
+\msg_new:nnnn { chemformula } { stand-alone }
+ {
+ You're~using~`chemformula'~as~a~stand-alone~package~or~have~loaded~it~
+ before~you've~loaded~`chemmacros',~too.~Some~features~might~not~be~
+ provided!~Espacially~you~cannot~use~\token_to_str:N \chemsetup \c_space_tl
+ to~setup~your~formulae.
+ }
+ {
+ You're~using~`chemformula'~as~a~stand-alone~package~or~have~loaded~it~
+ before~you've~loaded~`chemmacros',~too.~Some~features~might~not~be~
+ provided!~Espacially~you~cannot~use~\token_to_str:N \chemsetup \c_space_tl
+ to~setup~your~formulae.
+ }
+
+\msg_new:nnnn { chemformula } { command-deprecated }
+ {
+ The~command~\token_to_str:N #1 \c_space_tl is~deprecated.~Use~
+ \token_to_str:N #2 \c_space_tl instead.
+ }
+ {
+ The~command~\token_to_str:N #1 \c_space_tl is~deprecated.~Use~
+ \token_to_str:N #2 \c_space_tl instead.
+ }
+
+\cs_new_protected:Npn \chemformula_define_deprecated:NNn #1#2#3
+ {
+ \cs_new_protected:Npn #1
+ {
+ \chemformula_error:nnxx { chemformula } { command-deprecated }
+ { #1 } { #2 }
+ #3
+ }
+ }
+
+\NewDocumentCommand \DeprecatedFormulaCommand { mmm }
+ { \chemformula_define_deprecated:NNn #1 #2 { #3 } }
+
+% --------------------------------------------------------------------------
+% variants of kernel functions:
+\cs_generate_variant:Nn \keys_set:nn { nV }
+\cs_generate_variant:Nn \tl_if_blank:nF { V }
+\cs_generate_variant:Nn \tl_if_in:nnT { x }
+\cs_generate_variant:Nn \prop_get:Nn { NV }
+\cs_generate_variant:Nn \tl_set_rescan:Nnn { NnV }
+
+% --------------------------------------------------------------------------
+% package options:
+\bool_new:N \l__chemformula_strict_bool
+\keys_define:nn { chemmacros / chemformula }
+ {
+ strict .bool_set:N = \l__chemformula_strict_bool ,
+ strict .default:n = true
+ }
+
+\ProcessKeysOptions{ chemmacros / chemformula }
+
+\AtBeginDocument
+ {
+ \@ifpackageloaded{ chemmacros }
+ {
+ \bool_if:NT \l_chemmacros_strict_bool
+ { \bool_set_true:N \l__chemformula_strict_bool }
+ }
+ {}
+ }
+
+% --------------------------------------------------------------------------
+% VARIABLES
+% temporary variables:
\tl_new:N \l__chemformula_tmpa_tl
\tl_new:N \l__chemformula_tmpb_tl
\tl_new:N \l__chemformula_tmpc_tl
+
\dim_new:N \l__chemformula_tmpa_dim
\dim_new:N \l__chemformula_tmpb_dim
+
\int_new:N \l__chemformula_tmpa_int
\int_new:N \l__chemformula_tmpb_int
+
\box_new:N \l__chemformula_tmpa_box
\box_new:N \l__chemformula_tmpb_box
-%-----------------------------------------------------------------------------%
-% gobble options
-\DeclareOption* { }
-\ProcessOptions \scan_stop:
+% booleans:
+% this one is officially used to detect wether we're in \ch or not:
+\bool_new:N \l_chemformula_inside_ch_bool
+% those are private:
+\bool_new:N \l__chemformula_formal_charges_bool
+\bool_new:N \l__chemformula_formal_chem_bool
+\bool_set_true:N \l__chemformula_formal_chem_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_no_stoich_bool
+\bool_new:N \l__chemformula_is_plus_bool
+\bool_new:N \l__chemformula_is_up_bool
+\bool_new:N \l__chemformula_is_down_bool
+\bool_new:N \l__chemformula_is_arrow_bool
+\bool_new:N \l__chemformula_is_name_bool
+\bool_new:N \l__chemformula_stoich_is_iupac_bool
+\bool_new:N \l__chemformula_stoich_parse_iupac_bool
+\bool_new:N \l__chemformula_first_last_text_bool
+\bool_new:N \l__chemformula_first_last_double_bool
+\bool_new:N \l__chemformula_first_last_single_bool
+\bool_new:N \l__chemformula_first_last_math_bool
+\bool_new:N \l__chemformula_first_last_dollar_bool
+\bool_new:N \l__chemformula_first_last_mathbraces_bool
+\bool_new:N \l__chemformula_number_style_math_bool
+\bool_new:N \l__chemformula_charge_style_math_bool
+\bool_new:N \l__chemformula_sub_bool
+\bool_new:N \l__chemformula_sup_bool
+\bool_new:N \l__chemformula_is_isotope_bool
+\bool_new:N \l__chemformula_xfrac_bool
+\bool_new:N \l__chemformula_nicefrac_bool
+\bool_new:N \l__chemformula_mathfrac_bool
+\bool_set_true:N \l__chemformula_mathfrac_bool
+\bool_new:N \l__chemformula_fss_bool
+\bool_new:N \l__chemformula_fontspec_bool
+\bool_new:N \l__chemformula_fss_family_bool
+\bool_new:N \l__chemformula_fss_series_bool
+\bool_new:N \l__chemformula_fss_shape_bool
+\bool_new:N \l__chemformula_name_width_bool
+\bool_new:N \l__chemformula_charge_full_shift_bool
+
+% dimensions:
+\dim_new:N \l__chemformula_arrow_length_dim
+\dim_new:N \l__chemformula_arrow_label_offset_dim
+\dim_set:Nn \l__chemformula_arrow_label_offset_dim { 2pt }
+\dim_new:N \l__chemformula_arrow_minimum_length_dim
+\dim_new:N \l__chemformula_arrow_shortage_dim
+\dim_new:N \l__chemformula_arrow_offset_dim
+\dim_set:Nn \l__chemformula_arrow_offset_dim { .75em }
+\dim_new:N \l__chemformula_compound_sep_dim
+\dim_set:Nn \l__chemformula_compound_sep_dim { .5em }
+\dim_new:N \l__chemformula_arrow_yshift_dim
+\dim_set:Nn \l__chemformula_arrow_yshift_dim { 0pt }
+\dim_new:N \l__chemformula_radical_radius_dim
+\dim_set:Nn \l__chemformula_radical_radius_dim { .2ex }
+\dim_new:N \l__chemformula_radical_hshift_dim
+\dim_set:Nn \l__chemformula_radical_hshift_dim { .15em }
+\dim_new:N \l__chemformula_radical_vshift_dim
+\dim_set:Nn \l__chemformula_radical_vshift_dim { .5ex }
+\dim_new:N \l__chemformula_radical_space_dim
+\dim_set:Nn \l__chemformula_radical_space_dim { .15em }
+\dim_new:N \l__chemformula_arrow_head_dim
+\dim_new:N \l__chemformula_name_dim
+\dim_new:N \l__chemformula_adduct_space_dim
+\dim_set:Nn \l__chemformula_adduct_space_dim { .1333em }
+\dim_new:N \l__chemformula_charge_shift_dim
+\dim_set:Nn \l__chemformula_charge_shift_dim { .5ex }
+\dim_new:N \l__chemformula_subscript_shift_dim
+\dim_new:N \l__chemformula_superscript_shift_dim
+\dim_new:N \l__chemformula_subscript_dim
+\dim_zero:N \l__chemformula_subscript_dim
+\dim_new:N \l__chemformula_superscript_dim
+\dim_zero:N \l__chemformula_superscript_dim
+\dim_new:N \l__chemformula_bond_dim
+\dim_set:Nn \l__chemformula_bond_dim { .5833em }
+\dim_new:N \l__chemformula_bond_space_dim
+\dim_set:Nn \l__chemformula_bond_space_dim { .07em }
+
+% skips:
+\skip_new:N \l__chemformula_stoich_space_skip
+\skip_set:Nn \l__chemformula_stoich_space_skip { .1667em plus .0333em minus .0117em }
+\skip_new:N \l__chemformula_math_space_skip
+\skip_set:Nn \l__chemformula_math_space_skip { .1667em plus .0333em minus .0117em }
+\skip_new:N \l__chemformula_plus_space_skip
+\skip_set:Nn \l__chemformula_plus_space_skip { .3em plus .1em minus .1em }
+
-\RequirePackage { nicefrac }
+% integers:
+\int_new:N \l__chemformula_count_tokens_int
+
+% token lists:
+\tl_new:N \l__chemformula_arrow_ratio_tl
+\tl_set:Nn \l__chemformula_arrow_ratio_tl { .6 }
+\tl_new:N \l__chemformula_radical_style_tl
+\tl_new:N \l__chemformula_arrow_head_tl
+\tl_set:Nn \l__chemformula_arrow_head_tl { cf }
+\tl_new:N \l__chemformula_upper_label_tl
+\tl_new:N \l__chemformula_lower_label_tl
+\tl_new:N \l__chemformula_arrow_style_tl
+\tl_new:N \l__chemformula_arrow_label_style_tl
+\tl_set:Nn \l__chemformula_arrow_label_style_tl { \footnotesize }
+\tl_new:N \l__chemformula_arrow_tmp_tl
+\tl_new:N \l__chemformula_arrow_type_tl
+\tl_new:N \l__chemformula_name_tmp_tl
+\tl_new:N \l__chemformula_chemformula_tmpa_tl
+\tl_new:N \g__chemformula_options_tl
+\tl_new:N \g__chemformula_output_tl
+\tl_new:N \l__chemformula_input_tl
+\tl_new:N \l__chemformula_stoich_tl
+\tl_new:N \l__chemformula_decimal_output_tl
+\tl_set:Nn \l__chemformula_decimal_output_tl { . }
+\tl_new:N \l__chemformula_font_family_tl
+\tl_set_eq:NN \l__chemformula_font_family_tl \f@family
+\tl_new:N \l__chemformula_font_series_tl
+\tl_set_eq:NN \l__chemformula_font_series_tl \f@series
+\tl_new:N \l__chemformula_font_shape_tl
+\tl_set_eq:NN \l__chemformula_font_shape_tl \f@shape
+\tl_new:N \l__chemformula_format_tl
+\tl_new:N \l__chemformula_fontspec_options_tl
+\tl_new:N \l__chemformula_fontspec_argument_tl
+\tl_new:N \l__chemformula_name_format_tl
+\tl_set:Nn \l__chemformula_name_format_tl { \scriptsize\centering }
+\tl_new:N \l_chemormula_sup_super_factor_tl
+\tl_new:N \l__chemformula_subscript_shift_additional_tl
+\tl_set:Nn \l__chemformula_subscript_shift_additional_tl { 0pt }
+\tl_new:N \l__chemformula_superscript_shift_additional_tl
+\tl_set:Nn \l__chemformula_superscript_shift_additional_tl { 0pt }
+\tl_new:N \l__chemformula_bond_style_tl
+\tl_new:N \l__chemformula_subscript_tl
+\tl_new:N \l__chemformula_superscript_tl
+\tl_new:N \g__chemformula_input_up_tl
+
+% property lists:
+\prop_new:N \l__chemformula_arrows_code_prop
+\prop_new:N \l__chemformula_cmpd_prop
+\prop_new:N \l__chemformula_bonds_prop
+\prop_new:N \l__chemformula_stoich_prop
+\prop_new:N \l__chemformula_charge_prop
+\prop_new:N \l__chemformula_numbers_prop
+\prop_new:N \l__chemformula_no_stoich_prop
+
+% sequences:
+\seq_new:N \l__chemformula_arrows_type_seq
+\seq_new:N \l__chemformula_input_seq
+
+% boxes:
+\box_new:N \l__chemformula_arrow_arg_i_box
+\box_new:N \l__chemformula_arrow_arg_ii_box
+\box_new:N \l__chemformula_superscript_box
+\box_new:N \l__chemformula_subscript_box
-%-----------------------------------------------------------------------------%
-% HELPER FUNCTIONS
+% --------------------------------------------------------------------------
+% general and helper functions:
\cs_new:Npn \chemformula_tikz:nn #1#2
{ \tikz [ #1 ] { #2 } }
\cs_generate_variant:Nn \chemformula_tikz:nn { xn,nf }
@@ -118,50 +369,135 @@
{ \draw [ #1 ] #2 ; }
\cs_generate_variant:Nn \chemformula_draw:nn { xn,nx,xx,xf }
-%-----------------------------------------------------------------------------%
-% Some basic internal commands:
-\cs_new:Npn \chemformula_plus:
+\cs_new:Npn \chemformula_allow_break:
+ { \tex_penalty:D \c_zero }
+
+\cs_new_protected:Npn \chemformula_leave_vmode:
+ { \hbox_unpack:N \c_empty_box }
+
+\cs_new:Npn \chemformula_nobreak:
+ { \tex_penalty:D \c_ten_thousand }
+
+\cs_new:Npn \chemformula_skip_nobreak:N #1
+ {
+ \chemformula_nobreak:
+ \skip_horizontal:N #1
+ \chemformula_nobreak:
+ }
+
+\cs_new_protected:Npn \chemformula_dim_to_width:Nn #1#2
+ {
+ \hbox_set:Nn \l__chemformula_tmpa_box { #2 }
+ \dim_set:Nn #1 { \box_wd:N \l__chemformula_tmpa_box }
+ \box_clear:N \l__chemformula_tmpa_box
+ }
+
+% an l3 conditional that can test 2e's conditionals that go like
+% \iffoo ... \else ... \fi
+% see http://tex.stackexchange.com/a/119806/5049
+\prg_new_conditional:Npnn \chemformula_latex_if:n #1 {p,T,F,TF}
+ { \use:c { if #1 } \prg_return_true: \else: \prg_return_false: \fi: }
+
+% --------------------------------------------------------------------------
+% circled charge signs:
+\cs_new_protected:Npn \chemformula_fplus:
+ { \ensuremath { \__chemformula_fplus: } }
+
+\cs_new:Npn \__chemformula_fplus:
+ { \mathpalette \__chemformula_fplus_aux: \bigcirc }
+
+\cs_new:Npn \__chemformula_fplus_aux: #1#2
{
- \bool_if:nTF
- { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool }
+ \ooalign
{
- \bool_if:NTF \l__chemmacros_circled_chem_bool
- { \chemmacros_fplus: }
- { \mode_if_math:TF { \oplus } { $ \oplus $ } }
+ \tex_hfil:D
+ $
+ #1
+ \chemformula_plain_plus:
+ $
+ \tex_hfil:D
+ \tex_cr:D
+ \tex_hfil:D
+ $#1#2$
+ \tex_hfil:D
+ \tex_cr:D
}
+ }
+
+\cs_new_protected:Npn \chemformula_fminus:
+ { \ensuremath { \__chemformula_fminus: } }
+
+\cs_new:Npn \__chemformula_fminus:
+ { \mathpalette \__chemformula_fminus_aux_aux: \bigcirc }
+
+\cs_new:Npn \__chemformula_fminus_aux_aux: #1#2
+ {
+ \ooalign
{
- \bool_if:NTF \l__chemformula_charge_style_math_bool
- { \ensuremath { + } }
- { \mode_if_math:TF { \text { + } } { + } }
+ \tex_hfil:D
+ $
+ #1
+ \chemformula_plain_minus:
+ $
+ \tex_hfil:D
+ \tex_cr:D
+ \tex_hfil:D
+ $#1#2$
+ \tex_hfil:D
+ \tex_cr:D
}
}
-\cs_new:Npn \chemformula_minus:
+\AtBeginDocument{
+ \@ifpackageloaded { chemmacros }
+ {
+ \bool_if:nT
+ { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool }
+ { \bool_set_true:N \l__chemformula_formal_charges_bool }
+ \bool_if:NF \l__chemmacros_circled_chem_bool
+ { \bool_set_false:N \l__chemformula_formal_chem_bool }
+ }
+ { }
+}
+
+\cs_new_protected:Npn \chemformula_plain_plus:
+ {
+ \bool_if:NTF \l__chemformula_charge_style_math_bool
+ { \ensuremath { + } }
+ { \mode_if_math:TF { \text { + } } { + } }
+ }
+
+\cs_new_protected:Npn \chemformula_plus:
{
- \bool_if:nTF
- { \l__chemmacros_circled_bool && !\l__chemmacros_circled_formal_bool }
+ \bool_if:NTF \l__chemformula_formal_charges_bool
{
- \bool_if:NTF \l__chemmacros_circled_chem_bool
- { \chemmacros_fminus: }
- { \mode_if_math:TF { \ominus } { $ \ominus $ } }
+ \bool_if:NTF \l__chemformula_formal_chem_bool
+ { \chemformula_fplus: }
+ { \mode_if_math:TF { \oplus } { \( \oplus \) } }
}
+ { \chemformula_plain_plus: }
+ }
+
+\cs_new_protected:Npn \chemformula_plain_minus:
+ {
+ \bool_if:NTF \l__chemformula_charge_style_math_bool
+ { \ensuremath { - } }
+ { \mode_if_math:TF { \text { \textendash } } { \textendash } }
+ }
+
+\cs_new_protected:Npn \chemformula_minus:
+ {
+ \bool_if:NTF \l__chemformula_formal_charges_bool
{
- \bool_if:NTF \l__chemformula_charge_style_math_bool
- { \ensuremath { - } }
- { \mode_if_math:TF { \text { \textendash } } { \textendash } }
+ \bool_if:NTF \l__chemformula_formal_chem_bool
+ { \chemformula_fminus: }
+ { \mode_if_math:TF { \ominus } { \( \ominus \) } }
}
+ { \chemformula_plain_minus: }
}
-\tl_new:N \l__chemformula_radical_style_tl
-\dim_new:N \l__chemformula_radical_radius_dim
-\dim_set:Nn \l__chemformula_radical_radius_dim { .2ex }
-\dim_new:N \l__chemformula_radical_hshift_dim
-\dim_set:Nn \l__chemformula_radical_hshift_dim { .15em }
-\dim_new:N \l__chemformula_radical_vshift_dim
-\dim_set:Nn \l__chemformula_radical_vshift_dim { .5ex }
-\dim_new:N \l__chemformula_radical_space_dim
-\dim_set:Nn \l__chemformula_radical_space_dim { .15em }
-
+% --------------------------------------------------------------------------
+% Some basic internal commands:
\cs_new_protected:Npn \chemformula_radical:
{
\chemformula_tikz:xn
@@ -194,16 +530,15 @@
\cs_new:Npn \chemformula_adduct:
{
- \skip_horizontal:N \l__chemformula_cdot_space_dim
+ \skip_horizontal:N \l__chemformula_adduct_space_dim
\textperiodcentered
- \skip_horizontal:N \l__chemformula_cdot_space_dim
+ \skip_horizontal:N \l__chemformula_adduct_space_dim
}
\cs_new_eq:NN \chemformula_star_adduct: \chemformula_adduct:
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% ARROW DEFINITION
% arrow heads:
-\dim_new:N \l__chemformula_arrow_head_dim
% full tip for pairs
\pgfarrowsdeclare { cf } { cf }
@@ -290,30 +625,14 @@
\pgfusepathqfillstroke
}
-% a possibility to overwrite the arrow tips:
+% a possibility to overwrite the arrow tips -- undocumented:
\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}
-%-----------------------------------------------------------------------------%
-% variables
-\dim_new:N \l__chemformula_arrow_length_dim
-\dim_new:N \l__chemformula_arrow_label_offset_dim
-\dim_set:Nn \l__chemformula_arrow_label_offset_dim { 2pt }
-\dim_new:N \l__chemformula_arrow_minimum_length_dim
-\dim_new:N \l__chemformula_arrow_shortage_dim
-\dim_new:N \l__chemformula_arrow_offset_dim
-\dim_set:Nn \l__chemformula_arrow_offset_dim { .75em }
-\dim_new:N \l__chemformula_compound_sep_dim
-\dim_set:Nn \l__chemformula_compound_sep_dim { .5em }
-\dim_new:N \l__chemformula_arrow_yshift_dim
-\dim_set:Nn \l__chemformula_arrow_yshift_dim { 0pt }
-
-\tl_new:N \l__chemformula_arrow_ratio_tl
-\tl_set:Nn \l__chemformula_arrow_ratio_tl { .6 }
-
+% --------------------------------------------------------------------------
% determine length in dependency of labels
\cs_new_protected:Npn \__chemformula_determine_arrow_length:NN #1#2
{
@@ -350,50 +669,18 @@
}
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% define arrow types
-\tl_new:N \l__chemformula_arrow_head_tl
-\tl_set:Nn \l__chemformula_arrow_head_tl { cf }
-\tl_new:N \l__chemformula_upper_label_tl
-\tl_new:N \l__chemformula_lower_label_tl
-\tl_new:N \l__chemformula_arrow_style_tl
-\tl_new:N \l__chemformula_arrow_label_style_tl
-\tl_set:Nn \l__chemformula_arrow_label_style_tl { \footnotesize }
-\tl_new:N \l__chemformula_arrow_tmp_tl
-\prop_new:N \l__chemformula_arrows_code_prop
-\seq_new:N \l__chemformula_arrows_type_seq
-\tl_new:N \l__chemformula_arrow_type_tl
-\box_new:N \l__chemformula_arrow_arg_i_box
-\box_new:N \l__chemformula_arrow_arg_ii_box
-
-% read optional arguments
-\cs_new:Npn \__chemformula_arrow_read_args:w
- {
- \peek_meaning:NTF [
- { \__chemformula_arrow_read_args_aux_i:w }
- { \__chemformula_arrow_read_args_aux_iii: }
- }
+% read arrow labels:
-\cs_new_protected:Npn \__chemformula_arrow_read_args_aux_i:w [#1]
+\cs_new:Npn \chemformula_arrow_labels:nn #1#2
{
\hbox_set:Nn \l__chemformula_arrow_arg_i_box
{ \tl_use:N \l__chemformula_arrow_label_style_tl #1 }
- \peek_meaning:NTF [
- { \__chemformula_arrow_read_args_aux_ii:w }
- { \__chemformula_arrow_read_args_aux_iii: }
- }
-
-\cs_new_protected:Npn \__chemformula_arrow_read_args_aux_ii:w [#1]
- {
\hbox_set:Nn \l__chemformula_arrow_arg_ii_box
- { \tl_use:N \l__chemformula_arrow_label_style_tl #1 }
- \__chemformula_arrow_read_args_aux_iii:
- }
-
-\cs_new:Npn \__chemformula_arrow_read_args_aux_iii:
- {
- % now we have both arguments do the actual drawing:
+ { \tl_use:N \l__chemformula_arrow_label_style_tl #2 }
+ % now that we have both arguments do the actual drawing:
\prop_get:NVN \l__chemformula_arrows_code_prop
\l__chemformula_arrow_type_tl
\l__chemformula_tmpb_tl
@@ -409,13 +696,19 @@
\box_clear:N \l__chemformula_arrow_arg_ii_box
% then get the arrow type
\tl_set:Nn \l__chemformula_arrow_type_tl { #1 }
- \__chemformula_arrow_read_args:w
+ }
+
+% this will be \arrow inside \ch
+\DeclareDocumentCommand \charrow { mO{}O{} }
+ {
+ \__chemformula_arrows_get:n { #1 }
+ \chemformula_arrow_labels:nn { #2 } { #3 }
}
% draw the arrows
\cs_new:Npn \__chemformula_arrow_draw:n #1
{
- \chemmacros_allow_break:
+ \chemformula_allow_break:
% prepare arrow code for drawing:
\tl_set_rescan:Nnn \l__chemformula_tmpc_tl
{ \char_set_catcode_letter:N \_ } { #1 }
@@ -455,7 +748,7 @@
;
\tl_use:N \l__chemformula_tmpc_tl
}
- \chemmacros_allow_break:
+ \chemformula_allow_break:
}
\cs_generate_variant:Nn \__chemformula_arrow_draw:n { V }
@@ -464,7 +757,7 @@
\NewDocumentCommand \DeclareChemArrow { mm }
{
\prop_if_in:NnTF \l__chemformula_arrows_code_prop { #1 }
- { \chemmacros_msg:nnxx { chemformula } { declare-arrow } { #1 } {} }
+ { \chemformula_error:nnxx { chemformula } { declare-arrow } { #1 } {} }
{
% store type in the sequence and code in the property list
\seq_put_right:Nn \l__chemformula_arrows_type_seq { #1 }
@@ -476,7 +769,7 @@
{
\prop_if_in:NnTF \l__chemformula_arrows_code_prop { #1 }
{ \prop_put:Nnn \l__chemformula_arrows_code_prop { #1 } { #2 } }
- { \chemmacros_msg:nnxx { chemformula } { renew-arrow } { #1 } {} }
+ { \chemformula_error:nnxx { chemformula } { renew-arrow } { #1 } {} }
}
\NewDocumentCommand \ShowChemArrow { m }
@@ -540,7 +833,7 @@
% net reaction:
\DeclareChemArrow { == } { \node at ([yshift=-.2ex]cf_arrow_mid) { = } ; }
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% arrow customization
\keys_define:nn { chemmacros / chemformula }
{
@@ -550,53 +843,65 @@
arrow-ratio .tl_set:N = \l__chemformula_arrow_ratio_tl ,
label-offset .dim_set:N = \l__chemformula_arrow_label_offset_dim ,
compound-sep .dim_set:N = \l__chemformula_compound_sep_dim ,
-% arrow-tips .tl_set:N = \l__chemformula_arrow_head_tl ,
arrow-style .tl_set:N = \l__chemformula_arrow_style_tl ,
label-style .tl_set:N = \l__chemformula_arrow_label_style_tl
}
-%-----------------------------------------------------------------------------%
-\seq_new:N \l__chemformula_input_seq
+% --------------------------------------------------------------------------
% MAIN COMMAND
\cs_new_protected:Npn \__chemformula_ch_main:n #1
{
\group_begin:
\seq_set_split:Nnn \l__chemformula_input_seq { ~ } { #1 }
\cs_set_eq:NN \xspace \scan_stop:
+ % the next two necessary any more but shouldn't do harm, too:
\cs_set_nopar:Npn \[ { [ }
\cs_set_nopar:Npn \] { ] }
- \bool_set_true:N \l__chemformula_inside_ch_bool
- \tl_if_blank:oF { \g__chemformula_options_tl }
+ \bool_set_true:N \l_chemformula_inside_ch_bool
+ \tl_if_blank:VF \g__chemformula_options_tl
{
- \keys_set:no { chemmacros / chemformula }
- { \g__chemformula_options_tl }
+ \keys_set:nV
+ { chemmacros / chemformula }
+ \g__chemformula_options_tl
}
\seq_map_function:NN
\l__chemformula_input_seq
\chemformula_input:n
-% \tl_set_eq:NN
-% \l__chemformula_output_tl
-% \l__chemformula_input_tl
- \tl_set_rescan:Nno \l__chemformula_input_tl
+ \tl_set_rescan:NnV \l__chemformula_input_tl
{ \ExplSyntaxOn \makeatletter }
- { \l__chemformula_input_tl }
+ \l__chemformula_input_tl
\chemformula_write:V \l__chemformula_input_tl
\group_end:
}
+\cs_new:Npn \chemformula_write:n #1
+ {
+ \mode_if_math:TF
+ {
+ \mathchoice
+ { \text { #1 } }
+ { \text { #1 } }
+ { \text { \scriptsize #1 } }
+ { \text { \tiny #1 } }
+ }
+ { #1 }
+ }
+\cs_generate_variant:Nn \chemformula_write:n { V }
+
% internal version of \ch command:
\cs_new_protected:Npn \chemformula_ch:nn #1#2
{
\group_align_safe_begin:
- \chemmacros_leave_vmode:
- \IfNoValueTF { #1 }
+ \chemformula_leave_vmode:
+ \tl_if_blank:nTF { #1 }
{ \tl_gclear:N \g__chemformula_options_tl }
- { \tl_gset:Nn \g__chemformula_options_tl { #1 } }
+ { \tl_gset:Nn \g__chemformula_options_tl { #1 } }
\__chemformula_ch_aux_i:w #2 \\ \q_no_value \q_stop
\group_align_safe_end:
- \tl_use:N \g__chemformula_output_tl
+ \tl_use:N \g__chemformula_output_tl
\tl_gclear:N \g__chemformula_output_tl
}
+\cs_generate_variant:Nn \chemformula_ch:nn { V , nV , VV }
% Trickery to use \ch inside align environment:
% bypass \\:
@@ -627,18 +932,20 @@
\__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} }
+ \tl_gput_right:Nn \g__chemformula_output_tl { \label { #2 } }
\__chemformula_ch_aux_iii:w #3 \q_stop
}
}
+% here's something not working when used together with `hyperref'
+% which seems to be related to \nonumber
% bypass \tag:
\cs_new_protected: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} }
+ \tl_gput_right:Nn \g__chemformula_output_tl { \protect\tag { #2 } }
\__chemformula_ch_aux_iv:w #3 \q_stop
}
}
@@ -650,30 +957,30 @@
{ \__chemformula_ch_main:n { #1 } }
\quark_if_no_value:nF { #3 }
{
- \tl_gput_right:Nn \g__chemformula_output_tl { \intertext{#2} }
+ \tl_gput_right:Nn \g__chemformula_output_tl { \intertext { #2 } }
\__chemformula_ch_aux_v:w #3 \q_stop
- }
+ }
}
-% user command:
-\NewDocumentCommand \ch { om }
+% --------------------------------------------------------------------------
+% user commands:
+\NewDocumentCommand \ch { O{}m }
{ \chemformula_ch:nn { #1 } { #2 } }
-\cs_new:Npn \chemformula_write:n #1
+\tl_new:N \l__chemformula_compound_tl
+\cs_new_protected:Npn \chemformula_chcpd:nn #1#2
{
- \mode_if_math:TF
- {
- \mathchoice
- { \text { #1 } }
- { \text { #1 } }
- { \text { \scriptsize #1 } }
- { \text { \tiny #1 } }
- }
- { #1 }
+ \group_begin:
+ \keys_set:nn { chemmacros / chemformula } { #1 }
+ \chemformula_input_cmpd:nN { #2 } \l__chemformula_compound_tl
+ \chemformula_write:V \l__chemformula_compound_tl
+ \group_end:
}
-\cs_generate_variant:Nn \chemformula_write:n { V }
-%-----------------------------------------------------------------------------%
+\NewDocumentCommand \chcpd { O{}m }
+ { \chemformula_chcpd:nn { #1 } { #2 } }
+
+% --------------------------------------------------------------------------
% arrow generation & detection
\cs_new:Npn \__chemformula_generate_arrows:Nn #1#2
{
@@ -681,7 +988,7 @@
\seq_map_inline:Nn \l__chemformula_arrows_type_seq
{
\tl_replace_all:Nnn \l__chemformula_tmpa_tl
- { ##1 } { \__chemformula_arrows_get:n { ##1 } }
+ { ##1 } { \charrow { ##1 } }
}
\tl_set_eq:NN #1 \l__chemformula_tmpa_tl
}
@@ -698,37 +1005,35 @@
}
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% --------------------------------------------------------------------------
% compound names
-\dim_new:N \l__chemformula_name_dim
-\tl_new:N \l__chemformula_name_tmp_tl
-
\cs_new:Npn \__chemformula_name_cmpd:w
- { \peek_meaning:NTF ( { \__chemformula_name_cmpd_aux:w } { ! } }
+ { \peek_meaning:NTF ( { \chname } { ! } }
-% TODO
-% this is no document command -- but now nesting of brackets is possible
-\NewDocumentCommand \__chemformula_name_cmpd_aux:w {r()r()}
+\NewDocumentCommand \chname { R(){}R(){} }
+ { \chemformula_chwritebelow:nn { #1 } { #2 } }
+
+\cs_new:Npn \chemformula_chwritebelow:nn #1#2
{
\(
\underset
{
\bool_if:NF \l__chemformula_name_width_bool
{
- \chemmacros_dim_to_width:Nn \l__chemformula_name_dim
+ \chemformula_dim_to_width:Nn \l__chemformula_name_dim
{ \l__chemformula_name_format_tl #1 }
}
\parbox
{ \dim_use:N \l__chemformula_name_dim }
{ \l__chemformula_name_format_tl #1 }
}
- { \text { \vphantom{\gas} #2 } }
+ { \text { \strut #2 } }
\)
}
\cs_new_protected:Npn \__chemformula_generate_name:Nn #1#2
{
- \tl_set:Nn \l__chemformula_tmpa_tl { #2 }
+ \__chemformula_sanitize:Nn \l__chemformula_tmpa_tl { #2 }
\tl_if_in:VnT \l__chemformula_tmpa_tl { ! }
{
\tl_replace_all:Nnn \l__chemformula_tmpa_tl
@@ -747,97 +1052,8 @@
{ \bool_set_true:N \l__chemformula_is_name_bool }
}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% --------------------------------------------------------------------------
% 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_no_stoich_bool
-\bool_new:N \l__chemformula_is_plus_bool
-\bool_new:N \l__chemformula_is_up_bool
-\bool_new:N \l__chemformula_is_down_bool
-\bool_new:N \l__chemformula_is_arrow_bool
-\bool_new:N \l__chemformula_is_name_bool
-\bool_new:N \l__chemformula_stoich_is_iupac_bool
-\bool_new:N \l__chemformula_stoich_parse_iupac_bool
-\bool_new:N \l__chemformula_first_last_text_bool
-\bool_new:N \l__chemformula_first_last_double_bool
-\bool_new:N \l__chemformula_first_last_single_bool
-\bool_new:N \l__chemformula_first_last_math_bool
-\bool_new:N \l__chemformula_first_last_dollar_bool
-\bool_new:N \l__chemformula_first_last_mathbraces_bool
-\bool_new:N \l__chemformula_number_style_math_bool
-\bool_new:N \l__chemformula_charge_style_math_bool
-\bool_new:N \l__chemformula_sub_bool
-\bool_new:N \l__chemformula_sup_bool
-\bool_new:N \l__chemformula_is_isotope_bool
-\bool_new:N \l__chemformula_xfrac_bool
-\bool_new:N \l__chemformula_nicefrac_bool
-\bool_new:N \l__chemformula_mathfrac_bool
- \bool_set_true:N \l__chemformula_mathfrac_bool
-\bool_new:N \l__chemformula_fss_bool
-\bool_new:N \l__chemformula_fontspec_bool
-\bool_new:N \l__chemformula_fss_family_bool
-\bool_new:N \l__chemformula_fss_series_bool
-\bool_new:N \l__chemformula_fss_shape_bool
-\bool_new:N \l__chemformula_name_width_bool
-\bool_new:N \l__chemformula_charge_full_shift_bool
-
-% token lists:
-\tl_new:N \l__chemformula_chemformula_tmpa_tl
-\tl_new:N \g__chemformula_options_tl
-\tl_new:N \g__chemformula_output_tl
-% \tl_new:N \l__chemformula_output_tl
-\tl_new:N \l__chemformula_input_tl
-\tl_new:N \l__chemformula_stoich_tl
-\tl_new:N \l__chemformula_decimal_output_tl
-\tl_set:Nn \l__chemformula_decimal_output_tl { . }
-\tl_new:N \l__chemformula_font_family_tl
-\tl_set_eq:NN \l__chemformula_font_family_tl \f@family
-\tl_new:N \l__chemformula_font_series_tl
-\tl_set_eq:NN \l__chemformula_font_series_tl \f@series
-\tl_new:N \l__chemformula_font_shape_tl
-\tl_set_eq:NN \l__chemformula_font_shape_tl \f@shape
-\tl_new:N \l__chemformula_format_tl
-\tl_new:N \l__chemformula_fontspec_options_tl
-\tl_new:N \l__chemformula_fontspec_argument_tl
-\tl_new:N \l__chemformula_name_format_tl
-\tl_set:Nn \l__chemformula_name_format_tl { \scriptsize\centering }
-\tl_new:N \l_chemormula_sup_super_factor_tl
-\tl_new:N \l__chemformula_subscript_shift_additional_tl
-\tl_set:Nn \l__chemformula_subscript_shift_additional_tl { 0pt }
-\tl_new:N \l__chemformula_superscript_shift_additional_tl
-\tl_set:Nn \l__chemformula_superscript_shift_additional_tl { 0pt }
-\tl_new:N \l__chemformula_bond_style_tl
-
-% dimensions and skips:
-\skip_new:N \l__chemformula_stoich_space_skip
-\skip_set:Nn \l__chemformula_stoich_space_skip { .1667em plus .0333em minus .0117em }
-\skip_new:N \l__chemformula_math_space_skip
-\skip_set:Nn \l__chemformula_math_space_skip { .1667em plus .0333em minus .0117em }
-\skip_new:N \l__chemformula_plus_space_skip
-\skip_set:Nn \l__chemformula_plus_space_skip { .3em plus .1em minus .1em }
-\dim_new:N \l__chemformula_cdot_space_dim
-\dim_set:Nn \l__chemformula_cdot_space_dim { .1333em }
-\dim_new:N \l__chemformula_charge_shift_dim
-\dim_set:Nn \l__chemformula_charge_shift_dim { .5ex }
-\dim_new:N \l__chemformula_subscript_shift_dim
-\dim_new:N \l__chemformula_superscript_shift_dim
-\dim_new:N \l__chemformula_subscript_dim
-\dim_zero:N \l__chemformula_subscript_dim
-\dim_new:N \l__chemformula_superscript_dim
-\dim_zero:N \l__chemformula_superscript_dim
-\dim_new:N \l__chemformula_bond_dim
-\dim_set:Nn \l__chemformula_bond_dim { .5833em }
-
-% integers:
-\int_new:N \l__chemformula_count_tokens_int
-
-% property lists:
-% behaviour in a compound
-\prop_new:N \l__chemformula_cmpd_prop
\prop_put:Nnn \l__chemformula_cmpd_prop { 0 } { \chemformula_subscript:n { 0 } }
\prop_put:Nnn \l__chemformula_cmpd_prop { 1 } { \chemformula_subscript:n { 1 } }
\prop_put:Nnn \l__chemformula_cmpd_prop { 2 } { \chemformula_subscript:n { 2 } }
@@ -855,7 +1071,6 @@
\prop_put:Nnn \l__chemformula_cmpd_prop { + } { \chemformula_triple_bond: }
% numbers
-\prop_new:N \l__chemformula_numbers_prop
\prop_put:Nnn \l__chemformula_numbers_prop { 0 } { 0 }
\prop_put:Nnn \l__chemformula_numbers_prop { 1 } { 1 }
\prop_put:Nnn \l__chemformula_numbers_prop { 2 } { 2 }
@@ -868,23 +1083,21 @@
\prop_put:Nnn \l__chemformula_numbers_prop { 9 } { 9 }
% behaviour in a charge
-\prop_new:N \l__chemformula_charge_prop
-\prop_put:Nnn \l__chemformula_charge_prop { 0 } { \__chemformula_charge_style:n { 0 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 1 } { \__chemformula_charge_style:n { 1 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 2 } { \__chemformula_charge_style:n { 2 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 3 } { \__chemformula_charge_style:n { 3 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 4 } { \__chemformula_charge_style:n { 4 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 5 } { \__chemformula_charge_style:n { 5 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 6 } { \__chemformula_charge_style:n { 6 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 7 } { \__chemformula_charge_style:n { 7 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 8 } { \__chemformula_charge_style:n { 8 } }
-\prop_put:Nnn \l__chemformula_charge_prop { 9 } { \__chemformula_charge_style:n { 9 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 0 } { \chemformula_charge_style:n { 0 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 1 } { \chemformula_charge_style:n { 1 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 2 } { \chemformula_charge_style:n { 2 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 3 } { \chemformula_charge_style:n { 3 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 4 } { \chemformula_charge_style:n { 4 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 5 } { \chemformula_charge_style:n { 5 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 6 } { \chemformula_charge_style:n { 6 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 7 } { \chemformula_charge_style:n { 7 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 8 } { \chemformula_charge_style:n { 8 } }
+\prop_put:Nnn \l__chemformula_charge_prop { 9 } { \chemformula_charge_style:n { 9 } }
\prop_put:Nnn \l__chemformula_charge_prop { + } { \chemformula_plus: }
\prop_put:Nnn \l__chemformula_charge_prop { - } { \chemformula_minus: }
\prop_put:Nnn \l__chemformula_charge_prop { . } { \chemformula_radical: }
% stoichiometric factors
-\prop_new:N \l__chemformula_stoich_prop
\prop_put:Nnn \l__chemformula_stoich_prop { 0 } { 0 }
\prop_put:Nnn \l__chemformula_stoich_prop { 1 } { 1 }
\prop_put:Nnn \l__chemformula_stoich_prop { 2 } { 2 }
@@ -902,7 +1115,6 @@
\prop_put:Nnn \l__chemformula_stoich_prop { ( } { ( }
\prop_put:Nnn \l__chemformula_stoich_prop { ) } { ) }
-\prop_new:N \l__chemformula_no_stoich_prop
\prop_put:Nnn \l__chemformula_no_stoich_prop { . } { }
\prop_put:Nnn \l__chemformula_no_stoich_prop { , } { }
\prop_put:Nnn \l__chemformula_no_stoich_prop { / } { }
@@ -910,12 +1122,8 @@
\prop_put:Nnn \l__chemformula_no_stoich_prop { ( } { }
\prop_put:Nnn \l__chemformula_no_stoich_prop { ) } { }
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% bonds:
-\dim_new:N \l__chemformula_bond_space_dim
-\dim_set:Nn \l__chemformula_bond_space_dim { .07em }
-\prop_new:N \l__chemformula_bonds_prop
-
\cs_new:Npn \chemformula@bondlength
{ \l__chemformula_bond_dim }
@@ -932,9 +1140,9 @@
\cs_new:Npn \chemformula_triple_bond:
{ \chemformula_bond:n { triple } }
-\cs_new:Npn \chemformula_bond:n #1
+\cs_new_protected:Npn \chemformula_bond:n #1
{
- \chemmacros_skip_nobreak:N \l__chemformula_bond_space_dim
+ \chemformula_skip_nobreak:N \l__chemformula_bond_space_dim
\chemformula_tikz:nn
{
inner~sep = 0 ,
@@ -953,14 +1161,14 @@
{ \__chemformula_bond_draw:n { single } }
{ \__chemformula_bond_draw:n { #1 } }
}
- \chemmacros_skip_nobreak:N \l__chemformula_bond_space_dim
+ \chemformula_skip_nobreak:N \l__chemformula_bond_space_dim
}
\cs_new_protected:Npn \__chemformula_bond_draw:n #1
{
\tl_set_rescan:Nnn \l__chemformula_tmpa_tl {} { #1 }
- \exp_args:NNo \prop_get:Nn \l__chemformula_bonds_prop
- { \l__chemformula_tmpa_tl }
+ \prop_get:NV \l__chemformula_bonds_prop
+ \l__chemformula_tmpa_tl
}
\tikzset { chembond/.style={butt~cap-butt~cap,\l__chemformula_bond_style_tl} }
@@ -968,7 +1176,7 @@
\NewDocumentCommand \DeclareChemBond { mm }
{
\cs_if_exist:cTF { chemformula_bond_type_#1 }
- { \chemmacros_msg:nnxx { chemformula } { declare-bond } { #1 } {} }
+ { \chemformula_error:nnxx { chemformula } { declare-bond } { #1 } {} }
{
\cs_new:cpn { chemformula_bond_type_#1 } {}
\prop_put:Nnn \l__chemformula_bonds_prop { #1 } { #2 }
@@ -978,7 +1186,7 @@
\NewDocumentCommand \DeclareChemBondAlias { mm }
{
\cs_if_exist:cTF { chemformula_bond_type_#1 }
- { \chemmacros_msg:nnxx { chemformula } { declare-bond } { #1 } {} }
+ { \chemformula_error:nnxx { chemformula } { declare-bond } { #1 } {} }
{
\cs_new:cpn { chemformula_bond_type_#1 } {}
\prop_get:NnN \l__chemformula_bonds_prop { #2 } \l__chemformula_tmpa_tl
@@ -990,7 +1198,7 @@
{
\cs_if_exist:cTF { chemformula_bond_type_#1 }
{ \prop_put:Nnn \l__chemformula_bonds_prop { #1 } { #2 } }
- { \chemmacros_msg:nnxx { chemformula } { renew-bond } { #1 } {} }
+ { \chemformula_error:nnxx { chemformula } { renew-bond } { #1 } {} }
}
\NewDocumentCommand \ShowChemBond { m }
@@ -1071,7 +1279,7 @@
{ \draw[chembond,<-butt~cap] (chemformula-bond-start) -- (chemformula-bond-end) ; }
\DeclareChemBondAlias{<co}{coordleft}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% sub- and superscripts
\cs_new:Npn \__chemformula_number_style:n #1
{
@@ -1079,19 +1287,17 @@
{ \ensuremath { #1 } }
{ \ensuremath { \text { #1 } } }
}
+\cs_generate_variant:Nn \__chemformula_number_style:n { V }
-\cs_new:Npn \__chemformula_charge_style:n #1
+\cs_new_protected:Npn \chemformula_charge_style:n #1
{
\bool_if:NTF \l__chemformula_charge_style_math_bool
{ \ensuremath { #1 } }
{ \ensuremath { \text { #1 } } }
}
-\cs_generate_variant:Nn \__chemformula_charge_style:n { V }
+\cs_generate_variant:Nn \chemformula_charge_style:n { V }
% subscripts
-\tl_new:N \l__chemformula_subscript_tl
-\box_new:N \l__chemformula_subscript_box
-
% remove double or nested sub- and superscripts
\cs_new_protected:Npn \chemformula_subscript:n #1
{
@@ -1129,7 +1335,7 @@
}
}
}
-\cs_generate_variant:Nn \__chemformula_subscript:n { o,V }
+\cs_generate_variant:Nn \__chemformula_subscript:n { V }
\cs_new_protected:Npn \__chemformula_clean_subscript:
{
@@ -1146,7 +1352,7 @@
\cs_new_protected:Npn \__chemformula_subscript_raise:N #1
{
\hbox_set:Nn \l__chemformula_tmpa_box
- { $\scriptstyle Hg$ }
+ { \(\scriptstyle Hg\) }
\hbox_set:Nn \l__chemformula_tmpb_box { Hg }
\dim_set:Nn #1
{
@@ -1157,17 +1363,23 @@
\tex_raise:D #1
}
-\cs_new:Npn \__chemformula_subscript_write:n #1
+\cs_new_protected:Npn \__chemformula_subscript_write:n #1
{
- \__chemformula_subscript_raise:N \l__chemformula_subscript_shift_dim
- \hbox:n
- {
- $\scriptstyle
- \prop_get:NoNTF \l__chemformula_numbers_prop
- { #1 } \l__chemformula_tmpa_tl
- { \__chemformula_number_style:n { \l__chemformula_tmpa_tl } }
- { \__chemformula_number_style:n { #1 } }$
- }
+ \group_begin:
+ \tl_set_eq:NN \chemformula_subscript:n \use:n
+ \tl_set_eq:NN \chemformula_superscript:n \use:n
+ \__chemformula_subscript_raise:N \l__chemformula_subscript_shift_dim
+ \hbox:n
+ {
+ \(
+ \scriptstyle
+ \prop_get:NoNTF \l__chemformula_numbers_prop
+ { #1 } \l__chemformula_tmpa_tl
+ { \__chemformula_number_style:V \l__chemformula_tmpa_tl }
+ { \__chemformula_number_style:n { #1 } }
+ \)
+ }
+ \group_end:
}
\cs_generate_variant:Nn \__chemformula_subscript_write:n { V }
@@ -1182,9 +1394,6 @@
\cs_generate_variant:Nn \__chemformula_measure_subscript:n { V }
% superscripts
-\tl_new:N \l__chemformula_superscript_tl
-\box_new:N \l__chemformula_superscript_box
-
% remove double or nested sub- and superscripts
\cs_new_protected:Npn \chemformula_superscript:n #1
{
@@ -1219,7 +1428,7 @@
}
}
}
-\cs_generate_variant:Nn \__chemformula_superscript:n { o,V }
+\cs_generate_variant:Nn \__chemformula_superscript:n { V }
\cs_new_protected:Npn \__chemformula_clean_superscript:
{
@@ -1242,7 +1451,7 @@
\cs_new_protected:Npn \__chemformula_superscript_raise:N #1
{
\hbox_set:Nn \l__chemformula_tmpa_box
- { $\scriptstyle Hg$ }
+ { \(\scriptstyle Hg\) }
\hbox_set:Nn \l__chemformula_tmpb_box { Hg }
\dim_set:Nn #1
{
@@ -1253,17 +1462,23 @@
\tex_raise:D #1
}
-\cs_new:Npn \__chemformula_superscript_write:n #1
+\cs_new_protected:Npn \__chemformula_superscript_write:n #1
{
- \__chemformula_superscript_raise:N \l__chemformula_superscript_shift_dim
- \hbox:n
- {
- $\scriptstyle
- \prop_get:NoNTF \l__chemformula_charge_prop
- { #1 } \l__chemformula_tmpa_tl
- { \__chemformula_charge_style:V \l__chemformula_tmpa_tl }
- { \__chemformula_charge_style:n { #1 } }$
- }
+ \group_begin:
+ \tl_set_eq:NN \chemformula_subscript:n \use:n
+ \tl_set_eq:NN \chemformula_superscript:n \use:n
+ \__chemformula_superscript_raise:N \l__chemformula_superscript_shift_dim
+ \hbox:n
+ {
+ \(
+ \scriptstyle
+ \prop_get:NoNTF \l__chemformula_charge_prop
+ { #1 } \l__chemformula_tmpa_tl
+ { \tl_use:N \l__chemformula_tmpa_tl }
+ { \chemformula_charge_style:n { #1 } }
+ \)
+ }
+ \group_end:
}
\cs_generate_variant:Nn \__chemformula_superscript_write:n { V }
@@ -1341,7 +1556,8 @@
\bool_if:NTF \l__chemformula_charge_full_shift_bool
{
\tl_if_blank:VF \l__chemformula_subscript_tl
- { \dim_set:Nn \l__chemformula_tmpa_dim { - \l__chemformula_superscript_dim } }
+ { \dim_set:Nn \l__chemformula_tmpa_dim
+ { - \l__chemformula_superscript_dim } }
}
{
\tl_if_blank:VF \l__chemformula_superscript_tl
@@ -1367,23 +1583,15 @@
\tl_clear:N \l__chemformula_superscript_tl
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% read the input
\cs_new_protected:Npn \chemformula_input:n #1
{
- \tl_set_rescan:Nnn \l__chemformula_chemformula_tmpa_tl
- {
- \char_set_catcode_letter:N \{
- \char_set_catcode_letter:N \}
- \char_set_catcode_letter:N \\
- \char_set_catcode_other:N \"
- \char_set_catcode_math_superscript:N \^
- }
- { #1 }
+ \__chemformula_sanitize:Nn \l__chemformula_chemformula_tmpa_tl { #1 }
\chemformula_input_escape_text:V \l__chemformula_chemformula_tmpa_tl
\chemformula_input_escape_math:n { #1 }
\chemformula_input_stoich:n { #1 }
- \__chemformula_clean_chem_macros:V \l__chemformula_chemformula_tmpa_tl
+ \__chemformula_clean_chemmacros:V \l__chemformula_chemformula_tmpa_tl
\chemformula_input_cmpd:VN
\l__chemformula_chemformula_tmpa_tl \l__chemformula_input_tl
\chemformula_input_arrow:n { #1 }
@@ -1393,7 +1601,7 @@
\chemformula_input_down:n { #1 }
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% set options for next compound:
\cs_new_protected:Npn \chemformula_input_options:n #1
{
@@ -1412,7 +1620,7 @@
{ \bool_set_false:N \l__chemformula_is_option_bool }
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input stoichiometric factors
\cs_new_protected:Npn \chemformula_input_stoich:n #1
{
@@ -1470,6 +1678,7 @@
\DeclareInstance { xfrac } { chemformula-text-frac } { text }
{
slash-left-kern = -.15em ,
+ numerator-top-sep = 0pt ,
slash-right-kern = -.15em
}
@@ -1530,9 +1739,8 @@
{ \sfrac[chemformula-text-frac]{#1}{#2} }
\bool_if:NT \l__chemformula_nicefrac_bool
{ \nicefrac{#1}{#2} }
- % FIXME: why doesn't this work without \textstyle?
\bool_if:NT \l__chemformula_mathfrac_bool
- { $ \textstyle \frac{ \text { #1 } } { \text { #2 } } $ }
+ { \( \frac{ \text { #1 } } { \text { #2 } } \) }
}
\cs_new:Npn \__chemformula_misc_frac:nnn #1#2#3
@@ -1542,10 +1750,10 @@
\bool_if:NT \l__chemformula_nicefrac_bool
{ #1\nicefrac{#2}{#3} }
\bool_if:NT \l__chemformula_mathfrac_bool
- { #1 $ \frac{ \text { #2 } } { \text { #3 } } $ }
+ { #1 \( \frac{ \text { #2 } } { \text { #3 } } \) }
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input compounds
\cs_new_protected:Npn \chemformula_input_cmpd:nN #1#2
{
@@ -1565,7 +1773,8 @@
\tl_put_right:Nn #2
{
\group_begin:
- \keys_set:nV { chemmacros / chemformula }
+ \keys_set:nV
+ { chemmacros / chemformula }
\l__chemformula_internal_options_tl
}
}
@@ -1597,7 +1806,7 @@
}
{
\tl_put_right:Nn #2
- { \skip_horizontal:N \l__chemformula_stoich_space_skip }
+ { \chemformula_skip_nobreak:N \l__chemformula_stoich_space_skip }
\tl_clear:N \l__chemformula_stoich_tl
}
}
@@ -1640,20 +1849,25 @@
{
% expl3 catcodes:
\char_set_catcode_letter:N \_
+ \char_set_catcode_letter:N \:
+ % I've forgotten why I put this here:
\char_set_catcode_math_superscript:N \^
- % disable some of the specials:
+ % disable some of the specials (needed for sub- and superscripts):
\char_set_catcode_letter:N \{
\char_set_catcode_letter:N \}
- \char_set_catcode_letter:N \\
+ % this one seems not necessary any more:
+% \char_set_catcode_letter:N \\
\char_set_catcode_letter:N \#
% make the naming work with babel languages like French that make
% ! active:
\char_set_catcode_other:N \!
+ % ensure " is other:
+ \char_set_catcode_other:N \"
}
{ #2 }
}
+\cs_generate_variant:Nn \__chemformula_sanitize:Nn { NV }
-\cs_generate_variant:Nn \tl_if_in:nnT { x }
\cs_new_protected:Npn \__chemformula_handle_sub_and_superscripts:nN #1#2
{
\__chemformula_sanitize:Nn \l__chemformula_tmpa_tl { #1 }
@@ -1717,9 +1931,9 @@
}
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% clean up chemmacros commands:
-\cs_new_protected:Npn \__chemformula_clean_chem_macros:n #1
+\cs_new_protected:Npn \__chemformula_clean_chemmacros:n #1
{
\cs_set:Nn \chemmacros_text:n
{
@@ -1729,9 +1943,9 @@
}
\cs_set:Npn \chemmacros_xspace: {}
}
-\cs_generate_variant:Nn \__chemformula_clean_chem_macros:n { V }
+\cs_generate_variant:Nn \__chemformula_clean_chemmacros:n { V }
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input "and" sign
\cs_new_protected:Npn \chemformula_input_plus:n #1
{
@@ -1739,7 +1953,7 @@
{
\tl_put_right:Nn \l__chemformula_input_tl
{
- \skip_horizontal:N \l__chemformula_plus_space_skip
+ \chemformula_skip_nobreak:N \l__chemformula_plus_space_skip
+
\skip_horizontal:N \l__chemformula_plus_space_skip
}
@@ -1747,9 +1961,8 @@
\bool_set_false:N \l__chemformula_is_plus_bool
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input escaping gas
-\tl_new:N \g__chemformula_input_up_tl
\cs_new_protected:Npn \chemformula_input_up:n #1
{
\group_begin:
@@ -1764,23 +1977,23 @@
{
\tl_gclear:N \g__chemformula_input_up_tl
\tl_if_eq:nnT { #1 } { ^ }
- { \tl_gset:Nn \g__chemformula_input_up_tl { $\uparrow$ } }
+ { \tl_gset:Nn \g__chemformula_input_up_tl { \(\uparrow\) } }
\group_end:
\tl_put_right:NV \l__chemformula_input_tl \g__chemformula_input_up_tl
\bool_set_false:N \l__chemformula_is_up_bool
}
\cs_generate_variant:Nn \__chemformula_input_up:n { V }
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input precipitate
\cs_new_protected:Npn \chemformula_input_down:n #1
{
\tl_if_eq:nnT { #1 } { v }
- { \tl_put_right:Nn \l__chemformula_input_tl { $\downarrow$ } }
+ { \tl_put_right:Nn \l__chemformula_input_tl { \(\downarrow\) } }
\bool_set_false:N \l__chemformula_is_down_bool
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input arrow
\cs_new_protected:Npn \chemformula_input_arrow:n #1
{
@@ -1798,7 +2011,7 @@
}
\cs_generate_variant:Nn \chemformula_input_arrow:n { o }
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input compound name
\cs_new_protected:Npn \chemformula_input_name:n #1
{
@@ -1815,7 +2028,7 @@
\bool_set_false:N \l__chemformula_is_name_bool
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input escaped text
% #1: <bool> #2: <tl> #3: <first> #4: <last>
\cs_new_protected:Npn \__chemformula_bool_set_if_first_last:Nnnn #1#2#3#4
@@ -1861,6 +2074,7 @@
{
\char_set_catcode_letter:N \_
\char_set_catcode_other:N \:
+
}
{ #1 }
\tl_replace_all:Nnn \l__chemformula_tmpa_tl
@@ -1869,9 +2083,6 @@
{ _ } { \sb }
\tl_replace_all:Nnn \l__chemformula_tmpa_tl
{ chemformulaplaceholder } { \_ }
- \tl_set_rescan:Nno \l__chemformula_tmpa_tl
- { }% TODO da war \ExplSyntaxOff drin: brauchts das?
- { \l__chemformula_tmpa_tl }
\tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl
}
@@ -1899,7 +2110,7 @@
}
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% input escaped math
\cs_new_protected:Npn \chemformula_input_escape_math:n #1
{
@@ -1930,12 +2141,9 @@
{ _ } { \sb }
\tl_replace_all:Nnn \l__chemformula_tmpa_tl
{ chemformulaplaceholder } { \_ }
- \tl_set_rescan:Nno \l__chemformula_tmpa_tl
- { }% TODO da war \ExplSyntaxOff drin: brauchts das?
- { \l__chemformula_tmpa_tl }
\tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl
\tl_put_right:Nn \l__chemformula_input_tl
- { \skip_horizontal:N \l__chemformula_math_space_skip }
+ { \chemformula_skip_nobreak:N \l__chemformula_math_space_skip }
}
\cs_new:Npn \__chemformula_read_escape_dollar:w $#1$ \q_nil
@@ -1962,7 +2170,7 @@
}
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
% customization of output other than arrows
\keys_define:nn { chemmacros / chemformula }
{
@@ -2005,7 +2213,7 @@
\bool_set_false:N \l__chemformula_mathfrac_bool ,
stoich-paren-parse .bool_set:N = \l__chemformula_stoich_parse_iupac_bool ,
stoich-space .skip_set:N = \l__chemformula_stoich_space_skip ,
- adduct-space .dim_set:N = \l__chemformula_cdot_space_dim ,
+ adduct-space .dim_set:N = \l__chemformula_adduct_space_dim ,
plus-space .skip_set:N = \l__chemformula_plus_space_skip ,
math-space .skip_set:N = \l__chemformula_math_space_skip ,
name-format .tl_set:N = \l__chemformula_name_format_tl ,
@@ -2046,21 +2254,125 @@
\tl_set:Nn \l__chemformula_format_tl { #1 }
}
-%-----------------------------------------------------------------------------%
+% --------------------------------------------------------------------------
+
+\NewDocumentCommand \setchemformula { m }
+ { \keys_set:nn { chemmacros / chemformula } { #1 } }
+
+% --------------------------------------------------------------------------
% hyperref support
\AfterPackage* { hyperref }
- { \pdfstringdefDisableCommands { \cs_set:Npn \ch #1 { #1 } } }
+ {
+ \pdfstringdefDisableCommands
+ {
+ \cs_set:Npn \chcpd #1 { #1 }
+ \cs_set:Npn \charrow #1 { #1 }
+ \cs_set:Npn \chname (#1)(#2) { #2~(#1) }
+ \cs_set:Npn \ch #1 { #1 }
+ }
+ }
\tex_endinput:D
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-VERSION HISTORY
-see the chemmacros.sty file
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% --------------------------------------------------------------------------
+VERSION HISTORY
+2012/01/28 - version 3.0 - bundled with packages `chemmacros' and `ghs'
+2012/01/30 - version 3.0a - bugfix
+ - renamed formula => chemformula
+ (following a request by Karl Berry for TeXlive)
+2012/02/03 - version 3.0b - stepped number with `chemmacros'
+2012/02/05 - version 3.0c - stepped number with `chemmacros'
+2012/02/10 - version 3.0d - several bugfixes
+ - new arrow type <>
+2012/02/19 - version 3.1 - new arrow types -/>, </- and <o>
+ - new commands \DeclareChemArrow, \RenewChemArrow and
+ \ShowChemArrow
+2012/02/26 - version 3.1a - stepped number with `chemmacros'
+2012/03/03 - version 3.1b - arrow types are stored in a sequence to automate the
+ search and replace in the right order
+ - new arrow type ==
+ - IUPAC compliance for stoichiometric factors
+ - new handling of super- and subscripts to correct
+ various flaws: clear distinction between isotope and
+ formula
+ - new option charge-vshift
+2012/03/14 - version 3.1c - improved arrow labels
+2012/03/20 - version 3.2 - new: option input via @{<options>}
+2012/05/07 - version 3.3 - \ch now bypasses \ref{}, \label{}, and \intertext{}
+2012/05/13 - version 3.3a - stepped number with `chemmacros'
+2012/05/18 - version 3.3b - stepped number with `chemmacros'
+2012/05/18 - version 3.3c - stepped number with `chemmacros'
+2012/07/24 - version 3.3d - stepped number with `chemmacros'
+ - default bond length set to 1.1667ex
+ - bug fix in the bonds
+2012/08/21 - version 3.3e - stepped number with `chemmacros'
+2012/09/11 - version 3.4 - cleaned a little, minor bug fixes
+ - switched to internal scratch variables
+ - new command \bond, more bond types
+ - new commands \DeclareChemBond, \DeclareChemBondAlias,
+ \RenewChemBond and \ShowChemBond
+ - radical point thicker, new options `radical-style'
+ and `radical-radius'
+2012/10/03 - version 3.4a - stepped number with `chemmacros'
+2013/01/04 - version 3.4b - bug fix in the sub- and superscript handling
+2013/01/28 - version 3.5 - disallow breaks at bonds
+ - allow breaks after arrows
+ - made some spaces in chemformulas stretch- and
+ shrinkable
+ - various internal code improvements
+ - changed defaults for horizontal spaces that have in
+ set in ex into corresponding values in em.
+ - improvements to the placement of sub- and superscripts
+2013/02/19 - version 3.5a - stepped number with `chemmacros'
+2013/02/26 - version 3.6 - support for use with the `breqn' package
+ - math escaping also via \(\)
+ - internal: clearer escaping macros
+ - new options: `radical-vshift', `radical-hshift'
+ and `radical-space'
+ - bug fix: `radical-...' options are now correctly set
+ - stoichiometric factors: add leading 0 if missing
+ - new option: `stoich-paren-parse'
+ - internal changes: be way more rigid about protected
+ and expandable macros
+ - internal changes: clearer distinction between
+ private macros and accessable module macros
+ - internal changes: clearer distinction between
+ document commands and module level commands
+ - !()() syntax now also works with babel's French
+2013/02/27 - version 3.6a - bug fix: escaped text and math stays escaped, i.e.
+ also arrow code like `<=>'
+2013/04/19 - version 3.6b - new option `arrow-min-length'
+ - bug fix: stoichiometric fractions correctly displayed
+2013/07/06 - version 4.0 - don't need `chemmacros' package any more,
+ `chemformula' can be used stand-alone;
+ this has lead to a few definitions that previously
+ were done by chemmacros; chemmacros will get them
+ now from chemformula when needed
+ - bug fix: allow braces in subscripts and superscripts
+ by disabling superfluous \chemformula_subscript:n
+ and \chemformula_superscript:n in the scripts write
+ commands
+ - remove superfluous rescanning at the begin of the
+ formula input; this is handled by the sanitize
+ command later anyway
+ - changed internal mathshifts from $ ... $ to \( ... \)
+ - removed superfluous \textstyle from math-frac
+ definition
+ - new command \charrow{}[][] that allows direct
+ access to chemformula's arrows
+ - new command \chname()() that allows direct access
+ to chemformula's naming
+ - new command \chcpd[]{} that allows typesetting a
+ simple single formula - also not nestable with \ch
+ - new command \setchemformula
+ - package option: `strict'
+ - don't allow a line break before a plus
+ (`chem-and')
+ - don't allow a line break between a stoichiometric
+ factor and a compound
+ - changed formal charges to match ``plain'' charges
+
+% --------------------------------------------------------------------------
% TODO
-- Bug: math- und text-escaping schützt nicht vor arrow-Umwandlung: \ch{"->"}
- Addukte: Zahlen nach * und . automatisch erkennen?
-- allow fractions in subscripts: _{$\frac{1}{2}$} ?
- optionale Argumente von \\ nach außen weiterreichen?
-- vertikalen Shift der Hoch- und Tiefstellungen mit \mathchoice anpassen:
- \( K = \frac{[\ch{Na+}]^2[\ch{SO4^2-}]}{[\ch{Na2SO4}]} \) \ No newline at end of file