[latex3-commits] [git/LaTeX3-latex3-latex2e] OR-lab: approach for tagging \footref (not yet integrated) (e248c9d5)

Frank Mittelbach frank.mittelbach at latex-project.org
Wed Mar 9 16:43:45 CET 2022


Repository : https://github.com/latex3/latex2e
On branch  : OR-lab
Link       : https://github.com/latex3/latex2e/commit/e248c9d56c4e75c3b0cd0557c82c78c5125e6413

>---------------------------------------------------------------

commit e248c9d56c4e75c3b0cd0557c82c78c5125e6413
Author: Frank Mittelbach <frank.mittelbach at latex-project.org>
Date:   Wed Mar 9 16:43:45 2022 +0100

    approach for tagging \footref (not yet integrated)


>---------------------------------------------------------------

e248c9d56c4e75c3b0cd0557c82c78c5125e6413
 required/latex-lab/footref-tagging-approach.tex | 99 +++++++++++++++++++++++++
 1 file changed, 99 insertions(+)

diff --git a/required/latex-lab/footref-tagging-approach.tex b/required/latex-lab/footref-tagging-approach.tex
new file mode 100644
index 00000000..20eab259
--- /dev/null
+++ b/required/latex-lab/footref-tagging-approach.tex
@@ -0,0 +1,99 @@
+% 2022-03-09   not yet integrated
+
+
+% !Mode:: "TeX:UTF-8:Main"
+\documentclass{article}
+
+%\input{regression-test}
+
+
+\usepackage{footmisc}
+\usepackage{hyperref}
+\ExplSyntaxOn\makeatletter
+%ref attribute absfootnote
+\ref_attribute_gset:nnnn
+  { absfootnote } {0} { now }
+  { \int_use:N \c at absfootnote }
+
+\cs_generate_variant:Nn\ref_label:nn{nV}
+
+% a list for the attributes to label, currently only absfootnote
+\clist_new:N\g__kernel_extref_clist
+\clist_gput_right:Nn\g__kernel_extref_clist{absfootnote}
+
+% extend the label command
+\def\label#1{
+  \@bsphack
+  \ref_label:nV{#1}\g__kernel_extref_clist
+  \protected at write\@auxout{}%
+         {\string\newlabel{#1}{{\@currentlabel}{\thepage}}}%
+  \@esphack}
+
+% make the reference id customizable:
+\tl_new:N  \__tag_FEMARK_id_tl
+\tl_set:Nn \__tag_FEMARK_id_tl  {\the\c at absfootnote}
+
+\cs_set:Npn \tag at FEMark #1 {
+  \tag_if_loaded:TF
+     {
+       \tag_mc_end_push:
+       \exp_args:Nx
+       \tag_struct_begin:n{tag=Lbl,ref=fn.\__tag_FEMARK_id_tl}
+       \tag_mc_begin:n{tag=Lbl}
+       \IfPackageLoadedTF{hyperref}{ \hyper at linkstart
+         {link}{fn.\__tag_FEMARK_id_tl} }{}
+       #1
+      \IfPackageLoadedTF{hyperref}{ \hyper at linkend }{}
+      \tag_mc_end:
+      \tag_struct_end:
+      \tag_mc_begin_pop:n{}
+     }
+     { #1 }
+}
+
+% copy back to \@kernel at process@makefnmark
+\cs_set_eq:NN \@kernel at process@makefnmark \tag at FEMark
+
+% set the id_tl to the default c at absfootnote
+\DeclareDocumentCommand\footnote {om} {
+  \fn_step_fnmark:nn {#1} \@mpfn
+  \cs_set_eq:NN \__fnote_footnotemark_finish: \prg_do_nothing:
+  \tl_set:Nn \__tag_FEMARK_id_tl  {\the\c at absfootnote} %<--------?
+  \@footnotemark
+  \cs_set_eq:NN \__fnote_footnotemark_finish: \__fnote_finish:
+  \@footnotetext {#2}
+  \__fnote_footnotemark_finish:
+}
+
+% use the label value here
+\DeclareDocumentCommand\footref {m}{%
+  \begingroup
+    \IfPackageLoadedTF{hyperref}
+     {\unrestored at protected@xdef\@thefnmark{\ref*{#1}}}% no link!
+     {\unrestored at protected@xdef\@thefnmark{\ref{#1}}}%
+  \endgroup
+  \tl_set:Nn \__tag_FEMARK_id_tl  {\ref_value:nnn {#1}{absfootnote}{1}}
+  \@footnotemark
+}
+
+\ExplSyntaxOff
+
+\showoutput
+
+\begin{document}
+
+%\START
+
+Test\footnote{A}xxx\footnote{\label{foo}B}xxx\footnote[7]{C}
+
+
+\renewcommand\thefootnote{\fnsymbol{footnote}}
+
+
+Test\footnote{D} and\footnote{E}xxx\footref{foo}
+
+
+
+\newpage
+%\OMIT
+\end{document}





More information about the latex3-commits mailing list.