Skip to content

Commit

Permalink
(hopefully) last update before upload to CTAN (minor changes in nomen…
Browse files Browse the repository at this point in the history
…clature and redox)
  • Loading branch information
cgnieder committed Sep 10, 2015
1 parent 03cfcef commit bc15a49
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 89 deletions.
2 changes: 2 additions & 0 deletions chemmacros.module.base.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@
\chemmacros_nobreak:
}

% do I use those at all?
\prg_new_conditional:Npnn \chemmacros_tex_if:nn #1#2 {p,T,F,TF}
{ \use:c { if #1 } #2 \prg_return_true: \else: \prg_return_false: \fi: }

\prg_new_conditional:Npnn \chemmacros_latex_if:n #1 {p,T,F,TF}
{ #1 { \prg_return_true: } { \prg_return_false: } }

% this is used at least in the `isotope' module
\prg_new_conditional:Npnn \chemmacros_is_int:n #1 {p,T,F,TF}
{
\if_charcode:w ! \if_int_compare:w 9 < 1#1 ! \else: _ \fi:
Expand Down
32 changes: 20 additions & 12 deletions chemmacros.module.nomenclature.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\ChemModule{nomenclature}{2015/07/22 chemical names}
\ChemModule{nomenclature}{2015/09/09 chemical names}

\RequirePackage{scrlfile}

Expand Down Expand Up @@ -294,7 +294,7 @@
% after it
% - add a little space at breaking points if not broken
% - enables all naming commands regardless if they're definied otherwise or not
\cs_new_protected:Nn \chemmacros_allow_hyphens:
\cs_new_protected:Npn \chemmacros_allow_hyphens:
{
\chemmacros_nobreak:
\skip_horizontal:N \c_zero_dim
Expand All @@ -314,24 +314,30 @@
break-space .dim_set:N = \l__chemmacros_iupac_break_dim
}

\cs_new_protected:Nn \chemmacros_break_point_hyphen:
\cs_new_protected:Npn \__chemmacros_break_point_insert:n #1
{
\chemmacros_nobreak:
\tex_discretionary:D { - } { }
\tex_discretionary:D { - } { } {#1}
\chemmacros_allow_hyphens:
}
\cs_new_protected:Npn \chemmacros_break_point_hyphen:
{
\mode_if_math:TF
{ - }
{
\tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim
-
\tex_kern:D \l__chemmacros_iupac_hyphen_post_dim
\__chemmacros_break_point_insert:n
{
\tex_kern:D \l__chemmacros_iupac_hyphen_pre_dim
-
\tex_kern:D \l__chemmacros_iupac_hyphen_post_dim
}
}
\chemmacros_allow_hyphens:
}

\cs_new_protected:Npn \chemmacros_break_point:
{
\chemmacros_nobreak:
\tex_discretionary:D { - } { }
\__chemmacros_break_point_insert:n
{ \tex_kern:D \l__chemmacros_iupac_break_dim }
\chemmacros_allow_hyphens:
}

\cs_new_protected:Npn \chemmacros_superscript:n #1
Expand Down Expand Up @@ -405,7 +411,8 @@
\bool_set_true:N \l__chemmacros_inside_iupac_bool
\chemmacros_make_iupac:
\chemmacros_ignore_spaces:
\cs_set_eq:NN \- \chemmacros_break_point_hyphen:
\chemmacros_if_compatiblity:nnT {<=} {5.2}
{ \chemmacros_define_deprecated:NN \- - }
\tl_set_rescan:Nnn \l__chemmacros_tmpa_tl
{ \chemmacros_activate_all_iupac_shorthands: }
{#1}
Expand All @@ -415,6 +422,7 @@
\group_end:

\NewChemIUPACShorthand | \chemmacros_break_point:
\NewChemIUPACShorthand - \chemmacros_break_point_hyphen:
\NewChemIUPACShorthand ^ \chemmacros_superscript:n

% Thanks to Joseph Wright and Enrico Gregorio for the help on the curious
Expand Down
14 changes: 6 additions & 8 deletions chemmacros.module.redox.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
\ChemModule{redox}{2015/07/22 oxidation numbers, redox reactions}
\ChemModule{redox}{2015/09/09 oxidation numbers, redox reactions}

\chemmacros_load_modules:n {tikz,xfrac}

Expand Down Expand Up @@ -120,8 +120,7 @@

\cs_new_protected:Npn \__chemmacros_ox_is_integer:n #1
{
\fp_set:Nn \l__chemmacros_tmpa_fp { round(#1 + 1 , 0 ) - 1 }
\fp_compare:nNnTF { \l__chemmacros_tmpa_fp } = {#1}
\fp_compare:nNnTF {#1} = { round((#1) + 1 , 0 ) - 1 }
{ \bool_set_true:N \l__chemmacros_ox_integer_bool }
{
\bool_set_false:N \l__chemmacros_ox_integer_bool
Expand All @@ -132,23 +131,22 @@
\cs_new_protected:Npn \__chemmacros_fp_to_Roman:n #1
{
\group_begin:
\fp_compare:nTF { \l__chemmacros_tmpa_fp = 0 }
\fp_compare:nNnTF {#1} = { 0 }
{0}
{ \int_to_Roman:n { \fp_to_int:N \l__chemmacros_tmpa_fp } }
{ \int_to_Roman:n { \fp_to_int:n {#1} } }
\group_end:
}

\cs_new_protected:Npn \__chemmacros_fp_to_arabic:n #1
{
\group_begin:
\fp_set:Nn \l__chemmacros_tmpa_fp {#1}
\bool_if:NTF \l__chemmacros_ox_decimal_marker_comma_bool
{
\tl_set:Nx \l__chemmacros_tmpa_tl { \fp_to_decimal:N \l__chemmacros_tmpa_fp }
\tl_set:Nx \l__chemmacros_tmpa_tl { \fp_to_decimal:n {#1} }
\tl_replace_once:Nnn \l__chemmacros_tmpa_tl {.} { {,} }
\tl_use:N \l__chemmacros_tmpa_tl
}
{ \fp_to_decimal:N \l__chemmacros_tmpa_fp }
{ \fp_to_decimal:n {#1} }
\group_end:
}

Expand Down
13 changes: 4 additions & 9 deletions chemmacros4.sty
Original file line number Diff line number Diff line change
Expand Up @@ -1277,14 +1277,13 @@
\chemmacros_allow_hyphens:
}

\cs_new_protected:Npn \chemmacros_superscript:
{ \mode_if_math:TF { \sb } { \textsuperscript } }
\cs_new_protected:Npn \chemmacros_superscript:n #1
{ \mode_if_math:TF { \sb {#1} } { \textsuperscript {#1} } }

\bool_new:N \l__chemmacros_inside_iupac_bool

\char_set_active_eq:NN | \chemmacros_break_point:

\char_set_active_eq:NN ^ \chemmacros_superscript:
\char_set_active_eq:NN ^ \chemmacros_superscript:n

\group_begin:
\char_set_catcode_active:N \|
Expand All @@ -1309,11 +1308,6 @@
\group_end:
}

% \cs_new_protected:Npn \chemmacros_iupac_aux:n #1
% {
% #1
% \group_end:
% }
\group_end:

% Thanks to Joseph Wright and Enrico Gregorio for the help on the curious
Expand Down Expand Up @@ -4096,6 +4090,7 @@ Version history
2015/08/29 - version 5.0 - integration as v4.7 into v5.0 of chemmacros for
backwards compatibility
- fix typo in \l_chemformula_formal_charges_bool
- remove \tl_to_lowercase:n

% --------------------------------------------------------------------------- %
% TODO:
Expand Down
Binary file modified chemmacros_en.pdf
Binary file not shown.
Loading

0 comments on commit bc15a49

Please sign in to comment.