summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/chemnum/chemnum.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-10-03 03:00:57 +0000
committerNorbert Preining <norbert@preining.info>2019-10-03 03:00:57 +0000
commit93c3758895674cc9ea3e8aaeeb3cf5d1bdc0e3be (patch)
tree5150bfff26491c4e57ddff629e62b4066295a925 /macros/latex/contrib/chemnum/chemnum.sty
parentd94b7a8c132734a1bc4046d54a75c7882c4c2619 (diff)
CTAN sync 201910030300
Diffstat (limited to 'macros/latex/contrib/chemnum/chemnum.sty')
-rw-r--r--macros/latex/contrib/chemnum/chemnum.sty348
1 files changed, 210 insertions, 138 deletions
diff --git a/macros/latex/contrib/chemnum/chemnum.sty b/macros/latex/contrib/chemnum/chemnum.sty
index 659378bf72..b7d1277df4 100644
--- a/macros/latex/contrib/chemnum/chemnum.sty
+++ b/macros/latex/contrib/chemnum/chemnum.sty
@@ -12,7 +12,7 @@
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% --------------------------------------------------------------------------
-% Copyright 2011-2016 Clemens Niederberger
+% Copyright 2011--2019 Clemens Niederberger
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -26,32 +26,41 @@
%
% The Current Maintainer of this work is Clemens Niederberger.
% --------------------------------------------------------------------------
-\def\chemnumdate{2016/04/14}
-\def\chemnumversion{1.2}
-\def\chemnuminfo{a comprehensive approach for the numbering of chemical compounds}
+\RequirePackage{expl3,xparse,l3keys2e}
-\RequirePackage{expl3}[2016/03/28]
-\RequirePackage{xparse,l3keys2e}
+\ExplSyntaxOn
+\tl_const:Nn \c_chemnum_date_tl {2019/10/02}
+\tl_const:Nn \c_chemnum_version_number_tl {1.2}
+\tl_const:Nn \c_chemnum_version_suffix_tl {c}
+\tl_const:Nx \c_chemnum_version_tl
+ { \c_chemnum_version_number_tl \c_chemnum_version_suffix_tl }
+\tl_const:Nn \c_chemnum_info_tl
+ {a~ comprehensive~ approach~ for~ the~ numbering~ of~ chemical~ compounds}
% ----------------------------------------------------------------------------
% provide the package:
-\ProvidesExplPackage{chemnum}
- {\chemnumdate}
- {\chemnumversion}
- {\chemnuminfo\space (CN)}
+\ProvidesExplPackage
+ {chemnum}
+ {\c_chemnum_date_tl}
+ {\c_chemnum_version_tl}
+ {\c_chemnum_info_tl \c_space_tl (CN)}
% ----------------------------------------------------------------------------
% required packages:
% language support:
-\RequirePackage{translations}[2015/11/07]
+\RequirePackage{translations}
+
% greek alphabet for the labels matching to chemmacros' selection:
-\RequirePackage{chemgreek}[2016/02/10]
+\RequirePackage{chemgreek}
\RequirePackage{psfrag}
% ----------------------------------------------------------------------------
% messages:
\msg_new:nnn {chemnum} {missing-label}
- { The~ key~ `#1'~ has~ no~ label~ associated~ \msg_line_context: }
+ {
+ The~ key~ `#1' \tl_if_blank:nF {#2} {~ of~`#2'} ~ has~ no~ label~
+ associated~ \msg_line_context:
+ }
\msg_new:nnn {chemnum} {erroneous-argument-combination}
{
@@ -210,6 +219,8 @@
\int_new:N \l__chemnum_tmpb_int
\int_new:N \l__chemnum_tmpc_int
+\str_new:N \l__chemnum_tmpa_str
+
% ----------------------------------------------------------------------------
% variables:
\prop_new:N \l__chemnum_label_formats_prop
@@ -227,6 +238,7 @@
\seq_new:N \g__chemnum_defined_compounds_seq
\seq_new:N \g__chemnum_compound_defined_subcompounds_seq
+\tl_const:Nn \c_chemnum_nothing_here_tl {??}
\tl_new:N \l__chemnum_label_format_tl
\tl_set:Nn \l__chemnum_label_format_tl {\bfseries}
\tl_new:N \l__chemnum_local_label_format_tl
@@ -367,13 +379,13 @@
sub-counter-format .groups:n = {compound,general} ,
% label:
pre-label-code .tl_set:N = \l__chemnum_pre_label_default_tl ,
- pre-label-code .groups:n = {compound} ,
+ pre-label-code .groups:n = {compound,general} ,
post-label-code .tl_set:N = \l__chemnum_post_label_default_tl ,
- post-label-code .groups:n = {compound} ,
+ post-label-code .groups:n = {compound,general} ,
pre-main-label-code .tl_set:N = \l__chemnum_pre_main_label_default_tl ,
- pre-main-label-code .groups:n = {compound} ,
+ pre-main-label-code .groups:n = {compound,general} ,
post-main-label-code .tl_set:N = \l__chemnum_post_main_label_default_tl ,
- post-main-label-code .groups:n = {compound} ,
+ post-main-label-code .groups:n = {compound,general} ,
main-sub-sep .tl_set:N = \l__chemnum_compound_separator_tl ,
main-sub-sep .groups:n = {general,list} ,
list-label-sep .tl_set:N = \l__chemnum_main_separator_tl ,
@@ -512,14 +524,15 @@
% if the `chemnum' package is removed from the preamble
\AtBeginDocument
{
- \if@filesw
- \iow_now:Nn \@auxout
- {
- \providecommand\chemnum@cmpd[8]{} ^^J
- \providecommand\chemnum@subcmpd[4]{} ^^J
- \providecommand\chemnum@check{}
- }
- \fi
+ \legacy_if:nT {@filesw}
+ {
+ \iow_now:Nn \@auxout
+ {
+ \providecommand\chemnum@cmpd[8]{} ^^J
+ \providecommand\chemnum@subcmpd[4]{} ^^J
+ \providecommand\chemnum@check{}
+ }
+ }
}
% we use this one to trigger a LaTeX rerun warning -- to be precise the
@@ -528,7 +541,11 @@
{ \AtEndDocument { \def \chemnum@check { \@tempswatrue } } }
% add the rerun check at the end:
-\AtEndDocument { \if@filesw \iow_now:Nn \@auxout { \chemnum@check } \fi }
+\AtEndDocument
+ {
+ \legacy_if:nT {@filesw}
+ { \iow_now:Nn \@auxout { \chemnum@check } }
+ }
% ----------------------------------------------------------------------------
% initiating new compounds
@@ -624,8 +641,8 @@
\int_gincr:N \g__chemnum_main_int
\stepcounter{cmpdmain}
}
- \seq_if_exist:cF { g__chemnum_#1_initiated_subcompounds_seq }
- { \seq_new:c { g__chemnum_#1_initiated_subcompounds_seq } }
+ \seq_if_exist:cF {g__chemnum_#1_initiated_subcompounds_seq}
+ { \seq_new:c {g__chemnum_#1_initiated_subcompounds_seq} }
}
% #1: main ID
@@ -643,11 +660,11 @@
\chemnum_subcompound_set_property:nnnn {#1} {#2} {ID} {#2}
\chemnum_subcompound_set_property:nnnn {#1} {#2} {main-compound} {#1}
\chemnum_subcompound_set_property:nnnx {#1} {#2} {number}
- { \int_use:c { g__chemnum_compound_#1_subcompound_int } }
+ { \int_use:c {g__chemnum_compound_#1_subcompound_int} }
\chemnum_subcompound_set_property:nnnx {#1} {#2} {counter-representation}
{
\__chemnum_label_format:cV
- { g__chemnum_compound_#1_subcompound_int }
+ {g__chemnum_compound_#1_subcompound_int}
\l__chemnum_default_subcounter_representation_tl
}
}
@@ -661,26 +678,41 @@
\cs_new_protected:Npn \chemnum_initialize_subcompound:nn #1#2
{
- \int_if_exist:cF { g__chemnum_compound_#1_subcompound_int }
- { \int_new:c { g__chemnum_compound_#1_subcompound_int } }
- \int_gincr:c { g__chemnum_compound_#1_subcompound_int }
- \seq_if_exist:cF { g__chemnum_compound_#1_subcompounds_seq }
- { \seq_new:c { g__chemnum_compound_#1_subcompounds_seq } }
- \prop_if_exist:cF { g__chemnum_compound_#1_subcompounds_prop }
- { \prop_new:c { g__chemnum_compound_#1_subcompounds_prop } }
- \seq_if_in:cnF { g__chemnum_compound_#1_subcompounds_seq } {#2}
- { \seq_gput_right:cn { g__chemnum_compound_#1_subcompounds_seq } {#2} }
+ \int_if_exist:cF {g__chemnum_compound_#1_subcompound_int}
+ { \int_new:c {g__chemnum_compound_#1_subcompound_int} }
+ \int_gincr:c {g__chemnum_compound_#1_subcompound_int}
+ \seq_if_exist:cF {g__chemnum_compound_#1_subcompounds_seq}
+ { \seq_new:c {g__chemnum_compound_#1_subcompounds_seq} }
+ \prop_if_exist:cF {g__chemnum_compound_#1_subcompounds_prop}
+ { \prop_new:c {g__chemnum_compound_#1_subcompounds_prop} }
+ \seq_if_in:cnF {g__chemnum_compound_#1_subcompounds_seq} {#2}
+ { \seq_gput_right:cn {g__chemnum_compound_#1_subcompounds_seq} {#2} }
\seq_gput_right:Nn \g__chemnum_compound_defined_subcompounds_seq {#1#2}
- \prop_gput:cnx { g__chemnum_compound_#1_subcompounds_prop } {#2}
+ \prop_gput:cnx {g__chemnum_compound_#1_subcompounds_prop} {#2}
{
- \int_use:c { g__chemnum_compound_#1_subcompound_int } :
+ \int_use:c {g__chemnum_compound_#1_subcompound_int} :
\__chemnum_label_format:cV
- { g__chemnum_compound_#1_subcompound_int }
+ {g__chemnum_compound_#1_subcompound_int}
\l__chemnum_default_subcounter_representation_tl
}
}
% ----------------------------------------------------------------------------
+
+\cs_new:Npn \__chemnum_nothing_here:n #1
+ {
+ \c_chemnum_nothing_here_tl
+ \msg_warning:nnn {chemnum} {missing-label} {#1}
+ }
+
+\cs_new:Npn \__chemnum_nothing_here:nn #1#2
+ {
+ \c_chemnum_nothing_here_tl
+ \msg_warning:nnnn {chemnum} {missing-label} {#1} {#2}
+ }
+\cs_generate_variant:Nn \__chemnum_nothing_here:nn {x}
+
+% ----------------------------------------------------------------------------
\cs_new_protected:Npn \chemnum_log_main:n #1
{
\bool_if:NT \l__chemnum_log_bool
@@ -716,7 +748,7 @@
\prg_new_protected_conditional:Npnn \chemnum_subcompound_if_initiated:nn #1#2
{ T,F,TF }
{
- \seq_if_in:cnTF { g__chemnum_#1_initiated_subcompounds_seq } {#2}
+ \seq_if_in:cnTF {g__chemnum_#1_initiated_subcompounds_seq} {#2}
{ \prg_return_true: }
{ \prg_return_false: }
}
@@ -745,12 +777,12 @@
% #2: property to be defined
\cs_new_protected:Npn \chemnum_compound_declare_property:nn #1#2
{
- \seq_if_exist:cF { g__chemnum_compound_#1_properties_seq }
- { \seq_new:c { g__chemnum_compound_#1_properties_seq } }
- \prop_if_exist:cF { g__chemnum_compound_#1_prop }
- { \prop_new:c { g__chemnum_compound_#1_prop } }
- \seq_if_in:cnF { g__chemnum_compound_#1_properties_seq } {#2}
- { \seq_gput_right:cn { g__chemnum_compound_#1_properties_seq } {#2} }
+ \seq_if_exist:cF {g__chemnum_compound_#1_properties_seq }
+ { \seq_new:c {g__chemnum_compound_#1_properties_seq} }
+ \prop_if_exist:cF {g__chemnum_compound_#1_prop}
+ { \prop_new:c {g__chemnum_compound_#1_prop} }
+ \seq_if_in:cnF {g__chemnum_compound_#1_properties_seq} {#2}
+ { \seq_gput_right:cn {g__chemnum_compound_#1_properties_seq} {#2} }
}
% #1: ID
@@ -766,8 +798,8 @@
% #3: value of property
\cs_new_protected:Npn \chemnum_compound_set_property:nnn #1#2#3
{
- \seq_if_in:cnTF { g__chemnum_compound_#1_properties_seq } {#2}
- { \prop_gput:cnn { g__chemnum_compound_#1_prop } {#2} {#3} }
+ \seq_if_in:cnTF {g__chemnum_compound_#1_properties_seq} {#2}
+ { \prop_gput:cnn {g__chemnum_compound_#1_prop} {#2} {#3} }
{ \msg_error:nnn {chemnum} {property-undefined} {#1} {#2} }
}
\cs_generate_variant:Nn \chemnum_compound_set_property:nnn { nnV , nnx }
@@ -776,15 +808,15 @@
% #2: property to be updated
\cs_new_protected:Npn \chemnum_compound_update_property:nn #1#2
{
- \seq_if_in:cnTF { g__chemnum_compound_#1_properties_seq } {#2}
+ \seq_if_in:cnTF {g__chemnum_compound_#1_properties_seq} {#2}
{
- \prop_get:cnN { g__chemnum_compound_#1_prop } {previous-#2}
+ \prop_get:cnN {g__chemnum_compound_#1_prop} {previous-#2}
\l__chemnum_tmpa_tl
- \prop_get:cnN { g__chemnum_compound_#1_prop } {#2}
+ \prop_get:cnN {g__chemnum_compound_#1_prop} {#2}
\l__chemnum_tmpb_tl
\tl_if_eq:NNF \l__chemnum_tmpb_tl \l__chemnum_tmpa_tl
{
- \prop_gput:cnV { g__chemnum_compound_#1_prop }
+ \prop_gput:cnV {g__chemnum_compound_#1_prop}
{previous-#2}
\l__chemnum_tmpb_tl
}
@@ -795,7 +827,7 @@
% #1: ID
\cs_new_protected:Npn \chemnum_compound_update_properties:n #1
{
- \seq_map_inline:cn { g__chemnum_compound_#1_properties_seq }
+ \seq_map_inline:cn {g__chemnum_compound_#1_properties_seq}
{ \chemnum_compound_update_property:nn {#1} {##1} }
}
@@ -804,8 +836,8 @@
% #3: property to be defined
\cs_new_protected:Npn \chemnum_subcompound_declare_property:nnn #1#2#3
{
- \seq_if_in:cnF { g__chemnum_compound_#1_#2_properties_seq } {#3}
- { \seq_gput_right:cn { g__chemnum_compound_#1_#2_properties_seq } {#3} }
+ \seq_if_in:cnF {g__chemnum_compound_#1_#2_properties_seq} {#3}
+ { \seq_gput_right:cn {g__chemnum_compound_#1_#2_properties_seq} {#3} }
}
% #1: main ID
@@ -813,11 +845,11 @@
% #3: properties to be defined
\cs_new_protected:Npn \chemnum_subcompound_declare_properties:nnn #1#2#3
{
- \seq_if_exist:cF { g__chemnum_compound_#1_#2_properties_seq }
- { \seq_new:c { g__chemnum_compound_#1_#2_properties_seq } }
- \prop_if_exist:cF { g__chemnum_compound_#1_#2_properties_prop }
- { \prop_new:c { g__chemnum_compound_#1_#2_properties_prop } }
- \clist_map_inline:nn { #3 }
+ \seq_if_exist:cF {g__chemnum_compound_#1_#2_properties_seq}
+ { \seq_new:c {g__chemnum_compound_#1_#2_properties_seq} }
+ \prop_if_exist:cF {g__chemnum_compound_#1_#2_properties_prop}
+ { \prop_new:c {g__chemnum_compound_#1_#2_properties_prop} }
+ \clist_map_inline:nn {#3}
{ \chemnum_subcompound_declare_property:nnn {#1} {#2} {##1} }
}
@@ -827,8 +859,8 @@
% #4: value of property
\cs_new_protected:Npn \chemnum_subcompound_set_property:nnnn #1#2#3#4
{
- \seq_if_in:cnTF { g__chemnum_compound_#1_#2_properties_seq } {#3}
- { \prop_gput:cnn { g__chemnum_compound_#1_#2_properties_prop } {#3} {#4} }
+ \seq_if_in:cnTF {g__chemnum_compound_#1_#2_properties_seq} {#3}
+ { \prop_gput:cnn {g__chemnum_compound_#1_#2_properties_prop} {#3} {#4} }
{ \msg_error:nnn {chemnum} {property-undefined} {#1.#2} {#3} }
}
\cs_generate_variant:Nn \chemnum_subcompound_set_property:nnnn { nnnV , nnnx }
@@ -838,15 +870,15 @@
% #3: property to be updated
\cs_new_protected:Npn \chemnum_subcompound_update_property:nnn #1#2#3
{
- \seq_if_in:cnTF { g__chemnum_compound_#1_#2_properties_seq }
+ \seq_if_in:cnTF {g__chemnum_compound_#1_#2_properties_seq}
{
- \prop_get:cnN { g__chemnum_compound_#1_#2_properties_prop } {previous-#3}
+ \prop_get:cnN {g__chemnum_compound_#1_#2_properties_prop} {previous-#3}
\l__chemnum_tmpa_tl
- \prop_get:cnN { g__chemnum_compound_#1_#2_properties_prop } {#3}
+ \prop_get:cnN {g__chemnum_compound_#1_#2_properties_prop} {#3}
\l__chemnum_tmpb_tl
\tl_if_eq:NNF \l__chemnum_tmpb_tl \l__chemnum_tmpa_tl
{
- \prop_gput:cnV { g__chemnum_compound_#1_#2_properties_prop }
+ \prop_gput:cnV {g__chemnum_compound_#1_#2_properties_prop}
{previous-#3}
\l__chemnum_tmpb_tl
}
@@ -858,7 +890,7 @@
% #2: sub ID
\cs_new_protected:Npn \chemnum_subcompound_update_properties:nn #1#2
{
- \seq_map_inline:cn { g__chemnum_compound_#1_#2_properties_seq }
+ \seq_map_inline:cn {g__chemnum_compound_#1_#2_properties_seq}
{ \chemnum_subcompound_update_property:nnn {#1} {#2} {##1} }
}
@@ -869,14 +901,14 @@
\cs_new_protected:Npn \chemnum_get_compound_property_or:nnn #1#2#3
{
- \prop_get:cnNTF { g__chemnum_compound_#1_prop } {#2}
+ \prop_get:cnNTF {g__chemnum_compound_#1_prop} {#2}
\l__chemnum_tmpa_tl
{ \tl_use:N \l__chemnum_tmpa_tl }
{#3}
}
\cs_new:Npn \chemnum_expandable_get_compound_property:nn #1#2
- { \prop_item:cn { g__chemnum_compound_#1_prop } {#2} }
+ { \prop_item:cn {g__chemnum_compound_#1_prop} {#2} }
\cs_generate_variant:Nn \chemnum_expandable_get_compound_property:nn { V }
% #1: main ID
@@ -887,14 +919,14 @@
\cs_new_protected:Npn \chemnum_get_subcompound_property_or:nnnn #1#2#3#4
{
- \prop_get:cnNTF { g__chemnum_compound_#1_#2_properties_prop } {#3}
+ \prop_get:cnNTF {g__chemnum_compound_#1_#2_properties_prop} {#3}
\l__chemnum_tmpa_tl
{ \tl_use:N \l__chemnum_tmpa_tl }
{#4}
}
\cs_new:Npn \chemnum_expandable_get_subcompound_property:nnn #1#2#3
- { \prop_item:cn { g__chemnum_compound_#1_#2_properties_prop } {#3} }
+ { \prop_item:cn {g__chemnum_compound_#1_#2_properties_prop} {#3} }
% ----------------------------------------------------------------------------
\DeclareExpandableDocumentCommand \cmpdproperty { mm }
@@ -911,7 +943,7 @@
\cs_new_protected:Npn \chemnum_initiate_subcompound:nn #1#2
{
\chemnum_subcompound_if_initiated:nnF {#1} {#2}
- { \seq_gput_right:cn { g__chemnum_#1_initiated_subcompounds_seq } {#2} }
+ { \seq_gput_right:cn {g__chemnum_#1_initiated_subcompounds_seq} {#2} }
}
% ----------------------------------------------------------------------------
@@ -927,13 +959,11 @@
% #8: label format
\cs_new_protected:Npn \__chemnum_write_compound_to_auxfile_x:nnnnnnnn #1#2#3#4#5#6#7#8
{
- \if@filesw
- \token_if_eq_meaning:NNT \@nodocument \relax
- {
- \iow_now:Nx \@auxout
- { \exp_not:N \chemnum@cmpd {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8} }
- }
- \fi
+ \legacy_if:nT {@filesw}
+ {
+ \iow_now:Nx \@auxout
+ { \exp_not:N \chemnum@cmpd {#1}{#2}{#3}{#4}{#5}{#6}{#7}{#8} }
+ }
}
\cs_generate_variant:Nn \__chemnum_write_compound_to_auxfile_x:nnnnnnnn { nnnVVVVV }
@@ -955,13 +985,11 @@
% #3: counter representation
\cs_new_protected:Npn \__chemnum_write_subcompound_to_auxfile_x:nnnn #1#2#3#4
{
- \if@filesw
- \token_if_eq_meaning:NNT \@nodocument \relax
- {
- \iow_now:Nx \@auxout
- { \exp_not:N \chemnum@subcmpd {#1}{#2}{#3}{#4} }
- }
- \fi
+ \legacy_if:nT {@filesw}
+ {
+ \iow_now:Nx \@auxout
+ { \exp_not:N \chemnum@subcmpd {#1}{#2}{#3}{#4} }
+ }
}
\cs_new_protected:Npn \chemnum_save_subcompound_to_auxfile:nn #1#2
@@ -989,21 +1017,21 @@
\cs_new_protected:Npn \chemnum@cmpd #1#2#3#4#5#6#7#8
{
% \chemnum_initialize_compound:n {#1}
- \prop_if_exist:cF { g__chemnum_compound_#1_prop }
- { \prop_new:c { g__chemnum_compound_#1_prop } }
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_if_exist:cF {g__chemnum_compound_#1_prop}
+ { \prop_new:c {g__chemnum_compound_#1_prop} }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-number} {#2}
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-counter-representation} {#3}
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-pre-label-code} {#4}
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-post-label-code} {#5}
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-pre-main-label-code} {#6}
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-post-main-label-code} {#7}
- \prop_gput:cnn { g__chemnum_compound_#1_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_prop}
{previous-label-format} {#8}
}
@@ -1013,15 +1041,15 @@
% #4: counter representation
\cs_new_protected:Npn \chemnum@subcmpd #1#2#3#4
{
- \prop_if_exist:cF { g__chemnum_compound_#1_#2_properties_prop }
- { \prop_new:c { g__chemnum_compound_#1_#2_properties_prop } }
- \seq_if_exist:cF { g__chemnum_compound_#1_subcompounds_seq }
- { \seq_new:c { g__chemnum_compound_#1_subcompounds_seq } }
- \seq_if_in:cnF { g__chemnum_compound_#1_subcompounds_seq } {#2}
- { \seq_gput_right:cn { g__chemnum_compound_#1_subcompounds_seq } {#2} }
- \prop_gput:cnn { g__chemnum_compound_#1_#2_properties_prop }
+ \prop_if_exist:cF {g__chemnum_compound_#1_#2_properties_prop}
+ { \prop_new:c {g__chemnum_compound_#1_#2_properties_prop} }
+ \seq_if_exist:cF {g__chemnum_compound_#1_subcompounds_seq}
+ { \seq_new:c {g__chemnum_compound_#1_subcompounds_seq} }
+ \seq_if_in:cnF {g__chemnum_compound_#1_subcompounds_seq} {#2}
+ { \seq_gput_right:cn {g__chemnum_compound_#1_subcompounds_seq} {#2} }
+ \prop_gput:cnn {g__chemnum_compound_#1_#2_properties_prop}
{previous-number} {#3}
- \prop_gput:cnn { g__chemnum_compound_#1_#2_properties_prop }
+ \prop_gput:cnn {g__chemnum_compound_#1_#2_properties_prop}
{previous-counter-representation} {#4}
}
@@ -1060,7 +1088,6 @@
% #3: sub ID
\cs_new_protected:Npn \chemnum_declare_subcompound:nnn #1#2#3
{
- % \keys_set:nn {chemnum} {#1}
\chemnum_subcompound_if_initiated:nnF {#2} {#3}
{
\bool_if:NT \g__chemnum_initiate_sub_bool
@@ -1170,8 +1197,11 @@
\chemnum_get_compound_property:nn {#1} {previous-label-format}
{
\chemnum_get_compound_property_or:nnn {#1}
- { previous-counter-representation }
- { ?? \__chemnum_rerun: }
+ {previous-counter-representation}
+ {
+ \__chemnum_nothing_here:n {#1}
+ \__chemnum_rerun:
+ }
}
\group_end:
\chemnum_get_compound_property:nn {#1} {previous-post-main-label-code}
@@ -1189,7 +1219,10 @@
{
\chemnum_get_subcompound_property_or:nnnn {#1} {#2}
{previous-counter-representation}
- { ?? \__chemnum_rerun: }
+ {
+ \__chemnum_nothing_here:nn {#2} {#1}
+ \__chemnum_rerun:
+ }
}
\group_end:
}
@@ -1265,7 +1298,7 @@
{
\tl_clear:N \l__chemnum_tmpa_tl
\tl_set:Nx \l__chemnum_tmpa_tl
- { \seq_use:cn { g__chemnum_compound_##4_subcompounds_seq } { , } }
+ { \seq_use:cn {g__chemnum_compound_##4_subcompounds_seq} {,} }
\tl_if_blank:VF \l__chemnum_tmpa_tl
{
\chemnum_write_sublist:NNnnV ##1 ##2 {##3} {##4}
@@ -1294,8 +1327,8 @@
{
\bool_if:NTF #2
{
- \chemnum_hyper_link:nn {#4}
- { \chemnum_compound_read:n {#4} }
+ \bool_if:NF \l__chemnum_sub_only_bool
+ { \chemnum_hyper_link:nn {#4} { \chemnum_compound_read:n {#4} } }
\bool_if:NT #1
{ \msg_error:nn {chemnum} {erroneous-argument-combination} }
}
@@ -1353,10 +1386,18 @@
}
% ----------------------------------------------------------------------------
-\cs_set_protected:Npn \chemnum_show_key_def:n #1
- { \marginpar { \fbox { \normalfont \ttfamily #1 } } }
+\cs_new_protected:Npn \chemnum_print_label_id:n #1
+ {
+ \group_begin:
+ \str_set:Nn \l__chemnum_tmpa_str {#1}
+ \str_use:N \l__chemnum_tmpa_str
+ \group_end:
+ }
+
+\cs_new_protected:Npn \chemnum_show_label_margin:n #1
+ { \marginpar { \fbox {#1} } }
-\cs_set_protected:Npn \chemnum_show_key_ref:n #1
+\cs_new_protected:Npn \chemnum_show_label_inline:n #1
{
\group_begin:
\hbox_unpack:N \c_empty_box % this is \leavevmode
@@ -1366,18 +1407,38 @@
\hbox_overlap_right:n
{
\tex_vrule:D \tex_raise:D .75em
- \hbox:n
- { \underbar { \normalfont \footnotesize \ttfamily #1 } }
+ \hbox:n { \underbar {#1} }
}
}
\group_end:
}
-% ----------------------------------------------------------------------------
+\NewDocumentCommand \cmpdprintlabelid {m}
+ { \chemnum_print_label_id:n {#1} }
+
+\NewDocumentCommand \cmpdshowlabelmargin {m}
+ { \chemnum_show_label_margin:n {#1} }
+
+\NewDocumentCommand \cmpdshowlabelinline {m}
+ { \chemnum_show_label_inline:n {#1} }
+
\NewDocumentCommand \chemnumshowdef {m}
- { \chemnum_show_key_def:n {#1} }
+ {
+ \cmpdshowlabelmargin
+ {
+ \normalfont \ttfamily
+ \cmpdprintlabelid {#1}
+ }
+ }
+
\NewDocumentCommand \chemnumshowref {m}
- { \chemnum_show_key_ref:n {#1} }
+ {
+ \cmpdshowlabelinline
+ {
+ \normalfont \ttfamily \footnotesize
+ \cmpdprintlabelid {#1}
+ }
+ }
\NewDocumentCommand \cmpdshowdef {m} { \chemnumshowdef {#1} }
\NewDocumentCommand \cmpdshowref {m} { \chemnumshowref {#1} }
@@ -1396,7 +1457,7 @@
\l__chemnum_tmpc_seq
\l__chemnum_sub_separator_tl
{#5}
- \seq_remove_duplicates:N \l__chemnum_tmpc_seq
+ \seq_remove_duplicates:N \l__chemnum_tmpc_seq
\seq_map_inline:Nn \l__chemnum_tmpc_seq
{
\bool_if:NF #2
@@ -1467,29 +1528,34 @@
\seq_clear:N #7
\bool_if:NF #1
{
- \seq_map_inline:cn { g__chemnum_compound_#5_subcompounds_seq }
+ \seq_if_exist:cTF {g__chemnum_compound_#5_subcompounds_seq}
{
- \seq_if_in:NnT #3 {##1}
+ \seq_map_inline:Nn #3
{
- \seq_put_right:Nn #6
- { \chemnum_write_subcompound:NNnnn #1 #2 {#4} {#5} {##1} }
- \bool_if:NTF #2
+ \seq_if_in:cnTF {g__chemnum_compound_#5_subcompounds_seq} {##1}
{
- \seq_put_right:Nx #7
+ \seq_put_right:Nn #6
+ { \chemnum_write_subcompound:NNnnn #1 #2 {#4} {#5} {##1} }
+ \bool_if:NTF #2
{
- \chemnum_expandable_get_subcompound_property:nnn
- {#5} {##1} {previous-number}
+ \seq_put_right:Nx #7
+ {
+ \chemnum_expandable_get_subcompound_property:nnn
+ {#5} {##1} {previous-number}
+ }
}
- }
- {
- \seq_put_right:Nx #7
{
- \chemnum_expandable_get_subcompound_property:nnn
- {#5} {##1} {number}
+ \seq_put_right:Nx #7
+ {
+ \chemnum_expandable_get_subcompound_property:nnn
+ {#5} {##1} {number}
+ }
}
}
+ { \__chemnum_nothing_here:nn {##1} {#5} }
}
}
+ { \__chemnum_nothing_here:xn { \seq_use:Nnnn #3 {,~} {,~} {,~} } {#5} }
}
}
@@ -1917,8 +1983,8 @@
}
\NewDocumentCommand \initcmpd {O{}m}
- { \chemnum_init:nn {#1} {#2} }
-\@onlypreamble\cmpdinit
+ { \AtBeginDocument { \chemnum_init:nn {#1} {#2} } }
+\@onlypreamble\initcmpd
% ----------------------------------------------------------------------------
% resetting compound numbering
@@ -2008,4 +2074,10 @@ HISTORY:
\prop_item:Nn)
2016/04/14 v1.2 - changes to how compounds are saved to auxfile
- hyperref support: backlinks to first appearance of label
-
+2016/05/11 v1.2a - pre- and post-label options now belong both to the
+ `compound' and the `general' groups
+2016/10/22 v1.2b - enable label keys to be printed (with `show-keys') if they
+ contain underscores or similar tokens
+ - easier customization possibilities of the `show-keys'
+ functions
+2019/10/02 v1.2c - fix issues #5, #7