脚注文本在页面底部重复多次

脚注文本在页面底部重复多次

为什么脚注文字在页面底部重复多次?

如何仅获取一次脚注文本?(而不是像以下示例中那样获取 6 次)

\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}


% https://tex.stackexchange.com/questions/645421/tabularray-with-footnotes/712683#712683
\UseTblrLibrary{counter}
\UseTblrLibrary{functional}

\makeatletter
\IgnoreSpacesOn
\tlNew \gFootNoteTl
\intNew \gFootNoteInt
\prgNewFunction \footNote {m}
  {
    \tlPutRight \gFootNoteTl
      {
        \stepcounter{footnote}
        \footnotetext{#1}
      }
    \prgReturn {\footnotemark{}}
  }
\AddToHook{env/longtblr/before}{
  \intSetEq \gFootNoteInt \c@footnote
  \tlClear \gFootNoteTl
}
\AddToHook{env/longtblr/after}{
  \intSetEq \c@footnote \gFootNoteInt
  \tlUse \gFootNoteTl
}
\IgnoreSpacesOff
\makeatother


\begin{document}

\begin{longtblr}[
  presep=-4pt,postsep=0pt
]{
  colspec = {lX},
  colsep=4pt,
  hline{odd}={solid},
  row{odd}={belowsep=0pt},
  row{even}={abovesep=0pt},
  cell{even}{1} = {c=2}{wd=\textwidth-8pt,halign=j}
}
    01/01/2020 $-$ 31/12/2022 & \textbf{First}\\
    \lipsum[2] &\\
    01/01/2018 $-$ 31/12/2019 \footNote{my footnote} & \textbf{Second}\\
    \lipsum[2] &\\
    01/01/2016 $-$ 31/12/2017 & \textbf{Third}\\
    \lipsum[2] &\\
\end{longtblr}

\end{document}

在此处输入图片描述

根据@daleif 和@gusbrs 的评论进行编辑,我非常感谢他们!

\prgReturn {\footnotemark{}}条件之外的移动\IfBooleanF,阻止脚注符号下移至表中的下一行:

\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}


% https://tex.stackexchange.com/questions/645421/tabularray-with-footnotes/712683#712683
\UseTblrLibrary{counter}
\UseTblrLibrary{functional}

\makeatletter
\IgnoreSpacesOn
\tlNew \gFootNoteTl
\intNew \gFootNoteInt
\prgNewFunction \footNote {m}
  {
    \IfBooleanF { \lTblrMeasuringBool }
      {
        \tlPutRight \gFootNoteTl
          {
            \stepcounter{footnote}
            \footnotetext{#1}
          }
        %\prgReturn {\footnotemark{}}  % <-- Before
      }
      \prgReturn {\footnotemark{}} % <-- Now
  }
\AddToHook{env/longtblr/before}{
  \intSetEq \gFootNoteInt \c@footnote
  \tlClear \gFootNoteTl
}
\AddToHook{env/longtblr/after}{
  \intSetEq \c@footnote \gFootNoteInt
  \tlUse \gFootNoteTl
}
\IgnoreSpacesOff
\makeatother


\begin{document}

\begin{longtblr}[
  presep=-4pt,postsep=0pt
]{
  colspec = {lX},
  colsep=4pt,
  hline{odd}={solid},
  row{odd}={belowsep=0pt},
  row{even}={abovesep=0pt},
  cell{even}{1} = {c=2}{wd=\textwidth-8pt,halign=j}
}
    01/01/2020 $-$ 31/12/2022 & \textbf{First}\\
    \lipsum[2] &\\
    01/01/2018 $-$ 31/12/2019 \footNote{my footnote} & \textbf{Second}\\
    \lipsum[2] &\\
    01/01/2016 $-$ 31/12/2017 & \textbf{Third}\\
    \lipsum[2] &\\
\end{longtblr}

\end{document}

在此处输入图片描述

答案1

tabularray表格在获得最终排版形式之前会执行多次测量,因此您的脚注每次都会排版。您可以使用以下方法测试测量过程\lTblrMeasuringBool

\documentclass{article}
\usepackage[a4paper,margin=1mm]{geometry}
\usepackage{lipsum}
\usepackage{tabularray}


% https://tex.stackexchange.com/questions/645421/tabularray-with-footnotes/712683#712683
\UseTblrLibrary{counter}
\UseTblrLibrary{functional}

\makeatletter
\IgnoreSpacesOn
\tlNew \gFootNoteTl
\intNew \gFootNoteInt
\prgNewFunction \footNote {m}
  {
    \IfBooleanF { \lTblrMeasuringBool }
      {
        \tlPutRight \gFootNoteTl
          {
            \stepcounter{footnote}
            \footnotetext{#1}
          }
        \prgReturn {\footnotemark{}}
      }
  }
\AddToHook{env/longtblr/before}{
  \intSetEq \gFootNoteInt \c@footnote
  \tlClear \gFootNoteTl
}
\AddToHook{env/longtblr/after}{
  \intSetEq \c@footnote \gFootNoteInt
  \tlUse \gFootNoteTl
}
\IgnoreSpacesOff
\makeatother


\begin{document}

\begin{longtblr}[
  presep=-4pt,postsep=0pt
]{
  colspec = {lX},
  colsep=4pt,
  hline{odd}={solid},
  row{odd}={belowsep=0pt},
  row{even}={abovesep=0pt},
  cell{even}{1} = {c=2}{wd=\textwidth-8pt,halign=j}
}
    01/01/2020 $-$ 31/12/2022 & \textbf{First}\\
    \lipsum[2] &\\
    01/01/2018 $-$ 31/12/2019 \footNote{my footnote} & \textbf{Second}\\
    \lipsum[2] &\\
    01/01/2016 $-$ 31/12/2017 & \textbf{Third}\\
    \lipsum[2] &\\
\end{longtblr}

\end{document}

在此处输入图片描述

但请注意,上面的 MWE 是“原理证明”,它还不够好,因为我在测量过程中完全禁用了脚注,而您实际上应该在这些过程中包含标记,以免标记本身的宽度使测量结果偏离。但我不太明白你在那里想做什么,所以我只是禁用了它。

相关内容