From 1c830519a1d93bbc7d81a87c98e0f6e587d8d12c Mon Sep 17 00:00:00 2001 From: Clemens Niederberger Date: Sat, 7 Mar 2020 13:50:23 +0100 Subject: [PATCH] resolve issue #31 --- README | 2 +- chemmacros.history | 5 ++--- chemmacros.module.chemformula.code.tex | 8 +++----- chemmacros.module.redox.code.tex | 27 ++++++++++++++++++++++++-- chemmacros.sty | 2 +- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/README b/README index 9b1d826..a3e932f 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -the CHEMMACROS package v5.11 2020/02/29 +the CHEMMACROS package v5.11 2020/03/07 comprehensive support for typesetting chemistry documents diff --git a/chemmacros.history b/chemmacros.history index d52ce4d..2104a10 100644 --- a/chemmacros.history +++ b/chemmacros.history @@ -390,7 +390,6 @@ Version history - prefer lazy boolean evaluation - prefer the kernel commands to \chemmacros_leave_vmode: and \chemmacros_tex_if: -2020/02/29 - version 5.11 - use \ch even for simple formulas – resolves issue - #28 (chemformula) - - let \chemmacros_iupac:nn think we're in the +2020/03/07 - version 5.11 - let \chemmacros_iupac:nn think we're in the document – fixes issue #30 (nomenclature) + - add option redox/format diff --git a/chemmacros.module.chemformula.code.tex b/chemmacros.module.chemformula.code.tex index 0445aa0..c2fb135 100644 --- a/chemmacros.module.chemformula.code.tex +++ b/chemmacros.module.chemformula.code.tex @@ -131,11 +131,7 @@ { \chemmacros_integrate_package:nnn {} {chemformula} {2015/09/08} \cs_set_protected:Npn \chemmacros_chemformula:n #1 - { - \chemmacros_if_compatibility:nnTF {>} {5.10} - { \chemformula_ch:nn {} {#1} } - { \chemformula_chcpd:nn {} {#1} } - } + { \chemformula_chcpd:nn {} {#1} } \cs_set_protected:Npn \chemmacros_reaction:n #1 { \chemformula_ch:nn {} {#1} } } @@ -243,3 +239,5 @@ 2016/05/03 - correct wrong method check 2020/02/02 - lazy boolean evaluation 2020/02/29 - use \ch even for simple formulas – resolves issue #28 +2020/03/02 - undo last change: this makes problems with oxidation numbers in a + reaction diff --git a/chemmacros.module.redox.code.tex b/chemmacros.module.redox.code.tex index 2c0421b..f3f8b29 100644 --- a/chemmacros.module.redox.code.tex +++ b/chemmacros.module.redox.code.tex @@ -52,9 +52,20 @@ \bool_new:N \l__chemmacros_ox_top_bool \bool_new:N \l__chemmacros_ox_align_center_bool +\ChemCompatibilityFrom{5.11} +\tl_new:N \l__chemmacros_ox_format_tl +\EndChemCompatibility + \int_new:N \l__chemmacros_ox_number_int \fp_new:N \l__chemmacros_ox_number_fp +\cs_new_protected:Npn \__chemmacros_ox_format:n #1 + { + \chemmacros_if_compatibility:nnTF {>=} {5.11} + { { \l__chemmacros_ox_format_tl {#1} } } + { \use:n {#1} } + } + \cs_new_protected:Npn \__chemmacros_ox_process_number:n #1 { \bool_if:NTF \l__chemmacros_ox_parse_bool @@ -180,7 +191,10 @@ \hbox_set:Nn \l__chemmacros_tmpa_box { \chemmacros_text:n - { \relsize {-3} \__chemmacros_ox_process_number:n {#1} } + { + \__chemmacros_ox_format:n + { \relsize {-3} \__chemmacros_ox_process_number:n {#1} } + } } \hbox_set:Nn \l__chemmacros_tmpb_box { \chemmacros_chemformula:n {#2} } \chemmacros_math:n @@ -196,7 +210,10 @@ { \box_use:N \l__chemmacros_tmpb_box \tl_use:N \l__chemmacros_ox_side_connect_tl - ( \__chemmacros_ox_process_number:n {#1} ) + ( + \__chemmacros_ox_format:n + { \__chemmacros_ox_process_number:n {#1} } + ) } } \bool_if:NT \l__chemmacros_ox_top_bool @@ -285,6 +302,11 @@ } \EndChemCompatibility +\ChemCompatibilityFrom{5.11} +\chemmacros_define_keys:nn {redox} + { format .tl_set:N = \l__chemmacros_ox_format_tl } +\EndChemCompatibility + % \ox[]{,} % \ox*[]{,} => always number on the top \cs_new_protected:Npn \chemmacros_ox:nnnn #1#2#3#4 @@ -433,3 +455,4 @@ 2015/09/30 - new option `explicit-zero-sign' 2020/02/02 - lazy boolean evaluation - prefer \legacy_if:nTF over \chemmacros_if_tex:nnTF +2020/03/02 - add option redox/format diff --git a/chemmacros.sty b/chemmacros.sty index 43458f8..f994ff6 100644 --- a/chemmacros.sty +++ b/chemmacros.sty @@ -31,7 +31,7 @@ % -------------------------------------------------------------------------- % package information: -\tl_const:Nn \c_chemmacros_date_tl {2020/02/29} +\tl_const:Nn \c_chemmacros_date_tl {2020/03/07} \tl_const:Nn \c_chemmacros_version_major_number_tl {5} \tl_const:Nn \c_chemmacros_version_minor_number_tl {11} \tl_const:Nn \c_chemmacros_version_subrelease_tl {}