packages feed

pandoc-3.14: test/command/11936.md

Footnotes in tables are deferred. Each `\pandocfootnotetext` must
be matched to its `\pandocfootnotemark`, and the text of a nested
note must come after the text containing its mark.

```
% pandoc -f native -t latex
[ Table
    ( "" , [] , [] )
    (Caption Nothing [])
    [ ( AlignDefault , ColWidthDefault )
    , ( AlignDefault , ColWidthDefault )
    ]
    (TableHead
       ( "" , [] , [] )
       [ Row
           ( "" , [] , [] )
           [ Cell
               ( "" , [] , [] )
               AlignDefault
               (RowSpan 1)
               (ColSpan 1)
               [ Plain [ Str "A" ] ]
           , Cell
               ( "" , [] , [] )
               AlignDefault
               (RowSpan 1)
               (ColSpan 1)
               [ Plain [ Str "B" ] ]
           ]
       ])
    [ TableBody
        ( "" , [] , [] )
        (RowHeadColumns 0)
        []
        [ Row
            ( "" , [] , [] )
            [ Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain
                    [ Str "x"
                    , Note
                        [ Para
                            [ Str "outer"
                            , Space
                            , Note [ Para [ Str "inner note" ] ]
                            ]
                        ]
                    ]
                ]
            , Cell
                ( "" , [] , [] )
                AlignDefault
                (RowSpan 1)
                (ColSpan 1)
                [ Plain [ Str "y" , Note [ Para [ Str "second" ] ] ] ]
            ]
        ]
    ]
    (TableFoot ( "" , [] , [] ) [])
]
^D
{\def\LTcaptype{none} % do not increment counter
\begin{longtable}[]{@{}ll@{}}
\toprule\noalign{}
A & B \\
\midrule\noalign{}
\endhead
\bottomrule\noalign{}
\endlastfoot
x\pandocfootnotemark{2} & y\pandocfootnotemark{3} \\
\end{longtable}
}
\pandocfootnotetext{2}{outer \pandocfootnotemark{1}}
\pandocfootnotetext{1}{inner note}
\pandocfootnotetext{3}{second}
```

The LaTeX reader handles this output, ignoring the definitions of
the macros from the template:

```
% pandoc -f latex -t markdown
\makeatletter
\protected\def\pandocfootnotemark#1{\footnotemark{}%
  \expandafter\xdef\csname pandoc@fn@#1\endcsname{%
    \noexpand\pandoc@fnrestore
    {\unexpanded\expandafter{\@thefnmark}}%
    {\ifdefined\Hy@footnote@currentHref
       \unexpanded\expandafter{\Hy@footnote@currentHref}\fi}}}
\def\pandoc@fnrestore#1#2{%
  \gdef\@thefnmark{#1}%
  \ifdefined\Hy@footnote@currentHref\gdef\Hy@footnote@currentHref{#2}\fi}
\newcommand\pandocfootnotetext[1]{%
  \csname pandoc@fn@#1\endcsname\@footnotetext}
\makeatother

\begin{tabular}{ll}
x\pandocfootnotemark{2} & y\pandocfootnotemark{3} \\
\end{tabular}
\pandocfootnotetext{2}{outer \pandocfootnotemark{1}}
\pandocfootnotetext{1}{inner note}
\pandocfootnotetext{3}{second}
^D
  ------- -------
  x[^1]   y[^2]
  ------- -------

[^1]: outer [^3]

[^2]: second

[^3]: inner note
```

It also handles adjustments to the footnote counter with
`\footnotemark` and `\footnotetext`, as in output from
earlier versions of pandoc:

```
% pandoc -f latex -t markdown
\begin{tabular}{ll}
x\footnotemark{} & y\footnotemark{} \\
\end{tabular}
\addtocounter{footnote}{-1}
\footnotetext{first}
\addtocounter{footnote}{1}
\footnotetext{second}
^D
  ------- -------
  x[^1]   y[^2]
  ------- -------

[^1]: first

[^2]: second
```