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.sty594
1 files changed, 340 insertions, 254 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
index c42a9feca39..c58a8f6fde9 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
@@ -72,6 +72,34 @@
exist.
}
+\msg_set:nnnn { chemformula } { declare-bond }
+ {
+ The~bond~type~ \tl_to_str:n { #1 } \c_space_tl is~already~defined.
+ }
+ {
+ You've~tried~to~define~the~bond~type~\tl_to_str:n { #1 } \c_space_tl with
+ ~\token_to_str:N \DeclareChemBond \c_space_tl but~it~already~exists.
+ ~Choose~another~name.
+ }
+
+\msg_set: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
+\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
+
%-----------------------------------------------------------------------------%
% gobble options
\DeclareOption* { }
@@ -91,7 +119,7 @@
%-----------------------------------------------------------------------------%
% Some basic internal commands:
-\cs_new:Nn \chemformula_plus:
+\cs_new:Npn \chemformula_plus:
{
\bool_if:nTF
{ \l_chemmacros_circled_bool && !\l_chemmacros_circled_formal_bool }
@@ -107,7 +135,7 @@
}
}
-\cs_new:Nn \chemformula_minus:
+\cs_new:Npn \chemformula_minus:
{
\bool_if:nTF
{ \l_chemmacros_circled_bool && !\l_chemmacros_circled_formal_bool }
@@ -123,8 +151,30 @@
}
}
-\cs_new:Nn \chemformula_radical: { \textperiodcentered }
-\cs_new:Nn \chemformula_adduct:
+\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 }
+
+\cs_new:Npn \chemformula_radical:
+ {
+ \chemformula_tikz:xn
+ {
+ \l_chemformula_radical_style_tl ,
+ baseline,
+ minimum~height=0pt,
+ inner~sep=0pt,
+ outer~sep=0pt
+ }
+ { \fill (0,0)++(.3ex,.7ex) circle (\l_chemformula_radical_radius_dim) ; }
+ }
+
+\keys_define:nn { chemformula }
+ {
+ radical-style .tl_set:N = \l_chemformula_radical_style_tl ,
+ radical-radius .dim_set:N = \l_chemformula_radical_radius_dim
+ }
+
+\cs_new:Npn \chemformula_adduct:
{
\skip_horizontal:N \l_chemformula_cdot_space_dim
\textperiodcentered
@@ -252,14 +302,14 @@
% determine length in dependency of labels
\cs_new:Npn \chemformula_determine_arrow_length:nn #1#2
{
- \box_set_eq:NN \l_tmpa_box #1
- \dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box }
- \box_set_eq:NN \l_tmpa_box #2
- \dim_set:Nn \l_tmpb_dim { \box_wd:N \l_tmpa_box }
- \box_clear:N \l_tmpa_box
- \dim_compare:nTF { \l_tmpa_dim >= \l_tmpb_dim }
- { \dim_set_eq:NN \l_chemformula_arrow_length_dim \l_tmpa_dim }
- { \dim_set_eq:NN \l_chemformula_arrow_length_dim \l_tmpb_dim }
+ \box_set_eq:NN \l_chemformula_tmpa_box #1
+ \dim_set:Nn \l_chemformula_tmpa_dim { \box_wd:N \l_chemformula_tmpa_box }
+ \box_set_eq:NN \l_chemformula_tmpa_box #2
+ \dim_set:Nn \l_chemformula_tmpb_dim { \box_wd:N \l_chemformula_tmpa_box }
+ \box_clear:N \l_chemformula_tmpa_box
+ \dim_compare:nTF { \l_chemformula_tmpa_dim >= \l_chemformula_tmpb_dim }
+ { \dim_set_eq:NN \l_chemformula_arrow_length_dim \l_chemformula_tmpa_dim }
+ { \dim_set_eq:NN \l_chemformula_arrow_length_dim \l_chemformula_tmpb_dim }
\dim_add:Nn \l_chemformula_arrow_length_dim
{ \l_chemformula_arrow_offset_dim }
\dim_add:Nn \l_chemformula_arrow_length_dim
@@ -323,8 +373,8 @@
% now we have both arguments do the actual drawing:
\prop_get:NVN \l_chemformula_arrows_code_prop
\l_chemformula_arrow_type_tl
- \l_tmpb_tl
- \chemformula_arrow_draw:V \l_tmpb_tl
+ \l_chemformula_tmpb_tl
+ \chemformula_arrow_draw:V \l_chemformula_tmpb_tl
}
% get arrows (for the use in \ch to replace the symbol)
@@ -344,7 +394,7 @@
{
% prepare arrow code for drawing:
% TODO: flexible Pfeilspitzen, TikZ-Keys ermöglichen
- \tl_set_rescan:Nnn \l_tmpc_tl { \char_set_catcode_letter:N \_ } { #1 }
+ \tl_set_rescan:Nnn \l_chemformula_tmpc_tl { \char_set_catcode_letter:N \_ } { #1 }
% determine length of the arrow
\chemformula_determine_arrow_length:NN
\l_chemformula_arrow_arg_i_box
@@ -379,7 +429,7 @@
[ below=\l_chemformula_arrow_label_offset_dim ] at (cf_arrow_mid)
{ \box_use:N \l_chemformula_arrow_arg_ii_box }
;
- \tl_use:N \l_tmpc_tl
+ \tl_use:N \l_chemformula_tmpc_tl
}
}
\cs_generate_variant:Nn \chemformula_arrow_draw:n { V }
@@ -407,8 +457,8 @@
\NewDocumentCommand \ShowChemArrow { m }
{
- \prop_get:NnN \l_chemformula_arrows_code_prop { #1 } \l_tmpa_tl
- \tl_to_str:N \l_tmpa_tl
+ \prop_get:NnN \l_chemformula_arrows_code_prop { #1 } \l_chemformula_tmpa_tl
+ \tl_to_str:N \l_chemformula_tmpa_tl
}
% declare arrows in the right order
@@ -504,7 +554,7 @@
\group_end:
}
-\cs_new:Nn \chemformula_ch:nn
+\cs_new:Npn \chemformula_ch:nn #1#2
{
\group_align_safe_begin:
\chemmacros_leave_vmode:
@@ -578,7 +628,7 @@
\NewDocumentCommand \ch { om }
{ \chemformula_ch:nn { #1 } { #2 } }
-\cs_new:Nn \chemformula_write:V
+\cs_new:Npn \chemformula_write:n #1
{
\mode_if_math:TF
{
@@ -590,18 +640,19 @@
}
{ #1 }
}
+\cs_generate_variant:Nn \chemformula_write:n { V }
%-----------------------------------------------------------------------------%
% arrow generation & detection
\cs_set:Nn \chemformula_generate_arrows:V
{
- \tl_set:No \l_tmpa_tl { #1 }
+ \tl_set:No \l_chemformula_tmpa_tl { #1 }
\seq_map_inline:Nn \l_chemformula_arrows_type_seq
{
- \tl_replace_all:Nnn \l_tmpa_tl
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl
{ ##1 } { \chemformula_arrows_get:n { ##1 } }
}
- \tl_set_eq:NN \l_chemformula_output_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_chemformula_output_tl \l_chemformula_tmpa_tl
}
\cs_new:Npn \chemformula_detect_arrows:n #1
@@ -609,8 +660,8 @@
\bool_set_false:N \l_chemformula_is_arrow_bool
\prop_map_inline:Nn \l_chemformula_arrows_code_prop
{
- \tl_set_rescan:Nnn \l_tmpa_tl {} { ##1 }
- \tl_if_in:noT { #1 } { \l_tmpa_tl }
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl {} { ##1 }
+ \tl_if_in:noT { #1 } { \l_chemformula_tmpa_tl }
{ \bool_set_true:N \l_chemformula_is_arrow_bool }
}
}
@@ -641,27 +692,27 @@
\)
}
-\cs_new:Npn \width_to_dim:nn #1#2
+\cs_new:Npn \width_to_dim:Nn #1#2
{
- \hbox_set:Nn \l_tmpa_box { #2 }
- \dim_set:Nn #1 { \box_wd:N \l_tmpa_box }
- \box_clear:N \l_tmpa_box
+ \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
}
-\cs_generate_variant:Nn \width_to_dim:nn { Nn }
-\cs_new:Nn \chemformula_generate_name:V
+\cs_new:Npn \chemformula_generate_name:n #1
{
- \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
+ \tl_set:Nn \l_chemformula_tmpa_tl { #1 }
+ \tl_if_in:VnT \l_chemformula_tmpa_tl { ! }
+ { \tl_replace_all:Nnn \l_chemformula_tmpa_tl { ! } { \chemformula_name_cmpd:w } }
+ \tl_set_eq:NN \l_chemformula_output_tl \l_chemformula_tmpa_tl
}
+\cs_generate_variant:Nn \chemformula_generate_name:n { V }
\cs_new:Npn \chemformula_detect_name:n #1
{
\bool_set_false:N \l_chemformula_is_name_bool
- \tl_set:No \l_tmpa_tl { #1 }
- \tl_if_in:onT { \l_tmpa_tl } { ! }
+ \tl_set:Nn \l_chemformula_tmpa_tl { #1 }
+ \tl_if_in:VnT \l_chemformula_tmpa_tl { ! }
{ \bool_set_true:N \l_chemformula_is_name_bool }
}
@@ -699,7 +750,7 @@
\bool_new:N \l_chemformula_charge_full_shift_bool
% token lists:
-\tl_new:N \l_chemformula_tmpa_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_output_tl
@@ -838,34 +889,26 @@
%-----------------------------------------------------------------------------%
% bonds:
-\dim_new:N \l_chemformula_bond_space_dim
+\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 }
\cs_new:Npn \chemformula_single_bond:
{
\bool_if:NTF \l_chemformula_sup_bool
{ \chemformula_minus: }
- {
- \skip_horizontal:N \l_chemformula_bond_space_dim
- \chemformula_tikz:nn
- {
- inner~sep = 0 ,
- outer~sep = 0 ,
- text~height = 1em ,
- baseline = (chemformula-single-bond.base)
- }
- {
- \draw node[draw=none,minimum~height=1em,minimum~width=0]
- (chemformula-single-bond) at (0,0) {} ;
- \draw[butt~cap-butt~cap,\l_chemformula_bond_style_tl]
- (chemformula-single-bond) ++ (0,-.1716em)
- -- ++( \l_chemformula_bond_dim ,0);
- }
- \skip_horizontal:N \l_chemformula_bond_space_dim
- }
+ { \chemformula_bond:n { single } }
}
\cs_new:Npn \chemformula_double_bond:
+ { \chemformula_bond:n { double } }
+
+\cs_new:Npn \chemformula_triple_bond:
+ { \chemformula_bond:n { triple } }
+
+\cs_new:Npn \chemformula_bond:n #1
{
\skip_horizontal:N \l_chemformula_bond_space_dim
\chemformula_tikz:nn
@@ -873,69 +916,160 @@
inner~sep = 0 ,
outer~sep = 0 ,
text~height = 1em ,
- baseline = (chemformula-double-bond.base)
+ baseline = (chemformula-bond-ground.base)
}
{
- \draw node[draw=none,minimum~height=1em,minimum~width=0]
- (chemformula-double-bond) at (0,0) {} ;
- \draw[butt~cap-butt~cap]
- (chemformula-double-bond) ++ (0,-.0858em) -- ++
- (\l_chemformula_bond_dim ,0) ;
- \draw[butt~cap-butt~cap]
- (chemformula-double-bond) ++ (0,-.2574em) -- ++
- (\l_chemformula_bond_dim ,0) ;
+ \draw node[draw=none,minimum~height=1em,minimum~width=0]
+ (chemformula-bond-ground) at (0,0) {};
+ \draw (chemformula-bond-ground) ++ (0,-.1716em)
+ coordinate (chemformula-bond-start) ;
+ \draw (chemformula-bond-start) ++(\l_chemformula_bond_dim ,0)
+ coordinate (chemformula-bond-end) ;
+ \tl_if_blank:nTF { #1 }
+ { \chemformula_bond_draw:n { single } }
+ { \chemformula_bond_draw:n { #1 } }
}
\skip_horizontal:N \l_chemformula_bond_space_dim
}
-\cs_new:Npn \chemformula_triple_bond:
+\cs_new:Npn \chemformula_bond_draw:n #1
{
- \skip_horizontal:N \l_chemformula_bond_space_dim
- \chemformula_tikz:nn
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl {} { #1 }
+ \exp_args:NNo \prop_get:Nn \l_chemformula_bonds_prop
+ { \l_chemformula_tmpa_tl }
+ }
+
+\tikzset { chembond/.style={butt~cap-butt~cap,\l_chemformula_bond_style_tl} }
+
+\NewDocumentCommand \DeclareChemBond { mm }
+ {
+ \cs_if_exist:cTF { chemformula_bond_type_#1 }
+ { \chemmacros_msg:nnxx { chemformula } { declare-bond } { #1 } {} }
{
- inner~sep = 0 ,
- outer~sep = 0 ,
- text~height = 1em ,
- baseline = (chemformula-triple-bond.base)
+ \cs_new:cpn { chemformula_bond_type_#1 } {}
+ \prop_put:Nnn \l_chemformula_bonds_prop { #1 } { #2 }
}
+ }
+
+\NewDocumentCommand \DeclareChemBondAlias { mm }
+ {
+ \cs_if_exist:cTF { chemformula_bond_type_#1 }
+ { \chemmacros_msg:nnxx { chemformula } { declare-bond } { #1 } {} }
{
- \draw node[draw=none,minimum~height=1em,minimum~width=0]
- (chemformula-triple-bond) at (0,0) {} ;
- \draw[butt~cap-butt~cap]
- (chemformula-triple-bond) ++ (0,-.0429em) -- ++
- (\l_chemformula_bond_dim ,0) ;
- \draw[butt~cap-butt~cap]
- (chemformula-triple-bond) ++ (0,-.1716em) -- ++
- (\l_chemformula_bond_dim ,0) ;
- \draw[butt~cap-butt~cap]
- (chemformula-triple-bond) ++ (0,-.3003em) -- ++
- (\l_chemformula_bond_dim ,0) ;
+ \cs_new:cpn { chemformula_bond_type_#1 } {}
+ \prop_get:NnN \l_chemformula_bonds_prop { #2 } \l_chemformula_tmpa_tl
+ \prop_put:Nno \l_chemformula_bonds_prop { #1 } { \l_chemformula_tmpa_tl }
}
- \skip_horizontal:N \l_chemformula_bond_space_dim
}
+\NewDocumentCommand \RenewChemBond { mm }
+ {
+ \cs_if_exist:cTF { chemformula_bond_type_#1 }
+ { \prop_put:Nnn \l_chemformula_bonds_prop { #1 } { #2 } }
+ { \chemmacros_msg:nnxx { chemformula } { renew-bond } { #1 } {} }
+ }
+
+\NewDocumentCommand \ShowChemBond { m }
+ {
+ \prop_get:NnN \l_chemformula_bonds_prop { #1 } \l_chemformula_tmpa_tl
+ \tl_to_str:N \l_chemformula_tmpa_tl
+ }
+
+\NewDocumentCommand \bond { m }
+ { \chemformula_bond:n { #1 } }
+
+% now let's declare some default bonds:
+\DeclareChemBond{single}
+ { \draw[chembond] (chemformula-bond-start) -- (chemformula-bond-end) ; }
+\DeclareChemBondAlias{normal}{single}
+\DeclareChemBondAlias{sb}{single}
+
+\DeclareChemBond{semisingle}
+ { \draw[chembond,densely~dotted] (chemformula-bond-start) -- (chemformula-bond-end) ; }
+\DeclareChemBondAlias{dotted}{semisingle}
+
+\DeclareChemBond{double}
+ {
+ \draw (chemformula-bond-start) ++ (0,.0858em) coordinate (double-start-up) ;
+ \draw (chemformula-bond-end) ++ (0,.0858em) coordinate (double-end-up) ;
+ \draw (chemformula-bond-start) ++ (0,-.0858em) coordinate (double-start-down) ;
+ \draw (chemformula-bond-end) ++ (0,-.0858em) coordinate (double-end-down) ;
+ \draw[chembond]
+ (double-start-down) -- (double-end-down)
+ (double-start-up) -- (double-end-up) ;
+ }
+\DeclareChemBondAlias{db}{double}
+
+\DeclareChemBond{semidouble}
+ {
+ \draw (chemformula-bond-start) ++ (0,.0858em) coordinate (double-start-up) ;
+ \draw (chemformula-bond-end) ++ (0,.0858em) coordinate (double-end-up) ;
+ \draw (chemformula-bond-start) ++ (0,-.0858em) coordinate (double-start-down) ;
+ \draw (chemformula-bond-end) ++ (0,-.0858em) coordinate (double-end-down) ;
+ \draw[chembond] (double-start-down) -- (double-end-down) ;
+ \draw[chembond,densely~dotted] (double-start-up) -- (double-end-up) ;
+ }
+
+\DeclareChemBondAlias{deloc}{semidouble}
+% \DeclareChemBondAlias{deloc2}{semidouble}
+
+\DeclareChemBond{triple}
+ {
+ \draw (chemformula-bond-start) ++ (0,.1287em) coordinate (triple-start-up) ;
+ \draw (chemformula-bond-end) ++ (0,.1287em) coordinate (triple-end-up) ;
+ \draw (chemformula-bond-start) ++ (0,-.1287em) coordinate (triple-start-down) ;
+ \draw (chemformula-bond-end) ++ (0,-.1287em) coordinate (triple-end-down) ;
+ \draw[chembond]
+ (triple-start-down) -- (triple-end-down)
+ (chemformula-bond-start) -- (chemformula-bond-end)
+ (triple-start-up) -- (triple-end-up) ;
+ }
+\DeclareChemBondAlias{tp}{triple}
+
+\DeclareChemBond{semitriple}
+ {
+ \draw (chemformula-bond-start) ++ (0,.1287em) coordinate (triple-start-up) ;
+ \draw (chemformula-bond-end) ++ (0,.1287em) coordinate (triple-end-up) ;
+ \draw (chemformula-bond-start) ++ (0,-.1287em) coordinate (triple-start-down) ;
+ \draw (chemformula-bond-end) ++ (0,-.1287em) coordinate (triple-end-down) ;
+ \draw[chembond]
+ (triple-start-down) -- (triple-end-down)
+ (chemformula-bond-start) -- (chemformula-bond-end) ;
+ \draw[chembond,densely~dotted] (triple-start-up) -- (triple-end-up) ;
+ }
+\DeclareChemBondAlias{tdeloc}{semitriple}
+
+\DeclareChemBond{coordright}
+ { \draw[chembond,butt~cap->] (chemformula-bond-start) -- (chemformula-bond-end) ; }
+\DeclareChemBondAlias{co>}{coordright}
+
+\DeclareChemBond{coordleft}
+ { \draw[chembond,<-butt~cap] (chemformula-bond-start) -- (chemformula-bond-end) ; }
+\DeclareChemBondAlias{<co}{coordleft}
+
%-----------------------------------------------------------------------------%
% sub- and superscripts
-\cs_new:Nn \chemformula_number_style:n
+\cs_new:Npn \chemformula_number_style:n #1
{
\bool_if:NTF \l_chemformula_number_style_math_bool
{ \ensuremath { #1 } }
{ \ensuremath { \text { #1 } } }
}
-\cs_new:Nn \chemformula_charge_style:n
+\cs_new: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 }
% subscripts
\tl_new:N \l_chemformula_subscript_tl
\box_new:N \l_chemformula_subscript_box
% remove double or nested sub- and superscripts
-\cs_new:Nn \chemformula_subscript:n
+\cs_new:Npn \chemformula_subscript:n #1
{
\tl_if_eq:nnTF { #1 }{ \chemformula_superscript:n }
{ \chemformula_subscript_aux:n }
@@ -943,18 +1077,18 @@
\tl_if_eq:nnTF { #1 }{ \chemformula_subscript:n }
{ \chemformula_subscript_aux:n }
{
- \tl_set:Nn \l_tmpc_tl { #1 }
+ \tl_set:Nn \l_chemformula_tmpc_tl { #1 }
\tl_if_in:nnT { #1 } { \chemformula_subscript:n }
- { \tl_remove_all:Nn \l_tmpc_tl { \chemformula_subscript:n } }
+ { \tl_remove_all:Nn \l_chemformula_tmpc_tl { \chemformula_subscript:n } }
\tl_if_in:nnT { #1 } { \chemformula_superscript:n }
- { \tl_remove_all:Nn \l_tmpc_tl { \chemformula_superscript:n } }
- \exp_args:No \chemformula_subscript_aux:n { \l_tmpc_tl }
+ { \tl_remove_all:Nn \l_chemformula_tmpc_tl { \chemformula_superscript:n } }
+ \chemformula_subscript_aux:V \l_chemformula_tmpc_tl
}
}
}
% handle subscripts
-\cs_new:Nn \chemformula_subscript_aux:n
+\cs_new:Npn \chemformula_subscript_aux:n #1
{
\tl_put_right:Nn \l_chemformula_subscript_tl { #1 }
\chemformula_clean_subscript:
@@ -971,6 +1105,7 @@
}
}
}
+\cs_generate_variant:Nn \chemformula_subscript_aux:n { o,V }
\cs_new:Npn \chemformula_clean_subscript:
{
@@ -984,28 +1119,28 @@
{ \chemformula_star_adduct: } { * }
}
-\cs_new:Nn \chemformula_subscript_write:nV
+\cs_new:Npn \chemformula_subscript_write:n #1
{
- \exp_args:No \dim_set:Nn \l_tmpa_dim
- { \l_chemformula_subscript_shift_dim * #1 }
- \tex_raise:D \l_tmpa_dim
+ \tex_raise:D \l_chemformula_subscript_shift_dim
\hbox:n
{
$\scriptstyle
\prop_get:NoNTF \l_chemformula_numbers_prop
- { #2 } \l_tmpa_tl
- { \chemformula_number_style:n { \l_tmpa_tl } }
- { \chemformula_number_style:n { #2 } }$
+ { #1 } \l_chemformula_tmpa_tl
+ { \chemformula_number_style:n { \l_chemformula_tmpa_tl } }
+ { \chemformula_number_style:n { #1 } }$
}
}
+\cs_generate_variant:Nn \chemformula_subscript_write:n { V }
-\cs_new:Nn \chemformula_measure_subscript:V
+\cs_new:Npn \chemformula_measure_subscript:n #1
{
- \hbox_set:Nn \l_tmpa_box
- { \chemformula_subscript_write:nV { 1 } \l_chemformula_subscript_tl }
- \dim_set:Nn \l_chemformula_subscript_dim { -\box_wd:N \l_tmpa_box }
- \box_clear:N \l_tmpa_box
+ \hbox_set:Nn \l_chemformula_tmpa_box
+ { \chemformula_subscript_write:n { #1 } }
+ \dim_set:Nn \l_chemformula_subscript_dim { -\box_wd:N \l_chemformula_tmpa_box }
+ \box_clear:N \l_chemformula_tmpa_box
}
+\cs_generate_variant:Nn \chemformula_measure_subscript:n { V }
% superscripts
\tl_new:N \l_chemformula_superscript_tl
@@ -1020,18 +1155,18 @@
\tl_if_eq:nnTF { #1 } { \chemformula_subscript:n }
{ \chemformula_superscript_aux:n }
{
- \tl_set:Nn \l_tmpc_tl { #1 }
+ \tl_set:Nn \l_chemformula_tmpc_tl { #1 }
\tl_if_in:nnT { #1 } { \chemformula_subscript:n }
- { \tl_remove_all:Nn \l_tmpc_tl { \chemformula_subscript:n } }
+ { \tl_remove_all:Nn \l_chemformula_tmpc_tl { \chemformula_subscript:n } }
\tl_if_in:nnT { #1 } { \chemformula_superscript:n }
- { \tl_remove_all:Nn \l_tmpc_tl { \chemformula_superscript:n } }
- \exp_args:No \chemformula_superscript_aux:n { \l_tmpc_tl }
+ { \tl_remove_all:Nn \l_chemformula_tmpc_tl { \chemformula_superscript:n } }
+ \chemformula_superscript_aux:V \l_chemformula_tmpc_tl
}
}
}
% handle superscripts
-\cs_new:Nn \chemformula_superscript_aux:n
+\cs_new:Npn \chemformula_superscript_aux:n #1
{
\tl_put_right:Nn \l_chemformula_superscript_tl { #1 }
\chemformula_clean_superscript:
@@ -1045,6 +1180,7 @@
}
}
}
+\cs_generate_variant:Nn \chemformula_superscript_aux:n { o,V }
\cs_new:Npn \chemformula_clean_superscript:
{
@@ -1064,29 +1200,29 @@
{ . } { \chemformula_radical: }
}
-\cs_new:Nn \chemformula_superscript_write:nV
+\cs_new:Npn \chemformula_superscript_write:n #1
{
- \exp_args:No \dim_set:Nn \l_tmpa_dim
- { \l_chemformula_superscript_shift_dim * #1 }
- \tex_raise:D \l_tmpa_dim
+ \tex_raise:D \l_chemformula_superscript_shift_dim
\hbox:n
{
$\scriptstyle
\prop_get:NoNTF \l_chemformula_charge_prop
- { #2 } \l_tmpa_tl
- { \chemformula_charge_style:n { \l_tmpa_tl } }
- { \chemformula_charge_style:n { #2 } }$
+ { #1 } \l_chemformula_tmpa_tl
+ { \chemformula_charge_style:V \l_chemformula_tmpa_tl }
+ { \chemformula_charge_style:n { #1 } }$
}
}
+\cs_generate_variant:Nn \chemformula_superscript_write:n { V }
-\cs_new:Nn \chemformula_measure_superscript:V
+\cs_new:Npn \chemformula_measure_superscript:n #1
{
- \hbox_set:Nn \l_tmpa_box
- { \chemformula_superscript_write:nV { 1 } \l_chemformula_superscript_tl }
+ \hbox_set:Nn \l_chemformula_tmpa_box
+ { \chemformula_superscript_write:n { #1 } }
\dim_set:Nn \l_chemformula_superscript_dim
- { -\box_wd:N \l_tmpa_box }
- \box_clear:N \l_tmpa_box
+ { -\box_wd:N \l_chemformula_tmpa_box }
+ \box_clear:N \l_chemformula_tmpa_box
}
+\cs_generate_variant:Nn \chemformula_measure_superscript:n { V }
% typeset both sub- and superscripts
\cs_new:Npn \chemformula_use_sub_and_superscript:
@@ -1126,7 +1262,7 @@
% typeset superscript
\tl_if_blank:VF \l_chemformula_superscript_tl
{
- \chemformula_superscript_write:nV { 1 } \l_chemformula_superscript_tl
+ \chemformula_superscript_write:V \l_chemformula_superscript_tl
% skip back for the subscript
\tl_if_blank:VF \l_chemformula_subscript_tl
{
@@ -1145,21 +1281,21 @@
}
% typeset subscript
\tl_if_blank:VF \l_chemformula_subscript_tl
- { \chemformula_subscript_write:nV { 1 } \l_chemformula_subscript_tl }
+ { \chemformula_subscript_write:V \l_chemformula_subscript_tl }
\bool_if:NF \l_chemformula_is_isotope_bool
{
- \dim_zero:N \l_tmpa_dim
+ \dim_zero:N \l_chemformula_tmpa_dim
\bool_if:NTF \l_chemformula_charge_full_shift_bool
{
\tl_if_blank:VF \l_chemformula_subscript_tl
- { \dim_set:Nn \l_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
{
\tl_if_blank:VF \l_chemformula_subscript_tl
{
- \dim_set:Nn \l_tmpa_dim
+ \dim_set:Nn \l_chemformula_tmpa_dim
{
\l_chemformula_charge_shift_dim
- \l_chemformula_superscript_dim
@@ -1168,8 +1304,8 @@
}
}
}
- \dim_compare:nT { \l_tmpa_dim > 0pt }
- { \skip_horizontal:N \l_tmpa_dim }
+ \dim_compare:nT { \l_chemformula_tmpa_dim > 0pt }
+ { \skip_horizontal:N \l_chemformula_tmpa_dim }
}
\group_end:
% clean up
@@ -1182,7 +1318,7 @@
% read the input
\cs_new:Npn \chemformula_input:n #1
{
- \tl_set_rescan:Nnn \l_chemformula_tmpa_tl
+ \tl_set_rescan:Nnn \l_chemformula_chemformula_tmpa_tl
{
\char_set_catcode_letter:N \{
\char_set_catcode_letter:N \}
@@ -1190,12 +1326,12 @@
\char_set_catcode_other:N \"
}
{ #1 }
- \chemformula_input_escape_text:o { \l_chemformula_tmpa_tl }
+ \chemformula_input_escape_text:o { \l_chemformula_chemformula_tmpa_tl }
\chemformula_input_escape_math:n { #1 }
\chemformula_input_stoich:n { #1 }
- \chemformula_clean_chem_macros:o { \l_chemformula_tmpa_tl }
+ \chemformula_clean_chem_macros:o { \l_chemformula_chemformula_tmpa_tl }
\chemformula_input_cmpd:VN
- \l_chemformula_tmpa_tl \l_chemformula_input_tl
+ \l_chemformula_chemformula_tmpa_tl \l_chemformula_input_tl
\chemformula_input_arrow:n { #1 }
\chemformula_input_name:n { #1 }
\chemformula_input_plus:n { #1 }
@@ -1208,14 +1344,14 @@
\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 { @ }
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl { \makeatletter } { #1 }
+ \tl_if_in:VnTF \l_chemformula_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 { @ }
+ \tl_remove_all:Nn \l_chemformula_tmpa_tl { @ }
\exp_last_unbraced:Nno \tl_set:Nn \l_chemformula_internal_options_tl
- { \l_tmpa_tl }
+ { \l_chemformula_tmpa_tl }
}
{ \bool_set_false:N \l_chemformula_is_option_bool }
}
@@ -1228,10 +1364,10 @@
\tl_put_right:Nn \l_chemformula_stoich_tl { \chemformula_font_inner: }
\tl_map_inline:nn { #1 }
{
- \prop_get:NnNTF \l_chemformula_stoich_prop { ##1 } \l_tmpa_tl
+ \prop_get:NnNTF \l_chemformula_stoich_prop { ##1 } \l_chemformula_tmpa_tl
{
\bool_if:NT \l_chemformula_stoich_bool
- { \tl_put_right:Nx \l_chemformula_stoich_tl { \l_tmpa_tl } }
+ { \tl_put_right:Nx \l_chemformula_stoich_tl { \l_chemformula_tmpa_tl } }
}
{ \bool_set_false:N \l_chemformula_stoich_bool }
}
@@ -1249,7 +1385,7 @@
{ \tl_clear:N \l_chemformula_stoich_tl }
}
-\cs_new:Nn \chemformula_bm:n { #1 }
+\cs_new:Npn \chemformula_bm:n #1 { #1 }
\cs_new:Npn \chemformula_parse_stoich:n #1
{
@@ -1307,7 +1443,7 @@
%-----------------------------------------------------------------------------%
% input compounds
-\cs_new:Nn \chemformula_input_cmpd:nN
+\cs_new:Npn \chemformula_input_cmpd:nN #1#2
{
\tl_if_blank:VTF \l_chemformula_stoich_tl
{
@@ -1363,7 +1499,7 @@
}
\cs_generate_variant:Nn \chemformula_input_cmpd:nN { VN }
-\cs_new:Nn \chemformula_font_inner:
+\cs_new:Npn \chemformula_font_inner:
{
\bool_if:NT \l_chemformula_fss_bool
{
@@ -1383,8 +1519,8 @@
{ \cs_set:Nn \chemformula_bm:n { ##1 } }
}
-\cs_new:Nn \chemformula_font: {}
-\cs_new:Nn \chemformula_fontspec:n
+\cs_new:Npn \chemformula_font: {}
+\cs_new:Npn \chemformula_fontspec:n #1
{
\tl_if_in:nnTF { #1 } { [ }
{ \chemformula_fontspec_aux:w #1 \q_stop }
@@ -1394,9 +1530,9 @@
\cs_new:Npn \chemformula_fontspec_aux:w [#1]#2 \q_stop
{ \newfontfamily \chemformula_font: [ #1 ] { #2 } }
-\cs_new:Nn \chemformula_handle_sub_and_superscripts:nN
+\cs_new:Npn \chemformula_handle_sub_and_superscripts:nN #1#2
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl
{
\char_set_catcode_letter:N \_
\char_set_catcode_letter:N \{
@@ -1406,29 +1542,29 @@
}
{ #1 }
% let's see if the compound starts with a sub- or superscript:
- \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_tmpa_tl } { ^ }
+ \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_chemformula_tmpa_tl } { ^ }
{ \bool_set_true:N \l_chemformula_is_isotope_bool }
- \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_tmpa_tl } { _ }
+ \exp_args:Nx \tl_if_in:nnT { \tl_head:V \l_chemformula_tmpa_tl } { _ }
{ \bool_set_true:N \l_chemformula_is_isotope_bool }
\exp_args:NNx \prop_if_in:NnT \l_chemformula_numbers_prop
- { \tl_head:V \l_tmpa_tl }
+ { \tl_head:V \l_chemformula_tmpa_tl }
{ \bool_set_true:N \l_chemformula_is_isotope_bool }
- \tl_if_in:VnT \l_tmpa_tl { ^ }
+ \tl_if_in:VnT \l_chemformula_tmpa_tl { ^ }
{
- \tl_replace_all:Nnn \l_tmpa_tl { ^ }
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { ^ }
{ \chemformula_superscript:n }
}
- \tl_if_in:VnT \l_tmpa_tl { _ }
+ \tl_if_in:VnT \l_chemformula_tmpa_tl { _ }
{
- \tl_replace_all:Nnn \l_tmpa_tl { _ }
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { _ }
{ \chemformula_subscript:n }
}
\int_zero:N \l_chemformula_count_tokens_int
- \tl_map_inline:Nn \l_tmpa_tl
+ \tl_map_inline:Nn \l_chemformula_tmpa_tl
{
\int_incr:N \l_chemformula_count_tokens_int
\int_compare:nTF
- { \l_chemformula_count_tokens_int = \tl_length:N \l_tmpa_tl }
+ { \l_chemformula_count_tokens_int = \tl_length:N \l_chemformula_tmpa_tl }
{
\tl_if_eq:nnTF { ##1 } { + }
{
@@ -1442,15 +1578,15 @@
{ \chemformula_superscript:n { \chemformula_minus: } }
}
{
- \prop_get:NnNTF \l_chemformula_cmpd_prop { ##1 } \l_tmpb_tl
- { \tl_put_right:No #2 { \l_tmpb_tl } }
+ \prop_get:NnNTF \l_chemformula_cmpd_prop { ##1 } \l_chemformula_tmpb_tl
+ { \tl_put_right:No #2 { \l_chemformula_tmpb_tl } }
{ \tl_put_right:Nn #2 { ##1 } }
}
}
}
{
- \prop_get:NnNTF \l_chemformula_cmpd_prop { ##1 } \l_tmpb_tl
- { \tl_put_right:No #2 { \l_tmpb_tl } }
+ \prop_get:NnNTF \l_chemformula_cmpd_prop { ##1 } \l_chemformula_tmpb_tl
+ { \tl_put_right:No #2 { \l_chemformula_tmpb_tl } }
{ \tl_put_right:Nn #2 { ##1 } }
}
}
@@ -1458,7 +1594,7 @@
%-----------------------------------------------------------------------------%
% clean up chemmacros commands:
-\cs_new:Nn \chemformula_clean_chem_macros:n
+\cs_new:Npn \chemformula_clean_chem_macros:n #1
{
\cs_set:Nn \chemmacros_text:n
{
@@ -1472,7 +1608,7 @@
%-----------------------------------------------------------------------------%
% input "and" sign
-\cs_new:Nn \chemformula_input_plus:n
+\cs_new:Npn \chemformula_input_plus:n #1
{
\tl_if_eq:nnT { #1 } { + }
{
@@ -1488,7 +1624,7 @@
%-----------------------------------------------------------------------------%
% input escaping gas
-\cs_new:Nn \chemformula_input_up:n
+\cs_new:Npn \chemformula_input_up:n #1
{
\tl_if_eq:nnT { #1 } { ^ }
{ \tl_put_right:Nn \l_chemformula_input_tl { $\uparrow$ } }
@@ -1497,7 +1633,7 @@
%-----------------------------------------------------------------------------%
% input precipitate
-\cs_new:Nn \chemformula_input_down:n
+\cs_new:Npn \chemformula_input_down:n #1
{
\tl_if_eq:nnT { #1 } { v }
{ \tl_put_right:Nn \l_chemformula_input_tl { $\downarrow$ } }
@@ -1506,7 +1642,7 @@
%-----------------------------------------------------------------------------%
% input arrow
-\cs_new:Nn \chemformula_input_arrow:n
+\cs_new:Npn \chemformula_input_arrow:n #1
{
\bool_if:nT
{
@@ -1521,7 +1657,7 @@
%-----------------------------------------------------------------------------%
% input compound name
-\cs_new:Nn \chemformula_input_name:n
+\cs_new:Npn \chemformula_input_name:n #1
{
\bool_if:nT
{
@@ -1535,7 +1671,7 @@
%-----------------------------------------------------------------------------%
% input escaped text
-\cs_new:Nn \chemformula_input_escape_text:n
+\cs_new:Npn \chemformula_input_escape_text:n #1
{
\chemformula_first_last_text:n { #1 }
\bool_if:NT \l_chemformula_first_last_double_bool
@@ -1553,45 +1689,45 @@
\cs_new:Npn \chemformula_read_escape_double:w "#1" \q_nil
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl
{ \ExplSyntaxNamesOn \char_set_catcode_other:N \: }
{ { #1 } }
- \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder }
- \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
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { \_ } { chemformulaplaceholder }
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { chemformulaplaceholder } { \_ }
+ \tl_set_rescan:Nno \l_chemformula_tmpa_tl { \ExplSyntaxOff } { \l_chemformula_tmpa_tl }
+ \tl_put_right:NV \l_chemformula_input_tl \l_chemformula_tmpa_tl
}
\cs_new:Npn \chemformula_read_escape_single:w '#1' \q_nil
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl
{ \ExplSyntaxNamesOn \char_set_catcode_other:N \: }
{ { #1 } }
- \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder }
- \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
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { \_ } { chemformulaplaceholder }
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token?
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { chemformulaplaceholder } { \_ }
+ \tl_set_rescan:Nno \l_chemformula_tmpa_tl { \ExplSyntaxOff } { \l_chemformula_tmpa_tl }
+ \tl_put_right:NV \l_chemformula_input_tl \l_chemformula_tmpa_tl
}
-\cs_new:Nn \chemformula_first_last_text:n
+\cs_new:Npn \chemformula_first_last_text:n #1
{
\bool_set_false:N \l_chemformula_first_last_double_bool
\bool_set_false:N \l_chemformula_first_last_single_bool
\bool_set_false:N \l_chemformula_first_last_text_bool
- \int_zero:N \l_tmpa_int
- \int_zero:N \l_tmpb_int
- \tl_map_inline:nn { #1 } { \int_incr:N \l_tmpa_int }
+ \int_zero:N \l_chemformula_tmpa_int
+ \int_zero:N \l_chemformula_tmpb_int
+ \tl_map_inline:nn { #1 } { \int_incr:N \l_chemformula_tmpa_int }
\tl_map_inline:nn { #1 }
{
- \int_incr:N \l_tmpb_int
- \int_compare:nT { \l_tmpb_int = 1 }
+ \int_incr:N \l_chemformula_tmpb_int
+ \int_compare:nT { \l_chemformula_tmpb_int = 1 }
{
\tl_if_eq:nnT { ##1 } { " }
{ \bool_set_true:N \l_chemformula_first_last_double_bool }
}
- \int_compare:nT { \l_tmpb_int = \l_tmpa_int }
+ \int_compare:nT { \l_chemformula_tmpb_int = \l_chemformula_tmpa_int }
{
\tl_if_eq:nnF { ##1 } { " }
{ \bool_set_false:N \l_chemformula_first_last_double_bool }
@@ -1599,16 +1735,16 @@
}
\bool_if:NF \l_chemformula_first_last_double_bool
{
- \int_zero:N \l_tmpb_int
+ \int_zero:N \l_chemformula_tmpb_int
\tl_map_inline:nn { #1 }
{
- \int_incr:N \l_tmpb_int
- \int_compare:nT { \l_tmpb_int = 1 }
+ \int_incr:N \l_chemformula_tmpb_int
+ \int_compare:nT { \l_chemformula_tmpb_int = 1 }
{
\tl_if_eq:nnT { ##1 } { ' }
{ \bool_set_true:N \l_chemformula_first_last_single_bool }
}
- \int_compare:nT { \l_tmpb_int = \l_tmpa_int }
+ \int_compare:nT { \l_chemformula_tmpb_int = \l_chemformula_tmpa_int }
{
\tl_if_eq:nnF { ##1 } { ' }
{ \bool_set_false:N \l_chemformula_first_last_single_bool }
@@ -1619,7 +1755,7 @@
%-----------------------------------------------------------------------------%
% input escaped math
-\cs_new:Nn \chemformula_input_escape_math:n
+\cs_new:Npn \chemformula_input_escape_math:n #1
{
\chemformula_first_last_math:n { #1 }
\bool_if:NT \l_chemformula_first_last_math_bool
@@ -1628,36 +1764,36 @@
\cs_new:Npn \chemformula_read_escape_math:w $#1$ \q_nil
{
- \tl_set_rescan:Nnn \l_tmpa_tl
+ \tl_set_rescan:Nnn \l_chemformula_tmpa_tl
{
\ExplSyntaxNamesOn \char_set_catcode_letter:N \{
\char_set_catcode_letter:N \}
}
{ \mbox { \( #1 \) } }
- \tl_replace_all:Nnn \l_tmpa_tl { \_ } { chemformulaplaceholder }
- \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
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { \_ } { chemformulaplaceholder }
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { _ } { \sb } % TODO use \c_math_subscript_token
+ \tl_replace_all:Nnn \l_chemformula_tmpa_tl { chemformulaplaceholder } { \_ }
+ \tl_set_rescan:Nno \l_chemformula_tmpa_tl { \ExplSyntaxOff } { \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_dim }
}
-\cs_new:Nn \chemformula_first_last_math:n
+\cs_new:Npn \chemformula_first_last_math:n #1
{
\bool_set_false:N \l_chemformula_first_last_math_bool
- \int_zero:N \l_tmpa_int
- \int_zero:N \l_tmpb_int
- \tl_map_inline:nn { #1 } { \int_incr:N \l_tmpa_int }
+ \int_zero:N \l_chemformula_tmpa_int
+ \int_zero:N \l_chemformula_tmpb_int
+ \tl_map_inline:nn { #1 } { \int_incr:N \l_chemformula_tmpa_int }
\tl_map_inline:nn { #1 }
{
- \int_incr:N \l_tmpb_int
- \int_compare:nT { \l_tmpb_int = 1 }
+ \int_incr:N \l_chemformula_tmpb_int
+ \int_compare:nT { \l_chemformula_tmpb_int = 1 }
{
\tl_if_eq:nnT { ##1 } { $ }
{ \bool_set_true:N \l_chemformula_first_last_math_bool }
}
- \int_compare:nT { \l_tmpb_int = \l_tmpa_int }
+ \int_compare:nT { \l_chemformula_tmpb_int = \l_chemformula_tmpa_int }
{
\tl_if_eq:nnF { ##1 } { $ }
{ \bool_set_false:N \l_chemformula_first_last_math_bool }
@@ -1770,60 +1906,10 @@
\tex_endinput:D
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
VERSION HISTORY
-2012/01/28 - version 3.0 - first published to CTAN with the chemmacros bundle
-2012/01/30 - version 3.0a - bugfix: subscripts in escaped inputs failed,
- renamed formula => chemformula
-2012/02/02 - version 3.0b - updated documentation
-2012/02/05 - version 3.0c - renamed pictogram files
-2012/02/10 - version 3.0d - \xspace disabled inside \ch{}
- - bugfix: \ch{_{123}^{23}U} now compiles (\leavevmode
- added)
- - bugfix: right shift for the super- und subscripts
- - bugfix: escaped text recognizes space by ~ again
- - * in superscript now gives excited state
- - new arrow type <>
-2012/02/19 - version 3.1 - new functions in the chemmacros package
- - new arrow types -/>, </- and <o>
- - new commands \DeclareChemArrow, \RenewChemArrow and
- \ShowChemArrow
-2012/02/26 - version 3.1a - changes in the chemmacros package
-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 - 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
-2012/05/07 - version 3.3 - \ch now bypasses \ref{}, \label{}, and \intertext{}
- - new features in chemmacros.sty
-2012/05/13 - version 3.3a - Italian translations of the H, EUH and P statements
- - fix of unexpected behaviour in the compound naming
- mechanism
-2012/05/18 - version 3.3b - compatibility with MiKTeX
-2012/05/18 - version 3.3c - fix in the `ghsystem/language' option
-2012/07/24 - version 3.3d - additional picture file type `pdf'
- - default bond length set to 1.1667ex
- - bug fix in the bonds
- - added kerning to cip commands, new option
- `iupac/cip-kern'
- - bug fix: messages needed to be defined before the
- options
-2012/08/08 - version 3.3e - new option ox/align=center|right
+see the chemmacros.sty file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO
-- Option, die den Punkt . in \ch zum Radikal-Punkt macht, evtl \chemformula_radical:
- an chemfigs \lewis anpassen
-- 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?