TransWikia.com

Why footnote doesn't work in tabular environment?

TeX - LaTeX Asked by yegor256 on February 25, 2021

This is what I’m trying to do:

documentclass[11pt,oneside]{article}
usepackage{tablefootnote}
begin{document}
begin{tabular}{l}
Hellofootnote{World!} 
Hellotablefootnote{World!} 
end{tabular}
end{document}

I see footnote marks, but I don’t see footnote texts. What is wrong?

2 Answers

I will make the assumption that in your real documents, the footnotes associated with tabular material are a bit less simplistic than "World". If that's indeed the case, you may want to familiarize yourself with the powerful threeparttable package, its tnote macro, and its tablenotes environment. The argument of tnote can be just about any symbol, and arguments can be repeated if needed.

enter image description here

documentclass[11pt]{article}
usepackage{threeparttable,array}
begin{document}
begin{center}
setlengthextrarowheight{2pt} % for a more open look
begin{threeparttable}
begin{tabular}{l}
hline
Hellotnote{a} 
Goodbyetnote{*} 
hline
end{tabular}
footnotesize
begin{tablenotes}
item[a] World!
item[*] World.
end{tablenotes}
end{threeparttable}
end{center}
end{document}

Answered by Mico on February 25, 2021

When using tablefootnote, in the first line of your tabular it should be tablefootnote instead of footnote. Then the two tablefootnote commands are in a tabular, but not in a table environment. Either add a table environment:

begin{table}
begin{tabular}{l}
Hellofootnote{World!} 
Hellotablefootnote{World!} 
end{tabular}
end{table}

(and maybe centering, caption[...]{...}, label{...}, ...),

or a spewnotes after the tabular, so that the tablefootnote package knows that you finished the table:

begin{tabular}{l}
Hellofootnote{World!} 
Hellotablefootnote{World!} 
end{tabular}
spewnotes

The command spewnotes is not yet defined in current version 2014/01/27 1.1c of package tablefootnote, thus after

usepackage{tablefootnote}

it is necessary to write:

makeatletter
@ifpackagelater{tablefootnote}{2014/01/27}
  {relax% should include spewnotes
  }%
  {newcommand{spewnotes}{%
      ltx@ifpackageloaded{footnotebackref}{%
        LetLtxMacro{tfncurrentmft}{@makefntext}%
        LetLtxMacro{@makefntext}{tablemakefntext}%
         tfn@tablefootnoteprintout%
        LetLtxMacro{@makefntext}{tfncurrentmft}%
       }{% footnotebackref not loaded
        tfn@tablefootnoteprintout%
       }%
      gdeftfn@fnt{0}%
      globallettfn@tablefootnoteprintoutrelax% just to be sure and safe
    }%
  }
makeatother

Thus the complete document reads:

documentclass[11pt,oneside]{article}
usepackage{tablefootnote}
makeatletter
@ifpackagelater{tablefootnote}{2014/01/27}
  {% should include spewnotes
  }%
  {newcommand{spewnotes}{%
      ltx@ifpackageloaded{footnotebackref}{%
        LetLtxMacro{tfncurrentmft}{@makefntext}%
        LetLtxMacro{@makefntext}{tablemakefntext}%
         tfn@tablefootnoteprintout%
        LetLtxMacro{@makefntext}{tfncurrentmft}%
       }{% footnotebackref not loaded
        tfn@tablefootnoteprintout%
       }%
      gdeftfn@fnt{0}%
      globallettfn@tablefootnoteprintoutrelax% just to be sure and safe
    }%
  }
makeatother

begin{document}
begin{tabular}{l}
Hellotablefootnote{World!} 
Hellotablefootnote{World!} 
end{tabular}
spewnotes

end{document}

Answered by Stephen on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP