2

Why is the footnote text repeated several times at the bottom of the page?

How to get the footnote text only once? (and not 6 times as in the following example)

\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}

enter image description here

EDITED after the comments of @daleif and @gusbrs, who I thank a lot!

The moving of \prgReturn {\footnotemark{}} outside the \IfBooleanF condition, impedes the footnote symbol to go down to the following line in the table:

\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}

enter image description here

3
  • 1
    Should table notes come right after the table anyways?
    – daleif
    Commented Mar 14 at 12:01
  • 1
    If you add \typeout{foo} to \footNote you can see that it gets executed 6 times. Presumably for measuring etc. align from amsmath does something similar (runs twice) but has a setting one can test for to see if we are in a measuring state. Perhaps this has something similar (have not checked)
    – daleif
    Commented Mar 14 at 12:06
  • Thanks @daleif :-)
    – Ommo
    Commented Mar 14 at 13:18

1 Answer 1

4

tabularray tables perform a number of measuring passes before getting its final typeset form, so your footnote gets typeset every pass. You can test for measuring passes with \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}

enter image description here

Note, however, that the MWE above is "proof of principle", it is not quite good enough, because I disabled the footnote completely in the measuring passes, and you actually should include the mark in those passes not to throw the measurement off by the width of the mark itself. But I did not quite understand what you were trying to do there, so I just disabled it.

7
  • It seems enough if you move \prgReturn {\footnotemark{}} out of the boolean test, at least then the footnote number should be there during the measuring. Though in this case it does not matter much, but would matter if the footnote was in the text part.
    – daleif
    Commented Mar 14 at 13:33
  • 2
    @daleif I suppose so, but I'm unacquainted with this functional library and have no idea of what \prgReturn is supposed to be. So I preferred being explicit about my ignorance, and just left the warning. ;-)
    – gusbrs
    Commented Mar 14 at 13:34
  • thanks a lot! :-)
    – Ommo
    Commented Mar 14 at 14:04
  • @gusbrs I have noticed that the footnote symbol inside the table goes to the following line (in this case is partially covered by the text of \lipsum)..How to leave it just beside the date?
    – Ommo
    Commented Mar 14 at 14:24
  • 1
    @Ommo That's an effect of the measuring problem stated in the answer. The width is calculated without the mark, so it falls on the next line. As mentioned to daleif, I don't quite know functional and have no idea what \prgReturn is. So you have to figure that out, the answer tells you how to distinguish measuring passes from the final one. A simple test suggests that daleif's suggestion works (just moving \prgReturn {\footnotemark{}} out of the boolean test). But you must know if that's what you really want to do.
    – gusbrs
    Commented Mar 14 at 14:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .