%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % - chemnum - chemnum.sty - % % - a comprehensive approach for the numbering of chemical compounds - % % --------------------------------------------------------------------------- % % - Clemens NIEDERBERGER - % % - 2012/02/26 - % % --------------------------------------------------------------------------- % % - 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-2012 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, chemnum-codehelper.tex, scheme-tmp.eps, - % % - scheme-bla.eps, README and the derived files chemnum_doc_de.pdf and - % % - chemnum_doc_en.pdf - % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage { expl3 , xparse , l3keys2e , etoolbox , psfrag } \ProvidesExplPackage {chemnum} {2012/02/26} {0.4a} {An approach for the numbering of 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/09/17 } { } { \msg_error:nnx { chemnum } { support-outdated } { expl3 } \tex_endinput:D } \@ifpackagelater { xparse } { 2011/09/17 } { } { \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 } { textgreek-loaded } { The~package~textgreek~has~already~been~loaded. \\ \tl_if_blank:nF { #1 } { Option~#1~will~not~be~used. } } { The~package~textgreek~has~already~been~loaded. \\ \tl_if_blank:nF { #1 } { Option~#1~will~not~be~used. } } % textgreek support and package options: \bool_new:N \l_chemnum_textgreek_bool \bool_set_false:N \l_chemnum_textgreek_bool \cs_new_nopar:Npn \chemnum_load_textgreek:n #1 { \AtEndPreamble { \exp_args:No \file_if_exist:nTF { textgreek . sty } { \@ifpackageloaded { textgreek } { \msg_warning:nnx { chemnum } { textgreek-loaded } { #1 } } { \RequirePackage [ #1 ] { textgreek } } \bool_set_true:N \l_chemnum_textgreek_bool } { \msg_warning:nnx { chemnum } { support-missing } { textgreek } \bool_set_false:N \l_chemnum_textgreek_bool } } } \cs_new:Npn \chemnum_package_options:n #1 { \keys_set:nn { chemnum / package } { #1 } } \keys_define:nn { chemnum / package } { textgreek .choice: , textgreek / artemisia .code:n = \chemnum_load_textgreek:n { #1 } , textgreek / cbgreek .code:n = \chemnum_load_textgreek:n { #1 } , textgreek / euler .code:n = \chemnum_load_textgreek:n { #1 } , textgreek / false .code:n = { \bool_set_false:N \l_chemnum_textgreek_bool } , textgreek .default:n = cbgreek } \ProcessKeysOptions { chemnum / package } \AtBeginDocument{ \bool_if:NTF \l_chemnum_textgreek_bool { \cs_new_eq:NN \chemnum_alpha \textalpha \cs_new_eq:NN \chemnum_beta \textbeta \cs_new_eq:NN \chemnum_gamma \textgamma \cs_new_eq:NN \chemnum_delta \textdelta \cs_new_eq:NN \chemnum_epsilon \textepsilon \cs_new_eq:NN \chemnum_zeta \textzeta \cs_new_eq:NN \chemnum_eta \texteta \cs_new_eq:NN \chemnum_theta \texttheta \cs_new_eq:NN \chemnum_iota \textiota \cs_new_eq:NN \chemnum_kappa \textkappa \cs_new_eq:NN \chemnum_lambda \textlambda \cs_new_eq:NN \chemnum_mu \textmugreek \cs_new_eq:NN \chemnum_nu \textnu \cs_new_eq:NN \chemnum_xi \textxi \cs_new_eq:NN \chemnum_omikron \textomikron \cs_new_eq:NN \chemnum_pi \textpi \cs_new_eq:NN \chemnum_rho \textrho \cs_new_eq:NN \chemnum_sigma \textsigma \cs_new_eq:NN \chemnum_tau \texttau \cs_new_eq:NN \chemnum_upsilon \textupsilon \cs_new_eq:NN \chemnum_phi \textphi \cs_new_eq:NN \chemnum_chi \textchi \cs_new_eq:NN \chemnum_psi \textpsi \cs_new_eq:NN \chemnum_omega \textomega \cs_new_eq:NN \chemnum_Alpha \textAlpha \cs_new_eq:NN \chemnum_Beta \textBeta \cs_new_eq:NN \chemnum_Gamma \textGamma \cs_new_eq:NN \chemnum_Delta \textDelta \cs_new_eq:NN \chemnum_Epsilon \textEpsilon \cs_new_eq:NN \chemnum_Zeta \textZeta \cs_new_eq:NN \chemnum_Eta \textEta \cs_new_eq:NN \chemnum_Theta \textTheta \cs_new_eq:NN \chemnum_Iota \textIota \cs_new_eq:NN \chemnum_Kappa \textKappa \cs_new_eq:NN \chemnum_Lambda \textLambda \cs_new_eq:NN \chemnum_Mu \textMugreek \cs_new_eq:NN \chemnum_Nu \textNu \cs_new_eq:NN \chemnum_Xi \textXi \cs_new_eq:NN \chemnum_Omikron \textOmikron \cs_new_eq:NN \chemnum_Pi \textPi \cs_new_eq:NN \chemnum_Rho \textRho \cs_new_eq:NN \chemnum_Sigma \textSigma \cs_new_eq:NN \chemnum_Tau \textTau \cs_new_eq:NN \chemnum_Upsilon \textUpsilon \cs_new_eq:NN \chemnum_Phi \textPhi \cs_new_eq:NN \chemnum_Chi \textChi \cs_new_eq:NN \chemnum_Psi \textPsi \cs_new_eq:NN \chemnum_Omega \textOmega } { \RequirePackage { bm }% abhängig machen von textoption bold \cs_new_nopar:Npn \chemnum_bm:n #1 { \bool_if:NTF \l_chemnum_cmpd_bold_bool { \bm { #1 } } { #1 } } \cs_new_nopar:Npn \chemnum_alpha { \ensuremath { \chemnum_bm:n { \mathrm { \alpha } } } } \cs_new_nopar:Npn \chemnum_beta { \ensuremath { \chemnum_bm:n { \mathrm { \beta } } } } \cs_new_nopar:Npn \chemnum_gamma { \ensuremath { \chemnum_bm:n { \mathrm { \gamma } } } } \cs_new_nopar:Npn \chemnum_delta { \ensuremath { \chemnum_bm:n { \mathrm { \delta } } } } \cs_new_nopar:Npn \chemnum_epsilon { \ensuremath { \chemnum_bm:n { \mathrm { \varepsilon } } } } \cs_new_nopar:Npn \chemnum_zeta { \ensuremath { \chemnum_bm:n { \mathrm { \zeta } } } } \cs_new_nopar:Npn \chemnum_eta { \ensuremath { \chemnum_bm:n { \mathrm { \eta } } } } \cs_new_nopar:Npn \chemnum_theta { \ensuremath { \chemnum_bm:n { \mathrm { \theta } } } } \cs_new_nopar:Npn \chemnum_iota { \ensuremath { \chemnum_bm:n { \mathrm { \iota } } } } \cs_new_nopar:Npn \chemnum_kappa { \ensuremath { \chemnum_bm:n { \mathrm { \kappa } } } } \cs_new_nopar:Npn \chemnum_lambda { \ensuremath { \chemnum_bm:n { \mathrm { \lampda } } } } \cs_new_nopar:Npn \chemnum_mu { \ensuremath { \chemnum_bm:n { \mathrm { \mu } } } } \cs_new_nopar:Npn \chemnum_nu { \ensuremath { \chemnum_bm:n { \mathrm { \nu } } } } \cs_new_nopar:Npn \chemnum_xi { \ensuremath { \chemnum_bm:n { \mathrm { \xi } } } } \cs_new_nopar:Npn \chemnum_omikron { \ensuremath { \chemnum_bm:n { \mathrm { o } } } } \cs_new_nopar:Npn \chemnum_pi { \ensuremath { \chemnum_bm:n { \mathrm { \pi } } } } \cs_new_nopar:Npn \chemnum_rho { \ensuremath { \chemnum_bm:n { \mathrm { \rho } } } } \cs_new_nopar:Npn \chemnum_sigma { \ensuremath { \chemnum_bm:n { \mathrm { \sigma } } } } \cs_new_nopar:Npn \chemnum_tau { \ensuremath { \chemnum_bm:n { \mathrm { \tau } } } } \cs_new_nopar:Npn \chemnum_upsilon { \ensuremath { \chemnum_bm:n { \mathrm { \upsilon } } } } \cs_new_nopar:Npn \chemnum_phi { \ensuremath { \chemnum_bm:n { \mathrm { \varphi } } } } \cs_new_nopar:Npn \chemnum_chi { \ensuremath { \chemnum_bm:n { \mathrm { \chi } } } } \cs_new_nopar:Npn \chemnum_psi { \ensuremath { \chemnum_bm:n { \mathrm { \psi } } } } \cs_new_nopar:Npn \chemnum_omega { \ensuremath { \chemnum_bm:n { \mathrm { \omega } } } } \cs_new_nopar:Npn \chemnum_Alpha { \ensuremath { \chemnum_bm:n { \mathrm { A } } } } \cs_new_nopar:Npn \chemnum_Beta { \ensuremath { \chemnum_bm:n { \mathrm { B } } } } \cs_new_nopar:Npn \chemnum_Gamma { \ensuremath { \chemnum_bm:n { \mathrm { \Gamma } } } } \cs_new_nopar:Npn \chemnum_Delta { \ensuremath { \chemnum_bm:n { \mathrm { \Delta } } } } \cs_new_nopar:Npn \chemnum_Epsilon { \ensuremath { \chemnum_bm:n { \mathrm { E } } } } \cs_new_nopar:Npn \chemnum_Zeta { \ensuremath { \chemnum_bm:n { \mathrm { Z } } } } \cs_new_nopar:Npn \chemnum_Eta { \ensuremath { \chemnum_bm:n { \mathrm { H } } } } \cs_new_nopar:Npn \chemnum_Theta { \ensuremath { \chemnum_bm:n { \mathrm { \Theta } } } } \cs_new_nopar:Npn \chemnum_Iota { \ensuremath { \chemnum_bm:n { \mathrm { I } } } } \cs_new_nopar:Npn \chemnum_Kappa { \ensuremath { \chemnum_bm:n { \mathrm { K } } } } \cs_new_nopar:Npn \chemnum_Lambda { \ensuremath { \chemnum_bm:n { \mathrm { \Lambda } } } } \cs_new_nopar:Npn \chemnum_Mu { \ensuremath { \chemnum_bm:n { \mathrm { M } } } } \cs_new_nopar:Npn \chemnum_Nu { \ensuremath { \chemnum_bm:n { \mathrm { N } } } } \cs_new_nopar:Npn \chemnum_Xi { \ensuremath { \chemnum_bm:n { \mathrm { \Xi } } } } \cs_new_nopar:Npn \chemnum_Omikron { \ensuremath { \chemnum_bm:n { \mathrm { O } } } } \cs_new_nopar:Npn \chemnum_Pi { \ensuremath { \chemnum_bm:n { \mathrm { \Pi } } } } \cs_new_nopar:Npn \chemnum_Rho { \ensuremath { \chemnum_bm:n { \mathrm { P } } } } \cs_new_nopar:Npn \chemnum_Sigma { \ensuremath { \chemnum_bm:n { \mathrm { \Sigma } } } } \cs_new_nopar:Npn \chemnum_Tau { \ensuremath { \chemnum_bm:n { \mathrm { T } } } } \cs_new_nopar:Npn \chemnum_Upsilon { \ensuremath { \chemnum_bm:n { \mathrm { \Upsilon } } } } \cs_new_nopar:Npn \chemnum_Phi { \ensuremath { \chemnum_bm:n { \mathrm { \Phi } } } } \cs_new_nopar:Npn \chemnum_Chi { \ensuremath { \chemnum_bm:n { \mathrm { X } } } } \cs_new_nopar:Npn \chemnum_Psi { \ensuremath { \chemnum_bm:n { \mathrm { \Psi } } } } \cs_new_nopar:Npn \chemnum_Omega { \ensuremath { \chemnum_bm:n { \mathrm { \Omega } } } } } } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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 { } % error message \msg_set:nnn { chemnum } { cmpd-style } { The~value~of~"cmpd-style~=~