summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx')
-rw-r--r--Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx499
1 files changed, 288 insertions, 211 deletions
diff --git a/Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx b/Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx
index 66c25fc3e89..4a3a046a21d 100644
--- a/Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx
+++ b/Master/texmf-dist/tex/latex/latex-lab/latex-lab-footnotes.ltx
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% Copyright 2021,2022 LaTeX Project
+%% Copyright 2021-2023 LaTeX Project
%%
%% This file was generated from file(s) of the `LaTeX-lab Bundle'.
%% ------------------------------------------------------------------------------------
@@ -34,34 +34,31 @@
%%
%% File: latex-lab-footnotes.dtx
\ProvidesFile{latex-lab-footnotes.ltx}
- [2022-07-22 v0.6b changes to the footnote interfaces]
-
-
- % not looked at yet
-
-\long\def\@mpfootnotetext#1{%
- \global\setbox\@mpfootins\vbox{%
- \unvbox\@mpfootins
- \reset@font\footnotesize
- \hsize\columnwidth
- \@parboxrestore
- \def\@currentcounter{mpfootnote}%
- \protected@edef\@currentlabel
- {\csname p@mpfootnote\endcsname\@thefnmark}%
- \color@begingroup
- \@makefntext{%
- \rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}%
- \par
- \color@endgroup}}
-
-\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\@thefnmark}}}
-
-\def\@mpfn{footnote}
-\def\thempfn{\thefootnote}
-
+ [2023-02-04 v0.7 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 \ref_label:nn { Vn }
+\cs_generate_variant:Nn \ref_value:nn { Vn }
+\cs_generate_variant:Nn \prop_gput:Nnn {cxn}
+\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}
{
@@ -75,7 +72,6 @@
\group_end:
}
}
-
\cs_new_protected:Npn \fnote_set_fnmark:nn #1#2 {
\tl_if_novalue:nTF {#1}
{
@@ -88,19 +84,20 @@
\group_end:
}
}
-
-
-\bool_new:N \g_fnote_debug_bool
-\bool_gset_true:N \g_fnote_debug_bool % for now we have debugging turned on by default
-
-
\NewMirroredHookPair{fnmark/before}{fnmark/after}
\NewHook{fnmark}
\NewHook{fnmark/begin}
\NewHook{fnmark/end}
-
-\cs_new:Npn \__fnote_debug_footnotemark: {
- \bool_if:NT \g_fnote_debug_bool
+\NewMirroredHookPair{fntext/before}{fntext/after}
+\NewHook{fntext}
+\NewHook{fntext/para}
+\NewHook{fntext/begin}
+\NewHook{fntext/end}
+\bool_new:N \g_fnote_debug_bool
+\bool_gset_true:N \g_fnote_debug_bool
+\cs_new_protected:Npn \__fnote_debug_footnotemark:
+ {
+ \bool_if:NT \g_fnote_debug_bool
{
\LogHook{fnmark/before}
\LogHook{fnmark}
@@ -109,8 +106,26 @@
\LogHook{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
+ {
+ \cs_log:N\@footnotetext@cfgpoint
+ \cs_log:N\@footnotetext@cfgpointii
+ \cs_log:N\@footnotetext@cfgpointiii
+ \cs_log:N\@footnotetext@cfgpointiv
+ \cs_log:N\@makefntext@cfgpoint
+ \cs_log:N\@makefntext@cfgpointii
+ \LogHook{fntext/before}
+ \LogHook{fntext}
+ \LogHook{fntext/para}
+ \LogHook{fntext/begin}
+ \LogHook{fntext/end}
+ \LogHook{fntext/after}
+ \cs_gset_eq:NN \__fnote_debug_footnotetext: \prg_do_nothing:
+ }
+ }
\cs_new_protected:Npn \fnote_footnotemark: {
\__fnote_debug_footnotemark:
\UseHook{fnmark/before}
@@ -125,8 +140,7 @@
\@makefnmark
\__fnote_footnotemark_finish:
}
-
-\cs_new:Npn \__fnote_finish: {
+\cs_new_protected:Npn \__fnote_finish: {
\UseHook{fnmark/end}
\ifhmode
\spacefactor \@x@sf \relax
@@ -135,39 +149,8 @@
}
\cs_new_eq:NN \__fnote_footnotemark_finish: \__fnote_finish:
-
\def \@kernel@process@makefnmark { }
-
-
-
\cs_set_eq:NN \@footnotemark \fnote_footnotemark:
-
-
-\NewMirroredHookPair{fntext/before}{fntext/after}
-\NewHook{fntext}
-\NewHook{fntext/para}
-\NewHook{fntext/begin}
-\NewHook{fntext/end}
-
-\cs_new:Npn \__fnote_debug_footnotetext: {
- \bool_if:NT \g_fnote_debug_bool
- {
- \cs_log:N\@footnotetext@cfgpoint
- \cs_log:N\@footnotetext@cfgpointii
- \cs_log:N\@footnotetext@cfgpointiii
- \cs_log:N\@footnotetext@cfgpointiv
- \cs_log:N\@makefntext@cfgpoint
- \cs_log:N\@makefntext@cfgpointii
- \LogHook{fntext/before}
- \LogHook{fntext}
- \LogHook{fntext/para}
- \LogHook{fntext/begin}
- \LogHook{fntext/end}
- \LogHook{fntext/after}
- \cs_gset_eq:NN \__fnote_debug_footnotetext: \prg_do_nothing:
- }
- }
-
\cs_new_protected:Npn \fnote_footnotetext:n #1 {
\__fnote_debug_footnotetext:
\UseHook{fntext/before}
@@ -201,32 +184,24 @@
}
\UseHook{fntext/after}
}
-
\cs_new_protected:Npn \@footnotetext@cfgpoint { \insert\footins }
-
\cs_new_protected:Npn \@footnotetext@cfgpointii { \@makefntext }
-
\cs_new_protected:Npn \@footnotetext@cfgpointiii { \rule\z@\footnotesep }
-
\cs_new_protected:Npn \@footnotetext@cfgpointiv { \@finalstrut\strutbox }
-
\cs_new_protected:Npn \@kernel@process@footnotetext {}
-
-
-\AddToHook{begindocument}{
- \cs_set_eq:NN \@footnotetext \fnote_footnotetext:n
-}
-
-
-
+\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
-}
+\AtBeginDocument
+ {
+ \ifdim \footnotemargin=\maxdimen
+ \setlength\footnotemargin{1.8em}
+ \fi
+ }
\cs_new_protected:Npn \fnote_makefntext:n #1 {
\@makefntext@cfgpoint
@@ -248,16 +223,12 @@
\@makefntext@cfgpointii
{ #1 }
}
-
\cs_new_protected:Npn \@makefntext@cfgpoint { \noindent }
-
\cs_new_protected:Npn \@makefntext@cfgpointii #1 { #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
@@ -289,139 +260,245 @@
{ \exp_stop_f: #1 \@makefntext@processX { \use:n } { \@makefnmark } }
\cs_new:Npn \@makefntext@processX #1#2{\@makefntext@cfgpoint{#1{#2}}}
-\AddToHook{begindocument}{
- \cs_if_eq:NNTF \@makefntext \old@std@class@makefntext
- {
- \cs_set_eq:NN \@makefntext \fnote_makefntext:n
- }
- {
- \__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_finish:
- \@footnotetext {#2}
- \__fnote_footnotemark_finish:
-}
-
-
-\DeclareDocumentCommand\footnotemark {o} {
- \fnote_step_fnmark:nn {#1} { footnote }
- \@footnotemark
-}
+\AddToHook{begindocument}
+ {
+ \cs_if_eq:NNTF \@makefntext \old@std@class@makefntext
+ {
+ \cs_set_eq:NN \@makefntext \fnote_makefntext:n
+ }
+ {
+ \__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_finish:
+ \@footnotetext {#2}
+ \__fnote_footnotemark_finish:
+ }
-\DeclareDocumentCommand\footref {m}{%
- \begingroup
- \unrestored@protected@xdef\@thefnmark{\ref{#1}}%
- \endgroup
- \@footnotemark
-}
+\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
+ }
+\cs_new_protected:Npn \@mpfootnotetext@cfgpoint #1
+ {
+ \global\setbox\@mpfootins\vbox{%
+ \unvbox\@mpfootins
+ #1
+ }
+ }
+\RequirePackage{etoolbox}
+\ExplSyntaxOff
+\patchcmd\@iiiminipage
+ {\let\@footnotetext\@mpfootnotetext}
+ {\let\@footnotetext@cfgpoint\@mpfootnotetext@cfgpoint}
+ {}{\ERROR}
+\ExplSyntaxOn
+\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}}
-\AddToHook{package/hyperref/after}{
- \let\H@@footnotetext\fnote_footnotetext:n
- \let\H@@footnotemark\fnote_footnotemark:
- \let \@footnotetext \fnote_footnotetext:n
- \let \@footnotemark \fnote_footnotemark:
-}
-
-
-
-
-
-
-
-
-\newcounter{absfootnote}
-\AddToHook{fnmark/begin}{\stepcounter{absfootnote}} % too simple (fails with opt args)
-
-
-\cs_new_protected:Npn \tag_if_loaded:TF { \cs_if_exist:NTF \tag_struct_begin:n }
-
-\cs_new_protected:Npn \tag@FEMark #1 {
- \tag_if_loaded:TF
+\def\hyper@nopatch@footnote{}
+\AtBeginDocument
+ {
+ \providecommand\hyper@linkstart{\@gobbletwo}
+ \providecommand\hyper@linkend{\@empty}
+ }
+\AtBeginDocument
+ {
+ \@ifpackageloaded{hyperref}
{
- \tag_mc_end_push:
- \exp_args:Nx
- \tag_struct_begin:n{tag=Lbl,ref=fn.\the\c@absfootnote}
- \tag_mc_begin:n{tag=Lbl}
- \IfPackageLoadedTF{hyperref}{ \hyper@linkstart
- {link}{fn.\the\c@absfootnote} }{}
- #1
- \IfPackageLoadedTF{hyperref}{ \hyper@linkend }{}
- \tag_mc_end:
- \tag_struct_end:
- \tag_mc_begin_pop:n{}
+ \legacy_if:nF{Hy@hyperfootnotes}{\bool_set_false:N \l_fnote_link_bool}
}
+ {
+ \bool_set_false:N \l_fnote_link_bool
+ }
+ }
+\ref_attribute_gset:nnnn {fnote/struct}{1}{now}{\l__fnote_currentstruct_tl}
+\cs_new_protected:Npn \__fnote_label_hook: {}
+\AddToHook{begindocument/before}
+ {
+ \RequirePackage{nameref}
+ \g@addto@macro\label@hook
+ {
+ \__fnote_label_hook:
+ }
+ }
+\AddToHook{fntext/begin}
+ {
+ \cs_set_protected:Npn \__fnote_label_hook:
+ {
+ \ref_label:Vn \label@name {fnote/struct}
+ }
+ }
+\cs_new_protected:Npn \fnote_new:nn #1 #2 % #1 name, #2 options
+ {
+ \prop_new:c { g__fnote_currentmarks_ #1 _prop }
+ }
+
+\fnote_new:nn {default}{}
+\cs_new_protected:Npn \fnote_mark_gput:nn #1 #2 % #1 the representation of the mark, #2 type
+ {
+ \prop_gput:cxn { 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: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:nnN {ooN}
+\cs_new_protected:Npn \tag@FEMark #1 %#1 content
+ {
+ \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:Nx \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} }
+ { \ref_value:Vn\l__fnote_currentlabel_tl {fnote/struct} }
+ }
+ \tl_set:Nx \l__fnote_linktarget_tl {footnote*.\ref_value:Vn\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{}
+ }
\cs_set_eq:NN \@kernel@process@makefnmark \tag@FEMark
-\cs_set:Npn \@kernel@process@footnotetext #1#2 {
- \tag_if_loaded:TF
- {
- \tag_mc_end_push:
- \tag_struct_begin:n { tag=FENote,label=fn.\the\c@absfootnote }
- #1 {#2}
- \tag_struct_end:
- \tag_mc_begin_pop:n{}
- }
- { #1 {#2} }
-}
-
-\cs_set:Npn \@makefntext@cfgpoint #1 {
- \noindent
- \cs_if_exist:NT \tag_struct_begin:n { \tag_mc_end_push: }
- \tag@FELbl { #1 }
-}
-\cs_set:Npn \@makefntext@cfgpointii #1 {
- \tag@FENote { #1 }
- \cs_if_exist:NT \tag_struct_begin:n { \tag_mc_begin_pop:n{} }
-}
-
-\cs_new_protected:Npn \tag@FELbl #1 {
- \tag_if_loaded:TF
- {
- % target should perhaps be raised ...
- \IfPackageLoadedTF{hyperref}{ \hypertarget{fn.\the\c@absfootnote}{} }{}
- %\tag_struct_begin:n { tag=FENote,label=fn.\the\c@absfootnote } %alternativ location for structure
- \tag_struct_begin:n { tag=Lbl }
- \tag_mc_begin:n { tag=Lbl }
- #1
- \tag_mc_end:
- \tag_struct_end:
- }
- { #1 }
-}
+\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}
+\cs_new_protected:Npn \tag@FENote #1#2 % #1 config point, \insert\footins #2 content
+ {
+ \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:Nx \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: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
-\cs_new_protected:Npn \tag@FENote #1 {
- \tag_if_loaded:TF
- {
- \tag_mc_begin:n{tag=FENote}
- #1
+ }
+ #1 {#2}
+ \tag_struct_end:
+ \tag_mc_begin_pop:n{}
+ }
+\cs_set_eq:NN \@kernel@process@footnotetext \tag@FENote
+\cs_set_protected:Npn \@makefntext@cfgpoint #1 %#1 code that typesets the mark.
+ {
+ \noindent
+ \tag_mc_end_push:
+ \tag@FENoteLbl { #1 }
+ \tag_mc_begin_pop:n{}
+ }
+\cs_new_protected:Npn \tag@FENoteLbl #1
+ {
+ %\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: %alternative location for structure end but ends inside a P
- }
- { #1 }
-}
-
+ \tag_struct_end:
+ }
+\cs_set_protected:Npn \@makefntext@cfgpointii #1
+ {
+ \tag_mc_end_push:
+ \tag@FENotetext { #1 }
+ \tag_mc_begin_pop:n{}
+ }
+\cs_new_protected:Npn \tag@FENotetext #1
+ {
+ \tag_mc_begin:n{}
+ #1
+ \tag_mc_end:
+ }
\ExplSyntaxOff
\endinput