From 6fb328049faa528f5ee3bd6aadb19902dccc32e1 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 23 Dec 2020 03:03:16 +0000 Subject: CTAN sync 202012230303 --- macros/latex/contrib/chemformula/README | 8 +- .../contrib/chemformula/chemformula-manual.cls | 61 +++ .../contrib/chemformula/chemformula-manual.pdf | Bin 859314 -> 899303 bytes .../contrib/chemformula/chemformula-manual.tex | 107 ++--- macros/latex/contrib/chemformula/chemformula.sty | 535 +++++++++++---------- 5 files changed, 365 insertions(+), 346 deletions(-) (limited to 'macros/latex/contrib/chemformula') diff --git a/macros/latex/contrib/chemformula/README b/macros/latex/contrib/chemformula/README index d539688182..c25182cc82 100644 --- a/macros/latex/contrib/chemformula/README +++ b/macros/latex/contrib/chemformula/README @@ -1,5 +1,5 @@ -------------------------------------------------------------------------- -the CHEMFORMULA package v4.15j 2020/03/07 +the CHEMFORMULA package v4.16 2020/12/22 typeset chemical compounds and reactions @@ -11,12 +11,12 @@ E-Mail: contact@mychemistry.eu Copyright 2011--2020 Clemens Niederberger This work may be distributed and/or modified under the -conditions of the LaTeX Project Public License, either version 1.3 +conditions of the LaTeX Project Public License, either version 1.3c 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. +and version 1.3c or later is part of all distributions of LaTeX +version 2008/05/04 or later. This work has the LPPL maintenance status `maintained'. diff --git a/macros/latex/contrib/chemformula/chemformula-manual.cls b/macros/latex/contrib/chemformula/chemformula-manual.cls index 1935e5d8b3..e9da59b2c5 100644 --- a/macros/latex/contrib/chemformula/chemformula-manual.cls +++ b/macros/latex/contrib/chemformula/chemformula-manual.cls @@ -239,10 +239,68 @@ \RequirePackage{csquotes,varioref} \defbibheading{bibliography}{\section{References}} +\newpackagename\chemmacros{chemmacros} + +\newidxcmd\manual{\textsf{#1}}[\ (manual)] +\newidxcmd\arrowtype{\code{#1}}[\ (arrow type)] + +\newcommand*\cf@arrow{% + \@ifstar + {\cf@arrow@star} + {\cf@arrow@nostar}% +} +\newrobustcmd*\cf@arrow@star[1]{% + \@ifnextchar[ + {\cf@arrow@star@opt{#1}} + {\cf@arrow@star@opt{#1}[]}% +} +\newrobustcmd*\cf@arrow@nostar[1]{% + \@ifnextchar[ + {\cf@arrow@nostar@opt{#1}} + {\cf@arrow@nostar@opt{#1}[]}% +} +\def\cf@arrow@star@opt#1[#2]{% + \ifblank{#2} + {\item\arrowtype*{#1}} + {\item\arrowtype*{#1}#2}% + \cnltx@checkdefault{\hfill\newline}% +} +\def\cf@arrow@nostar@opt#1[#2]{% + \ifblank{#2} + {\item\arrowtype{#1}} + {\item\arrowtype{#1}#2}% + \cnltx@checkdefault{\hfill\newline}% +} + +\newenvironment{codedesc} + {% + \def\Code##1{\item\code{##1}\hfill\newline}% + \cnltxlist + } + {\endcnltxlist} + +\newenvironment{arrows} + {% + \let\arrow\cf@arrow + \cnltxlist + } + {\endcnltxlist} + +\renewcommand*\AmS{\hologo{AmS}} + +\newcommand*\TikZ{Ti\textit{k}Z} + +\newname\hensel{Martin Hensel} + \RequirePackage[biblatex]{embrac}[2012/06/29] \ChangeEmph{[}[,.02em]{]}[.055em,-.08em] \ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em] +\newenvironment{changes}[1]{% + \subsection*{Version #1 (\csuse{chemformula@ver@#1})} + \itemize\let\change\item +}{\enditemize} + \chemformula@add@version{2012-01-28}{3.0} \chemformula@add@version{2012-01-30}{3.0a} \chemformula@add@version{2012-02-03}{3.0b} @@ -299,5 +357,8 @@ \chemformula@add@version{2019-09-27}{4.15g} \chemformula@add@version{2019-10-13}{4.15h} \chemformula@add@version{2020-02-01}{4.15i} +\chemformula@add@version{2020-03-07}{4.15j} +\chemformula@add@version{2020-03-15}{4.15k} +\chemformula@add@version{2020-12-22}{4.16} \endinput diff --git a/macros/latex/contrib/chemformula/chemformula-manual.pdf b/macros/latex/contrib/chemformula/chemformula-manual.pdf index 6e3c49e1af..6ce31cd5de 100644 Binary files a/macros/latex/contrib/chemformula/chemformula-manual.pdf and b/macros/latex/contrib/chemformula/chemformula-manual.pdf differ diff --git a/macros/latex/contrib/chemformula/chemformula-manual.tex b/macros/latex/contrib/chemformula/chemformula-manual.tex index 6ceb89003d..00b7b2aa89 100644 --- a/macros/latex/contrib/chemformula/chemformula-manual.tex +++ b/macros/latex/contrib/chemformula/chemformula-manual.tex @@ -19,12 +19,12 @@ % Copyright 2011--2020 Clemens Niederberger % % This work may be distributed and/or modified under the -% conditions of the LaTeX Project Public License, either version 1.3 +% conditions of the LaTeX Project Public License, either version 1.3c % 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. +% and version 1.3c or later is part of all distributions of LaTeX +% version 2008/05/04 or later. % % This work has the LPPL maintenance status `maintained'. % @@ -36,21 +36,20 @@ \chemsetup{ greek = newtx , - modules = {redox,reactions,units} , formula = chemformula , chemformula/format = \libertineLF } -\usepackage[accsupp]{acro} +\usepackage{acro} \acsetup{ - long-format = \scshape , - short-format = \scshape + format/long = \scshape , + format/short = \scshape } \DeclareAcronym{iupac}{ short = iupac , long = International Union of Pure and Applied Chemistry , pdfstring = IUPAC , - accsupp = IUPAC + short-acc = IUPAC } \sisetup{ @@ -59,9 +58,6 @@ text-rm=\libertineLF } -\usepackage{filecontents} - -\defbibheading{bibliography}{\section{References}} \addbibresource{\jobname.bib} \begin{filecontents*}{\jobname.bib} @book{iupac:greenbook, @@ -90,61 +86,6 @@ slash-left-kern = .05em } -\newpackagename\chemmacros{chemmacros} - -\newidxcmd\manual{\textsf{#1}}[\ (manual)] -\newidxcmd\arrowtype{\code{#1}}[\ (arrow type)] - -\makeatletter -\newcommand*\cf@arrow{% - \@ifstar - {\cf@arrow@star} - {\cf@arrow@nostar}% -} -\newrobustcmd*\cf@arrow@star[1]{% - \@ifnextchar[ - {\cf@arrow@star@opt{#1}} - {\cf@arrow@star@opt{#1}[]}% -} -\newrobustcmd*\cf@arrow@nostar[1]{% - \@ifnextchar[ - {\cf@arrow@nostar@opt{#1}} - {\cf@arrow@nostar@opt{#1}[]}% -} -\def\cf@arrow@star@opt#1[#2]{% - \ifblank{#2} - {\item\arrowtype*{#1}} - {\item\arrowtype*{#1}#2}% - \cnltx@checkdefault{\hfill\newline}% -} -\def\cf@arrow@nostar@opt#1[#2]{% - \ifblank{#2} - {\item\arrowtype{#1}} - {\item\arrowtype{#1}#2}% - \cnltx@checkdefault{\hfill\newline}% -} - -\newenvironment{codedesc} - {% - \def\Code##1{\item\code{##1}\hfill\newline}% - \cnltxlist - } - {\endcnltxlist} - -\newenvironment{arrows} - {% - \let\arrow\cf@arrow - \cnltxlist - } - {\endcnltxlist} -\makeatother - -\renewcommand*\AmS{\hologo{AmS}} - -\newcommand*\TikZ{Ti\textit{k}Z} - -\newname\hensel{Martin Hensel} - \begin{document} \section{Introduction} @@ -612,9 +553,13 @@ The usage is best described with an example. So let's see how the } \NewChemBondAlias{co>}{coordright} \end{sourcecode} -Two points are important: the names of the starting and the ending -coordinates, \code{chemformula-bond-start} and \code{chemformula-bond-end}, -and the \TikZ\ style of the bonds \code{chembond}. + +Two points are important: +\begin{itemize} + \item the names of the starting and the ending coordinates, \\ + \code{chemformula-bond-start} and \code{chemformula-bond-end}, + \item and the \TikZ\ style of the bonds \code{chembond}. +\end{itemize} So, let's say you want to define a special kind of dashed bond. You could do this: @@ -645,15 +590,23 @@ It only exists so you can use it to access the bond length as set with These options allow you to customize the ouptut of the compounds: \begin{options} \keyval{subscript-vshift}{dim}\Default{0pt} - Extra vertical shift of the subscripts. + Extra vertical shift of the subscripts. This only works when + \keyis{math-scripts}{false} is in effect. \keychoice{subscript-style}{text,math}\Default{text} Style that is used to typeset the subscripts. \keyval{charge-hshift}{dim}\Default{.25em} Shift of superscripts when following a subscript.\label{desc:charge-hshift} \keyval{charge-vshift}{dim}\Default{0pt} - Extra vertical shift of the superscripts. + Extra vertical shift of the superscripts. This only works when + \keyis{math-scripts}{false} is in effect. \keychoice{charge-style}{text,math}\Default{text} Style that is used to typeset the superscripts. + \keybool{math-scripts}\Default{false} + \sinceversion{4.16}Switches to \TeX's native subscript and superscript + mechanism which might be your option of choice for the sake of + typographical consistency. \emph{This option is experimental. Please + report any problems you experience with this option to \chemformula's + bug tracker.} \keychoice{circled}{formal,\default{all},none}\Default{formal} \sinceversion{4.6}Like \chemmacros' package option but local to \chemformula's \cs{ch}. That is: since \chemmacros' macros use @@ -1516,10 +1469,6 @@ There are a number of options for customizations: \end{options} \appendix -\newenvironment{changes}[2][]{% - \subsection*{Version #2\ifblank{#1}{}{ (#1)}} - \itemize\let\change\item -}{\enditemize} \section{History Since Version~4.0} @@ -1623,4 +1572,12 @@ There are a number of options for customizations: \change Various bug fixes. \end{changes} +\begin{changes}{4.16} + \change New option \option{math-scripts} + \change Use \LaTeX's new hooks and get rid of redundant package dependencies + and code. +\end{changes} + +\printbibliography + \end{document} diff --git a/macros/latex/contrib/chemformula/chemformula.sty b/macros/latex/contrib/chemformula/chemformula.sty index 1f926e1243..4ba76f16b5 100644 --- a/macros/latex/contrib/chemformula/chemformula.sty +++ b/macros/latex/contrib/chemformula/chemformula.sty @@ -26,13 +26,13 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\RequirePackage{expl3,xparse,l3keys2e,tikz,amsmath,xfrac,nicefrac,scrlfile} +\RequirePackage{tikz,amsmath,xfrac,nicefrac} \usetikzlibrary{arrows.meta} \ExplSyntaxOn -\tl_const:Nn \c_chemformula_date_tl {2020/03/07} -\tl_const:Nn \c_chemformula_version_number_tl {4.15} -\tl_const:Nn \c_chemformula_version_suffix_tl {j} +\tl_const:Nn \c_chemformula_date_tl {2020/12/22} +\tl_const:Nn \c_chemformula_version_number_tl {4.16} +\tl_const:Nn \c_chemformula_version_suffix_tl {} \tl_const:Nx \c_chemformula_version_tl { \c_chemformula_version_number_tl \c_chemformula_version_suffix_tl } \tl_const:Nn \c_chemformula_info_tl @@ -48,24 +48,24 @@ % warning and error messages: \msg_new:nnn {chemformula} {missing-argument} { - Maybe~you've~forgotten~to~add~the~second~argument~to~name~syntax?~ - "!()()".\\ - Or~you~have~forgotten~to~add~a~group~between~an~exclamation~mark~and~ - the~following~parenthesis?~"!~{}()"\\ - Either~way~-~I~don't~know~what~to~do~ \msg_line_context: . + Maybe~ you've~ forgotten~ to~ add~ the~ second~ argument~ to~ the~ name~ + syntax?~ "!()()".\\ + Or~ you~ have~ forgotten~ to~ add~ a~ group~ between~ an~ exclamation~ + mark~ and~ the~ following~ parenthesis?~ "!~{}()"\\ + Either~ way~ --~ I~ don't~ know~ what~ to~ do~ \msg_line_context: . } \msg_new:nnn {chemformula} {new-arrow} { - You've~tried~to~define~the~arrow~type~\tl_to_str:n {#1} \c_space_tl with - ~\token_to_str:N \NewChemArrow \c_space_tl but~it~already~exists. - ~Choose~another~name. + You've~ tried~ to~ define~ the~ arrow~ type~ \tl_to_str:n {#1}~ with~ + \token_to_str:N \NewChemArrow \c_space_tl but~ it~ already~ exists.~ + Choose~ another~ name. } \msg_new:nnn {chemformula} {renew-arrow} { - You've~tried~to~renew~the~arrow~type~\tl_to_str:n {#1} ~but~it~doesn't~ - exist. + You've~ tried~ to~ renew~ the~ arrow~ type~ \tl_to_str:n {#1}~ but~ it~ + doesn't~ exist. } \msg_new:nnn {chemformula} {unknown-arrow} @@ -75,15 +75,15 @@ \msg_new:nnn {chemformula} {new-bond} { - You've~tried~to~define~the~bond~type~\tl_to_str:n {#1} \c_space_tl with - ~\token_to_str:N \NewChemBond \c_space_tl but~it~already~exists. - ~Choose~another~name. + You've~ tried~ to~ define~ the~ bond~ type~ \tl_to_str:n {#1}~ with~ + \token_to_str:N \NewChemBond \c_space_tl but~ it~ already~ exists.~ + Choose~ another~ name. } \msg_new:nnn {chemformula} {renew-bond} { - You've~tried~to~renew~the~bond~type~\tl_to_str:n {#1} ~but~it~doesn't~ - exist. + You've~ tried~ to~ renew~ the~ bond~ type~ \tl_to_str:n {#1}~ but~ it~ + doesn't~ exist. } \msg_new:nnn {chemformula} {new-compound-property} @@ -128,22 +128,6 @@ \NewChemSymbol \c_space_tl but~ a~ symbol~ `#1'~ doesn't~ exist. } -\msg_new:nnn {chemformula} {command-deprecated} - { - The~command~\token_to_str:N #1 \c_space_tl is~deprecated.~Use~ - \token_to_str:N #2 \c_space_tl instead. - } - -\cs_new_protected:Npn \chemformula_define_deprecated:NNn #1#2#3 - { - \cs_new_protected:Npn #1 - { - \msg_warning:nnnn {chemformula} {command-deprecated} - {#1} {#2} - #3 - } - } - % -------------------------------------------------------------------------- % variants of kernel functions: \cs_generate_variant:Nn \keys_set:nn {nV} @@ -152,7 +136,7 @@ \cs_generate_variant:Nn \tl_if_eq:nnT {V,x} \cs_generate_variant:Nn \tl_if_eq:nnTF {o} \cs_generate_variant:Nn \tl_set:Nn {cV} -\cs_generate_variant:Nn \tl_replace_all:Nnn {NV} +\cs_generate_variant:Nn \tl_replace_all:Nnn {NV,Nnx} \cs_generate_variant:Nn \tl_replace_once:Nnn {Nxx} \cs_generate_variant:Nn \tl_set_rescan:Nnn {NnV} \cs_generate_variant:Nn \prop_item:Nn {NV} @@ -164,9 +148,9 @@ % -------------------------------------------------------------------------- % VARIABLES % temporary variables: -\tl_new:N \l__chemformula_tmpa_tl -\tl_new:N \l__chemformula_tmpb_tl -\tl_new:N \l__chemformula_tmpc_tl +\tl_new:N \l__chemformula_tmpa_tl +\tl_new:N \l__chemformula_tmpb_tl +\tl_new:N \l__chemformula_tmpc_tl \dim_new:N \l__chemformula_tmpa_dim \dim_new:N \l__chemformula_tmpb_dim @@ -183,166 +167,127 @@ \bool_new:N \l__chemformula_tmpa_bool -% booleans: -% these are official: -\bool_new:N \l_chemformula_inside_ch_bool -\bool_new:N \l_chemformula_formal_charges_bool -\bool_new:N \l_chemformula_formal_chem_bool -\bool_set_true:N \l_chemformula_formal_chem_bool -% those are private: -\bool_new:N \l__chemformula_options_bool -\bool_new:N \l__chemformula_is_option_bool -\bool_new:N \l__chemformula_stoich_bool -\bool_new:N \l__chemformula_no_stoich_bool -\bool_new:N \l__chemformula_is_addition_symbol_bool -\bool_new:N \l__chemformula_is_symbol_bool -\bool_new:N \l__chemformula_is_arrow_bool -\bool_new:N \l__chemformula_is_name_bool -\bool_new:N \l__chemformula_stoich_is_iupac_bool -\bool_new:N \l__chemformula_stoich_parse_iupac_bool -\bool_new:N \l__chemformula_first_last_text_bool -\bool_new:N \l__chemformula_first_last_double_bool -\bool_new:N \l__chemformula_first_last_single_bool -\bool_new:N \l__chemformula_first_last_math_bool -\bool_new:N \l__chemformula_first_last_dollar_bool -\bool_new:N \l__chemformula_first_last_mathbraces_bool -\bool_new:N \l__chemformula_number_style_math_bool -\bool_new:N \l__chemformula_charge_style_math_bool -\bool_new:N \l__chemformula_is_isotope_bool -\bool_new:N \l__chemformula_xfrac_bool -\bool_new:N \l__chemformula_nicefrac_bool -\bool_new:N \l__chemformula_mathfrac_bool -\bool_set_true:N \l__chemformula_mathfrac_bool -\bool_new:N \l__chemformula_fss_bool -\bool_new:N \l__chemformula_fontspec_bool -\bool_new:N \l__chemformula_fss_family_bool -\bool_new:N \l__chemformula_fss_series_bool -\bool_new:N \l__chemformula_fss_shape_bool -\bool_new:N \l__chemformula_name_width_bool -\bool_new:N \l__chemformula_charge_full_shift_bool -\bool_new:N \l__chemformula_tikzexternaldisable_bool -\bool_set_true:N \l__chemformula_tikzexternaldisable_bool -\bool_new:N \l__chemformula_kroegervink_bool -\bool_new:N \l__chemformula_inside_subscript_bool -\bool_new:N \l__chemformula_inside_superscript_bool +% booleans +\bool_new:N \l_chemformula_inside_ch_bool +\bool_new:N \l_chemformula_formal_charges_bool +\bool_new:N \l_chemformula_formal_chem_bool +\bool_new:N \l__chemformula_options_bool +\bool_new:N \l__chemformula_is_option_bool +\bool_new:N \l__chemformula_stoich_bool +\bool_new:N \l__chemformula_no_stoich_bool +\bool_new:N \l__chemformula_is_addition_symbol_bool +\bool_new:N \l__chemformula_is_symbol_bool +\bool_new:N \l__chemformula_is_arrow_bool +\bool_new:N \l__chemformula_is_name_bool +\bool_new:N \l__chemformula_stoich_is_iupac_bool +\bool_new:N \l__chemformula_stoich_parse_iupac_bool +\bool_new:N \l__chemformula_first_last_text_bool +\bool_new:N \l__chemformula_first_last_double_bool +\bool_new:N \l__chemformula_first_last_single_bool +\bool_new:N \l__chemformula_first_last_math_bool +\bool_new:N \l__chemformula_first_last_dollar_bool +\bool_new:N \l__chemformula_first_last_mathbraces_bool +\bool_new:N \l__chemformula_number_style_math_bool +\bool_new:N \l__chemformula_charge_style_math_bool +\bool_new:N \l__chemformula_is_isotope_bool +\bool_new:N \l__chemformula_xfrac_bool +\bool_new:N \l__chemformula_nicefrac_bool +\bool_new:N \l__chemformula_mathfrac_bool +\bool_new:N \l__chemformula_fss_bool +\bool_new:N \l__chemformula_fontspec_bool +\bool_new:N \l__chemformula_fss_family_bool +\bool_new:N \l__chemformula_fss_series_bool +\bool_new:N \l__chemformula_fss_shape_bool +\bool_new:N \l__chemformula_name_width_bool +\bool_new:N \l__chemformula_charge_full_shift_bool +\bool_new:N \l__chemformula_tikzexternaldisable_bool +\bool_new:N \l__chemformula_kroegervink_bool +\bool_new:N \l__chemformula_inside_subscript_bool +\bool_new:N \l__chemformula_inside_superscript_bool +\bool_new:N \l__chemformula_subsuper_use_math_bool +\bool_new:N \l__chemformula_subandsuper_bool % dimensions: -\dim_new:N \l__chemformula_arrow_length_dim -\dim_new:N \l__chemformula_arrow_label_height_dim -\dim_new:N \l__chemformula_arrow_label_offset_dim -\dim_set:Nn \l__chemformula_arrow_label_offset_dim {2pt} -\dim_new:N \l__chemformula_arrow_minimum_length_dim -\dim_new:N \l__chemformula_arrow_shortage_dim -\dim_new:N \l__chemformula_arrow_offset_dim -\dim_new:N \l__chemformula_arrow_yshift_dim -\dim_set:Nn \l__chemformula_arrow_yshift_dim {0pt} -\dim_new:N \l__chemformula_radical_radius_dim -\dim_set:Nn \l__chemformula_radical_radius_dim {.2ex} -\dim_new:N \l__chemformula_radical_hshift_dim -\dim_set:Nn \l__chemformula_radical_hshift_dim {.15em} -\dim_new:N \l__chemformula_radical_vshift_dim -\dim_set:Nn \l__chemformula_radical_vshift_dim {.5ex} -\dim_new:N \l__chemformula_radical_space_dim -\dim_set:Nn \l__chemformula_radical_space_dim {.3em} -\dim_new:N \l__chemformula_arrow_head_dim -\dim_new:N \l__chemformula_name_dim -\dim_new:N \l__chemformula_adduct_space_dim -\dim_set:Nn \l__chemformula_adduct_space_dim {.1333em} -\dim_new:N \l__chemformula_charge_shift_dim -\dim_set:Nn \l__chemformula_charge_shift_dim {.5ex} -\dim_new:N \l__chemformula_subscript_shift_dim -\dim_new:N \l__chemformula_superscript_shift_dim -\dim_new:N \l__chemformula_subscript_dim -\dim_zero:N \l__chemformula_subscript_dim -\dim_new:N \l__chemformula_superscript_dim -\dim_zero:N \l__chemformula_superscript_dim -\dim_new:N \l__chemformula_bond_dim -\dim_set:Nn \l__chemformula_bond_dim {.5833em} -\dim_new:N \l__chemformula_bond_space_dim -\dim_set:Nn \l__chemformula_bond_space_dim {.07em} -\dim_new:N \l__chemformula_elspec_pair_distance_dim -\dim_set:Nn \l__chemformula_elspec_pair_distance_dim {1ex} -\dim_new:N \l__chemformula_elspec_pair_line_length_dim -\dim_set:Nn \l__chemformula_elspec_pair_line_length_dim {1.5ex} -\dim_new:N \l__chemformula_elspec_pair_width_dim -\dim_set:Nn \l__chemformula_elspec_pair_width_dim {1pt} -\dim_new:N \l__chemformula_kroegervink_positive_radius_dim -\dim_set:Nn \l__chemformula_kroegervink_positive_radius_dim {.3ex} -\dim_new:N \l__chemformula_kroegervink_positive_hshift_dim -\dim_set:Nn \l__chemformula_kroegervink_positive_hshift_dim {.15em} -\dim_new:N \l__chemformula_kroegervink_positive_vshift_dim -\dim_set:Nn \l__chemformula_kroegervink_positive_vshift_dim {.5ex} -\dim_new:N \l__chemformula_kroegervink_positive_space_dim -\dim_set:Nn \l__chemformula_kroegervink_positive_space_dim {.4em} +\dim_new:N \l__chemformula_arrow_length_dim +\dim_new:N \l__chemformula_arrow_label_height_dim +\dim_new:N \l__chemformula_arrow_label_offset_dim +\dim_new:N \l__chemformula_arrow_minimum_length_dim +\dim_new:N \l__chemformula_arrow_shortage_dim +\dim_new:N \l__chemformula_arrow_offset_dim +\dim_new:N \l__chemformula_arrow_yshift_dim +\dim_new:N \l__chemformula_radical_radius_dim +\dim_new:N \l__chemformula_radical_hshift_dim +\dim_new:N \l__chemformula_radical_vshift_dim +\dim_new:N \l__chemformula_radical_space_dim +\dim_new:N \l__chemformula_arrow_head_dim +\dim_new:N \l__chemformula_name_dim +\dim_new:N \l__chemformula_adduct_space_dim +\dim_new:N \l__chemformula_charge_shift_dim +\dim_new:N \l__chemformula_subscript_shift_dim +\dim_new:N \l__chemformula_superscript_shift_dim +\dim_new:N \l__chemformula_subscript_dim +\dim_new:N \l__chemformula_superscript_dim +\dim_new:N \l__chemformula_bond_dim +\dim_new:N \l__chemformula_bond_space_dim +\dim_new:N \l__chemformula_elspec_pair_distance_dim +\dim_new:N \l__chemformula_elspec_pair_line_length_dim +\dim_new:N \l__chemformula_elspec_pair_width_dim +\dim_new:N \l__chemformula_kroegervink_positive_radius_dim +\dim_new:N \l__chemformula_kroegervink_positive_hshift_dim +\dim_new:N \l__chemformula_kroegervink_positive_vshift_dim +\dim_new:N \l__chemformula_kroegervink_positive_space_dim % skips: -\skip_new:N \l__chemformula_stoich_space_skip -\skip_set:Nn \l__chemformula_stoich_space_skip { .1667em plus .0333em minus .0117em } -\skip_new:N \l__chemformula_math_space_skip -\skip_set:Nn \l__chemformula_math_space_skip { .1667em plus .0333em minus .0117em } +\skip_new:N \l__chemformula_stoich_space_skip +\skip_new:N \l__chemformula_math_space_skip +\skip_new:N \l__chemformula_additions_symbol_space_skip % integers: -\int_new:N \l__chemformula_count_tokens_int -\int_new:N \g__chemformula_lewis_int +\int_new:N \l__chemformula_count_tokens_int +\int_new:N \g__chemformula_lewis_int % token lists: -\tl_new:N \l__chemformula_compound_sep_tl -\tl_set:Nn \l__chemformula_compound_sep_tl {.5em} -\tl_new:N \l__chemformula_compound_tl -\tl_new:N \l__chemformula_arrow_ratio_tl -\tl_set:Nn \l__chemformula_arrow_ratio_tl {.6} -\tl_new:N \l__chemformula_radical_style_tl -\tl_new:N \l__chemformula_arrow_head_tl -\tl_set:Nn \l__chemformula_arrow_head_tl {cf} -\tl_new:N \l__chemformula_upper_label_tl -\tl_new:N \l__chemformula_lower_label_tl -\tl_new:N \l__chemformula_arrow_style_tl -\tl_new:N \l__chemformula_arrow_label_style_tl -\tl_set:Nn \l__chemformula_arrow_label_style_tl { \footnotesize } -\tl_new:N \l__chemformula_arrow_type_tl -\tl_new:N \l__chemformula_arrow_penalty_tl -\tl_set:Nn \l__chemformula_arrow_penalty_tl {0} -\tl_new:N \l__chemformula_arrow_offset_tl -\tl_set:Nn \l__chemformula_arrow_offset_tl {.75em} -\tl_new:N \l__chemformula_bond_penalty_tl -\tl_set:Nn \l__chemformula_bond_penalty_tl {10000} -\tl_new:N \l__chemformula_chemformula_tmpa_tl -\tl_new:N \g__chemformula_options_tl -\tl_new:N \g__chemformula_output_tl -\tl_new:N \l__chemformula_input_tl -\tl_new:N \l__chemformula_stoich_tl -\tl_new:N \l__chemformula_decimal_output_tl -\tl_set:Nn \l__chemformula_decimal_output_tl {.} -\tl_new:N \l__chemformula_font_family_tl -\tl_set_eq:NN \l__chemformula_font_family_tl \f@family -\tl_new:N \l__chemformula_font_series_tl -\tl_set_eq:NN \l__chemformula_font_series_tl \f@series -\tl_new:N \l__chemformula_font_shape_tl -\tl_set_eq:NN \l__chemformula_font_shape_tl \f@shape -\tl_new:N \l__chemformula_format_tl -\tl_new:N \l__chemformula_atom_format_tl -\tl_new:N \l__chemformula_fontspec_options_tl -\tl_new:N \l__chemformula_fontspec_argument_tl -\tl_new:N \l__chemformula_name_format_tl -\tl_set:Nn \l__chemformula_name_format_tl { \scriptsize\centering } -\tl_new:N \l__chemformula_subscript_shift_additional_tl -\tl_set:Nn \l__chemformula_subscript_shift_additional_tl {0pt} -\tl_new:N \l__chemformula_superscript_shift_additional_tl -\tl_set:Nn \l__chemformula_superscript_shift_additional_tl {0pt} -\tl_new:N \l__chemformula_subscript_tl -\tl_new:N \l__chemformula_superscript_tl -\tl_new:N \l__chemformula_elspec_angle_tl -\tl_new:N \l__chemformula_elspec_radius_tl -\tl_set:Nn \l__chemformula_elspec_radius_tl {.5ex} -\tl_new:N \l__chemformula_elspec_default_type_tl -\tl_set:Nn \l__chemformula_elspec_default_type_tl {pair} +\tl_new:N \l__chemformula_compound_sep_tl +\tl_new:N \l__chemformula_compound_tl +\tl_new:N \l__chemformula_arrow_ratio_tl +\tl_new:N \l__chemformula_radical_style_tl +\tl_new:N \l__chemformula_arrow_head_tl +\tl_new:N \l__chemformula_upper_label_tl +\tl_new:N \l__chemformula_lower_label_tl +\tl_new:N \l__chemformula_arrow_style_tl +\tl_new:N \l__chemformula_arrow_label_style_tl +\tl_new:N \l__chemformula_arrow_type_tl +\tl_new:N \l__chemformula_arrow_penalty_tl +\tl_new:N \l__chemformula_arrow_offset_tl +\tl_new:N \l__chemformula_bond_penalty_tl +\tl_new:N \l__chemformula_chemformula_tmpa_tl +\tl_new:N \g__chemformula_options_tl +\tl_new:N \g__chemformula_output_tl +\tl_new:N \l__chemformula_input_tl +\tl_new:N \l__chemformula_stoich_tl +\tl_new:N \l__chemformula_decimal_output_tl +\tl_new:N \l__chemformula_font_family_tl +\tl_new:N \l__chemformula_font_series_tl +\tl_new:N \l__chemformula_font_shape_tl +\tl_new:N \l__chemformula_format_tl +\tl_new:N \l__chemformula_atom_format_tl +\tl_new:N \l__chemformula_fontspec_options_tl +\tl_new:N \l__chemformula_fontspec_argument_tl +\tl_new:N \l__chemformula_name_format_tl +\tl_new:N \l__chemformula_subscript_shift_additional_tl +\tl_new:N \l__chemformula_superscript_shift_additional_tl +\tl_new:N \l__chemformula_subscript_tl +\tl_new:N \l__chemformula_superscript_tl +\tl_new:N \l__chemformula_elspec_angle_tl +\tl_new:N \l__chemformula_elspec_radius_tl +\tl_new:N \l__chemformula_elspec_default_type_tl +\tl_new:N \l__chemformula_kroegervink_positive_style_tl +\tl_new:N \l__chemformula_kroegervink_neutral_tl +\tl_new:N \l__chemformula_adduct_penalty_tl +\tl_new:N \l__chemformula_catcodes_tl +\tl_new:N \l__chemformula_additions_symbol_penalty_tl + \tl_const:Nx \c__chemformula_colon_tl { \token_to_str:N : } -\tl_new:N \l__chemformula_kroegervink_positive_style_tl -\tl_new:N \l__chemformula_kroegervink_neutral_tl -\tl_set:Nn \l__chemformula_kroegervink_neutral_tl {$\times$} -\tl_new:N \l__chemformula_adduct_penalty_tl -\tl_set:Nn \l__chemformula_adduct_penalty_tl {300} -\tl_new:N \l__chemformula_catcodes_tl % property lists: \prop_new:N \l__chemformula_arrows_code_prop @@ -354,10 +299,14 @@ \prop_new:N \l__chemformula_no_stoich_prop \prop_new:N \l__chemformula_lewis_elspec_types_prop \prop_new:N \l__chemformula_kroegervink_prop +\prop_new:N \l__chemformula_symbols_prop +\prop_new:N \l__chemformula_clean_subscript_prop +\prop_new:N \l__chemformula_addition_symbol_prop % sequences: \seq_new:N \l__chemformula_arrows_type_seq \seq_new:N \l__chemformula_input_seq +\seq_new:N \l__chemformula_clean_subscript_seq % boxes: \box_new:N \l__chemformula_arrow_arg_i_box @@ -365,6 +314,57 @@ \box_new:N \l__chemformula_superscript_box \box_new:N \l__chemformula_subscript_box +% -------------------------------------------------------------------------- +% initial values: +\bool_set_true:N \l_chemformula_formal_chem_bool +\bool_set_true:N \l__chemformula_mathfrac_bool +\bool_set_true:N \l__chemformula_tikzexternaldisable_bool + +\tl_set:Nn \l__chemformula_compound_sep_tl {.5em} +\tl_set:Nn \l__chemformula_arrow_ratio_tl {.6} +\tl_set:Nn \l__chemformula_arrow_head_tl {cf} +\tl_set:Nn \l__chemformula_arrow_label_style_tl { \footnotesize } +\tl_set:Nn \l__chemformula_arrow_penalty_tl {0} +\tl_set:Nn \l__chemformula_arrow_offset_tl {.75em} +\tl_set:Nn \l__chemformula_bond_penalty_tl {10000} +\tl_set:Nn \l__chemformula_decimal_output_tl {.} +\tl_set:Nn \l__chemformula_name_format_tl { \scriptsize\centering } +\tl_set:Nn \l__chemformula_subscript_shift_additional_tl {0pt} +\tl_set:Nn \l__chemformula_superscript_shift_additional_tl {0pt} +\tl_set:Nn \l__chemformula_elspec_radius_tl {.5ex} +\tl_set:Nn \l__chemformula_elspec_default_type_tl {pair} +\tl_set:Nn \l__chemformula_kroegervink_neutral_tl {$\times$} +\tl_set:Nn \l__chemformula_adduct_penalty_tl {300} + +\tl_set_eq:NN \l__chemformula_font_family_tl \f@family +\tl_set_eq:NN \l__chemformula_font_series_tl \f@series +\tl_set_eq:NN \l__chemformula_font_shape_tl \f@shape + +\dim_set:Nn \l__chemformula_arrow_label_offset_dim {2pt} +\dim_set:Nn \l__chemformula_arrow_yshift_dim {0pt} +\dim_set:Nn \l__chemformula_radical_radius_dim {.2ex} +\dim_set:Nn \l__chemformula_radical_hshift_dim {.15em} +\dim_set:Nn \l__chemformula_radical_vshift_dim {.5ex} +\dim_set:Nn \l__chemformula_radical_space_dim {.3em} +\dim_set:Nn \l__chemformula_radical_space_dim {.3em} +\dim_set:Nn \l__chemformula_adduct_space_dim {.1333em} +\dim_set:Nn \l__chemformula_charge_shift_dim {.5ex} +\dim_set:Nn \l__chemformula_bond_dim {.5833em} +\dim_set:Nn \l__chemformula_bond_space_dim {.07em} +\dim_set:Nn \l__chemformula_elspec_pair_distance_dim {1ex} +\dim_set:Nn \l__chemformula_elspec_pair_line_length_dim {1.5ex} +\dim_set:Nn \l__chemformula_elspec_pair_width_dim {1pt} +\dim_set:Nn \l__chemformula_kroegervink_positive_radius_dim {.3ex} +\dim_set:Nn \l__chemformula_kroegervink_positive_hshift_dim {.15em} +\dim_set:Nn \l__chemformula_kroegervink_positive_vshift_dim {.5ex} +\dim_set:Nn \l__chemformula_kroegervink_positive_space_dim {.4em} + +\dim_zero:N \l__chemformula_superscript_dim +\dim_zero:N \l__chemformula_subscript_dim + +\skip_set:Nn \l__chemformula_stoich_space_skip { .1667em plus .0333em minus .0117em } +\skip_set:Nn \l__chemformula_math_space_skip { .1667em plus .0333em minus .0117em } + % -------------------------------------------------------------------------- % catcode stuff \cs_new_protected:Npn \__chemformula_save_catcodes: @@ -484,7 +484,8 @@ % -------------------------------------------------------------------------- % prevent externalisation of tikz parts of the formulae: -\AtBeginDocument { \providecommand \tikzexternaldisable {} } +\hook_gput_code:nnn {begindocument} {chemformula} + { \providecommand \tikzexternaldisable {} } \keys_define:nn {chemformula} { @@ -623,7 +624,7 @@ overlay } { - \fill (0,0) + \fill (0pt,0pt) ++( \l__chemformula_radical_hshift_dim , \l__chemformula_radical_vshift_dim @@ -1266,7 +1267,6 @@ % arrow generation & detection \cs_new_protected:Npn \__chemformula_generate_arrows:Nn #1#2 { - % TODO: is the rescan necessary? Can't we use strings? \tl_set_rescan:Nnn \l__chemformula_tmpa_tl { \char_set_catcode_other:N \> @@ -1349,25 +1349,25 @@ { \chemformula_dim_to_width:Nn \l__chemformula_name_dim { - \chemformula_group_begin: + \group_begin: \l__chemformula_name_format_tl {#1} - \chemformula_group_end: + \group_end: } } \parbox { \dim_use:N \l__chemformula_name_dim } { - \chemformula_group_begin: + \group_begin: \l__chemformula_name_format_tl {#1} - \chemformula_group_end: + \group_end: } } { \text { - \chemformula_group_begin: + \group_begin: \strut #2 - \chemformula_group_end: + \group_end: } } \c_math_toggle_token @@ -1769,9 +1769,6 @@ } \cs_generate_variant:Nn \__chemformula_subscript:n {V} -\prop_new:N \l__chemformula_clean_subscript_prop -\seq_new:N \l__chemformula_clean_subscript_seq - \cs_new_protected:Npn \chemformula_add_subscript_cleanup:nn #1#2 { \seq_put_right:Nn \l__chemformula_clean_subscript_seq {#1} @@ -1803,7 +1800,6 @@ { \prop_item:Nn \l__chemformula_clean_subscript_prop {##1} } } } -\cs_generate_variant:Nn \tl_replace_all:Nnn {Nnx} \cs_new_protected:Npn \__chemformula_subscript_raise:N #1 { @@ -1827,21 +1823,37 @@ \bool_set_true:N \l__chemformula_inside_subscript_bool \tl_set_eq:NN \chemformula_subscript:n \use:n \tl_set_eq:NN \chemformula_superscript:n \use:n - \__chemformula_subscript_raise:N \l__chemformula_subscript_shift_dim - \hbox:n + \bool_if:NTF \l__chemformula_subsuper_use_math_bool { \c_math_toggle_token - \scriptstyle - \prop_get:NoNTF \l__chemformula_numbers_prop - {#1} \l__chemformula_tmpa_tl - { \__chemformula_number_style:V \l__chemformula_tmpa_tl } - { \__chemformula_number_style:n {#1} } + \bool_if:NT \l__chemformula_subandsuper_bool + { \c_math_superscript_token {} } + \c_math_subscript_token + { \____chemformula_subscript:n {#1} } \c_math_toggle_token } + { + \__chemformula_subscript_raise:N \l__chemformula_subscript_shift_dim + \hbox:n + { + \c_math_toggle_token + \____chemformula_subscript:n {#1} + \c_math_toggle_token + } + } \group_end: } \cs_generate_variant:Nn \__chemformula_subscript_write:n {V} +\cs_new_protected:Npn \____chemformula_subscript:n #1 + { + \scriptstyle + \prop_get:NoNTF \l__chemformula_numbers_prop + {#1} \l__chemformula_tmpa_tl + { \__chemformula_number_style:V \l__chemformula_tmpa_tl } + { \__chemformula_number_style:n {#1} } + } + \cs_new_protected:Npn \__chemformula_measure_subscript:n #1 { \hbox_set:Nn \l__chemformula_tmpa_box @@ -1952,32 +1964,46 @@ \bool_set_true:N \l__chemformula_inside_superscript_bool \tl_set_eq:NN \chemformula_subscript:n \use:n \tl_set_eq:NN \chemformula_superscript:n \use:n - \__chemformula_superscript_raise:N \l__chemformula_superscript_shift_dim - \hbox:n + \bool_if:NTF \l__chemformula_subsuper_use_math_bool { \c_math_toggle_token - \scriptstyle - % TODO: this is at the wrong place here -- we need to map through - % the superscript tokens! - \bool_if:NTF \l__chemformula_kroegervink_bool - { % TODO: is the o argument necessary? - \prop_get:NoNTF \l__chemformula_kroegervink_prop - {#1} \l__chemformula_tmpa_tl - { \tl_use:N \l__chemformula_tmpa_tl } - { \chemformula_charge_style:n {#1} } - } - { % TODO: is the o argument necessary? - \prop_get:NoNTF \l__chemformula_charge_prop - {#1} \l__chemformula_tmpa_tl - { \tl_use:N \l__chemformula_tmpa_tl } - { \chemformula_charge_style:n {#1} } - } + \bool_if:NT \l__chemformula_subandsuper_bool + { \c_math_subscript_token {} } + \c_math_superscript_token + { \____chemformula_superscript:n {#1} } \c_math_toggle_token } + { + \__chemformula_superscript_raise:N \l__chemformula_superscript_shift_dim + \hbox:n + { + \c_math_toggle_token + \____chemformula_superscript:n {#1} + \c_math_toggle_token + } + } \group_end: } \cs_generate_variant:Nn \__chemformula_superscript_write:n {V} +\cs_new_protected:Npn \____chemformula_superscript:n #1 + { + \scriptstyle + \bool_if:NTF \l__chemformula_kroegervink_bool + { + \prop_get:NnNTF \l__chemformula_kroegervink_prop + {#1} \l__chemformula_tmpa_tl + { \tl_use:N \l__chemformula_tmpa_tl } + { \chemformula_charge_style:n {#1} } + } + { + \prop_get:NnNTF \l__chemformula_charge_prop + {#1} \l__chemformula_tmpa_tl + { \tl_use:N \l__chemformula_tmpa_tl } + { \chemformula_charge_style:n {#1} } + } + } + \cs_new_protected:Npn \__chemformula_measure_superscript:n #1 { \hbox_set:Nn \l__chemformula_tmpa_box @@ -2023,6 +2049,7 @@ { \tl_if_blank:VF \l__chemformula_subscript_tl { + \bool_set_true:N \l__chemformula_subandsuper_bool \bool_if:NTF \l__chemformula_charge_full_shift_bool { \chemformula_skip_nobreak:n { -\l__chemformula_subscript_dim } } { \chemformula_skip_nobreak:N \l__chemformula_charge_shift_dim } @@ -2133,7 +2160,7 @@ { \bool_set_true:N \l__chemformula_stoich_bool % the factor consists only of a parenthesis or a decimal marcer: - \bool_set_true:N \l__chemformula_no_stoich_bool + \bool_set_true:N \l__chemformula_no_stoich_bool \tl_map_inline:nn {#1} { \prop_if_in:NnF \l__chemformula_no_stoich_prop {##1} @@ -2282,7 +2309,6 @@ { \tl_if_blank:VTF \l__chemformula_stoich_tl { - % TODO \__chemformula_detect_addition_symbols:n {#2} \__chemformula_detect_symbols:n {#2} \__chemformula_detect_arrows:n {#2} @@ -2332,25 +2358,6 @@ } \cs_generate_variant:Nn \__chemformula_input_compound:Nn {NV} -% TODO: this is redundant at the moment -\bool_new:N \g__chemformula_compound_group_open_bool -\cs_new_protected:Npn \chemformula_group_begin: - { - \bool_if:NF \g__chemformula_compound_group_open_bool - { - % \group_begin: - \bool_gset_true:N \g__chemformula_compound_group_open_bool - } - } -\cs_new_protected:Npn \chemformula_group_end: - { - \bool_if:NT \g__chemformula_compound_group_open_bool - { - % \group_end: - \bool_gset_false:N \g__chemformula_compound_group_open_bool - } - } - \cs_new_protected:Npn \chemformula_font_inner: { \bool_if:NT \l__chemformula_fss_bool @@ -2549,10 +2556,6 @@ % -------------------------------------------------------------------------- % input "and" sign -\prop_new:N \l__chemformula_addition_symbol_prop -\skip_new:N \l__chemformula_additions_symbol_space_skip -\tl_new:N \l__chemformula_additions_symbol_penalty_tl - \skip_set:Nn \l__chemformula_additions_symbol_space_skip {.3em plus .1em minus .1em} \tl_set:Nn \l__chemformula_additions_symbol_penalty_tl {700} @@ -2670,8 +2673,6 @@ % -------------------------------------------------------------------------- % input escaping gas and precipitate -\prop_new:N \l__chemformula_symbols_prop - \cs_new_protected:Npn \__chemformula_input_symbol:n #1 { \prop_map_inline:Nn \l__chemformula_symbols_prop @@ -2870,16 +2871,9 @@ \char_set_catcode_letter:N \: } { \c_math_toggle_token #1 \c_math_toggle_token } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl - { \_ } { chemformulaplaceholder } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl - {_} { \sb } - \tl_replace_all:Nnn \l__chemformula_tmpa_tl - { chemformulaplaceholder } { \_ } - \tl_put_left:Nn \l__chemformula_tmpa_tl - { \chemformula_group_begin: } - \tl_put_right:Nn \l__chemformula_tmpa_tl - { \chemformula_group_end: } + \tl_replace_all:Nnn \l__chemformula_tmpa_tl {_} { \sb } + \tl_put_left:Nn \l__chemformula_tmpa_tl { \group_begin: } + \tl_put_right:Nn \l__chemformula_tmpa_tl { \group_end: } \tl_put_right:NV \l__chemformula_input_tl \l__chemformula_tmpa_tl \tl_put_right:Nn \l__chemformula_input_tl { \chemformula_skip_nobreak:N \l__chemformula_math_space_skip } @@ -2934,6 +2928,9 @@ \bool_set_false:N \l__chemformula_charge_full_shift_bool \dim_set:Nn \l__chemformula_charge_shift_dim {#1} } , + math-scripts .bool_set:N = + \l__chemformula_subsuper_use_math_bool , + math-scripts .initial:n = false , charge-hshift .default:n = .25em , charge-vshift .tl_set:N = \l__chemformula_superscript_shift_additional_tl , @@ -3285,7 +3282,7 @@ % -------------------------------------------------------------------------- % hyperref support -\AfterPackage* { hyperref } +\hook_gput_code:nnn {package/after/hyperref} {chemformula} { \pdfstringdefDisableCommands { @@ -3297,7 +3294,7 @@ } } -\tex_endinput:D +\file_input_stop: % -------------------------------------------------------------------------- VERSION HISTORY @@ -3511,6 +3508,10 @@ VERSION HISTORY 2020/02/01 - version 4.15i - fix issue #12 2020/03/07 - version 4.15j - make sure that < and > have catcode 12 when read as arrows -- again... +2020/03/15 - version 4.15k - fix https://tex.stackexchange.com/questions/532674/ +2020/12/22 - version 4.16 - new option `math-scripts' + - use LaTeX's new hooks + - get rid of unnecessary package dependencies % -------------------------------------------------------------------------- % IDEAS: -- cgit v1.2.3