%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % - chemnum - chemnum.sty % - a comprehensive approach for the numbering of chemical compounds % ----------------------------------------------------------------------------- % - Clemens NIEDERBERGER % - contact@mychemistry.eu % ----------------------------------------------------------------------------- % - If you have any ideas, questions, suggestions or bugs to report, please % - feel free to contact me. % ----------------------------------------------------------------------------- % - Copyright 2011-2013 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_de.tex, chemnum_en.tex, chemnum_it.tex % - scheme-tmp.ps, scheme-bla.ps, % - README % - chemnum_de.pdf, chemnum_en.pdf, chemnum_it.pdf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage { expl3 , xparse , l3keys2e , etoolbox , psfrag } \ProvidesExplPackage {chemnum} {2013/04/17} {0.6a} {a comprehensive 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/12/27 } { } { \msg_error:nnx { chemnum } { support-outdated } { expl3 } \tex_endinput:D } \@ifpackagelater { xparse } { 2011/12/27 } { } { \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_protected: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:Npn \__chemnum_bm:n #1 { \bool_if:NTF \l__chemnum_cmpd_bold_bool { \bm { #1 } } { #1 } } \cs_new:Npn \__chemnum_alpha: { \ensuremath { \__chemnum_bm:n { \mathrm { \alpha } } } } \cs_new:Npn \__chemnum_beta: { \ensuremath { \__chemnum_bm:n { \mathrm { \beta } } } } \cs_new:Npn \__chemnum_gamma: { \ensuremath { \__chemnum_bm:n { \mathrm { \gamma } } } } \cs_new:Npn \__chemnum_delta: { \ensuremath { \__chemnum_bm:n { \mathrm { \delta } } } } \cs_new:Npn \__chemnum_epsilon: { \ensuremath { \__chemnum_bm:n { \mathrm { \varepsilon } } } } \cs_new:Npn \__chemnum_zeta: { \ensuremath { \__chemnum_bm:n { \mathrm { \zeta } } } } \cs_new:Npn \__chemnum_eta: { \ensuremath { \__chemnum_bm:n { \mathrm { \eta } } } } \cs_new:Npn \__chemnum_theta: { \ensuremath { \__chemnum_bm:n { \mathrm { \theta } } } } \cs_new:Npn \__chemnum_iota: { \ensuremath { \__chemnum_bm:n { \mathrm { \iota } } } } \cs_new:Npn \__chemnum_kappa: { \ensuremath { \__chemnum_bm:n { \mathrm { \kappa } } } } \cs_new:Npn \__chemnum_lambda: { \ensuremath { \__chemnum_bm:n { \mathrm { \lampda } } } } \cs_new:Npn \__chemnum_mu: { \ensuremath { \__chemnum_bm:n { \mathrm { \mu } } } } \cs_new:Npn \__chemnum_nu: { \ensuremath { \__chemnum_bm:n { \mathrm { \nu } } } } \cs_new:Npn \__chemnum_xi: { \ensuremath { \__chemnum_bm:n { \mathrm { \xi } } } } \cs_new:Npn \__chemnum_omikron: { \ensuremath { \__chemnum_bm:n { \mathrm { o } } } } \cs_new:Npn \__chemnum_pi: { \ensuremath { \__chemnum_bm:n { \mathrm { \pi } } } } \cs_new:Npn \__chemnum_rho: { \ensuremath { \__chemnum_bm:n { \mathrm { \rho } } } } \cs_new:Npn \__chemnum_sigma: { \ensuremath { \__chemnum_bm:n { \mathrm { \sigma } } } } \cs_new:Npn \__chemnum_tau: { \ensuremath { \__chemnum_bm:n { \mathrm { \tau } } } } \cs_new:Npn \__chemnum_upsilon: { \ensuremath { \__chemnum_bm:n { \mathrm { \upsilon } } } } \cs_new:Npn \__chemnum_phi: { \ensuremath { \__chemnum_bm:n { \mathrm { \varphi } } } } \cs_new:Npn \__chemnum_chi: { \ensuremath { \__chemnum_bm:n { \mathrm { \chi } } } } \cs_new:Npn \__chemnum_psi: { \ensuremath { \__chemnum_bm:n { \mathrm { \psi } } } } \cs_new:Npn \__chemnum_omega: { \ensuremath { \__chemnum_bm:n { \mathrm { \omega } } } } \cs_new:Npn \__chemnum_Alpha: { \ensuremath { \__chemnum_bm:n { \mathrm { A } } } } \cs_new:Npn \__chemnum_Beta: { \ensuremath { \__chemnum_bm:n { \mathrm { B } } } } \cs_new:Npn \__chemnum_Gamma: { \ensuremath { \__chemnum_bm:n { \mathrm { \Gamma } } } } \cs_new:Npn \__chemnum_Delta: { \ensuremath { \__chemnum_bm:n { \mathrm { \Delta } } } } \cs_new:Npn \__chemnum_Epsilon: { \ensuremath { \__chemnum_bm:n { \mathrm { E } } } } \cs_new:Npn \__chemnum_Zeta: { \ensuremath { \__chemnum_bm:n { \mathrm { Z } } } } \cs_new:Npn \__chemnum_Eta: { \ensuremath { \__chemnum_bm:n { \mathrm { H } } } } \cs_new:Npn \__chemnum_Theta: { \ensuremath { \__chemnum_bm:n { \mathrm { \Theta } } } } \cs_new:Npn \__chemnum_Iota: { \ensuremath { \__chemnum_bm:n { \mathrm { I } } } } \cs_new:Npn \__chemnum_Kappa: { \ensuremath { \__chemnum_bm:n { \mathrm { K } } } } \cs_new:Npn \__chemnum_Lambda: { \ensuremath { \__chemnum_bm:n { \mathrm { \Lambda } } } } \cs_new:Npn \__chemnum_Mu: { \ensuremath { \__chemnum_bm:n { \mathrm { M } } } } \cs_new:Npn \__chemnum_Nu: { \ensuremath { \__chemnum_bm:n { \mathrm { N } } } } \cs_new:Npn \__chemnum_Xi: { \ensuremath { \__chemnum_bm:n { \mathrm { \Xi } } } } \cs_new:Npn \__chemnum_Omikron: { \ensuremath { \__chemnum_bm:n { \mathrm { O } } } } \cs_new:Npn \__chemnum_Pi: { \ensuremath { \__chemnum_bm:n { \mathrm { \Pi } } } } \cs_new:Npn \__chemnum_Rho: { \ensuremath { \__chemnum_bm:n { \mathrm { P } } } } \cs_new:Npn \__chemnum_Sigma: { \ensuremath { \__chemnum_bm:n { \mathrm { \Sigma } } } } \cs_new:Npn \__chemnum_Tau: { \ensuremath { \__chemnum_bm:n { \mathrm { T } } } } \cs_new:Npn \__chemnum_Upsilon: { \ensuremath { \__chemnum_bm:n { \mathrm { \Upsilon } } } } \cs_new:Npn \__chemnum_Phi: { \ensuremath { \__chemnum_bm:n { \mathrm { \Phi } } } } \cs_new:Npn \__chemnum_Chi: { \ensuremath { \__chemnum_bm:n { \mathrm { X } } } } \cs_new:Npn \__chemnum_Psi: { \ensuremath { \__chemnum_bm:n { \mathrm { \Psi } } } } \cs_new: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_protected: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_new:N \__chemnum_aux_file: \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: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: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: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:Npn \__chemnum_cmpd_style_value:n { } % error message \msg_set:nnn { chemnum } { cmpd-style } { The~value~of~"cmpd-style~=~