禁忌表中的脚注未显示

禁忌表中的脚注未显示

我应该使用哪个包来正确处理表格中的脚注tabu?我以为tabu应该可以做到一切tabularx,但脚注却没有显示在tabu表格中。

工作(使用tabularx):

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{5cm}{c}
Cell \footnote{Footnote}
\end{tabularx}
\end{document}

不工作(与tabu):

\documentclass{article}
\usepackage{tabu}
\begin{document}
\begin{tabu}{c}
Cell \footnote{Footnote}
\end{tabu}
\end{document}

答案1

\documentclass{article}
\usepackage{tabu}
\usepackage{hyperref}   % this line is added.
\begin{document}
\begin{tabu}{c}
Cell \footnote{Footnote}
\end{tabu}
\end{document}

正如@cacamailg 在评论中所说,“如果您在 tabu 之后加载 hyperref,它就会起作用”。谢谢,@cacamailg。

答案2

下面的代码似乎有效:

\documentclass{report}

%Thanks to David Carlisle for pushftn and popftn : http://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

\usepackage[hyperfootnotes=false]{hyperref}
%\usepackage{hyperref}
\usepackage{varwidth}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{tabu}

\begin{document}

\begin{table}[htbp]
\begin{varwidth}{\textwidth}
\caption{Testing table}
\renewcommand{\footnoterule}{\vspace{-0.5\skip\footins}}
%\renewcommand{\footnoterule}{}
\begingroup\pushftn
\begin{tabu} to \linewidth{lX}
\toprule
a & b\footnote{AB} \\
\midrule
c & d\footnote{CD} \\
\bottomrule
\end{tabu}
\endgroup\popftn
\end{varwidth}
\end{table}

\noindent
Some text 1\footnote{This is a footnote 1.}.
\noindent
Some text 2\footnote{This is a footnote 2.}.

\end{document}

相关内容