%% %% This is file `latex-lab-footnotes.ltx', %% generated with the docstrip utility. %% %% The original source files were: %% %% latex-lab-footnotes.dtx (with options: `kernel') %% %% This is a generated file. %% %% Copyright 2021-2023 LaTeX Project %% %% This file was generated from file(s) of the `LaTeX-lab Bundle'. %% ------------------------------------------------------------------------------------ %% %% It may be distributed and/or modified under the %% 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.3c or later is part of all distributions of LaTeX %% version 2008 or later. %% %% This file may only be distributed together with a copy of the LaTeX %% `LaTeX-lab Bundle'. You may however distribute the `LaTeX-lab Bundle' %% without such generated files. %% %% The newest sources can be found below %% %% https://github.com/latex3/latex2e/required/latex-lab %% %% where one can also log issues in case there are any. %% %% %% File: latex-lab-footnotes.dtx \def\ltlabfootnotedate{2024-03-12} \def\ltlabfootnoteversion{0.8d} \ProvidesFile{latex-lab-footnotes.ltx} [\ltlabfootnotedate\space v\ltlabfootnoteversion\space changes to the footnote interfaces] %% alterations not covered: \ExplSyntaxOn \prop_new:N \l__fnote_tmpa_prop \tl_new:N \l__fnote_tmpa_tl \tl_new:N \l_fnote_type_tl \tl_set:Nn \l_fnote_type_tl {default} \bool_new:N \l_fnote_link_bool \bool_set_true:N \l_fnote_link_bool \tl_new:N \l_fnote_link_type_tl \tl_set:Nn \l_fnote_link_type_tl {link} \tl_new:N \l__fnote_linktarget_tl \tl_new:N \l__fnote_currentlabel_tl \seq_new:N \l__fnote_currentrefs_seq \bool_new:N \l__fnote_autodetect_bool \bool_set_true:N \l__fnote_autodetect_bool \tl_new:N \l__fnote_currentstruct_tl \tl_set:Nn \l__fnote_currentstruct_tl {1} \cs_generate_variant:Nn \hook_gput_code:nnn{nne} \cs_generate_variant:Nn \tag_struct_use:n {e} \cs_new_protected:Npn \fnote_step_fnmark:nn #1#2 { \tl_if_novalue:nTF {#1} { \stepcounter {#2} \protected@xdef \@thefnmark { \use:c { the#2 } } } { \group_begin: \int_set:cn { c@#2 }{ #1 } \unrestored@protected@xdef \@thefnmark { \use:c { the#2 } } \group_end: } } \cs_new_protected:Npn \fnote_set_fnmark:nn #1#2 { \tl_if_novalue:nTF {#1} { \protected@xdef \@thefnmark { \use:c { the#2 } } } { \group_begin: \int_set:cn { c@#2 }{ #1 } \unrestored@protected@xdef \@thefnmark { \use:c { the#2 } } \group_end: } } \NewMirroredHookPair{fnmark/before}{fnmark/after} \NewHook{fnmark} \NewHook{fnmark/begin} \NewHook{fnmark/end} \NewMirroredHookPair{fntext/before}{fntext/after} \NewHook{fntext} \NewHook{fntext/para} \NewHook{fntext/begin} \NewHook{fntext/end} \bool_new:N \g_fnote_debug_bool \cs_new_protected:Npn \DebugFNotesOn { \bool_gset_true:N \g_fnote_debug_bool } \cs_new_protected:Npn \DebugFNotesOff { \bool_gset_false:N \g_fnote_debug_bool } \cs_new_protected:Npn \__fnote_debug_footnotemark: { \bool_if:NT \g_fnote_debug_bool { \hook_log:n {fnmark/before} \hook_log:n {fnmark} \hook_log:n {fnmark/begin} \hook_log:n {fnmark/end} \hook_log:n {fnmark/after} \cs_gset_eq:NN \__fnote_debug_footnotemark: \prg_do_nothing: } } \cs_new_protected:Npn \__fnote_debug_footnotetext: { \bool_if:NT \g_fnote_debug_bool { \socket_log:n {fntext/process} \socket_log:n {fntext/make} \socket_log:n {fntext/begin} \socket_log:n {fntext/end} \socket_log:n {fntext/mark} \socket_log:n {fntext/text} \socket_log:n {tagsupport/fnmark} \socket_log:n {tagsupport/fntext/begin} \socket_log:n {tagsupport/fntext/end} \socket_log:n {tagsupport/fntext/mark} \socket_log:n {tagsupport/fntext/text} \hook_log:n {fntext/before} \hook_log:n {fntext} \hook_log:n {fntext/para} \hook_log:n {fntext/begin} \hook_log:n {fntext/end} \hook_log:n {fntext/after} \cs_gset_eq:NN \__fnote_debug_footnotetext: \prg_do_nothing: } } \cs_new_protected:Npn \fnote_footnotemark: { \__fnote_debug_footnotemark: \hook_use:n {fnmark/before} \leavevmode \ifhmode \edef\@x@sf{\the\spacefactor} \hook_use:n {fnmark} \nobreak \fi \hook_use:n {fnmark/begin} \socket_use:nn {tagsupport/fnmark} \@makefnmark \__fnote_footnotemark_finish: } \cs_new_protected:Npn \__fnote_footnotemark_default_finish: { \UseHook{fnmark/end} \ifhmode \spacefactor \@x@sf \relax \fi \UseHook{fnmark/after} } \cs_new_eq:NN \__fnote_footnotemark_finish: \__fnote_footnotemark_default_finish: \NewSocket{tagsupport/fnmark}{1} \cs_set_eq:NN \@footnotemark \fnote_footnotemark: \cs_new_protected:Npn \fnote_footnotetext:n #1 { \__fnote_debug_footnotetext: \hook_use:n {fntext/before} \socket_use:n {tagsupport/fntext/begin} \socket_use:nn {fntext/process} { \hook_use:n {fntext} \reset@font \footnotesize \interlinepenalty\interfootnotelinepenalty \splittopskip\footnotesep \splitmaxdepth \dp\strutbox \floatingpenalty \@MM \hsize\columnwidth \@parboxrestore \parindent 1em % typical default used in \@makefntext moved up here \def\@currentcounter{footnote} \protected@edef \@currentlabel { \p@footnote \@thefnmark } \hook_use:n {fntext/para} \color@begingroup \socket_use:nn {fntext/make} { \socket_use:n {fntext/begin}% \hook_use:n {fntext/begin} \ignorespaces #1 \hook_use:n {fntext/end} \socket_use:n {fntext/end} } \par \color@endgroup } \socket_use:n{tagsupport/fntext/end} \hook_use:n {fntext/after} } \NewSocket {fntext/process}{1} \NewSocketPlug{fntext/process}{default}{ \insert\footins {#1} } \NewSocketPlug{fntext/process}{side} { \marginpar {#1} } \AssignSocketPlug{fntext/process}{default} \NewSocket {fntext/make}{1} \NewSocketPlug{fntext/make}{default}{ \@makefntext {#1} } \NewSocketPlug{fntext/make}{para} { \setbox\FN@tempboxa\hbox{\@makefntext{#1}}% \dp\FN@tempboxa\z@ \ht\FN@tempboxa \dimexpr\wd\FN@tempboxa *% \footnotebaselineskip /\columnwidth\relax \box\FN@tempboxa } \AssignSocketPlug{fntext/make}{default} \NewSocket {fntext/begin}{0} \NewSocketPlug{fntext/begin}{default}{ \rule\z@\footnotesep } \AssignSocketPlug{fntext/begin}{default} \NewSocket {fntext/end}{0} \NewSocketPlug{fntext/end}{default}{ \@finalstrut\strutbox } \NewSocketPlug{fntext/end}{para} {% \strut \penalty-10\relax \hskip\footglue } \AssignSocketPlug{fntext/end}{default} \NewSocket{tagsupport/fntext/begin}{0} \NewSocket{tagsupport/fntext/end}{0} \AddToHook{begindocument} { \cs_set_eq:NN \@footnotetext \fnote_footnotetext:n } \newdimen\footnotemargin \footnotemargin\maxdimen % no value given \AtBeginDocument { \ifdim \footnotemargin=\maxdimen \setlength\footnotemargin{1.8em} \fi } \cs_new_protected:Npn \fnote_makefntext:n #1 { \noindent \socket_use:nn {tagsupport/fntext/mark} { \socket_use:n {fntext/mark} } \socket_use:nn {tagsupport/fntext/text} { \socket_use:nn {fntext/text}{#1} } } \NewSocket {fntext/mark}{0} \NewSocketPlug{fntext/mark}{default}{ \ifdim\footnotemargin>\z@ \hb@xt@ \footnotemargin{\hss\@makefnmark} \else \ifdim\footnotemargin=\z@ \llap{\@makefnmark} \else \ifdim\footnotemargin=-\maxdimen \@makefnmark \else \llap{\hb@xt@ -\footnotemargin{\@makefnmark\hss}} \fi \fi \fi } \AssignSocketPlug{fntext/mark}{default} \NewSocket {fntext/text}{1} \NewSocket{tagsupport/fntext/mark}{1} \NewSocket{tagsupport/fntext/text}{1} \newcommand\old@std@class@makefntext[1]{% \parindent 1em% \noindent \hb@xt@1.8em{\hss\@makefnmark}#1} \tl_new:N \l__fnote_patch_tl \cs_new_eq:NN \__fnote_tmp:w \ERROR \cs_new_protected:Npn \__fnote_patch: { \tl_set:No \l__fnote_patch_tl { \@makefntext { \UseSocket{tagsupport/fntext/text}{##1} } } \tl_if_in:NnTF \l__fnote_patch_tl { \hbox } { \cs_set_eq:NN \__fnote_tmp:w \__fnote_patch_hbox:w } { \tl_if_in:NnTF \l__fnote_patch_tl { \hb@xt@ } { \cs_set_eq:NN \__fnote_tmp:w \__fnote_patch_hb@xt@:w } { \tl_if_in:NnTF \l__fnote_patch_tl { \makebox } { \cs_set_eq:NN \__fnote_tmp:w \__fnote_patch_makebox:w } { \tl_if_in:NnTF \l__fnote_patch_tl { \@makefnmark } { \cs_set_eq:NN \__fnote_tmp:w \__fnote_patch_@makefnmark:w } { \ERROR \cs_set_eq:NN \__fnote_tmp:w \exp_stop_f: } } } } \tl_set:Nf \l__fnote_patch_tl { \exp_after:wN \__fnote_tmp:w \l__fnote_patch_tl } \cs_set:Npn \__fnote_tmp:w { \long \def \@makefntext ####1 } \exp_after:wN \__fnote_tmp:w \exp_after:wN { \l__fnote_patch_tl } } \cs_new:Npn \__fnote_patch_hbox:w #1 \hbox #2 # { \exp_stop_f: #1 \@makefntext@processX { \hbox #2 } } \cs_new:Npn \__fnote_patch_hb@xt@:w #1 \hb@xt@ #2 # { \exp_stop_f: #1 \@makefntext@processX { \hb@xt@ #2 } } \cs_new:Npn \__fnote_patch_makebox:w #1 \makebox #2 # { \exp_stop_f: #1 \@makefntext@processX { \makebox #2 } } \cs_new:Npn \__fnote_patch_@makefnmark:w #1 \@makefnmark { \exp_stop_f: #1 \@makefntext@processX { \use:n } { \@makefnmark } } \cs_new:Npn \@makefntext@processX #1#2{\UseSocket{tagsupport/fntext/mark}{#1{#2}}} \AddToHook{begindocument} { \cs_if_eq:NNTF \@makefntext \old@std@class@makefntext { \cs_set_eq:NN \@makefntext \fnote_makefntext:n } { \cs_if_eq:NNF \@makefntext \footmisc@hang@makefntext { \__fnote_patch: } } } \DeclareDocumentCommand\footnotetext {o+m} { \fnote_set_fnmark:nn {#1} \@mpfn \@footnotetext {#2} } \DeclareDocumentCommand\footnote {o+m} { \fnote_step_fnmark:nn {#1} \@mpfn \cs_set_eq:NN \__fnote_footnotemark_finish: \prg_do_nothing: \@footnotemark \cs_set_eq:NN \__fnote_footnotemark_finish: \__fnote_footnotemark_default_finish: \@footnotetext {#2} \__fnote_footnotemark_finish: } \DeclareDocumentCommand\footnotemark {o} { \fnote_step_fnmark:nn {#1} { footnote } \@footnotemark } \DeclareDocumentCommand\footref {m} { \begingroup \unrestored@protected@xdef\@thefnmark{\ref*{#1}}% \endgroup \bool_set_false:N \l__fnote_autodetect_bool \tl_set:Nn \l__fnote_currentlabel_tl {#1} \@footnotemark \bool_set_true:N \l__fnote_autodetect_bool } \NewSocketPlug{fntext/process}{mp} { \global\setbox\@mpfootins\vbox{% \unvbox\@mpfootins #1 } } \AddToHook{class/memoir/before} { \let\new@std@class@makecol\@makecol } \AddToHook{class/memoir/after} { \cs_set_eq:NN \@footnotemark \fnote_footnotemark: \cs_set_eq:NN \@makefntext\old@std@class@makefntext \cs_set_eq:NN \@makecol\new@std@class@makecol } \AddToHook{package/setspace/after} {\let \@footnotetext \fnote_footnotetext:n \AddToHook{fntext}[setspace]{\let\baselinestretch\setspace@singlespace}} \def\hyper@nopatch@footnote{} \AtBeginDocument { \providecommand\hyper@linkstart{\@gobbletwo} \providecommand\hyper@linkend{\@empty} } \AtBeginDocument { \@ifpackageloaded{hyperref} { \legacy_if:nF{Hy@hyperfootnotes}{\bool_set_false:N \l_fnote_link_bool} } { \bool_set_false:N \l_fnote_link_bool } } \property_new:nnnn {fnote/struct}{now}{1}{\l__fnote_currentstruct_tl} \cs_new_protected:Npn \__fnote_label_hook:e #1 {} \AddToHookWithArguments{label}{ \__fnote_label_hook:e{#1}} \AddToHook{fntext/begin} { \cs_set_protected:Npn \__fnote_label_hook:e #1 { \property_record:ee {__fnote/#1} {fnote/struct} } } \cs_new_protected:Npn \fnote_class_new:nn #1 #2 % #1 name, #2 options { \prop_new:c { g__fnote_currentmarks_ #1 _prop } } \fnote_class_new:nn {default}{} \cs_new_protected:Npn \fnote_mark_gput:nn #1 #2 % #1 the representation of the mark, #2 type { \prop_gput:cen { g__fnote_currentmarks_ #2 _prop } { \tag_get:n{struct_num} } { #1 } } \cs_generate_variant:Nn \fnote_mark_gput:nn {no,oo} \cs_new_protected:Npn \fnote_mark_gpop_all:nnN #1 #2 #3 { \seq_clear:N #3 \prop_set_eq:Nc \l__fnote_tmpa_prop { g__fnote_currentmarks_ #2 _prop } \prop_map_inline:Nn \l__fnote_tmpa_prop { \tl_if_eq:nnT {#1} { ##2 } { \seq_put_right:Nn #3 { ##1 } \prop_gremove:cn { g__fnote_currentmarks_ #2 _prop } {##1} } } } \cs_generate_variant:Nn\fnote_mark_gpop_all:nnN {ooN} \NewSocketPlug{tagsupport/fnmark}{FEMark} { \tag_mc_end_push: \tag_struct_begin:n { tag=footnotemark } \bool_if:NTF \l__fnote_autodetect_bool { \fnote_mark_gput:oo {\@thefnmark}{\l_fnote_type_tl} \tl_set:Ne \l__fnote_linktarget_tl {footnote*.\tag_get:n{struct_num}} } { \hook_gput_code:nne {tagpdf/finish/before} {tagpdf/footnote} { \exp_not:N\fnote_gput_refs:ee { \tag_get:n{struct_num} } { \property_ref:ee{ __fnote/\l__fnote_currentlabel_tl } {fnote/struct} } } \tl_set:Ne \l__fnote_linktarget_tl {footnote*.\property_ref:ee {__fnote/\l__fnote_currentlabel_tl} {fnote/struct}} } \tag_mc_begin:n{tag=Lbl} % \bool_if:NTF \l_fnote_link_bool { \exp_args:No \hyper@linkstart { \l_fnote_link_type_tl } { \l__fnote_linktarget_tl } #1 \hyper@linkend } { #1 } \tag_mc_end: \tag_struct_end: \tag_mc_begin_pop:n{} } \AssignSocketPlug{tagsupport/fnmark}{FEMark} \cs_new_protected:Npn \__fnote_gput_ref:nn #1 #2 %#1 the structure number receiving the ref #2 { \tag_if_active:T { \tag_struct_gput:nne {#1}{ref}{\tag_struct_object_ref:e { #2 }} } } \cs_new_protected:Npn \fnote_gput_refs:nn #1 #2 % pair of numbers { \__fnote_gput_ref:nn {#1}{#2} \__fnote_gput_ref:nn {#2}{#1} } \cs_generate_variant:Nn \fnote_gput_refs:nn {ee} \tl_new:N \l__fnote_dflt_struct_tl \tl_set:Nn \l__fnote_dflt_struct_tl {1} \NewSocketPlug{tagsupport/fntext/begin}{FENote} { \tag_mc_end_push: \tag_check_child:nnTF {FENote}{pdf2} { \tag_struct_begin:n { tag=footnote } } { \tag_struct_begin:n { tag=footnote,parent=\l__fnote_dflt_struct_tl } } \tl_set:Ne \l__fnote_currentstruct_tl { \tag_get:n{struct_num} } \tag_struct_begin:n { tag=footnotelabel }\tag_struct_end: \bool_if:NTF \l__fnote_autodetect_bool { \fnote_mark_gpop_all:ooN { \@thefnmark }{ \l_fnote_type_tl } \l__fnote_currentrefs_seq \seq_map_inline:Nn \l__fnote_currentrefs_seq { \fnote_gput_refs:ee {##1}{ \l__fnote_currentstruct_tl } } } {%no auto } } \NewSocketPlug{tagsupport/fntext/end}{FENote} { \tag_struct_end: \tag_mc_begin_pop:n{} } \AssignSocketPlug{tagsupport/fntext/begin}{FENote} \AssignSocketPlug{tagsupport/fntext/end}{FENote} \NewSocketPlug{tagsupport/fntext/mark}{FENoteLbl} { \tag_mc_end_push: %\seq_show:N\l__fnote_currentrefs_seq \seq_map_inline:Nn\l__fnote_currentrefs_seq {\MakeLinkTarget*{footnote*.##1}} \MakeLinkTarget*{footnote*.\l__fnote_currentstruct_tl} \tag_struct_begin:n { tag=NonStruct,parent=\l__fnote_currentstruct_tl +1 } \tag_mc_begin:n { tag=Lbl } #1 \tag_mc_end: \tag_struct_end: \tag_mc_begin_pop:n{} } \AssignSocketPlug{tagsupport/fntext/mark}{FENoteLbl} \NewSocketPlug{tagsupport/fntext/text}{FENotetext} { \tag_mc_end_push: \tag_mc_begin:n{} #1 \tag_mc_end: \tag_mc_begin_pop:n{} } \AssignSocketPlug{tagsupport/fntext/text}{FENotetext} \ExplSyntaxOff \endinput %% %% End of file `latex-lab-footnotes.ltx'.