Skip to content

Commit

Permalink
implement issue #9
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Apr 17, 2017
1 parent 94cd59b commit 9e446a9
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 43 deletions.
6 changes: 5 additions & 1 deletion chemmacros.history
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,12 @@ Version history
2016/10/05 - version 5.7b - small improvement of the errorcheck module
2016/12/28 - version 5.7c - bug fix: typo in \chemmacros_tex_if:nnTF usage
(scheme)
2017/??/?? - version 5.8 - new option `nmr-base-format' (spectroscopy)
2017/04/17 - version 5.8 - new option `nmr-base-format' (spectroscopy)
- change \hapto and \dento to follow iupacs rules
according to IUPAC Red Book 2005. IR-10.2.5.2 The
eta convention (p.216) and IR-9.2.4.2 The
kappa convention (p.155f)
- fix error in \chemmacros_allow_hyphens: definition
(nomenclature)
- new options `cip-inner-format', `cip-outer-format'
and `cip-number-format' (nomenclature)
8 changes: 4 additions & 4 deletions chemmacros.module.acid-base.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
\tl_set:cn
{l__chemmacros_#2_tl}
{ \chemmacros_translate:n {#2} }
\chemmacros_if_compatiblity:nnTF {>} {5.6}
\chemmacros_if_compatibility:nnTF {>} {5.6}
{ \chemmacros_declare_translation:nnn {#2} {fallback} {#3} }
{ \DeclareTranslationFallback {#2} {#3} }
\cs_set_protected:Npn #1
Expand All @@ -90,7 +90,7 @@
\NewChemEqConstant \Kb {K-base} { \mathrm{b} }
\NewChemEqConstant \Kw {K-water} { \mathrm{w} }

\chemmacros_if_compatiblity:nnT {>=} {5.4}
\chemmacros_if_compatibility:nnT {>=} {5.4}
{
\chemmacros_define_keys:nn {acid-base}
{ eq-constant .tl_set:N = \l__chemmacros_equilibrium_constant_tl }
Expand Down Expand Up @@ -152,8 +152,8 @@
\ChemCompatibilityFrom{5.6}
\chemmacros_declare_translations:nn {K-acid}
{
German = \mathrm {s} ,
Dutch = \mathrm {z}
German = \mathrm {s} ,
Dutch = \mathrm {z}
}
\EndChemCompatibility
% --------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions chemmacros.module.base.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
\bool_new:N \l__chemmacros_in_document_bool
\bool_new:N \l__chemmacros_chemstyle_bool

\chemmacros_if_compatiblity:nnTF {>=} {5.2}
\chemmacros_if_compatibility:nnTF {>=} {5.2}
{ \AfterEndPreamble }
{ \AtBeginDocument }
{ \bool_set_true:N \l__chemmacros_in_document_bool }
Expand Down Expand Up @@ -458,7 +458,7 @@

% --------------------------------------------------------------------------

\chemmacros_if_compatiblity:nnT {>=} {5.2}
\chemmacros_if_compatibility:nnT {>=} {5.2}
{ \chemmacros_load_module:n {errorcheck} }

% --------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions chemmacros.module.chemformula.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,15 @@
{
!\l__chemmacros_formula_method_set_bool
&&
\chemmacros_if_compatiblity_p:nn {>=} {5.2}
\chemmacros_if_compatibility_p:nn {>=} {5.2}
&&
\chemmacros_if_compatiblity_p:nn {<} {5.6}
\chemmacros_if_compatibility_p:nn {<} {5.6}
}
{ \chemmacros_check_formula_method: }
{
\bool_if:NF \l__chemmacros_formula_method_set_bool
{
\chemmacros_if_compatiblity:nnTF {>=} {5.6}
\chemmacros_if_compatibility:nnTF {>=} {5.6}
{ \msg_info:nn {chemmacros} {default-formula-method} }
{ \msg_warning:nn {chemmacros} {default-formula-method} }
\chemmacros_set_formula_method:n {chemformula}
Expand Down
5 changes: 2 additions & 3 deletions chemmacros.module.lang.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
\tl_new:N \l__chemmacros_current_language_tl

\tl_const:Nx \c__chemmacros_keyword_prefix_tl
{ \chemmacros_if_compatiblity:nnT {>} {5.6} {chem-keyword-} }
{ \chemmacros_if_compatibility:nnT {>} {5.6} {chem-keyword-} }

\prop_new:N \g_chemmacros_translations_prop

Expand Down Expand Up @@ -121,10 +121,9 @@
% #3: translation
\cs_new_protected:Npn \chemmacros_declare_translation:nnn #1#2#3
{
% TODO: this should be \declaretranslation
\declaretranslation
{ \c__chemmacros_keyword_prefix_tl #1 }
{#2}
{ \c__chemmacros_keyword_prefix_tl #1 }
{#3}
\prop_gput:Nnn \g_chemmacros_translations_prop {#1(#2)} {#3}
}
Expand Down
65 changes: 59 additions & 6 deletions chemmacros.module.nomenclature.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
{ \chemmacros_cip:n {#1} }
\EndChemCompatibility

\ChemCompatibilityFrom{5.2}
\ChemCompatibilityBetween{5.2}{5.7}
\cs_new_protected:Npn \chemmacros_cip:n #1
{
\int_zero:N \l__chemmacros_tmpa_int
Expand All @@ -270,6 +270,54 @@
\DeclareChemIUPAC \cip { \chemmacros_cip:n }
\EndChemCompatibility

\ChemCompatibilityFrom{5.8}
\tl_new:N \l__chemmacros_cip_inner_tl
\tl_new:N \l__chemmacros_cip_outer_tl
\tl_new:N \l__chemmacros_cip_number_tl

\chemmacros_define_keys:nn {nomenclature}
{
cip-inner-format .tl_set:N = \l__chemmacros_cip_inner_tl ,
cip-inner-format .initial:n = \itshape ,
cip-outer-format .tl_set:N = \l__chemmacros_cip_outer_tl ,
cip-outer-format .initial:n = \upshape ,
cip-number-format .tl_set:N = \l__chemmacros_cip_number_tl ,
cip-number-format .initial:n = \upshape
}

\cs_new_protected:Npn \__chemmacros_cip:n #1
{
\tl_set:Nn \l__chemmacros_tmpa_tl {#1}
\int_step_inline:nnnn {0} {1} {9}
{
\tl_replace_all:Nnn \l__chemmacros_tmpa_tl
{##1}
{ { \l__chemmacros_cip_number_tl ##1} }
}
{ \l__chemmacros_cip_inner_tl \l__chemmacros_tmpa_tl }
}

\cs_new_protected:Npn \chemmacros_cip:n #1
{
\int_zero:N \l__chemmacros_tmpa_int
\group_begin:
\l__chemmacros_cip_outer_tl (
\clist_map_inline:nn
{#1}
{
\int_incr:N \l__chemmacros_tmpa_int
\__chemmacros_cip:n {##1}
\int_compare:nT
{ \l__chemmacros_tmpa_int < \clist_count:n {#1} }
{ , }
}
)
\group_end:
\tex_kern:D \l__chemmacros_cip_kern_dim
}
\DeclareChemIUPAC \cip { \chemmacros_cip:n }
\EndChemCompatibility

% remember: TikZ needs : to be other
\cs_new_protected:Npn \chemmacros_sconf:n #1
{
Expand Down Expand Up @@ -338,7 +386,7 @@
\chemmacros_coordination_symbol:nnnn
{ \l__chemmacros_coord_use_hyphen_bool }
{
\chemmacros_if_compatiblity_p:nn {>} {5.7}
\chemmacros_if_compatibility_p:nn {>} {5.7}
{ \c_true_bool }
{ \c_false_bool }
}
Expand All @@ -351,7 +399,7 @@
\chemmacros_coordination_symbol:nnnn
{ \l__chemmacros_coord_use_hyphen_bool }
{
\chemmacros_if_compatiblity_p:nn {>} {5.7}
\chemmacros_if_compatibility_p:nn {>} {5.7}
{ \c_true_bool }
{ \c_false_bool }
}
Expand All @@ -378,7 +426,9 @@
\cs_new_protected:Npn \chemmacros_allow_hyphens:
{
\chemmacros_nobreak:
\skip_horizontal:N \c_zero_dim
\chemmacros_if_compatibility:nnTF {<=} {5.7}
{ \skip_horizontal:N \c_zero_dim }
{ \skip_horizontal:N \c_zero_skip }
}

% #1: pre break
Expand Down Expand Up @@ -494,7 +544,7 @@
\prop_new:N \l__chemmacros_iupac_shorthands_prop

% #1: token
% #2: arg spec
% #2: definition
\cs_new_protected:Npn \chemmacros_define_iupac_shorthand:NN #1#2
{
\seq_if_in:NnF \l__chemmacros_iupac_shorthands_seq {#1}
Expand Down Expand Up @@ -592,7 +642,7 @@
\chemmacros_make_shorthands:
% what's this vvv in here for?
\chemmacros_ignore_spaces:
\chemmacros_if_compatiblity:nnT {<=} {5.2}
\chemmacros_if_compatibility:nnT {<=} {5.2}
{ \chemmacros_define_deprecated:NN \- - }
\tl_set_rescan:Nnn \l__chemmacros_tmpa_tl
{ \chemmacros_activate_all_iupac_shorthands: }
Expand Down Expand Up @@ -833,3 +883,6 @@
argument for setting options
2016/06/07 - rename functions which erroneously were assigned to the
`chemformula' module
2017/04/17 - fix erroneous definition of \chemmacros_allow_hyphens:
- new options `cip-inner-format', `cip-outer-format' and
`cip-number-format'
2 changes: 1 addition & 1 deletion chemmacros.module.particles.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
\bool_if:NTF \l__chemmacros_nucleophile_elpair_bool
{
\chemmacros_elpair:n { #2 }
\chemmacros_if_compatiblity:nnT {>=} {5.3}
\chemmacros_if_compatibility:nnT {>=} {5.3}
{ \skip_horizontal:N \l__chemmacros_nucleophile_dim }
\chemmacros_chemformula:n { {}^{-} }
}
Expand Down
4 changes: 2 additions & 2 deletions chemmacros.module.reactions.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@

\cs_if_exist:NTF \chapter
{
\chemmacros_if_compatiblity:nnTF {>=} {5.2}
\chemmacros_if_compatibility:nnTF {>=} {5.2}
{
\chemmacros_set_keys:nn {reactions}
{ list-heading-cmd = \chapter* {#1} }
}
{ \cs_set_protected:Npn \__chemmacros_reaction_heading:n { \chapter* } }
}
{
\chemmacros_if_compatiblity:nnTF {>=} {5.2}
\chemmacros_if_compatibility:nnTF {>=} {5.2}
{
\chemmacros_set_keys:nn {reactions}
{ list-heading-cmd = \section* {#1} }
Expand Down
2 changes: 1 addition & 1 deletion chemmacros.module.spectroscopy.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
\l__chemmacros_nmr_coupling_symbol_tl ,
atom-number-cs .code:n =
\cs_set_eq:NN \__chemmacros_nmr_number:n #1 ,
\chemmacros_if_compatiblity:nnT {>=} {5.3}
\chemmacros_if_compatibility:nnT {>=} {5.3}
{ atom-number-space .skip_set:N = \l__chemmacros_nmr_space_skip , }
coupling-pos-cs .code:n =
\cs_set_eq:NN \__chemmacros_nmr_position:n #1 ,
Expand Down
34 changes: 17 additions & 17 deletions chemmacros.sty
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

% --------------------------------------------------------------------------
% package information:
\tl_const:Nn \c_chemmacros_date_tl {2017/03/10}
\tl_const:Nn \c_chemmacros_date_tl {2017/04/17}
\tl_const:Nn \c_chemmacros_version_major_number_tl {5}
\tl_const:Nn \c_chemmacros_version_minor_number_tl {7}
\tl_const:Nn \c_chemmacros_version_subrelease_tl {d}
\tl_const:Nn \c_chemmacros_version_minor_number_tl {8}
\tl_const:Nn \c_chemmacros_version_subrelease_tl {0}
\tl_const:Nx \c_chemmacros_version_number_tl
{
\c_chemmacros_version_major_number_tl .
Expand Down Expand Up @@ -117,7 +117,7 @@
% #2: number
% #3: true
% #4: false
\prg_new_conditional:Npnn \chemmacros_if_compatiblity:nn #1#2 {p,T,F,TF}
\prg_new_conditional:Npnn \chemmacros_if_compatibility:nn #1#2 {p,T,F,TF}
{
\chemmacros_if_version:nnnTF
{ \fp_to_decimal:N \l__chemmacros_compatibility_version_fp }
Expand All @@ -126,35 +126,35 @@
{ \prg_return_true: }
{ \prg_return_false: }
}
\cs_generate_variant:Nn \chemmacros_if_compatiblity:nnT {nV}
\cs_generate_variant:Nn \chemmacros_if_compatibility:nnT {nV}

% user checks:
\NewDocumentCommand \IfChemCompatibilityTF {mm+m+m}
{ \chemmacros_if_compatiblity:nnTF {#1} {#2} {#3} {#4} }
{ \chemmacros_if_compatibility:nnTF {#1} {#2} {#3} {#4} }

\NewDocumentCommand \IfChemCompatibilityT {mm+m}
{ \chemmacros_if_compatiblity:nnT {#1} {#2} {#3} }
{ \chemmacros_if_compatibility:nnT {#1} {#2} {#3} }

\NewDocumentCommand \IfChemCompatibilityF {mm+m}
{ \chemmacros_if_compatiblity:nnF {#1} {#2} {#3} }
{ \chemmacros_if_compatibility:nnF {#1} {#2} {#3} }

% --------------------------------------------------------------------------
% compatibility coding:
\cs_new_protected:Npn \ChemCompatibility #1#2 \EndChemCompatibility
{ \chemmacros_if_compatiblity:nnT {=} {#1} {#2} }
{ \chemmacros_if_compatibility:nnT {=} {#1} {#2} }

\cs_new_protected:Npn \ChemCompatibilityFrom #1#2 \EndChemCompatibility
{ \chemmacros_if_compatiblity:nnT {>=} {#1} {#2} }
{ \chemmacros_if_compatibility:nnT {>=} {#1} {#2} }

\cs_new_protected:Npn \ChemCompatibilityTo #1#2 \EndChemCompatibility
{ \chemmacros_if_compatiblity:nnT {<=} {#1} {#2} }
{ \chemmacros_if_compatibility:nnT {<=} {#1} {#2} }

\cs_new_protected:Npn \ChemCompatibilityBetween #1#2#3 \EndChemCompatibility
{
\bool_if:nT
{
\chemmacros_if_compatiblity_p:nn {>=} {#1} &&
\chemmacros_if_compatiblity_p:nn {<=} {#2}
\chemmacros_if_compatibility_p:nn {>=} {#1} &&
\chemmacros_if_compatibility_p:nn {<=} {#2}
}
{#3}
}
Expand Down Expand Up @@ -183,29 +183,29 @@

% --------------------------------------------------------------------------
% let's see that the max number is the newest (=current) version
\chemmacros_if_compatiblity:nnT {>} { \c_chemmacros_version_number_tl }
\chemmacros_if_compatibility:nnT {>} { \c_chemmacros_version_number_tl }
{
\fp_set:Nn \l__chemmacros_compatibility_version_fp
{ \c_chemmacros_version_number_tl }
}

% --------------------------------------------------------------------------
% compatibility too low:
\chemmacros_if_compatiblity:nnT {<} {4.7}
\chemmacros_if_compatibility:nnT {<} {4.7}
{
\msg_warning:nnx {chemmacros} {too-low-compatibility}
{ \fp_to_tl:N \l__chemmacros_compatibility_version_fp }
}

% not the newest version:
\chemmacros_if_compatiblity:nnT {<} { \c_chemmacros_version_number_tl }
\chemmacros_if_compatibility:nnT {<} { \c_chemmacros_version_number_tl }
{
\msg_warning:nnx {chemmacros} {low-compatibility}
{ \fp_to_tl:N \l__chemmacros_compatibility_version_fp }
}

% --------------------------------------------------------------------------
\chemmacros_if_compatiblity:nnTF {<} {5.0}
\chemmacros_if_compatibility:nnTF {<} {5.0}
{ \RequirePackage{chemmacros4} }
{ \RequirePackage{chemmacros5} }

Expand Down
2 changes: 1 addition & 1 deletion chemmacros5.sty
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
% --------------------------------------------------------------------------
\cs_new_protected:Npn \__chemmacros_module:nnnn #1#2#3#4
{
\chemmacros_if_compatiblity:nnF {>=} {#4}
\chemmacros_if_compatibility:nnF {>=} {#4}
{
\msg_warning:nnnn {chemmacros} {module-not-available} {#2} {#4}
\tex_endinput:D
Expand Down
4 changes: 2 additions & 2 deletions chemmacros_en.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% arara: pdflatex
: pdflatex
% arara: biber
% arara: pdflatex
% arara: pdflatex
Expand Down Expand Up @@ -678,7 +678,7 @@ \subsubsection{For Module Writers}
we never know what the future actually will bring \chemmacros\ now has the
tools for tying code to a version number:
\begin{commands}
\expandable\explcommand{chemmacros_if_compatiblity:nn}[\TF\ \marg{comp}
\expandable\explcommand{chemmacros_if_compatibility:nn}[\TF\ \marg{comp}
\marg{num} \marg{true} \marg{false}]
expl3 version of \cs{IfChemCompatibilityTF}.
\end{commands}
Expand Down

0 comments on commit 9e446a9

Please sign in to comment.