diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex-dev/base/latex.ltx')
-rw-r--r-- | Master/texmf-dist/tex/latex-dev/base/latex.ltx | 1247 |
1 files changed, 873 insertions, 374 deletions
diff --git a/Master/texmf-dist/tex/latex-dev/base/latex.ltx b/Master/texmf-dist/tex/latex-dev/base/latex.ltx index 1e98573d2e7..4580afeec0e 100644 --- a/Master/texmf-dist/tex/latex-dev/base/latex.ltx +++ b/Master/texmf-dist/tex/latex-dev/base/latex.ltx @@ -512,7 +512,7 @@ \doublehyphendemerits=10000 \finalhyphendemerits=5000 \adjdemerits=10000 -\tracinglostchars=1 +\tracinglostchars=2 \ifx\directlua\@undefined % \tracingstacklevels=0 % added in 2021 \else @@ -692,7 +692,7 @@ \def\fmtname{LaTeX2e} \edef\fmtversion {2021-11-15} -\def\patch@level{-1} +\def\patch@level{-2} \edef\development@branch@name{develop \the\year-\the\month-\the\day} \iffalse \def\reserved@a#1/#2/#3\@nil{% @@ -770,6 +770,15 @@ {\@IncludeInRelease{#1}[#1]}}} \def\finish@module@release#1#2#3{% \toks@{[#1] #3}% + \begingroup + \edef\x{\detokenize\expandafter{\new@modulename}}% + \edef\y{\detokenize{#2}}% + \expandafter\endgroup + \ifx\x\y \else + \@latex@error{\noexpand\IncludeInRelease dated #1 in a module is not + allowed.\MessageBreak Use a date at least equal to \new@moduledate + \space for complete rollback}\@ehd + \fi \ifnum\expandafter\@parse@version\new@moduledate//00\@nil >\expandafter\@parse@version\fmtversion//00\@nil \GenericInfo{}{Applying: \the\toks@}% @@ -1672,8 +1681,8 @@ \xdef#1{\the\toks@}% \endgroup} %%% From File: ltcmd.dtx -\def\ltcmdversion{v1.0f} -\def\ltcmddate{2021-06-04} +\def\ltcmdversion{v1.0h} +\def\ltcmddate{2021-08-30} \message{document commands,} \ExplSyntaxOn \tl_new:N \l__cmd_arg_spec_tl @@ -1758,7 +1767,6 @@ #4 \__cmd_break_point:n {#2} } -\cs_generate_variant:Nn \__cmd_declare_cmd_internal:Nnnn { cnx } \cs_new_eq:NN \__cmd_break_point:n \use_none:n \cs_new_protected:Npn \__cmd_declare_cmd_code:Nnn { @@ -1861,15 +1869,8 @@ } \cs_new_protected:Npn \__cmd_declare_env_internal:nnnn #1#2#3#4 { - \__cmd_declare_cmd_internal:cnxn { environment~ #1 } {#2} - { - \cs_set_nopar:Npx \exp_not:c { environment~ #1 ~end~aux } - { - \exp_not:N \exp_not:N \exp_not:c { environment~ #1~end~aux~ } - \exp_not:n { \exp_not:o \l__cmd_args_tl } - } - \exp_not:n {#3} - } + \exp_args:Nc \__cmd_declare_cmd_internal:Nnnn { environment~ #1 } {#2} + {#3} { \cs_set_nopar:cpx { environment~ #1 ~end } { \exp_not:c { environment~ #1 ~end~aux } } @@ -1880,6 +1881,14 @@ \cs_set_eq:cc { end #1 } { environment~ #1 ~end } } } +\cs_new_protected:Npn \__cmd_set_environment_end:n #1 + { + \cs_set_nopar:cpx { environment~ #1 ~end~aux } + { + \exp_not:c { environment~ #1 ~end~aux~ } + \exp_not:o \l__cmd_args_tl + } + } \cs_new_protected:Npn \__cmd_start_env:nnnnn #1#2 { \conditionally@traceoff @@ -1907,7 +1916,10 @@ \tl_set:Nn \l__cmd_fn_code_tl {#2} \tl_set:Nn \l__cmd_defaults_tl {#5} \tl_set:Nn \l__cmd_process_all_tl {#6} - #4 \__cmd_run_code: + #4 + \bool_if:NT \l__cmd_environment_bool + { \exp_args:No \__cmd_set_environment_end:n \l__cmd_environment_str } + \__cmd_run_code: } \cs_generate_variant:Nn \__cmd_start_aux:NNnnnn { cc } \cs_new_protected:Npn \__cmd_run_code: @@ -2421,10 +2433,26 @@ { \__cmd_flush_m_args: \__cmd_add_default_E:nn {#1} {#2} + \use:x + { + \__cmd_replicate_processor:nn { \tl_count:n {#1} } + { \exp_not:o \l__cmd_process_one_tl } + } \__cmd_add_grabber:N E \tl_put_right:Nn \l__cmd_signature_tl { {#1} } \__cmd_prepare_signature:N } +\cs_new_protected:Npn \__cmd_replicate_processor:nn #1 #2 + { + \int_compare:nNnF {#1} > { 1 } { \use_none:nnn } + \tl_set:Nx \l__cmd_process_one_tl + { + \exp_not:n { \exp_not:n {#2} \if_false: { \fi: } } + \prg_replicate:nn { #1 - 2 } + { \exp_not:n { \exp_not:n { {#2} } } } + \exp_not:n { { \if_false: } \fi: \exp_not:n {#2} } + } + } \cs_new_protected:Npn \__cmd_add_type_m:w { \__cmd_add_default: @@ -2482,7 +2510,12 @@ \bool_set_false:N \l__cmd_long_bool \bool_set_false:N \l__cmd_obey_spaces_bool \tl_put_right:Nx \l__cmd_process_all_tl - { { \exp_not:o \l__cmd_process_one_tl } } + { + { + \if_charcode:w E #1 \use_i:nn \fi: + \exp_not:o \l__cmd_process_one_tl + } + } \tl_clear:N \l__cmd_process_one_tl } \cs_new_protected:Npn \__cmd_add_default:n #1 @@ -2624,6 +2657,319 @@ \cs_set_eq:NN #1 \__cmd_tmp:w \tl_set:Nn #2 {#1} } +\cs_new_protected:Npn \__cmd_copy:NN #1 #2 + { + \use:x + { + \int_set:Nn \tex_escapechar:D { 92 } + \exp_not:N \__cmd_cmd_type_cases:NnnnnF \exp_not:N #2 + { \__cmd_copy_command:nnNN } + { \__cmd_copy_expandable:nnNN } + { \__cmd_copy_environment:nnNN } + { \__cmd_copy_environment_end:nnNN } + { \__cmd_cant_copy:nwn { non-ltcmd } } + { \cs_to_str:N #1 } { \cs_to_str:N #2 } + \exp_not:N #1 \exp_not:N #2 + \exp_not:N \__cmd_break_point:n { \cs_to_str:N #2 } + \int_set:Nn \tex_escapechar:D { \int_use:N \tex_escapechar:D } + } + } +\cs_new_protected:Npn \__cmd_set_eq_if_exist:NN #1 #2 + { \cs_if_exist:NTF #2 { \cs_set_eq:NN } { \use_none:nn } #1 #2 } +\cs_generate_variant:Nn \__cmd_set_eq_if_exist:NN { cc } +\cs_new_protected:Npn \__cmd_cant_copy:nwn #1 #2 \__cmd_break_point:n #3 + { \msg_error:nnnn { cmd } { copy-bug } {#1} {#3} } +\msg_new:nnn { cmd } { copy-bug } + { + Error~while~copying~command~\iow_char:N\\#2:\\ + \str_case:nn {#1} + { + { non-ltcmd } { Command~is~not~a~valid~ltcmd~command. } + { unknown-type } { Found~an~unknown~argument~type. } + { invalid-end } + { Target~command~is~not~named~\iow_char:N \\end<name>. } + } + } +\tl_gput_right:Nn \@declarecommandcopylisthook + { { \__kernel_cmd_if_xparse:NTF \__cmd_copy:NN } } +\cs_new_protected:Npn \__cmd_copy_command:nnNN #1 #2 #3 #4 + { + \cs_set_eq:cc { #1 ~ code } { #2 ~ code } + \__cmd_set_eq_if_exist:cc { #1 ~ defaults } { #2 ~ defaults } + \cs_set_protected_nopar:Npx #3 + { \exp_after:wN \__cmd_copy_command:NnNNnnnn #4 {#1} } + } +\cs_new:Npn \__cmd_copy_command:NnNNnnnn #1 #2 #3 #4 #5 #6 #7 #8 + { + #1 \exp_not:n { {#2} } + \exp_not:c { #8 ~ } \exp_not:c { #8 ~ code } + \exp_not:n { {#5} {#6} {#7} } + } +\cs_new_protected:Npn \__cmd_copy_expandable:nnNN #1 #2 #3 #4 + { + \cs_set_eq:cc { #1 ~ code } { #2 ~ code } + \__cmd_set_eq_if_exist:cc { #1 ~ } { #2 ~ } + \__cmd_set_eq_if_exist:cc { #1 ~ \c_space_tl } { #2 ~ \c_space_tl } + \__cmd_set_eq_if_exist:cc { #1 ~ defaults } { #2 ~ defaults } + \exp_after:wN \__cmd_copy_expandable_signature:NnNNNNnnn #4 {#1} {#2} + \cs_set_nopar:Npx #3 + { \exp_after:wN \__cmd_copy_expandable:NnNNNNnnn #4 {#1} {#2} } + } +\cs_new:Npn \__cmd_copy_expandable:NnNNNNnnn #1 #2 #3 #4 #5 #6 #7 #8 #9 + { + \exp_not:N #1 \exp_not:n { {#2} } + \exp_not:c { #8 ~ } + \exp_not:c + { + #8 ~ + \str_if_eq:eeT + { \exp_not:c { #9 ~ \c_space_tl } } { \exp_not:N #4 } + { \c_space_tl } + } + \exp_not:c { #8 ~ code } + \str_if_eq:eeTF { \exp_not:N #6 } { ? } + { ? } + { \exp_not:c { #8 ~ defaults } } + { \exp_not:V \l__cmd_tmpa_tl } + } +\cs_new_protected:Npn \__cmd_copy_expandable_signature:NnNNNNnnn + #1 #2 #3 #4 #5 #6 #7 #8 #9 + { + \int_zero:N \l__cmd_current_arg_int + \tl_clear:N \l__cmd_tmpa_tl + \__cmd_copy_expandable:nnN {#8} {#9} #7 + \q_recursion_tail \q_recursion_stop + } +\cs_new_protected:Npn \__cmd_copy_expandable:nnN #1 #2 #3 + { + \quark_if_recursion_tail_stop:n {#3} + \int_incr:N \l__cmd_current_arg_int + \exp_after:wN \__cmd_copy_parse_grabber:w \token_to_str:N #3 {#1} {#2} + } +\use:x + { + \cs_new_protected:Npn \exp_not:N \__cmd_copy_parse_grabber:w ##1 + \tl_to_str:n { expandable_grab_ } ##2 \tl_to_str:n { :w } + { + \tl_put_right:Nx \exp_not:N \l__cmd_tmpa_tl + { \exp_not:N \exp_not:c { __cmd_expandable_grab_##2:w } } + \exp_not:N \cs_if_exist_use:cF { __cmd_copy_grabber_##2:w } + { \__cmd_cant_copy:nwn { unknown-type } } + } + } +\cs_new_protected:Npn \__cmd_copy_grabber_D:w #1 #2 #3 #4 #5 + { + \tl_put_right:Nx \l__cmd_tmpa_tl + { + \exp_not:c { #1 ~ (arg ~ \int_use:N \l__cmd_current_arg_int ) } + \exp_not:n { #4 #5 } + } + \cs_set_eq:cc + { #1 ~ (arg ~ \int_use:N \l__cmd_current_arg_int ) } + { #2 ~ (arg ~ \int_use:N \l__cmd_current_arg_int ) } + \__cmd_copy_expandable:nnN {#1} {#2} + } +\cs_new_protected:Npn \__cmd_copy_grabber_D_alt:w #1 #2 #3 #4 + { \__cmd_copy_grabber_D:w {#1} {#2} {#3} {#4} { } } +\cs_new_eq:NN \__cmd_copy_grabber_R:w \__cmd_copy_grabber_D:w +\cs_new_eq:NN \__cmd_copy_grabber_R_alt:w \__cmd_copy_grabber_D_alt:w +\cs_new_protected:Npn \__cmd_copy_grabber_E:w #1 #2 #3 #4 + { + \tl_put_right:Nn \l__cmd_tmpa_tl { {#3} {#4} } + \int_add:Nn \l__cmd_current_arg_int { \tl_count:n {#4} - 1 } + \__cmd_copy_expandable:nnN {#1} {#2} + } +\cs_new_eq:NN \__cmd_copy_grabber_E_long:w \__cmd_copy_grabber_E:w +\cs_new_protected:Npn \__cmd_copy_grabber_t:w #1 #2 #3 #4 + { + \tl_put_right:Nn \l__cmd_tmpa_tl { #3 #4 } + \__cmd_copy_expandable:nnN {#1} {#2} + } +\cs_new_protected:Npn \__cmd_copy_grabber_m:w { \__cmd_copy_expandable:nnN } +\cs_new_eq:NN \__cmd_copy_grabber_m_long:w \__cmd_copy_grabber_m:w +\cs_new_protected:Npn \__cmd_copy_environment:nnNN #1 #2 #3 #4 + { + \cs_set_eq:cc { environment~ #1 ~ code } { environment~ #2 ~ code } + \__cmd_set_eq_if_exist:cc + { environment~ #1 ~ defaults } { environment~ #2 ~ defaults } + \cs_set_protected_nopar:cpx { environment~ #1 } + { \exp_after:wN \__cmd_copy_environment:Nnnnnnn #4 {#1} } + \cs_set_eq:cc {#1} { environment~ #1 } + } +\cs_new:Npn \__cmd_copy_environment:Nnnnnnn #1 #2 #3 #4 #5 #6 #7 + { #1 \exp_not:n { {#2} } {#7} \exp_not:n { {#4} {#5} {#6} } } +\cs_new_protected:Npn \__cmd_copy_environment_end:nnNN #1 #2 + { + \__cmd_check_end:Nn \l__cmd_tmpa_tl {#1} + \__cmd_check_end:Nn \l__cmd_tmpb_tl {#2} + \exp_args:Noo \__cmd_copy_environment_end_aux:nnNN + { \l__cmd_tmpa_tl } { \l__cmd_tmpb_tl } + } +\cs_new_protected:Npn \__cmd_copy_environment_end_aux:nnNN #1 #2 #3 #4 + { + \cs_set_nopar:cpx { environment~ #1 ~end } + { \exp_not:c { environment~ #1 ~end~aux } } + \cs_set_eq:cc + { environment~ #1 ~end~aux~ } { environment~ #2 ~end~aux~ } + \cs_set_eq:cc { end #1 } { environment~ #1 ~end } + } +\cs_new_protected:Npn \__cmd_check_end:Nn #1 #2 + { + \tl_set:Nx #1 { \__cmd_check_end:n {#2} } + \token_if_eq_meaning:NNT #1 \q_nil + { \__cmd_cant_copy:nwn { invalid-end } } + } +\cs_set_protected:Npn \__cmd_tmp:w #1 + { + \cs_new:Npn \__cmd_check_end:n ##1 + { + \exp_after:wN \__cmd_check_end:w \tl_to_str:n {##1} + #1 \q_mark #1 \q_stop + } + \cs_new:Npn \__cmd_check_end:w ##1 #1 ##2 #1 ##3 \q_stop + { \if_meaning:w ##2 \q_mark \exp_not:N \q_nil \else: ##2 \fi: } + } +\exp_args:No \__cmd_tmp:w { \tl_to_str:n { end } } +\cs_new_protected:Npn \__cmd_show:N #1 + { + \use:x + { + \int_set:Nn \tex_escapechar:D { 92 } + \exp_not:N \__cmd_cmd_type_cases:NnnnnF \exp_not:N #1 + { \__cmd_show_command:N } + { \__cmd_show_expandable:N } + { \__cmd_show_environment:N } + { \__cmd_show_environment_end:N } + { \__cmd_cant_copy:nwn { non-ltcmd } } + \exp_not:N #1 + \exp_not:N \__cmd_break_point:n { \cs_to_str:N #1 } + \int_set:Nn \tex_escapechar:D { \int_use:N \tex_escapechar:D } + } + } +\cs_new_protected:Npn \__cmd_show_command:N #1 + { \exp_after:wN \__cmd_show_command:NnNNwN #1 \q__cmd #1 } +\cs_new_protected:Npn \__cmd_show_command:NnNNwN #1 #2 #3 #4 #5 \q__cmd #6 + { \__cmd_show_command_aux:nNNn { document~command } #6 #4 {#2} } +\cs_new_protected:Npn \__cmd_show_expandable:N #1 + { \exp_after:wN \__cmd_show_expandable:NnNNNNnN #1 #1 } +\cs_new_protected:Npn \__cmd_show_expandable:NnNNNNnN #1 #2 #3 #4 #5 #6 #7 #8 + { \__cmd_show_command_aux:nNNn { expandable~document~command } #8 #5 {#2} } +\cs_new_protected:Npn \__cmd_show_command_aux:nNNn #1 #2 #3 #4 + { + \__cmd_split_signature:n {#4} + \iow_term:x + { + > ~ \token_to_str:N #2 = #1: \iow_newline: + \tl_use:N \l__cmd_tmpa_tl + -> \cs_replacement_spec:N #3 . + } + } +\cs_new_protected:Npn \__cmd_show_environment:N #1 + { + \exp_after:wN \__cmd_show_environment:Nnnw #1 \q__cmd + \iow_term:x + { + > ~ \token_to_str:N \end { \cs_to_str:N #1 } : \iow_newline: + -> \exp_args:Nc \cs_replacement_spec:N + { environment~ \cs_to_str:N #1 ~end~aux~ } . + } + } +\cs_new_protected:Npn \__cmd_show_environment:Nnnw #1 #2 #3 #4 \q__cmd + { + \use:x + { + \__cmd_show_command_aux:nNNn { document~environment } + { \exp_not:N \begin {#3} } + \exp_not:c { environment~ #3 ~ code } + {#2} + } + } +\cs_new_protected:Npn \__cmd_show_environment_end:N #1 + { + \exp_args:NNx \__cmd_check_end:Nn \l__cmd_tmpa_tl { \cs_to_str:N #1 } + \exp_args:Nc \__cmd_show_environment:N { \l__cmd_tmpa_tl } + } +\tl_gput_right:Nn \@showcommandlisthook + { { \__kernel_cmd_if_xparse:NTF \__cmd_show:N } } +\cs_new_protected:Npn \__cmd_split_signature:n #1 + { + \int_set:Nn \l__cmd_current_arg_int { 1 } + \tl_clear:N \l__cmd_tmpa_tl + \tl_clear:N \l__cmd_tmpb_tl + \__cmd_split_signature_loop:Nw #1 \q_recursion_tail \q_recursion_stop + } +\cs_new_protected:Npn \__cmd_split_signature_loop:Nw #1 + { + \quark_if_recursion_tail_stop:N #1 + \tl_if_empty:NT \l__cmd_tmpb_tl { \__cmd_split_start_item: } + \tl_if_exist:cTF { c__cmd_show_type_#1_tl } + { + \use:c + { + __cmd_show_ + \if_case:w \tl_use:c { c__cmd_show_type_#1_tl } \exp_stop_f: + delim \or: delims \or: delims_opt \or: opt \or: + e \or: E \or: prefix \or: processor \fi: :Nw + } #1 + } + { \__cmd_split_end_item:n {#1} \__cmd_split_signature_loop:Nw } + } +\cs_set_protected:Npn \__cmd_tmp:w #1 #2 + { + \quark_if_nil:nF {#1} + { \tl_const:cn { c__cmd_show_type_#1_tl } {#2} \__cmd_tmp:w } + } +\__cmd_tmp:w t0 r1 d1 R2 D2 O3 e4 E5 +6 !6 >7 \q_nil \q_nil +\cs_new_protected:Npn \__cmd_show_delim:Nw #1 #2 + { \__cmd_split_end_item:n { #1 #2 } \__cmd_split_signature_loop:Nw } +\cs_new_protected:Npn \__cmd_show_delims:Nw #1 #2 #3 + { \__cmd_split_end_item:n { #1 #2 #3 } \__cmd_split_signature_loop:Nw } +\cs_new_protected:Npn \__cmd_show_delims_opt:Nw #1 #2 #3 #4 + { \__cmd_split_end_item:n { #1 #2 #3 {#4} } \__cmd_split_signature_loop:Nw } +\cs_new_protected:Npn \__cmd_show_opt:Nw #1 #2 + { \__cmd_split_end_item:n { #1 {#2} } \__cmd_split_signature_loop:Nw } +\cs_new_protected:Npn \__cmd_show_e:Nw #1 #2 + { + \tl_map_inline:nn {#2} + { + \__cmd_split_start_item: + \__cmd_split_end_item:n { #1 ##1 } + } + \__cmd_split_signature_loop:Nw + } +\cs_set_protected:Npn \__cmd_tmp:w #1 + { + \cs_new_protected:Npn \__cmd_show_E:Nw ##1 ##2 ##3 + { + \cs_set_protected:Npn \__cmd_tmp:w ####1 ####2 + { + \__cmd_split_start_item: + \__cmd_split_end_item:n { ##1 ####1 {####2} } + } + \__cmd_tl_mapthread_function:nnN {##2} + { ##3 {#1} {#1} {#1} {#1} {#1} {#1} {#1} {#1} {#1} } \__cmd_tmp:w + \__cmd_split_signature_loop:Nw + } + } +\exp_args:NV \__cmd_tmp:w \c_novalue_tl +\cs_new_protected:Npn \__cmd_show_prefix:Nw #1 + { \__cmd_split_add_item:n {#1} \__cmd_split_signature_loop:Nw } +\cs_new_protected:Npn \__cmd_show_processor:Nw #1 #2 + { \__cmd_split_add_item:n { #1 {#2} } \__cmd_split_signature_loop:Nw } +\cs_new_protected:Npn \__cmd_split_start_item: + { + \tl_set:Nx \l__cmd_tmpb_tl + { ~ \c_space_tl \c_hash_str \int_use:N \l__cmd_current_arg_int : } + } +\cs_new_protected:Npn \__cmd_split_add_item:n #1 + { \tl_put_right:Nx \l__cmd_tmpb_tl { \tl_to_str:n {#1} } } +\cs_new_protected:Npn \__cmd_split_end_item:n #1 + { + \tl_put_right:Nx \l__cmd_tmpa_tl + { \l__cmd_tmpb_tl \tl_to_str:n {#1} \iow_newline: } + \tl_clear:N \l__cmd_tmpb_tl + \int_incr:N \l__cmd_current_arg_int + } \cs_new_protected:Npn \__cmd_grab_b:w { \__cmd_grab_b_aux:NNw \cs_set_protected_nopar:Npn \tl_trim_spaces:n } \cs_new_protected:Npn \__cmd_grab_b_long:w @@ -3473,23 +3819,40 @@ #1 {#2} {#4} \__cmd_tl_mapthread_loop:w #1#3 \q_mark } -\cs_new_protected:Npn \__kernel_cmd_if_xparse:NTF #1 +\cs_new_protected:Npn \__cmd_cmd_type_cases:NnnnnF #1 #2 #3 #4 #5 #6 { - \exp_args:Nf \str_case_e:nnTF + \exp_args:Ne \str_case_e:nnF { \exp_args:Nf \tl_if_empty:nT { \cs_argument_spec:N #1 } { - \exp_last_unbraced:Nf \__cmd_cmd_if_xparse_aux:w - { \cs_replacement_spec:N #1 } ~ \q_stop + \token_if_macro:NT #1 + { + \exp_after:wN \exp_after:wN + \exp_after:wN \token_to_str:N + \exp_after:wN \use_i_delimit_by_q_stop:nw + #1 \scan_stop: \q_stop + } } } { - { \token_to_str:N \__cmd_start:nNNnnn } { } - { \token_to_str:N \__cmd_start_expandable:nNNNNn } { } - { \token_to_str:N \__cmd_start_env:nnnnn } { } + { \token_to_str:N \__cmd_start:nNNnnn } {#2} + { \token_to_str:N \__cmd_start_expandable:nNNNNn } {#3} + { \token_to_str:N \__cmd_start_env:nnnnn } {#4} + { + \exp_after:wN \token_to_str:N + \cs:w environment~ + \exp_last_unbraced:Ne \use_none:nnn + { \cs_to_str:N #1 } ~end~aux \cs_end: + } {#5} } + {#6} + } +\cs_new_protected:Npn \__kernel_cmd_if_xparse:NTF #1 + { + \__cmd_cmd_type_cases:NnnnnF #1 + { } { } { } { } { \use_iii:nnn } + \use_i:nn } -\cs_new:Npn \__cmd_cmd_if_xparse_aux:w #1 ~ #2 \q_stop {#1} \cs_new_protected:Npn \__cmd_peek_nonspace:NTF { \__cmd_peek_nonspace_aux:nNNTF { } \__cmd_peek_meaning:NTF } \cs_new_protected:Npn \__cmd_peek_nonspace_remove:NTF @@ -3584,6 +3947,13 @@ with~an~environment~that~already~has~a~definition. \\ \\ The~existing~definition~of~'#1'~will~not~be~altered. } +\msg_new:nnnn { cmd } { env-end-already-defined } + { End~of~environment~'#1'~already~defined. } + { + You~have~used~\NewDocumentEnvironment + with~an~environment~that~already~has~a~definition~for~'end#1'. \\ \\ + The~existing~definition~of~'#1'~will~not~be~altered. + } \msg_new:nnnn { cmd } { env-undefined } { Environment~'#1'~undefined. } { @@ -3834,7 +4204,11 @@ { \cs_if_exist:cTF {#1} { \msg_error:nnx { cmd } { env-already-defined } {#1} } - { \__cmd_declare_env:nnnn {#1} {#2} {#3} {#4} } + { + \cs_if_exist:cTF { end #1 } + { \msg_error:nnx { cmd } { env-end-already-defined } {#1} } + { \__cmd_declare_env:nnnn {#1} {#2} {#3} {#4} } + } } \cs_new_protected:Npn \RenewDocumentEnvironment #1#2#3#4 { @@ -3931,9 +4305,8 @@ \ExplSyntaxOff %%% From File: lthooks.dtx -\def\lthooksversion{v1.0n} -\def\lthooksdate{2021/05/26} - +\def\lthooksversion{v1.0r} +\def\lthooksdate{2021/09/06} \ExplSyntaxOn \bool_new:N \g__hook_debug_bool \cs_new_eq:NN \__hook_debug:n \use_none:n @@ -3958,10 +4331,8 @@ \tl_new:N \l__hook_tmpa_tl \tl_new:N \l__hook_tmpb_tl \seq_new:N \g__hook_all_seq -\tl_new:N \g__hook_removal_list_tl \tl_new:N \l__hook_cur_hook_tl \prop_new:N \l__hook_work_prop -\prop_new:N \g__hook_execute_immediately_prop \prop_new:N \g__hook_used_prop \tl_new:N \g__hook_hook_curr_name_tl \seq_new:N \g__hook_name_stack_seq @@ -3970,6 +4341,7 @@ \cs_generate_variant:Nn \tl_show:n { x } \cs_generate_variant:Nn \tl_log:n { x } \scan_new:N \s__hook_mark +\cs_new:Npn \__hook_clean_to_scan:w #1 \s__hook_mark { } \cs_new_protected:Npn \__hook_tl_set:Nn #1#2 { \cs_set_nopar:Npx #1 { \__kernel_exp_not:w {#2} } } \cs_new_protected:Npn \__hook_tl_set:Nx #1#2 @@ -4053,7 +4425,7 @@ } } } -\cs_new_protected:Npn \hook_disable:n #1 +\cs_new_protected:Npn \hook_disable_generic:n #1 { \__hook_normalize_hook_args:Nn \__hook_disable:n {#1} } \cs_new_protected:Npn \__hook_disable:n #1 { @@ -4068,29 +4440,22 @@ { \prg_return_true: } { \prg_return_false: } } -\cs_new_protected:Npn \hook_provide:n #1 - { \__hook_normalize_hook_args:Nn \__hook_provide:nn {#1} { } } -\cs_new_protected:Npn \hook_provide_reversed:n #1 - { \__hook_normalize_hook_args:Nn \__hook_provide:nn {#1} { - } } -\cs_new_protected:Npn \__hook_provide:nn #1 #2 +\cs_new_protected:Npn \hook_activate_generic:n #1 + { \__hook_normalize_hook_args:Nn \__hook_activate_generic:nn {#1} { } } +\cs_new_protected:Npn \__hook_activate_generic:nn #1 #2 { \__hook_if_disabled:nTF {#1} - { \msg_warning:nnn { hooks } { provide-disabled } {#1} } + { \msg_warning:nnn { hooks } { activate-disabled } {#1} } { - \__hook_if_declared:nTF {#1} - { - \str_if_eq:eeF { \tl_use:c { g__hook_#1_reversed_tl } } {#2} - { \msg_error:nnn { hooks } { provide-error } {#1} } - } + \__hook_if_declared:nF {#1} { \tl_new:c { g__hook_#1_declared_tl } \__hook_make_usable:n {#1} - \tl_gset:cn { g__hook_#1_reversed_tl } {#2} + \tl_gset:cx { g__hook_#1_reversed_tl } + { \__hook_if_generic_reversed:nT {#1} { - } } } } } -\cs_new_protected:Npn \hook_provide_pair:nn #1#2 - { \hook_provide:n {#1} \hook_provide_reversed:n {#2} } \cs_new:Npn \__hook_parse_label_default:n #1 { \tl_if_novalue:nTF {#1} @@ -4129,7 +4494,7 @@ { \tl_if_empty:NTF \@currname { - \msg_expandable_error:nnn { kernel } { should-not-happen } + \msg_expandable_error:nnn { latex2e } { should-not-happen } { Empty~default~label. } \__hook_make_name:n { label-missing } } @@ -4176,30 +4541,80 @@ { \__hook_parse_label_default:n {#5} } } } +\tl_gset:Nn \g__hook_hook_curr_name_tl { top-level } +\cs_new_protected:Npn \__hook_curr_name_push:n #1 + { \exp_args:Nx \__hook_curr_name_push_aux:n { \__hook_make_name:n {#1} } } +\cs_new_protected:Npn \__hook_curr_name_push_aux:n #1 + { + \tl_if_blank:nTF {#1} + { \msg_error:nn { hooks } { no-default-label } } + { + \str_if_eq:nnTF {#1} { top-level } + { + \msg_error:nnnnn { hooks } { set-top-level } + { to } { PushDefaultHookLabel } {#1} + } + { + \seq_gpush:NV \g__hook_name_stack_seq \g__hook_hook_curr_name_tl + \tl_gset:Nn \g__hook_hook_curr_name_tl {#1} + } + } + } +\cs_new_protected:Npn \__hook_curr_name_pop: + { + \seq_gpop:NNTF \g__hook_name_stack_seq \l__hook_return_tl + { \tl_gset_eq:NN \g__hook_hook_curr_name_tl \l__hook_return_tl } + { \msg_error:nn { hooks } { extra-pop-label } } + } +\tl_gput_right:Nn \@kernel@after@enddocument@afterlastpage + { \__hook_end_document_label_check: } +\cs_new_protected:Npn \__hook_end_document_label_check: + { + \seq_gpop:NNT \g__hook_name_stack_seq \l__hook_return_tl + { + \msg_error:nnx { hooks } { missing-pop-label } + { \g__hook_hook_curr_name_tl } + \tl_gset_eq:NN \g__hook_hook_curr_name_tl \l__hook_return_tl + \__hook_end_document_label_check: + } + } +\cs_new_protected:Npn \__hook_set_default_hook_label:n #1 + { + \seq_if_empty:NTF \g__hook_name_stack_seq + { + \msg_error:nnnnn { hooks } { set-top-level } + { for } { SetDefaultHookLabel } {#1} + } + { \exp_args:Nx \__hook_set_default_label:n { \__hook_make_name:n {#1} } } + } +\cs_new_protected:Npn \__hook_set_default_label:n #1 + { + \str_if_eq:nnTF {#1} { top-level } + { + \msg_error:nnnnn { hooks } { set-top-level } + { to } { SetDefaultHookLabel } {#1} + } + { \tl_gset:Nn \g__hook_hook_curr_name_tl {#1} } + } \cs_new_protected:Npn \hook_gput_code:nnn #1 #2 { \__hook_normalize_hook_args:Nnn \__hook_gput_code:nnn {#1} {#2} } \cs_new_protected:Npn \__hook_gput_code:nnn #1 #2 #3 { - \prop_if_in:NnTF \g__hook_execute_immediately_prop {#1} + \__hook_if_execute_immediately:nTF {#1} {#3} { - \__hook_if_marked_removal:nnTF {#1} {#2} - { \__hook_unmark_removal:nn {#1} {#2} } + \__hook_if_usable:nTF {#1} { - \__hook_if_usable:nTF {#1} - { - \__hook_hook_gput_code_do:nnn {#1} {#2} {#3} - \__hook_update_hook_code:n {#1} - } - { - \__hook_if_disabled:nTF {#1} - { \msg_error:nnn { hooks } { hook-disabled } {#1} } - { \__hook_try_declaring_generic_hook:nnn {#1} {#2} {#3} } - } + \__hook_hook_gput_code_do:nnn {#1} {#2} {#3} + \__hook_update_hook_code:n {#1} + } + { + \__hook_if_disabled:nTF {#1} + { \msg_error:nnn { hooks } { hook-disabled } {#1} } + { \__hook_try_declaring_generic_hook:nnn {#1} {#2} {#3} } } } } -\cs_generate_variant:Nn \__hook_gput_code:nnn { nxv } \cs_new_protected:Npn \__hook_hook_gput_code_do:nnn #1 #2 #3 { \__hook_debug:n{\iow_term:x{****~ Add~ to~ @@ -4231,86 +4646,92 @@ } \cs_new_protected:Npn \__hook_try_declaring_generic_hook:nnn #1 { - \__hook_try_declaring_generic_hook:nNNnn {#1} - \hook_gput_code:nnn \__hook_gput_undeclared_hook:nnn + \__hook_try_declaring_generic_hook:wnTF #1 / / / \scan_stop: {#1} + \hook_gput_code:nnn + \__hook_gput_undeclared_hook:nnn + {#1} } \cs_new_protected:Npn \__hook_try_declaring_generic_next_hook:nn #1 { - \__hook_try_declaring_generic_hook:nNNnn {#1} - \hook_gput_next_code:nn \__hook_gput_next_do:nn - } -\cs_new_protected:Npn \__hook_try_declaring_generic_hook:nNNnn #1 - { - \__hook_if_file_hook:wTF #1 / / \s__hook_mark - { - \exp_args:Ne \__hook_try_declaring_generic_hook_split:nNNnn - { \exp_args:Ne \__hook_file_hook_normalize:n {#1} } - } - { \__hook_try_declaring_generic_hook_split:nNNnn {#1} } - } -\cs_new_protected:Npn \__hook_try_declaring_generic_hook_split:nNNnn #1 #2 #3 - { \__hook_try_declaring_generic_hook:wnTF #1 / / / \scan_stop: {#1} - { #2 } - { #3 } {#1} + \hook_gput_next_code:nn + \__hook_gput_next_do:nn + {#1} } \prg_new_protected_conditional:Npnn \__hook_try_declaring_generic_hook:wn #1 / #2 / #3 / #4 \scan_stop: #5 { TF } { - \tl_if_empty:nTF {#2} - { \prg_return_false: } + \__hook_if_generic:nTF {#5} { - \prop_if_in:NnTF \c__hook_generics_prop {#1} + \__hook_if_usable:nF {#5} { - \__hook_if_usable:nF {#5} - { - \str_if_eq:nnT {#1} { cmd } - { \__hook_try_put_cmd_hook:n {#5} } - \__hook_make_usable:n {#5} - } - \prop_if_in:NnTF \c__hook_generics_reversed_ii_prop {#2} - { \tl_gset:cn { g__hook_#5_reversed_tl } { - } } - { - \prop_if_in:NnT \c__hook_generics_reversed_iii_prop {#3} - { \tl_gset:cn { g__hook_#5_reversed_tl } { - } } - } - \prg_return_true: + \str_if_eq:nnT {#1} { cmd } + { \__hook_try_put_cmd_hook:n {#5} } + \__hook_make_usable:n {#5} + } + \__hook_if_generic_reversed:nT {#5} + { \tl_gset:cn { g__hook_#5_reversed_tl } { - } } + \prg_return_true: + } + { + \__hook_if_deprecated_generic:nTF {#5} + { + \__hook_deprecated_generic_warn:n {#5} + \exp_after:wN \__hook_declare_deprecated_generic:NNn + \exp:w % \exp_end: } { \prg_return_false: } } } +\cs_new_protected:Npn \__hook_deprecated_generic_warn:n #1 + { \__hook_deprecated_generic_warn:w #1 \s__hook_mark } +\cs_new_protected:Npn \__hook_deprecated_generic_warn:w + #1 / #2 / #3 \s__hook_mark + { + \if_cs_exist:w __hook~#1/#2/#3 \cs_end: \else: + \msg_warning:nnnnn { hooks } { generic-deprecated } {#1} {#2} {#3} + \fi: + \cs_gset_eq:cN { __hook~#1/#2/#3 } \scan_stop: + } +\cs_new_protected:Npn \__hook_do_deprecated_generic:Nn #1 #2 + { \__hook_do_deprecated_generic:Nw #1 #2 \s__hook_mark } +\cs_new_protected:Npn \__hook_do_deprecated_generic:Nw #1 + #2 / #3 / #4 \s__hook_mark + { #1 { #2 / #4 / #3 } } +\cs_new_protected:Npn \__hook_declare_deprecated_generic:NNn #1 #2 #3 + { \__hook_declare_deprecated_generic:NNw #1 #2 #3 \s__hook_mark } +\cs_new_protected:Npn \__hook_declare_deprecated_generic:NNw #1 #2 + #3 / #4 / #5 \s__hook_mark + { + \__hook_try_declaring_generic_hook:wnTF #3 / #5 / #4 / \scan_stop: + { #3 / #5 / #4 } + #1 #2 { #3 / #5 / #4 } + } \prg_new_conditional:Npnn \__hook_if_file_hook:w - #1 / #2 / #3 \s__hook_mark { TF } + #1 / #2 \s__hook_mark #3 { TF } { - \str_if_eq:nnTF {#1} { file } + \__hook_if_generic:nTF {#3} { - \bool_lazy_or:nnTF - { \tl_if_empty_p:n {#3} } - { \str_if_eq_p:nn {#3} { / } } + \str_if_eq:nnTF {#1} { file } + { \prg_return_true: } { \prg_return_false: } - { - \prop_if_in:NnTF \c__hook_generics_file_prop {#2} - { \prg_return_true: } - { \prg_return_false: } - } } { \prg_return_false: } } -\cs_new:Npn \__hook_file_hook_normalize:n #1 - { \__hook_strip_double_slash:n {#1} } -\cs_new:Npn \__hook_strip_double_slash:n #1 - { \__hook_strip_double_slash:w #1 // \s__hook_mark } -\cs_new:Npn \__hook_strip_double_slash:w #1/#2/#3 // #4 \s__hook_mark - { - \tl_if_empty:nTF {#4} - { #1/#2/#3 } - { \__hook_strip_double_slash:w #1/#2/#3 / #4 \s__hook_mark } - } -\prop_const_from_keyval:Nn \c__hook_generics_prop - {cmd=,env=,file=,package=,class=,include=} -\prop_const_from_keyval:Nn \c__hook_generics_reversed_ii_prop {after=,end=} -\prop_const_from_keyval:Nn \c__hook_generics_reversed_iii_prop {after=} -\prop_const_from_keyval:Nn \c__hook_generics_file_prop {before=,after=} +\clist_map_inline:nn { cmd , env , file , package , class , include } + { + \tl_const:cn { c__hook_generic_#1/./before_tl } { + } + \tl_const:cn { c__hook_generic_#1/./after_tl } { - } + } +\tl_const:cn { c__hook_generic_env/./begin_tl } { + } +\tl_const:cn { c__hook_generic_env/./end_tl } { + } +\tl_const:cn { c__hook_generic_include/./end_tl } { - } +\clist_map_inline:nn { file , package , class , include } + { + \tl_const:cn { c__hook_deprecated_#1/./before_tl } { } + \tl_const:cn { c__hook_deprecated_#1/./after_tl } { } + } +\tl_const:cn { c__hook_deprecated_include/./end_tl } { } \cs_new_protected:Npn \hook_gremove_code:nn #1 #2 { \__hook_normalize_hook_args:Nnn \__hook_gremove_code:nn {#1} {#2} } \cs_new_protected:Npn \__hook_gremove_code:nn #1 #2 @@ -4327,37 +4748,22 @@ \str_if_eq:nnTF {#2} { top-level } { \__hook_tl_gclear:c { __hook_toplevel~#1 } } { - \prop_get:cnNTF { g__hook_#1_code_prop } {#2} \l__hook_return_tl - { \__hook_gremove_code_do:nn } - { \__hook_mark_removal:nn } - {#1} {#2} + \prop_gpop:cnNF { g__hook_#1_code_prop } {#2} \l__hook_return_tl + { \msg_warning:nnnn { hooks } { cannot-remove } {#1} {#2} } } } \__hook_if_usable:nT {#1} { \__hook_update_hook_code:n {#1} } } - { \__hook_mark_removal:nn {#1} {#2} } - } -\cs_new_protected:Npn \__hook_gremove_code_do:nn #1 #2 - { \prop_gremove:cn { g__hook_#1_code_prop } {#2} } -\cs_new_protected:Npn \__hook_mark_removal:nn #1 #2 - { - \tl_gput_right:Nx \g__hook_removal_list_tl - { \__hook_removal_tl:nn {#1} {#2} } - } -\cs_new_protected:Npn \__hook_unmark_removal:nn #1 #2 - { - \tl_gremove_once:Nx \g__hook_removal_list_tl - { \__hook_removal_tl:nn {#1} {#2} } - } -\prg_new_protected_conditional:Npnn \__hook_if_marked_removal:nn #1 #2 { TF } - { - \exp_args:NNx \tl_if_in:NnTF \g__hook_removal_list_tl - { \__hook_removal_tl:nn {#1} {#2} } - { \prg_return_true: } { \prg_return_false: } + { + \__hook_if_deprecated_generic:nTF {#1} + { + \__hook_deprecated_generic_warn:n {#1} + \__hook_do_deprecated_generic:Nn \__hook_gremove_code:nn {#1} {#2} + } + { \msg_warning:nnnn { hooks } { cannot-remove } {#1} {#2} } + } } -\cs_new:Npn \__hook_removal_tl:nn #1 #2 - { & \tl_to_str:n {#2} $ \tl_to_str:n {#1} $ } \prop_new:c {g__hook_??_code_prop} \prop_new:c {__hook~??} \tl_new:c {g__hook_??_reversed_tl} @@ -4368,6 +4774,13 @@ } \cs_new_protected:Npn \__hook_gset_rule:nnnn #1#2#3#4 { + \__hook_if_deprecated_generic:nT {#1} + { + \__hook_deprecated_generic_warn:n {#1} + \__hook_do_deprecated_generic:Nn \__hook_gset_rule:nnnn {#1} + {#2} {#3} {#4} + \exp_after:wN \use_none:nnnnnnnnn \use_none:n + } \__hook_init_structure:n {#1} \__hook_rule_gclear:nnn {#1} {#2} {#4} \cs_if_exist_use:cTF { __hook_rule_#3_gset:nnn } @@ -4421,12 +4834,12 @@ \fi: } \cs_new:Npn \__hook_if_label_case:nnnnn #1#2 - { - \cs:w use_ - \if_case:w \__hook_str_compare:nn {#1} {#2} - i \or: ii \else: iii \fi: :nnn - \cs_end: - } + { + \cs:w use_ + \if_case:w \__hook_str_compare:nn {#1} {#2} + i \or: ii \else: iii \fi: :nnn + \cs_end: + } \cs_new_eq:NN \__hook_update_hook_code:n \use_none:n \cs_new_protected:Npn \__hook_initialize_all: { \cs_gset_eq:NN \__hook_update_hook_code:n \__hook_initialize_hook_code:n @@ -4452,7 +4865,7 @@ \__hook_include_legacy_code_chunk:n {#1} \__hook_if_usable:nT {#1} { - \prop_if_empty:cTF {g__hook_#1_code_prop} + \prop_if_empty:cTF { g__hook_#1_code_prop } { \__hook_tl_gset:co { __hook~#1 } { @@ -4668,8 +5081,15 @@ { \__hook_log_cmd:x { >~\@spaces #1 } } \cs_new_protected:Npn \__hook_log:nN #1 #2 { + \__hook_if_deprecated_generic:nT {#1} + { + \__hook_deprecated_generic_warn:n {#1} + \__hook_do_deprecated_generic:Nn \__hook_log:nN {#1} #2 + \exp_after:wN \use_none:nnnnnnnnn \use_none:nnnnn + } \__hook_preamble_hook:n {#1} - \__hook_log_cmd:x { ^^J ->~The~hook~'#1': } + \__hook_log_cmd:x + { ^^J ->~The~ \__hook_if_generic:nT {#1} { generic~ } hook~'#1': } \__hook_if_usable:nF {#1} { \__hook_log_line:x { The~hook~is~not~declared. } } \__hook_if_disabled:nT {#1} @@ -4804,8 +5224,7 @@ \__hook_if_disabled:nTF {#1} { \msg_error:nnn { hooks } { hook-disabled } {#1} } { - \__hook_init_structure:n {#1} - \__hook_if_usable:nTF {#1} + \__hook_if_structure_exist:nTF {#1} { \__hook_gput_next_do:nn {#1} {#2} } { \__hook_try_declaring_generic_next_hook:nn {#1} {#2} } } @@ -4823,68 +5242,60 @@ { \__hook_tl_gset:Nn #1 { \__hook_clear_next:n {#2} } } \__hook_tl_gput_right:Nn #1 } +\cs_new_protected:Npn \hook_gclear_next_code:n #1 + { \__hook_normalize_hook_args:Nn \__hook_clear_next:n {#1} } \cs_new_protected:Npn \__hook_clear_next:n #1 { \cs_gset_eq:cN { __hook_next~#1 } \c_empty_tl } \cs_new_protected:Npn \hook_use:n #1 { - \tl_if_exist:cTF { __hook~#1 } + \tl_if_exist:cT { __hook~#1 } { \__hook_preamble_hook:n {#1} \cs:w __hook~#1 \cs_end: } - { \__hook_use:wn #1 / \s__hook_mark {#1} } } \cs_new:Npn \__hook_use_initialized:n #1 { \if_cs_exist:w __hook~#1 \cs_end: - \else: - \__hook_use_undefined:w + \cs:w __hook~#1 \exp_after:wN \cs_end: \fi: - \cs:w __hook~#1 \__hook_use_end: - } -\cs_new:Npn \__hook_use_undefined:w #1 #2 __hook~#3 \__hook_use_end: - { - #1 % fi - \__hook_use:wn #3 / \s__hook_mark {#3} } \cs_new_protected:Npn \__hook_preamble_hook:n #1 { \__hook_initialize_hook_code:n {#1} } -\cs_new_eq:NN \__hook_use_end: \cs_end: -\cs_new:Npn \__hook_use:wn #1 / #2 \s__hook_mark #3 +\cs_new_protected:Npn \hook_use_once:n #1 { - \str_if_eq:nnTF {#1} { file } - { \__hook_try_file_hook:n {#3} } - { } % Hook doesn't exist + \__hook_if_execute_immediately:nF {#1} + { \__hook_normalize_hook_args:Nn \__hook_use_once:n { \use:n {#1} } } } -\cs_new_protected:Npn \__hook_try_file_hook:n #1 +\cs_new_protected:Npn \__hook_use_once:n #1 { - \__hook_if_file_hook:wTF #1 / / \s__hook_mark - { - \exp_args:Ne \__hook_if_usable_use:n - { \exp_args:Ne \__hook_file_hook_normalize:n {#1} } - } - { \__hook_if_usable_use:n {#1} } % file/ generic hook (e.g. file/before) + \__hook_preamble_hook:n {#1} + \__hook_use_once_set:n {#1} + \__hook_use_initialized:n {#1} + \__hook_use_once_clear:n {#1} } -\cs_new_protected:Npn \__hook_if_usable_use:n #1 +\cs_new_protected:Npn \__hook_use_once_set:n #1 + { \__hook_tl_gset:cn { g__hook_#1_reversed_tl } { I } } +\cs_new_protected:Npn \__hook_use_once_clear:n #1 { - \tl_if_exist:cT { __hook~#1 } - { - \__hook_preamble_hook:n {#1} - \cs:w __hook~#1 \cs_end: - } + \__hook_tl_gclear:c { __hook~#1 } + \__hook_tl_gclear:c { __hook_next~#1 } + \__hook_tl_gclear:c { __hook_toplevel~#1 } + \prop_gclear:c { g__hook_#1_code_prop } } -\cs_new_protected:Npn \hook_use_once:n #1 +\prg_new_conditional:Npnn \__hook_if_execute_immediately:n #1 { F, TF } { - \tl_if_exist:cT { __hook~#1 } + \__hook_if_usable:nTF {#1} { - \tl_set:Nn \l__hook_return_tl {#1} - \__hook_normalize_hook_args:Nn \__hook_use_once_store:n - { \l__hook_return_tl } - \hook_use:n {#1} + \exp_after:wN \__hook_clean_to_scan:w + \if:w I \cs:w g__hook_#1_reversed_tl \cs_end: + \s__hook_mark \prg_return_true: + \else: + \s__hook_mark \prg_return_false: + \fi: } + { \prg_return_false: } } -\cs_new_protected:Npn \__hook_use_once_store:n #1 - { \prop_gput:Nnn \g__hook_execute_immediately_prop {#1} { } } \prg_new_conditional:Npnn \hook_if_empty:n #1 { p , T , F , TF } { @@ -4922,14 +5333,46 @@ } \prg_new_conditional:Npnn \__hook_if_reversed:n #1 { p , T , F , TF } { - \if_int_compare:w \cs:w g__hook_#1_reversed_tl \cs_end: 1 < 0 \exp_stop_f: + \exp_after:wN \__hook_clean_to_scan:w + \if:w - \cs:w g__hook_#1_reversed_tl \cs_end: + \s__hook_mark \prg_return_true: + \else: + \s__hook_mark \prg_return_false: + \fi: + } +\prg_new_conditional:Npnn \__hook_if_generic:n #1 { T, TF } + { \__hook_if_generic:w #1 / / / \s__hook_mark } +\cs_new:Npn \__hook_if_generic:w #1 / #2 / #3 / #4 \s__hook_mark + { + \cs_if_exist:cTF { c__hook_generic_#1/./#3_tl } + { \prg_return_true: } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \__hook_if_deprecated_generic:n #1 { T, TF } + { \__hook_if_deprecated_generic:w #1 / / / \s__hook_mark } +\cs_new:Npn \__hook_if_deprecated_generic:w #1 / #2 / #3 / #4 \s__hook_mark + { + \cs_if_exist:cTF { c__hook_deprecated_#1/./#2_tl } + { + \tl_if_empty:nTF {#3} + { \prg_return_false: } + { \prg_return_true: } + } + { \prg_return_false: } + } +\prg_new_conditional:Npnn \__hook_if_generic_reversed:n #1 { T } + { \__hook_if_generic_reversed:w #1 / / / \scan_stop: } +\cs_new:Npn \__hook_if_generic_reversed:w #1 / #2 / #3 / #4 \scan_stop: + { + \if_charcode:w - \cs:w c__hook_generic_#1/./#3_tl \cs_end: \prg_return_true: \else: \prg_return_false: \fi: } \prop_gput:Nnn \g_msg_module_type_prop { hooks } { LaTeX } -\prop_gput:Nnn \g_msg_module_type_prop { kernel } { LaTeX } +\prop_gput:Nnn \g_msg_module_type_prop { latex2e } { LaTeX } +\prop_gput:Nnn \g_msg_module_name_prop { latex2e } { kernel } \msg_new:nnnn { hooks } { labels-incompatible } { Labels~'#1'~and~'#2'~are~incompatible @@ -4949,7 +5392,7 @@ { Cannot~add~code~to~disabled~hook~'#1'. } { The~hook~'#1'~you~tried~to~add~code~to~was~previously~disabled~ - with~\iow_char:N\\hook_disable:n~or~\iow_char:N\\DisableHook,~so~ + with~\iow_char:N\\hook_disable_generic:n~or~\iow_char:N\\DisableGenericHook,~so~ it~cannot~have~code~added~to~it. } \msg_new:nnn { hooks } { empty-label } @@ -4966,7 +5409,7 @@ { Unknown~ relationship~ '#3'~ between~ labels~ '#2'~ and~ '#4'~ \str_if_eq:nnF {#1} {??} { ~in~hook~'#1' }. ~ - Perhaps~ a~ missspelling? + Perhaps~ a~ misspelling? } { The~ relation~ used~ not~ known~ to~ the~ system.~ Allowed~ values~ are~ @@ -5004,95 +5447,42 @@ Missing~\iow_char:N \\PopDefaultHookLabel. \\ The~label~'#1'~was~pushed~but~never~popped.~Something~is~wrong. } -\msg_new:nnn { kernel } { should-not-happen } +\msg_new:nnn { latex2e } { should-not-happen } { This~should~not~happen.~#1 \\ Please~report~at~https://github.com/latex3/latex2e. } -\msg_new:nnn { hooks } { provide-disabled } +\msg_new:nnn { hooks } { activate-disabled } { - Cannot~ provide~ hook~ '#1'~ because~ it~ is~ disabled! + Cannot~ activate~ hook~ '#1'~ because~ it~ is~ disabled! } -\msg_new:nnnn { hooks } { provide-error } +\msg_new:nnn { hooks } { cannot-remove } { - Hook~'#1'~ already~ declared~ as~ a~ - \__hook_if_reversed:nTF {#1} { reversed } { normal }~ hook! + Cannot~remove~chunk~'#2'~from~hook~'#1'~because~ + \__hook_if_structure_exist:nTF {#1} + { it~does~not~exist~in~that~hook. } + { the~hook~does~not~exist. } } +\msg_new:nnn { hooks } { generic-deprecated } { - You~ attempted~ to~ provide~ the~ hook~'#1'~ as~ a~ - \__hook_if_reversed:nTF {#1} { normal } { reversed }~ hook,~ but~ it~ - was~ already~ previously~ declared~ as~ a~ - \__hook_if_reversed:nTF {#1} { reversed } { normal }~ hook.~ - A~ redeclaration~ is~ not~ possible. + Generic~hook~'#1/#2/#3'~is~deprecated. \\ + Use~hook~'#1/#3/#2'~instead. } \NewDocumentCommand \NewHook { m }{ \hook_new:n {#1} } \NewDocumentCommand \NewReversedHook { m }{ \hook_new_reversed:n {#1} } \NewDocumentCommand \NewMirroredHookPair { mm }{ \hook_new_pair:nn {#1}{#2} } -\NewDocumentCommand \ProvideHook { m }{ \hook_provide:n {#1} } -\NewDocumentCommand \ProvideReversedHook { m }{ \hook_provide_reversed:n {#1} } -\NewDocumentCommand \ProvideMirroredHookPair { mm }{ \hook_provide_pair:nn {#1}{#2} } -\NewDocumentCommand \DisableHook { m }{ \hook_disable:n {#1} } +\NewDocumentCommand \ActivateGenericHook { m }{ \hook_activate_generic:n {#1} } +\NewDocumentCommand \DisableGenericHook { m }{ \hook_disable_generic:n {#1} } \NewDocumentCommand \AddToHook { m o +m } { \hook_gput_code:nnn {#1} {#2} {#3} } \NewDocumentCommand \AddToHookNext { m +m } { \hook_gput_next_code:nn {#1} {#2} } +\NewDocumentCommand \ClearHookNext { m } + { \hook_gclear_next_code:n {#1} } \NewDocumentCommand \RemoveFromHook { m o } { \hook_gremove_code:nn {#1} {#2} } -\tl_gset:Nn \g__hook_hook_curr_name_tl { top-level } -\cs_new_protected:Npn \__hook_curr_name_push:n #1 - { \exp_args:Nx \__hook_curr_name_push_aux:n { \__hook_make_name:n {#1} } } -\cs_new_protected:Npn \__hook_curr_name_push_aux:n #1 - { - \tl_if_blank:nTF {#1} - { \msg_error:nn { hooks } { no-default-label } } - { - \str_if_eq:nnTF {#1} { top-level } - { - \msg_error:nnnnn { hooks } { set-top-level } - { to } { PushDefaultHookLabel } {#1} - } - { - \seq_gpush:NV \g__hook_name_stack_seq \g__hook_hook_curr_name_tl - \tl_gset:Nn \g__hook_hook_curr_name_tl {#1} - } - } - } -\cs_new_protected:Npn \__hook_curr_name_pop: - { - \seq_gpop:NNTF \g__hook_name_stack_seq \l__hook_return_tl - { \tl_gset_eq:NN \g__hook_hook_curr_name_tl \l__hook_return_tl } - { \msg_error:nn { hooks } { extra-pop-label } } - } -\tl_gput_right:Nn \@kernel@after@enddocument@afterlastpage - { \__hook_end_document_label_check: } -\cs_new_protected:Npn \__hook_end_document_label_check: - { - \seq_gpop:NNT \g__hook_name_stack_seq \l__hook_return_tl - { - \msg_error:nnx { hooks } { missing-pop-label } - { \g__hook_hook_curr_name_tl } - \tl_gset_eq:NN \g__hook_hook_curr_name_tl \l__hook_return_tl - \__hook_end_document_label_check: - } - } \NewDocumentCommand \SetDefaultHookLabel { m } - { - \seq_if_empty:NTF \g__hook_name_stack_seq - { - \msg_error:nnnnn { hooks } { set-top-level } - { for } { SetDefaultHookLabel } {#1} - } - { \exp_args:Nx \__hook_set_default_label:n { \__hook_make_name:n {#1} } } - } -\cs_new_protected:Npn \__hook_set_default_label:n #1 - { - \str_if_eq:nnTF {#1} { top-level } - { - \msg_error:nnnnn { hooks } { set-top-level } - { to } { SetDefaultHookLabel } {#1} - } - { \tl_gset:Nn \g__hook_hook_curr_name_tl {#1} } - } + { \__hook_set_default_hook_label:n {#1} } \NewDocumentCommand \PushDefaultHookLabel { m } { \__hook_curr_name_push:n {#1} } \NewDocumentCommand \PopDefaultHookLabel { } @@ -5119,6 +5509,75 @@ \cs_new_eq:NN \IfHookEmptyTF \hook_if_empty:nTF \cs_new_eq:NN \IfHookExistsTF \__hook_if_usable:nTF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\cs_new_protected:Npn \hook_disable:n + { + \__hook_deprecated_warn:nn + { hook_disable:n } + { hook_disable_generic:n } + \hook_disable_generic:n + } +\cs_new_protected:Npn \hook_provide:n + { + \__hook_deprecated_warn:nn + { hook_provide:n } + { hook_activate_generic:n } + \hook_activate_generic:n + } +\cs_new_protected:Npn \hook_provide_reversed:n + { + \__hook_deprecated_warn:nn + { hook_provide_reversed:n } + { hook_activate_generic:n } + \__hook_activate_generic_reversed:n + } +\cs_new_protected:Npn \hook_provide_pair:nn + { + \__hook_deprecated_warn:nn + { hook_provide_pair:nn } + { hook_activate_generic:n } + \__hook_activate_generic_pair:nn + } +\cs_new_protected:Npn \__hook_activate_generic_reversed:n #1 + { \__hook_normalize_hook_args:Nn \__hook_activate_generic:nn {#1} { - } } +\cs_new_protected:Npn \__hook_activate_generic_pair:nn #1#2 + { \hook_activate_generic:n {#1} \__hook_activate_generic_reversed:n {#2} } +\cs_new_protected:Npn \DisableHook + { + \__hook_deprecated_warn:nn + { DisableHook } + { DisableGenericHook } + \hook_disable_generic:n + } +\cs_new_protected:Npn \ProvideHook + { + \__hook_deprecated_warn:nn + { ProvideHook } + { ActivateGenericHook } + \hook_activate_generic:n + } +\cs_new_protected:Npn \ProvideReversedHook + { + \__hook_deprecated_warn:nn + { ProvideReversedHook } + { ActivateGenericHook } + \__hook_activate_generic_reversed:n + } +\cs_new_protected:Npn \ProvideMirroredHookPair + { + \__hook_deprecated_warn:nn + { ProvideMirroredHookPair } + { ActivateGenericHook } + \__hook_activate_generic_pair:nn + } +\cs_new_protected:Npn \__hook_deprecated_warn:nn #1 #2 + { \msg_warning:nnnn { hooks } { deprecated } {#1} {#2} } +\msg_new:nnn { hooks } { deprecated } + { + Command~\iow_char:N\\#1~is~deprecated~and~will~be~removed~in~a~ + future~release. \\ \\ + Use~\iow_char:N\\#2~instead. + } +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \cs_new_eq:NN \@expl@@@initialize@all@@ \__hook_initialize_all: \cs_new_eq:NN \@expl@@@hook@curr@name@pop@@ @@ -5128,8 +5587,8 @@ %% File: ltcmdhooks.dtx (C) Copyright 2020-2021 %% Frank Mittelbach, Phelype Oleinik, LaTeX Team %%% From File: ltcmdhooks.dtx -\def\ltcmdhooksversion{v1.0b} -\def\ltcmdhooksdate{2021/05/26} +\def\ltcmdhooksversion{v1.0d} +\def\ltcmdhooksdate{2021/08/25} \ExplSyntaxOn \tl_new:N \g_hook_patch_action_list_tl \int_new:N \l__hook_patch_num_args_int @@ -5146,10 +5605,7 @@ #1 / #2 / #3 / #4 \s__hook_mark #5 { \__hook_debug:n { \iow_term:n { ->~Adding~cmd~hook~to~'#2'~(#3): } } - \str_case:nnTF {#3} - { { before } { } { after } { } } - { \exp_args:Nc \__hook_patch_cmd_or_delay:Nnn {#2} {#2} {#3} } - { \msg_error:nnnn { hooks } { wrong-cmd-hook } {#2} {#3} } + \exp_args:Nc \__hook_patch_cmd_or_delay:Nnn {#2} {#2} {#3} } \cs_new_protected:Npn \__hook_patch_cmd_or_delay:Nnn #1 #2 #3 { @@ -5237,10 +5693,17 @@ } \cs_new_protected:Npn \__hook_patch_DeclareRobustCommand:Nnn #1 { - \exp_args:Nc \@if@newcommand { \cs_to_str:N #1 ~ } - { \exp_args:Nc \__hook_patch_newcommand:Nnn } - { \exp_args:NNc \__hook_patch_expand_redefine:NNnn \c_false_bool } - { \cs_to_str:N #1 ~ } + \exp_args:Nc \__hook_patch_DeclareRobustCommand_aux:Nnn + { \cs_to_str:N #1 ~ } + } +\cs_new_protected:Npn \__hook_patch_DeclareRobustCommand_aux:Nnn #1 + { + \robust@command@chk@safe #1 + { \@if@newcommand #1 } + { \use_ii:nn } + { \__hook_patch_newcommand:Nnn } + { \__hook_patch_expand_redefine:NNnn \c_false_bool } + #1 } \cs_new_protected:Npn \__hook_patch_newcommand:Nnn #1 { @@ -5408,14 +5871,6 @@ \tl_rescan:nV { #4 \__hook_patch_required_catcodes: } \l__hook_tmpa_tl \cs_set_eq:NN #1 \kerneltmpDoNotUse } -\msg_new:nnnn { hooks } { wrong-cmd-hook } - { - Generic~hook~`cmd/#1/#2'~is~invalid. - } - { - You~tried~to~add~a~generic~hook~to~command~\iow_char:N \\#1,~but~`#2'~ - is~an~invalid~component.~Only~`before'~or~`after'~are~allowed. - } \msg_new:nnnn { hooks } { cant-patch } { Generic~hooks~cannot~be~added~to~'#1'. @@ -5616,6 +6071,22 @@ Type H <return> for immediate help.}% Class #1 Info: #2% }% } +\def\ClassNote#1#2{% + \GenericWarning{% + (#1) \space\space\@spaces\@spaces + }{% + Class #1 Info: #2% + }% +} +\def\ClassNoteNoLine#1#2{\ClassNote{#1}{#2\@gobble}} +\def\PackageNote#1#2{% + \GenericWarning{% + (#1) \@spaces\@spaces\@spaces + }{% + Package #1 Info: #2% + }% +} +\def\PackageNoteNoLine#1#2{\PackageNote{#1}{#2\@gobble}} \gdef\@latex@error#1#2{% \GenericError{% \space\space\space\@spaces\@spaces\@spaces @@ -5688,8 +6159,9 @@ Type H <return> for immediate help.}% \gdef\@nodocument{% \@latex@error{Missing \protect\begin{document}}\@ehd} \gdef\@badend#1{% - \@latex@error{\protect\begin{\@currenvir}\@currenvline - \space ended by \protect\end{#1}}\@eha} + \@latex@error{\protect\begin + {\detokenize\expandafter{\@currenvir}}\@currenvline + \space ended by \protect\end{\detokenize{#1}}}\@eha} \gdef\@badmath{% \@latex@error{Bad math environment delimiter}\@eha} \gdef\@toodeep{% @@ -5736,8 +6208,8 @@ Type H <return> for immediate help.}% \def\@restorepar{\def\par{\@par}} %% File: ltpara.dtx (C) Copyright 2020-2021 %%% From File: ltpara.dtx -\def\ltparaversion{v1.0g} -\def\ltparadate{2021/05/27} +\def\ltparaversion{v1.0j} +\def\ltparadate{2021/09/18} \ExplSyntaxOn @@ -5788,14 +6260,15 @@ Type H <return> for immediate help.}% \cs_set_eq:NN \IndentBox \g_para_indent_box \cs_set_eq:NN \OmitIndent \para_omit_indent: \cs_new_protected:Npn \para_end: { + \scan_stop: \mode_if_horizontal:TF { \mode_if_inner:F { \tex_unskip:D \hook_use:n{para/end} \@kernel@after@para@end \mode_if_horizontal:TF { - \if_int_compare:w 0 < \tex_lastnodetype:D - \tex_kern:D \c_zero_dim + \if_int_compare:w 11 = \tex_lastnodetype:D + \tex_hskip:D \c_zero_dim \fi: \tex_par:D \hook_use:n{para/after} @@ -5815,7 +6288,7 @@ Type H <return> for immediate help.}% \__para_handle_indent: \the\everypar } } - { \msg_error:nn { kernel }{ raw-para } } + { \msg_error:nn { latex2e }{ raw-para } } \tex_indent:D } \cs_new:Npn \para_raw_noindent: { @@ -5825,7 +6298,7 @@ Type H <return> for immediate help.}% \tex_everypar:D { \g__para_standard_everypar_tl } \the\everypar } } - { \msg_error:nn { kernel }{ raw-para } } + { \msg_error:nn { latex2e }{ raw-para } } \tex_noindent:D } \cs_new_eq:NN \para_raw_end: \tex_par:D @@ -5847,7 +6320,7 @@ Type H <return> for immediate help.}% in~ #2~ mode,~ but~ it~ didn't.~ Examine~ the~ hook~ code~ with~ \iow_char:N \\ShowHook~ to~ find~ the~ issue. } -\msg_new:nnnn { kernel } { raw-para } +\msg_new:nnnn { latex2e } { raw-para } { Not~ in~ vertical~ mode. } @@ -6255,12 +6728,12 @@ Type H <return> for immediate help.}% \fi \@filehook@set@CurrentFile \UseHook{include/before}% - \UseHook{include/before/#1}% + \UseOneTimeHook{include/#1/before}% \@input@{#1.tex}% - \UseHook{include/end/#1}% + \UseOneTimeHook{include/#1/end}% \UseHook{include/end}% \clearpage - \UseHook{include/after/#1}% + \UseOneTimeHook{include/#1/after}% \UseHook{include/after}% \clearpage \@writeckpt{#1}% @@ -6272,6 +6745,9 @@ Type H <return> for immediate help.}% \@nameuse{cp@#1}% \fi \let\@auxout\@mainaux} +\NewHook{include/before} +\NewReversedHook{include/end} +\NewReversedHook{include/after} \def\@writeckpt#1{% \if@filesw \immediate\write\@partaux{\string\@setckpt{#1}\@charlb}% @@ -6733,30 +7209,24 @@ Type H <return> for immediate help.}% \@ifundefined{c@#2}{\@nocounterr{#2}}% {% else both counter and within are defined #3}}} - -\def\counterwithout {\@ifstar\counterwithout@s\counterwithout@x} -\def\counterwithout@s#1#2{% - \@ifbothcounters{#1}{#2}{\@removefromreset{#1}{#2}}} -\def\counterwithout@x#1#2{% - \@ifbothcounters{#1}{#2}% - {\@removefromreset{#1}{#2}% - \expandafter - \gdef\csname the#1\expandafter\endcsname\expandafter - {\expandafter - \@arabic\csname c@#1\endcsname}}} - -\def\counterwithin{\@ifstar\counterwithin@s\counterwithin@x} -\def\counterwithin@s#1#2{% - \@ifbothcounters{#1}{#2}{\@addtoreset{#1}{#2}}} -\def\counterwithin@x#1#2{% - \@ifbothcounters{#1}{#2}% - {\@addtoreset{#1}{#2}% - \expandafter - \gdef\csname the#1\expandafter\endcsname\expandafter - {\csname the#2\expandafter\endcsname\expandafter - .\expandafter - \@arabic\csname c@#1\endcsname}}} - +\NewDocumentCommand \counterwithout {sO{\arabic}mm}{% + \@ifbothcounters{#3}{#4}{% + \@removefromreset{#3}{#4}% + \IfBooleanF #1% + {\expandafter + \gdef\csname the#3\endcsname {#2{#3}}}% + }% +} +\NewDocumentCommand \counterwithin {sO{\arabic}mm}{% + \@ifbothcounters{#3}{#4}{% + \@addtoreset{#3}{#4}% + \IfBooleanF #1% + {\expandafter + \gdef\csname the#3\expandafter\endcsname + \expandafter + {\csname the#4\endcsname .#2{#3}}}% + }% +} \def\arabic#1{\expandafter\@arabic\csname c@#1\endcsname} \def\roman#1{\expandafter\@roman\csname c@#1\endcsname} \def\Roman#1{\expandafter\@Roman\csname c@#1\endcsname} @@ -9128,6 +9598,9 @@ Type H <return> for immediate help.}% \fontshape\itdefault\selectfont} \let\DeclareFontSeriesDefault\@undefined % for rollback \newcommand\DeclareFontSeriesDefault[3][]{% + \expand@font@defaults + \maybe@update@bfseries@defaults + \maybe@update@mdseries@defaults \def\reserved@a{#1}% \ifx\reserved@a\@empty \ifcsname #2series\endcsname % supported are @@ -9155,6 +9628,8 @@ Type H <return> for immediate help.}% \fi } + + \def\bfseries@rm{bx} \def\bfseries@sf{bx} \def\bfseries@tt{bx} @@ -9235,18 +9710,20 @@ Type H <return> for immediate help.}% }% \expandafter\let\csname ver@mweights.sty\endcsname\fmtversion -\def\expand@font@defaults{% - \edef\rmdef@ult{\rmdefault}% - \edef\sfdef@ult{\sfdefault}% - \edef\ttdef@ult{\ttdefault}% - \series@maybe@drop@one@m\bfdefault\bfdef@ult - \series@maybe@drop@one@m\mddefault\mddef@ult - \UseHook{expand@font@defaults}% -} - \DeclareRobustCommand\bfseries{% \not@math@alphabet\bfseries\mathbf \expand@font@defaults + \maybe@update@bfseries@defaults + \ifx\f@family\rmdef@ult \fontseries\bfseries@rm + \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf + \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt + \else \fontseries\bfdefault + \fi\fi\fi + \UseHook{bfseries}% + \selectfont +} + +\def\maybe@update@bfseries@defaults{% \ifx\bfdefault\bfdefault@previous\else \expandafter\def\expandafter\bfdefault \expandafter{\bfdefault\@empty}% @@ -9256,18 +9733,22 @@ Type H <return> for immediate help.}% \let\bfseries@tt\bfdef@ult \UseHook{bfseries/defaults}% \fi - \ifx\f@family\rmdef@ult \fontseries\bfseries@rm - \else\ifx\f@family\sfdef@ult \fontseries\bfseries@sf - \else\ifx\f@family\ttdef@ult \fontseries\bfseries@tt - \else \fontseries\bfdefault - \fi\fi\fi - \UseHook{bfseries}% - \selectfont } \DeclareRobustCommand\mdseries{% \not@math@alphabet\mdseries\relax \expand@font@defaults + \maybe@update@mdseries@defaults + \ifx\f@family\rmdef@ult \fontseries\mdseries@rm + \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf + \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt + \else \fontseries\mddefault + \fi\fi\fi + \UseHook{mdseries}% + \selectfont +} + +\def\maybe@update@mdseries@defaults{% \ifx\mddefault\mddefault@previous\else \expandafter\def\expandafter\mddefault\expandafter{\mddefault\@empty}% \let\mddefault@previous\mddefault @@ -9276,13 +9757,17 @@ Type H <return> for immediate help.}% \let\mdseries@tt\mddef@ult \UseHook{mdseries/defaults}% \fi - \ifx\f@family\rmdef@ult \fontseries\mdseries@rm - \else\ifx\f@family\sfdef@ult \fontseries\mdseries@sf - \else\ifx\f@family\ttdef@ult \fontseries\mdseries@tt - \else \fontseries\mddefault - \fi\fi\fi - \UseHook{mdseries}% - \selectfont +} + + + +\def\expand@font@defaults{% + \edef\rmdef@ult{\rmdefault}% + \edef\sfdef@ult{\sfdefault}% + \edef\ttdef@ult{\ttdefault}% + \series@maybe@drop@one@m\bfdefault\bfdef@ult + \series@maybe@drop@one@m\mddefault\mddef@ult + \UseHook{expand@font@defaults}% } \DeclareRobustCommand\rmfamily{% @@ -9513,7 +9998,7 @@ Type H <return> for immediate help.}% \let \check@icl \@empty \let \check@icr \@empty \def \text@command #1{% - \def \reserved@a {#1}% + \edef \reserved@a {\unexpanded{#1}}% \ifx \reserved@a \@empty \let \check@icl \@empty \let \check@icr \@empty @@ -12291,7 +12776,9 @@ Type H <return> for immediate help.}% \protected@write\@auxout {\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% {\string\@writefile{#1}{#2}}} -\def\contentsline#1{\csname l@#1\endcsname} +\def\contentsline#1#2#3#4{\gdef\@contentsline@destination{#4}% + \csname l@#1\endcsname{#2}{#3}} +\let\@contentsline@destination\@empty \def\@dottedtocline#1#2#3#4#5{% \ifnum #1>\c@tocdepth \else \vskip \z@ \@plus.2\p@ @@ -12776,6 +13263,7 @@ Type H <return> for immediate help.}% \vfuzz\hfuzz} \overfullrule 0pt %%% From File: ltclass.dtx + \newif\if@compatibility \def\@documentclasshook{% \ifx\@normalsize\@undefined @@ -12784,18 +13272,14 @@ Type H <return> for immediate help.}% } \let\@declaredoptions\@empty \let\@classoptionslist\relax -\@onlypreamble\@classoptionslist \let\@raw@classoptionslist\relax \let\@unusedoptionlist\@empty -\@onlypreamble\@unusedoptionlist \let\CurrentOption\@empty \let\@currpath\@empty \let\@currname\@empty \global\let\@currext=\@empty \def\@clsextension{cls} \def\@pkgextension{sty} -\@onlypreamble\@clsextension -\@onlypreamble\@pkgextension \def\@pushfilename{% \@expl@push@filename@@ \xdef\@currnamestack{% @@ -12828,32 +13312,22 @@ Type H <return> for immediate help.}% \xdef\@kernel@currpathstack{#1}} \def\@ptionlist#1{% \@ifundefined{opt@#1}\@empty{\csname opt@#1\endcsname}} -\@onlypreamble\@ptionlist \def\@ifpackageloaded{\@ifl@aded\@pkgextension} \def\@ifclassloaded{\@ifl@aded\@clsextension} -\@onlypreamble\@ifpackageloaded -\@onlypreamble\@ifclassloaded \def\@ifl@aded#1#2{% \expandafter\ifx\csname ver@#2.#1\endcsname\relax \expandafter\@secondoftwo \else \expandafter\@firstoftwo \fi} -\@onlypreamble\@ifl@aded \def\@ifpackagelater{\@ifl@ter\@pkgextension} \def\@ifclasslater{\@ifl@ter\@clsextension} -\@onlypreamble\@ifpackagelater -\@onlypreamble\@ifclasslater \def\IfFormatAtLeastTF{\@ifl@t@r\fmtversion} \let\IfPackageAtLeastTF\@ifpackagelater \let\IfClassAtLeastTF\@ifclasslater -\@onlypreamble\IfFormatAtLeastTF -\@onlypreamble\IfPackageAtLeastTF -\@onlypreamble\IfClassAtLeastTF \def\@ifl@ter#1#2{% \expandafter\@ifl@t@r \csname ver@#2.#1\endcsname} -\@onlypreamble\@ifl@ter \def\@ifl@t@r#1#2{% \ifnum\expandafter\@parse@version@#1//00\@nil<% \expandafter\@parse@version@#2//00\@nil @@ -12862,7 +13336,6 @@ Type H <return> for immediate help.}% \expandafter\@firstoftwo \fi} \def\@parse@version@#1{\@parse@version0#1} -\@onlypreamble\@ifl@t@r \def\@parse@version#1/#2/#3#4#5\@nil{% \@parse@version@dash#1-#2-#3#4\@nil } @@ -12870,11 +13343,8 @@ Type H <return> for immediate help.}% \if\relax#2\relax\else#1\fi#2#3#4 } \def\@ifpackagewith{\@if@ptions\@pkgextension} \def\@ifclasswith{\@if@ptions\@clsextension} -\@onlypreamble\@ifpackagewith -\@onlypreamble\@ifclasswith \def\@if@ptions#1#2{% \@expandtwoargs\@if@pti@ns{\@ptionlist{#2.#1}}} -\@onlypreamble\@if@ptions \def\@if@pti@ns#1#2{% \let\reserved@a\@firstoftwo \edef\reserved@b{\zap@space#2 \@empty}% @@ -12889,7 +13359,10 @@ Type H <return> for immediate help.}% \fi }% \reserved@a} -\@onlypreamble\@if@pti@ns +\let \IfPackageLoadedTF \@ifpackageloaded +\let \IfClassLoadedTF \@ifclassloaded +\let \IfPackageLoadedWithOptionsTF \@ifpackagewith +\let \IfClassLoadedWithOptionsTF \@ifclasswith \def\ProvidesPackage#1{% \xdef\@gtempa{#1}% \@expandtwoargs\@expl@str@if@eq@@nnTF @@ -13134,7 +13607,7 @@ Type H <return> for immediate help.}% \def\reserved@b##1,{% \ifx\@nnil##1\relax\else \ifx\@nnil##1\@nnil\else - \noexpand\@onefilewithoptions##1[{#2}][{#4}]% + \noexpand\@onefilewithoptions##1[{\unexpanded{#2}}][{#4}]% \noexpand\@pkgextension \fi \expandafter\reserved@b @@ -13234,11 +13707,11 @@ Type H <return> for immediate help.}% \expandafter\let\csname\@currname.\@currext-h@@k\endcsname\@empty \ifx\@currext\@pkgextension \UseHook{package/before}% - \UseHook{package/before/\@currname}% + \UseOneTimeHook{package/\@currname/before}% \else \ifx\@currext\@clsextension \UseHook{class/before}% - \UseHook{class/before/\@currname}% + \UseOneTimeHook{class/\@currname/before}% \fi \fi \InputIfFileExists{\@currpath\@currpkg@reqd}{}% @@ -13258,15 +13731,19 @@ Type H <return> for immediate help.}% \csname unprocessedoptions-\@currname.\@currext\endcsname \@undefined \ifx\@currext\@pkgextension - \UseHook{package/after/\@currname}% + \UseOneTimeHook{package/\@currname/after}% \UseHook{package/after}% \else \ifx\@currext\@clsextension - \UseHook{class/after/\@currname}% + \UseOneTimeHook{class/\@currname/after}% \UseHook{class/after}% \fi \fi}% \@ifl@aded\@currext\@currname{}{\reserved@a}} +\NewHook{package/before} +\NewHook{class/before} +\NewReversedHook{package/after} +\NewReversedHook{class/after} \let\@@fileswith@pti@ns\@fileswith@pti@ns \@onlypreamble\@@fileswith@pti@ns \def\@reset@ptions{% @@ -13664,8 +14141,8 @@ Type H <return> for immediate help.}% \fi } %%% From File: ltfilehook.dtx -\providecommand\ltfilehookversion{v1.0k} -\providecommand\ltfilehookdate{2021/05/25} +\providecommand\ltfilehookversion{v1.0l} +\providecommand\ltfilehookdate{2021/08/27} \ExplSyntaxOn \tl_new:N \CurrentFile \tl_new:N \CurrentFilePath @@ -13718,7 +14195,7 @@ Type H <return> for immediate help.}% \seq_gpop:NNTF \g__filehook_input_file_seq \l__filehook_internal_tl { \exp_after:wN \__filehook_file_pop_assign:nnnn \l__filehook_internal_tl } { - \msg_error:nnn { kernel } { should-not-happen } + \msg_error:nnn { latex2e } { should-not-happen } { Tried~to~pop~from~an~empty~file~name~stack. } } } @@ -13754,12 +14231,14 @@ Type H <return> for immediate help.}% {\edef\reserved@a{\unqu@tefilef@und#1\@nil}% \@addtofilelist{\string@makeletter\reserved@a}% \UseHook{file/before}% - \UseHook{file/before/\CurrentFile}% + \UseHook{file/\CurrentFile/before}% \@@input #1% <- trailing space comes from \@filef@und }% - \UseHook{file/after/\CurrentFile}% + \UseHook{file/\CurrentFile/after}% \UseHook{file/after}} \def\unqu@tefilef@und"#1" \@nil{#1} +\NewHook{file/before} +\NewReversedHook{file/after} \ExplSyntaxOn \cs_new_protected:Npn \__filehook_subst_add:nn #1 #2 { @@ -13896,13 +14375,13 @@ Type H <return> for immediate help.}% \cs_generate_variant:Nn \__filehook_file_subst_loop:NN { cc } \cs_new:Npn \__filehook_file_subst_cycle_error:NN #1 #2 { - \__kernel_msg_expandable_error:nnff { kernel } { file-cycle } + \msg_expandable_error:nnff { latex2e } { file-cycle } {#1} { \use:c { @file-subst@ #1 } } \token_if_eq_meaning:NNF #1 #2 { \__filehook_file_subst_cycle_error:cN { @file-subst@ #1 } #2 } } \cs_generate_variant:Nn \__filehook_file_subst_cycle_error:NN { c } -\__kernel_msg_new:nnn { kernel } { file-cycle } +\msg_new:nnn { latex2e } { file-cycle } { File~loop!~#1~replaced~by~#2... } \ExplSyntaxOff \def\disable@package@load#1#2{% @@ -15244,6 +15723,25 @@ Type H <return> for immediate help.}% \fi \fi } +\def\ShowFloat#1{\begingroup + \let \fl@trace \fl@tracemessage + \fl@trace{***Float #1 details:}% + \ifcsname bx@#1\endcsname + \expandafter\fl@ShowFloat\csname bx@#1\endcsname + \else + \fl@trace{Not a float!}% + \fi + \endgroup +} +\def\fl@ShowFloat#1{% + \fl@traceval{\count#1}% % this here should be interpreted on day + \fl@traceval{\ht#1}% + \fl@traceval{\dp#1}% + \fl@traceval{\wd#1}% + {\tracingonline1\showboxbreadth10\showboxdepth3\showbox#1}% +} +\def \fl@traceval #1{\fl@trace{\string #1 = \the #1}} +\def \fl@tracemessage #1{{\let\@elt\@empty\typeout{LaTeX2e: #1}}} \def \suppressfloats {% \@ifnextchar [% \@flstop @@ -15767,7 +16265,7 @@ Type H <return> for immediate help.}% \reserved@a }} \def\@uclclist{\oe\OE\o\O\ae\AE - \dh\DH\dj\DJ\l\L\ng\NG\ss\SS\th\TH} + \dh\DH\dj\DJ\l\L\ng\NG\ss\SS\ij\IJ\th\TH} \protected@edef\MakeUppercase#1{\MakeUppercase{#1}} \protected@edef\MakeLowercase#1{\MakeLowercase{#1}} \let\reserved@a\@filelist @@ -15788,6 +16286,7 @@ Type H <return> for immediate help.}% \endgroup} \let\@filelist\@gobble \def\@addtofilelist#1{\xdef\@filelist{\@filelist,#1}}% +\let \IfPDFManagementActiveTF \@secondoftwo \@input{latex2e-first-aid-for-external-files.ltx} \makeatother \errorstopmode |