\footnotes 在环境中使用 \pushftn \popftn

\footnotes 在环境中使用 \pushftn \popftn

建议代码经过大卫·卡莱尔开箱即用,因为没有软件包依赖项。这是在需要\footnotemark+ 的环境中处理脚注的便捷解决方案footnotetext

\vbox我在与一起使用时没有遇到任何问题itemize

但是,当我尝试将其应用到居中表格时遇到了问题——脚注未呈现,只有脚注:

\documentclass{report}

%Thanks to David Carlisle for pushftn and popftn : https://tex.stackexchange.com/a/43695/7128
\makeatletter
\newtoks\FTN@ftn
\def\pushftn{%
 \let\@footnotetext\FTN@ftntext\let\@xfootnotenext\FTN@xftntext
  \let\@xfootnote\FTN@xfootnote}
\def\popftn{%
 \global\FTN@ftn\expandafter{\expandafter}\the\FTN@ftn}
\long\def\FTN@ftntext#1{%
  \edef\@tempa{\the\FTN@ftn\noexpand\footnotetext
                    [\the\csname c@\@mpfn\endcsname]}%
  \global\FTN@ftn\expandafter{\@tempa{#1}}}%
\long\def\FTN@xftntext[#1]#2{%
  \global\FTN@ftn\expandafter{\the\FTN@ftn\footnotetext[#1]{#2}}}
\def\FTN@xfootnote[#1]{%
   \begingroup
     \csname c@\@mpfn\endcsname #1\relax
     \unrestored@protected@xdef\@thefnmark{\thempfn}%
   \endgroup
   \@footnotemark\FTN@xftntext[#1]}

\makeatother

\begin{document}

\pushftn
\begin{table}[htbp]
\begin{center}
\begin{tabular}{ll}
\hline
X & Y \\
\hline
\hline
a & b \footnote{AB} \\
\hline
c & d \footnote{CD} \\
\hline
\end{tabular}
\end{center}
\end{table}
\popftn

\end{document}

我究竟做错了什么?

答案1

啊,你让我困惑了一会儿。坚持\begingroup在推动之前,\endgroup 流行音乐。

这个想法是你本地重新定义脚注命令以保存其内容,但代码假定当您执行已保存的命令时,它们会恢复其正常含义,否则它们只会再次保存其内容。

但请注意,将脚注从浮动表格中提取出来本质上是脆弱的,如果表格浮动到另一页,脚注将不会随之浮动,如果它在p浮动页面上结束,LaTeX 不支持此类页面上的脚注。

相关内容