%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % - chemnum - chemnum.sty - % % - a comprehensive numbering method for chemical compounds - % % --------------------------------------------------------------------------- % % - Clemens NIEDERBERGER - % % - 2011/09/03 - % % --------------------------------------------------------------------------- % % - http://www.mychemistry.eu/ - % % - contact@mychemistry.eu - % % --------------------------------------------------------------------------- % % - If you have any ideas, questions, suggestions or bugs to report, please - % % - feel free to contact me. - % % --------------------------------------------------------------------------- % % - Copyright 2011 Clemens Niederberger - % % - - % % - This work may be distributed and/or modified under the - % % - conditions of the LaTeX Project Public License, either version 1.3 - % % - of this license or (at your option) any later version. - % % - The latest version of this license is in - % % - http://www.latex-project.org/lppl.txt - % % - and version 1.3 or later is part of all distributions of LaTeX - % % - version 2005/12/01 or later. - % % - - % % - This work has the LPPL maintenance status `maintained'. - % % - - % % - The Current Maintainer of this work is Clemens Niederberger. - % % - - % % - This work consists of the files chemnum.sty, chemnum_doc_de.tex, - % % - chemnum_doc_en.tex, bsp.tex, scheme-tmp.eps, scheme-bla.eps README and - % % - the derived files chemnum_doc_de.pdf and chemnum_doc_en.pdf - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage { expl3 , xparse , etoolbox , psfrag } \ProvidesExplPackage {chemnum} {2011/09/03} {0.3a} {Numbering chemical compounds} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % CHECK FOR SUPPORT % this part of the code is based on the corresponding part of siunitx.sty % l3 support: \cs_if_exist:NTF \msg_set:nnnn { \msg_set:nnnn { chemnum } { support-outdated } { Support~package~#1~too~old. } { Please~install~an~up~to~date~version~of~#1. \\ Best~would~be~to~update~both~l3kernel~and~l3packages~bundles. \\ Loading~chemnum~will~abort! } } { \PackageError { chemnum } { Support~bundle~l3kernel~too~old. } { Please~install~an~up~to~date~version~of~the~l3kernel~bundle. \\ Loading~chemnum~will~abort! } \tex_endinput:D } \@ifpackagelater { expl3 } { 2011/06/04 } { } { \msg_error:nnx { chemnum } { support-outdated } { expl3 } \tex_endinput:D } \@ifpackagelater { xparse } { 2011/06/04 } { } { \msg_error:nnx { chemnum } { support-outdated } { xparse } \tex_endinput:D } % error for missing packages \msg_set:nnnn { chemnum } { support-missing } { Support~package~#1~missing. } { Support~package~#1~seems~to~be~missing. \\ Please~install~an~up~to~date~version~of~#1. \\ } % warning, if textgreek has already been loaded AND option % "textgreek = " is used \msg_set:nnnn { chemnum } { package-loaded } { Package~#1~already~loaded. } { The~package~#1~has~already~been~loaded. \\ \tl_if_blank:nF { #2 } { Option~#2~will~not~be~used. } } % textgreek support and package options: \bool_new:N \l_chemnum_textgreek_bool \cs_new:Npn \chemnum_load_package:nn #1#2 { \bool_if:cT { l_chemnum_#2_bool } { \AtEndPreamble { \exp_args:No \file_if_exist:nTF { #2 . sty } { \tl_if_blank:nTF { #1 } { \RequirePackage { #2 } } { \@ifpackageloaded { #2 } { \msg_warning:nnxx { chemnum } { package-loaded } { #2 } { #1 } } { \RequirePackage [ #1 ] { #2 } } } } { \msg_warning:nnx { chemnum } { support-missing } { #2 } \bool_set_false:c { l_chemnum_#2_bool } } } } } \cs_new:Npn \chemnum_package_options:n #1 { \keys_set:nn { chemnum / package } { #1 } } \keys_define:nn { chemnum / package } { textgreek .choice: , textgreek .choice_code:n = \chemnum_load_package:nn \l_keys_choice_tl { textgreek } , textgreek .generate_choices:n = { artemisia , cbgreek , euler } , textgreek .default:n = cbgreek } \DeclareOption { textgreek } { \bool_set_true:N \l_chemnum_textgreek_bool \chemnum_package_options:n { textgreek } } \DeclareOption { textgreek = artemisia } { \bool_set_true:N \l_chemnum_textgreek_bool \chemnum_package_options:n { textgreek = artemisia } } \DeclareOption { textgreek = cbgreek } { \bool_set_true:N \l_chemnum_textgreek_bool \chemnum_package_options:n { textgreek = cbgreek } } \DeclareOption { textgreek = euler } { \bool_set_true:N \l_chemnum_textgreek_bool \chemnum_package_options:n { textgreek = euler } } \DeclareOption { textgreek = false } { \bool_set_false:N \l_chemnum_textgreek_bool } \ExecuteOptions { textgreek } \ProcessOptions \scan_stop: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % TOOLS \int_new:N \g_chemnum_cmpd_main_int \prop_new:N \g_chemnum_label_prop \int_new:N \g_chemnum_cmpd_int \tl_new:N \l_chemnum_tmpa_tl \tl_new:N \l_chemnum_tmpb_tl \clist_new:N \g_chemnum_cmpd_save_clist %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % READ FROM PREVIOUS RUN, SAVE FOR NEXT RUN % save all labels in a clist \cs_new:Npn \chemnum_cmpd_save:n #1 { \clist_gput_right:Nn \g_chemnum_cmpd_save_clist { #1 } } \msg_set:nnn { chemnum } { missing-cmpd-file } { The~file~ \c_job_name_tl .cmpd~hasn't~been~available~yet. \\ Please~rerun~to~get~referencing~compound~labels~right. } \file_if_exist:nTF { ./ \c_job_name_tl . cmpd } { \file_input:n { ./ \c_job_name_tl . cmpd } } { \msg_warning:nn { chemnum }{ missing-cmpd-file } } % write ref commands for all labels in .cmpd file to make them % available at the next run \AtEndDocument { \iow_open:Nn \chemnum_aux_file { ./ \c_job_name_tl . cmpd } \clist_map_inline:Nn \g_chemnum_cmpd_save_clist { \iow_now:Nx \chemnum_aux_file { \use:c { cs_new_nopar:cpn } { chemnum_cmpd_ #1 _ref: } { \exp_not:f { \use:c { chemnum_cmpd_ #1 : } } } } \cs_if_exist:cT { chemnum_cmpd_ #1 _min: } { \iow_now:Nx \chemnum_aux_file { \use:c { cs_new_nopar:cpn } { chemnum_cmpd_ #1 _min_ref: } { \exp_not:f { \use:c { chemnum_cmpd_ #1 _min: } } } } } \cs_if_exist:cT { chemnum_cmpd_ #1 _max: } { \iow_now:Nx \chemnum_aux_file { \use:c { cs_new_nopar:cpn } { chemnum_cmpd_ #1 _max_ref: } { \exp_not:f { \use:c { chemnum_cmpd_ #1 _max: } } } } } } \iow_close:N \chemnum_aux_file } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % COMPOUND LABELS % STYLE OF COMPOUND LABEL \tl_new:N \l_chemnum_style_tmp_tl \bool_new:N \l_chemnum_cmpd_style_is_macro_bool % default style \cs_new_nopar:Npn \chemnum_cmpd_style_value:n { \bfseries } % error message \msg_set:nnn { chemnum } { cmpd-style } { The~value~of~"cmpd-style~=~