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.sty76
1 files changed, 50 insertions, 26 deletions
diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
index 715ff06b1ad..12344325e7d 100644
--- a/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
+++ b/Master/texmf-dist/tex/latex/chemmacros/chemformula.sty
@@ -302,6 +302,7 @@
\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 }
@@ -328,6 +329,13 @@
{ \l__chemformula_arrow_offset_dim }
\dim_add:Nn \l__chemformula_arrow_length_dim
{ \l__chemformula_arrow_offset_dim }
+ \dim_compare:nF
+ { \l__chemformula_arrow_length_dim > \l__chemformula_arrow_minimum_length_dim }
+ {
+ \dim_set_eq:NN
+ \l__chemformula_arrow_length_dim
+ \l__chemformula_arrow_minimum_length_dim
+ }
\dim_set:Nn \l__chemformula_arrow_shortage_dim
{
\l__chemformula_arrow_length_dim *
@@ -351,6 +359,7 @@
\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
@@ -535,14 +544,15 @@
% arrow customization
\keys_define:nn { chemmacros / chemformula }
{
- arrow-offset .dim_set:N = \l__chemformula_arrow_offset_dim ,
- arrow-yshift .dim_set:N = \l__chemformula_arrow_yshift_dim ,
- 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
+ arrow-offset .dim_set:N = \l__chemformula_arrow_offset_dim ,
+ arrow-min-length .dim_set:N = \l__chemformula_arrow_minimum_length_dim ,
+ arrow-yshift .dim_set:N = \l__chemformula_arrow_yshift_dim ,
+ 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
}
%-----------------------------------------------------------------------------%
@@ -564,12 +574,13 @@
\seq_map_function:NN
\l__chemformula_input_seq
\chemformula_input:n
- \__chemformula_generate_arrows:V \l__chemformula_input_tl
- \__chemformula_generate_name:V \l__chemformula_output_tl
- \tl_set_rescan:Nno \l__chemformula_output_tl
+% \tl_set_eq:NN
+% \l__chemformula_output_tl
+% \l__chemformula_input_tl
+ \tl_set_rescan:Nno \l__chemformula_input_tl
{ \ExplSyntaxOn \makeatletter }
- { \l__chemformula_output_tl }
- \chemformula_write:V \l__chemformula_output_tl
+ { \l__chemformula_input_tl }
+ \chemformula_write:V \l__chemformula_input_tl
\group_end:
}
@@ -664,17 +675,17 @@
%-----------------------------------------------------------------------------%
% arrow generation & detection
-\cs_new:Npn \__chemformula_generate_arrows:n #1
+\cs_new:Npn \__chemformula_generate_arrows:Nn #1#2
{
- \tl_set:Nn \l__chemformula_tmpa_tl { #1 }
+ \tl_set:Nn \l__chemformula_tmpa_tl { #2 }
\seq_map_inline:Nn \l__chemformula_arrows_type_seq
{
\tl_replace_all:Nnn \l__chemformula_tmpa_tl
{ ##1 } { \__chemformula_arrows_get:n { ##1 } }
}
- \tl_set_eq:NN \l__chemformula_output_tl \l__chemformula_tmpa_tl
+ \tl_set_eq:NN #1 \l__chemformula_tmpa_tl
}
-\cs_generate_variant:Nn \__chemformula_generate_arrows:n { V }
+\cs_generate_variant:Nn \__chemformula_generate_arrows:Nn { NV }
\cs_new_protected:Npn \__chemformula_detect_arrows:n #1
{
@@ -690,6 +701,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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 } { ! } }
@@ -714,14 +726,18 @@
\)
}
-\cs_new_protected:Npn \__chemformula_generate_name:n #1
+\cs_new_protected:Npn \__chemformula_generate_name:Nn #1#2
{
- \tl_set:Nn \l__chemformula_tmpa_tl { #1 }
+ \tl_set:Nn \l__chemformula_tmpa_tl { #2 }
\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
+ {
+ \tl_replace_all:Nnn \l__chemformula_tmpa_tl
+ { ! }
+ { \__chemformula_name_cmpd:w }
+ }
+ \tl_set_eq:NN #1 \l__chemformula_tmpa_tl
}
-\cs_generate_variant:Nn \__chemformula_generate_name:n { V }
+\cs_generate_variant:Nn \__chemformula_generate_name:Nn { NV }
\cs_new_protected:Npn \__chemformula_detect_name:n #1
{
@@ -773,7 +789,7 @@
\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_output_tl
\tl_new:N \l__chemformula_input_tl
\tl_new:N \l__chemformula_stoich_tl
\tl_new:N \l__chemformula_decimal_output_tl
@@ -1514,8 +1530,9 @@
{ \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
- { $ \frac{ \text { #1 } } { \text { #2 } } $ }
+ { $ \textstyle \frac{ \text { #1 } } { \text { #2 } } $ }
}
\cs_new:Npn \__chemformula_misc_frac:nnn #1#2#3
@@ -1773,7 +1790,10 @@
!\l__chemformula_first_last_text_bool &&
!\l__chemformula_first_last_math_bool
}
- { \tl_put_right:Nn \l__chemformula_input_tl { #1 } }
+ {
+ \__chemformula_generate_arrows:Nn \l__chemformula_arrow_tmp_tl { #1 }
+ \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_arrow_tmp_tl
+ }
\bool_set_false:N \l__chemformula_is_arrow_bool
}
\cs_generate_variant:Nn \chemformula_input_arrow:n { o }
@@ -1788,7 +1808,10 @@
!\l__chemformula_first_last_text_bool &&
!\l__chemformula_first_last_math_bool
}
- { \tl_put_right:Nn \l__chemformula_input_tl { #1 } }
+ {
+ \__chemformula_generate_name:Nn \l__chemformula_name_tmp_tl { #1 }
+ \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_name_tmp_tl
+ }
\bool_set_false:N \l__chemformula_is_name_bool
}
@@ -2035,6 +2058,7 @@ see the chemmacros.sty file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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?