Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Code proposed by David Carlisle works out-of-the box, cause has no package dependencies. It's comfortable solution of dealing with footnotes in environments needing \footnotemark+footnotetext.

I have no problems in using it with \vbox and itemize.

However when I try to apply it to centred tabular I encounter problem - footnotes are not rendered, only footmarks:

\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

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

What am I doing wrong?

share|improve this question
    
The table environment builds a box; so \pushftn must go inside it. Of course this will fail if the table is typeset as a page float. –  egreg Feb 8 '12 at 15:39
    
Also you might want to replace \begin{center} by \centering and delete \end{center}. –  Stephen Feb 8 '12 at 18:22
add comment

1 Answer

up vote 3 down vote accepted

Ah, you had me confused there for a while. Stick \begingroup before the push and \endgroup before the pop.

the idea is that you locally redefine the footnote commands to save their contents but the code assumes that by the time you execute the saved commands they have their normal meanings back, otherwise they just save their contents again.

Note though that lifting the footnotes out of the floating table is inherently fragile, if the table floats off to another page, the footnotes will not float with it, and if it ends on a p float page, LaTeX does not support footnotes on such a page.

share|improve this answer
    
Thank you. Now it works :) \begingroup and \endgroup solves problem. Your description clarifies me how all this works. Good point of not using footnotes inside floats, I've forgot about this. –  Grzegorz Wierzowiecki Feb 8 '12 at 16:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.