From 9d63d20b395741946482b9029e072ae7ebff21f0 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 2 May 2016 22:49:31 +0000 Subject: chemmacros (2may16) git-svn-id: svn://tug.org/texlive/trunk@40838 c570f23f-e606-0410-a88d-b1316a301751 --- .../chemmacros.module.reactions.code.tex | 226 +++++++++++++++++++-- 1 file changed, 207 insertions(+), 19 deletions(-) (limited to 'Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex') diff --git a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex index 8f8a98f8d95..ed8f48cfd5c 100644 --- a/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex +++ b/Master/texmf-dist/tex/latex/chemmacros/chemmacros.module.reactions.code.tex @@ -25,7 +25,7 @@ % % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- -\ChemModule{reactions}{2016/02/09 reaction environments} +\ChemModule{reactions}{2016/04/27 reaction environments} \chemmacros_load_module:n {chemformula} @@ -34,14 +34,14 @@ % -------------------------------------------------------------------------- \cs_new_protected:Npn \__chemmacros_record_for_lor:nnnnn #1#2#3#4#5 { - \tl_if_eq:nnT { #1 } { reaction } + \tl_if_eq:nnT {#1} {reaction} { \group_begin: % we need to prevent \Hy@make@anchor from being written to the lor % file: \bool_if:NT \l__chemmacros_hyperref_bool { \cs_set:Npn \Hy@make@anchor {} } - \addcontentsline { lor } { reaction } + \addcontentsline {lor} {reaction} { \tl_use:N \l__chemmacros_reaction_lorname_tl \tl_use:N \c_space_tl @@ -66,7 +66,7 @@ \maketag@@@{#3\ignorespaces#2{##1}\unskip\@@italiccorr#4} % this is added => this disturbs hyperref: \__chemmacros_record_for_lor:nnnnn - { #1 } { #3 } { #2 } { ##1 } { #4 } + {#1} {#3} {#2} {##1} {#4} } } } @@ -75,12 +75,12 @@ \cs_new_protected:Npn \chemmacros_add_reaction_description:n #1 { - \tl_if_blank:nF { #1 } - { \tl_gset:Nn \g__chemmacros_reaction_description_tl { : ~ #1 } } + \tl_if_blank:nF {#1} + { \tl_gset:Nn \g__chemmacros_reaction_description_tl {:~#1} } } -\NewDocumentCommand \AddRxnDesc { m } - { \chemmacros_add_reaction_description:n { #1 } } +\NewDocumentCommand \AddRxnDesc {m} + { \chemmacros_add_reaction_description:n {#1} } % define \listofreactions \tl_new:N \l__chemmacros_reaction_lorname_tl @@ -88,10 +88,18 @@ \tl_new:N \l__chemmacros_reaction_heading_tl \cs_new:Npn \__chemmacros_reaction_heading:n #1 - { \l__chemmacros_reaction_heading_tl { #1 } } + { \l__chemmacros_reaction_heading_tl {#1} } \cs_generate_variant:Nn \__chemmacros_reaction_heading:n { V } -\tl_set:Nn \l__chemmacros_reaction_lorname_tl { \chemmacros_translate:n {reaction} } +\ChemCompatibilityTo{5.5} +\tl_set:Nn \l__chemmacros_reaction_lorname_tl + { \chemmacros_translate:n {reaction} } +\EndChemCompatibility +\ChemCompatibilityFrom{5.6} +\tl_set:Nn \l__chemmacros_reaction_lorname_tl + { \chemmacros_translate:n {Reaction} } +\EndChemCompatibility + \tl_set:Nn \reactionlistname { \chemmacros_translate:n {list-of-reactions} } \chemmacros_define_keys:nn {reactions} @@ -109,12 +117,20 @@ \cs_if_exist:NTF \chapter { - \chemmacros_set_keys:nn {reactions} - { list-heading-cmd = \chapter* {#1} } + \chemmacros_if_compatiblity:nnTF {>=} {5.2} + { + \chemmacros_set_keys:nn {reactions} + { list-heading-cmd = \chapter* {#1} } + } + { \cs_set_protected:Npn \__chemmacros_reaction_heading:n { \chapter* } } } { - \chemmacros_set_keys:nn {reactions} - { list-heading-cmd = \section* {#1} } + \chemmacros_if_compatiblity:nnTF {>=} {5.2} + { + \chemmacros_set_keys:nn {reactions} + { list-heading-cmd = \section* {#1} } + } + { \cs_set_protected:Npn \__chemmacros_reaction_heading:n { \section* } } } \cs_new_protected:Npn \listofreactions @@ -123,14 +139,53 @@ \@starttoc {lor} } +\ChemCompatibilityTo{5.5} \cs_new_protected:Npn \l@reaction #1#2 - { \@dottedtocline { 1 } { 1.5em } { 2.3em } { #1 } { #2 } } + { \@dottedtocline {1} {1.5em} {2.3em} {#1} {#2} } +\EndChemCompatibility + +\ChemCompatibilityFrom{5.6} +\cs_new_eq:NN \l@reaction \l@figure + +\bool_new:N \l__chemmacros_reactions_tocbasic_bool +\cs_if_exist:NT \KOMAClassName + { \bool_set_true:N \l__chemmacros_reactions_tocbasic_bool } + +\chemmacros_define_keys:nn {reactions} + { tocbasic .bool_set:N = \l__chemmacros_reactions_tocbasic_bool } + +\AtEndPreamble + { + \bool_if:nT + { + \chemmacros_if_package_loaded_p:n {tocbasic} || + \l__chemmacros_reactions_tocbasic_bool + } + { + \RequirePackage {tocbasic} + \addtotoclist [float] {lor} + \cs_set_protected:Npn \listofreactions { \listoftoc {lor} } + \cs_new:Npn \listoflorname { \reactionlistname } + } + } + +\ChemCleverefSupport {reaction} + { \chemmacros_translate:n {reaction} } + [ \chemmacros_translate:n {Reaction} ] + { \chemmacros_translate:n {reactions} } + [ \chemmacros_translate:n {Reactions} ] +\ChemFancyrefSupport {rct} + { \chemmacros_translate:n {reaction} } + [ \chemmacros_translate:n {Reaction} ] +\EndChemCompatibility + % create new tagform \newtagform {reaction} {\{} {\}} \newcounter {chemmacros_save_reaction} \newcounter {reaction} +\ChemCompatibilityTo{5.5} \cs_new_protected:Npn \__chemmacros_begin_reaction: { % create individual names for `hyperref': @@ -146,6 +201,23 @@ \setcounter {equation} { \value {reaction} } \usetagform {reaction} } +\EndChemCompatibility + +\ChemCompatibilityFrom{5.6} +\cs_new_protected:Npn \__chemmacros_begin_reaction: + { + \patchcmd \thereaction {reaction} {equation} {} {} + \cs_set_eq:NN \theequation \thereaction + \cs_set_eq:NN \r@equation \r@reaction + \cs_set_eq:NN \p@equation \p@reaction + \cs_set:Npn \theHequation { R . \theHsection . \theequation } + \setcounter {chemmacros_save_reaction} { \value {equation} } + \setcounter {equation} { \value {reaction} } + \chemmacros_if_package_loaded:nT {cleveref} + { \crefalias {equation} {reaction} } + \usetagform {reaction} + } +\EndChemCompatibility % switch back to equation tags \cs_new_protected:Npn \__chemmacros_end_reaction: @@ -166,14 +238,14 @@ \tl_clear:N \l__chemmacros_reactions_args_tl \int_step_function:nnnN {2} {1} {#3+1} \__chemmacros_reactions_build_args:n } - \chemmacros_reaction_env:nnnV {#1} {#2} {#3} \l__chemmacros_reactions_args_tl + \chemmacros_declare_reaction_env:nnnV {#1} {#2} {#3} \l__chemmacros_reactions_args_tl } % #1: chem % #2: math % #3: args number % #4: argument list ({#2}{#3}...) -\cs_new_protected:Npn \chemmacros_reaction_env:nnnn #1#2#3#4 +\cs_new_protected:Npn \chemmacros_declare_reaction_env:nnnn #1#2#3#4 { \exp_args:Nnx \DeclareDocumentEnvironment {#1} { O{} \prg_replicate:nn {#3+0} {m} } { @@ -186,8 +258,9 @@ \ignorespacesafterend } } -\cs_generate_variant:Nn \chemmacros_reaction_env:nnnn {nnnV} - +\cs_generate_variant:Nn \chemmacros_declare_reaction_env:nnnn {nnnV} + +\ChemCompatibilityTo{5.5} \cs_new_protected:Npn \chemmacros_reaction_read:nnw #1#2#3 \end { \begin{#1}#2 @@ -195,6 +268,45 @@ \end{#1} \end } +\EndChemCompatibility + +\ChemCompatibilityFrom{5.6} +\cs_new_protected:Npn \chemmacros_reaction_read:nnw #1#2#3 \end + { + \tl_clear:N \l__chemmacros_tmpa_tl + \seq_clear:N \l__chemmacros_tmpc_seq + \seq_set_split:Nnn \l__chemmacros_tmpa_seq {\\} {#3} + \int_set:Nn \l__chemmacros_tmpa_int + { \seq_count:N \l__chemmacros_tmpa_seq } + \int_zero:N \l__chemmacros_tmpb_int + \seq_map_inline:Nn \l__chemmacros_tmpa_seq + { + \int_incr:N \l__chemmacros_tmpb_int + \seq_clear:N \l__chemmacros_tmpc_seq + \seq_set_split:Nnn \l__chemmacros_tmpb_seq {&} {##1} + \seq_map_inline:Nn \l__chemmacros_tmpb_seq + { + \seq_put_right:Nn \l__chemmacros_tmpc_seq + { \chemmacros_reaction:n {####1} } + } + \tl_put_right:Nx \l__chemmacros_tmpa_tl + { \seq_use:Nn \l__chemmacros_tmpc_seq {&} } + \int_compare:nF + { \l__chemmacros_tmpa_int = \l__chemmacros_tmpb_int } + { \tl_put_right:Nn \l__chemmacros_tmpa_tl {\\} } + } + \chemmacros_reaction_write:nnV {#1} {#2} \l__chemmacros_tmpa_tl + \end + } + +\cs_new_protected:Npn \chemmacros_reaction_write:nnn #1#2#3 + { + \begin{#1}#2 + #3 + \end{#1} + } +\cs_generate_variant:Nn \chemmacros_reaction_write:nnn { nnV } +\EndChemCompatibility \NewChemMacroset* {Reaction} {mO{}m} { \chemmacros_define_reaction:nnn {#1} {#3} {#2} } @@ -204,6 +316,74 @@ \NewChemReaction {reactions} {align} \NewChemReaction {reactions*} {align*} +% -------------------------------------------------------------------------- +\ChemCompatibilityTo{5.5} +\DeclareTranslationFallback {list-of-reactions} {List~ of~ Reactions} +\DeclareTranslation {English} {list-of-reactions} {List~ of~ Reactions} +\DeclareTranslation {German} {list-of-reactions} {Reaktionsverzeichnis} +\DeclareTranslation {Italian} {list-of-reactions} {Elenco~ delle~ reazioni} +\DeclareTranslation {French} {list-of-reactions} {Table~ des~ r\'eactions} +\DeclareTranslation {Dutch} {list-of-reactions} {Lijst~ van~ reacties} + +\DeclareTranslationFallback {reaction} {Reaction} +\DeclareTranslation {English} {reaction} {Reaction} +\DeclareTranslation {German} {reaction} {Reaktion} +\DeclareTranslation {Italian} {reaction} {Reazione} +\DeclareTranslation {French} {reaction} {R\'eaction} +\DeclareTranslation {Dutch} {reaction} {Reactie} +\EndChemCompatibility + +\ChemCompatibilityFrom{5.6} +\chemmacros_declare_translations:nn {list-of-reactions} + { + fallback = List~ of~ Reactions , + English = List~ of~ Reactions , + German = Reaktionsverzeichnis , + Italian = Elenco~ delle~ reazioni , + French = Table~ des~ r\'eactions , + Dutch = Lijst~ van~ reacties + } + +\chemmacros_declare_translations:nn {reaction} + { + fallback = reaction , + English = reaction , + German = Reaktion , + Italian = reazione , + French = r\'{e}action , + Dutch = reactie + } + +\chemmacros_declare_translations:nn {reactions} + { + fallback = reactions , + English = reactions , + German = Reaktionen , + Italian = reazioni , + French = r\'{e}actions , + Dutch = reacties + } + +\chemmacros_declare_translations:nn {Reaction} + { + fallback = Reaction , + English = Reaction , + German = Reaktion , + Italian = Reazione , + French = R\'{e}action , + Dutch = Reactie + } + +\chemmacros_declare_translations:nn {Reactions} + { + fallback = Reactions , + English = Reactions , + German = Reaktionen , + Italian = Reazioni , + French = R\'{e}actions , + Dutch = Reacties + } +\EndChemCompatibility % -------------------------------------------------------------------------- \tex_endinput:D @@ -211,3 +391,11 @@ directly 2015/10/14 - new option `list-heading-cmd' 2016/02/09 - added \ignorespacesafterend to environments +2016/03/17 - tocbasic integration of lor + - add missing compatibility check for the usage of the + `list-heading-cmd' option +2016/04/02 - adapt to new formula methods +2016/04/27 - correct \__chemmacros_begin_reaction: so tags obey \thereaction + - add cleveref support + - add fancyref support + - moved translations from lang module to reactions module -- cgit v1.2.3