TransWikia.com

Footnote in tabular environment

TeX - LaTeX Asked by strpeter on April 23, 2021

It seems as if footnotes would have only a problem with the table environment but in my minimal example non of those answers

seem to work for the tabular environment.

documentclass{scrartcl}

begin{document}
begin{tabular}{l}
Contentfootnote{Footnote}
end{tabular}
end{document}

6 Answers

another possibility is with the footnote package and makesavenoteenv{tabular}:

documentclass{scrartcl}
usepackage{footnote}
makesavenoteenv{tabular}
begin{document}
begin{tabular}{l}
Contentfootnote{footnote text}
end{tabular}
end{document}

If one has both tabular-only environment and tabular inside table, it is possibile to load both makesavenoteenv{tabular} and makesavenoteenv{table} in the preamble, like this:

documentclass{scrartcl}
usepackage{footnote}
makesavenoteenv{tabular}
makesavenoteenv{table}
begin{document}
begin{table}
begin{tabular}{l}
Contentfootnote{footnote text}
end{tabular}
end{table}
begin{tabular}{l}
Contentfootnote{footnote text}
end{tabular}
end{document}

So to have a more general solution.

Also, a fairly comprehensive list of solutions can be found inside the documentation for the tablefootnotepackage, starting from page 3, section "Alternatives".

Correct answer by Old Nick on April 23, 2021

For some reason (my preferred choice) the tablefootnote package only works if you wrap the tabular in a table float. A way around is to use footnotemark and footnotetext:

documentclass{scrartcl}

begin{document}    
before

begin{tabular}{l}
Contentfootnotemark
Content continuedfootnotemark
Content continued furtherfootnotemark
end{tabular}
footnotetext[1]{Footnote}
footnotetext[2]{Second footnote}
footnotetext{Third footnote}

after
end{document}

Note how manual numbering of all but the first footnotetext is necessary. In a longer document, an approach with manually decrementing and incrementing the footnote number might be more viable; that way, the only way you have to watch out for is decrementing by the correct number:

documentclass{scrartcl}
begin{document}    
before

begin{tabular}{l}
Contentfootnotemark
Content continuedfootnotemark
Content continued furtherfootnotemark
end{tabular}
addtocounter{footnote}{-2}
footnotetext[1]{Footnote}
addtocounter{footnote}{1}
footnotetext{Second footnote}
addtocounter{footnote}{1}
footnotetext{Third footnote}

after
end{document}

sample output

Answered by Count Zero on April 23, 2021

If you use bidiftnxtra (a part of bidi package), all combinations of table and tabular will work. Ofcourse, this only work if you are using xelatex but the approach can be ported to other packages too:

documentclass{scrartcl}
usepackage{bidi}
usepackage{bidiftnxtra}
begin{document}
begin{tabular}{l}
Contentfootnote{Footnote}
end{tabular}

begin{table}[h]
centering
begin{tabular}{l}
Contentfootnote{Footnote}
end{tabular}
caption{This is a captionfootnote{Another footnote.}}
end{table}
end{document}

Answered by Persian TeX Group on April 23, 2021

You can also use threeparttable package to insert footnotes in the tables.

documentclass{article}
usepackage[flushleft]{threeparttable}
begin{document}
begin{table}[h]
caption{Example of test session results}
label{tab:test_results}
centering
begin{threeparttable}
  begin{tabular}{|l|l|l|}
    hline
    Mutants & CPUtnote{1}     & Memorytnote{2}     hline
    Mutant-1   & 23 & 15  hline
    Mutant-2   & 32 & 11  hline
  end{tabular}
  begin{tablenotes}
    item[1] Measured in percentages.
    item[2] Measured in kilobytes (KB).
  end{tablenotes}
end{threeparttable}
end{table}
end{document}

Output:

Table

Answered by JohnM on April 23, 2021

I particularly like @CountZero's answer, yet it may happen that your footnote mark is on a different page than your footnote text. In that case, you can move around the footnotetext to solve that, but how do you become aware of it in the first place?

This code will issue a warning when that happens:

documentclass{article}

% works with hyperref, too:
% usepackage{hyperref}

% Footnotes in table with page-number check
usepackage{refcount}
newcommand{myfootnotemark}{footnotemarklabel{fn:mark}}
newcommand{myfootnotetext}[1]{footnotetext{#1label{fn:text}%
        edeffnmark{getpagerefnumber{fn:mark}}%
        edeffntext{getpagerefnumber{fn:text}}%
        ifxfnmarkfntextelseClassWarning{}{footnote mark and text on different pages!}fi}}

begin{document}
    begin{tabular}{l}
%       Table stuff footnote{This does not work: the footnote is missing.}
        Table stuff myfootnotemark
    end{tabular}

% uncomment to see the warning:
% pagebreak

myfootnotetext{So we do this instead!}

end{document}

It works only for a single footnotemark/footnotetext pair so far, but extension should not be too difficult and those who use this weird hack more than once in a document are hopefully apt enough to adapt my code accordingly :)

Answered by bers on April 23, 2021

I insert footnotes manually at the bottom of the table, which is pretty simple and requires no additional package:

begin{table}
caption{The Table.}
centering
  begin{tabular}{lrr}
   hline
          & Variable A & Variable B 
   hline
      Item 1        & 234.5 & 678.9 
      Item 2~$^{1}$ & 432.1 & 876.5 
   hline
   multicolumn{3}{l}{$^{1}$footnotesize{Here is a footnote.}} 
  end{tabular}
end{table}

Answered by Luís de Sousa on April 23, 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