0

When I use the mdframed environment around a table, I encounter two problems: (1) The footnotes do not appear at the bottom of the page; (2) The footnotes are marked with letters, while the rest of the footnotes in my document are in Arabic.

I tried using the tablefootnote package, but did not have much success. I wrote \footnotemark{} where I want a footnote, and then put footnotetext[1]{Text I want} outside of the mdframed environment. But this seemed like a really bad idea, because I need to manually adjust the footnote numbering if I add footnotes earlier in the document. (For example: if I add a footnote earlier than this one, I would need to go back and change footnotetext[1]{Text I want} to footnotetext[2]{Text I want}.)

I have included a screenshot:

enter image description here

And the code that produced the screenshot:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{float}
\usepackage{framed}
\usepackage{tcolorbox}
\usepackage{enumitem}
\usepackage{tablefootnote} %allows footnotes in tables to appear outside the table
%%table packages
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{mdframed}

\begin{document}
If I have footnote in the text\footnote{The first footnote} it gets put at the bottom of the page. But if my footnote is inside the \fbox{mdframed} environment, then the footnotes don't appear.

\begin{mdframed}
\begin{table}[H]
\hspace{-5mm}
\begin{tabular}{p{35mm}  p{25mm} <\raggedright }
\underline{Column 1} & \underline{Column 2} \\
Text & more text \\
Text with footnote\footnote{I want this footnote to be at the bottom, and in Arabic numbering!} & ?? \\
\end{tabular}
\end{table}
\end{mdframed}

This should be footnote number three\footnote{The third footnote}, but it is footnote number two.

\end{document}
2

2 Answers 2

2

You could do this:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{float}
\usepackage{framed}
\usepackage{tcolorbox}
\usepackage{enumitem}
\usepackage{tablefootnote} %allows footnotes in tables to appear outside the table
%%table packages
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{mdframed}

\begin{document}
If I have footnote in the text\footnote{The first footnote} it gets put at the bottom of the page. But if my footnote is inside the \fbox{mdframed} environment, then the footnotes don't appear.

\begin{mdframed}
\begin{table}[H]
\hspace{-5mm}
\begin{tabular}{p{35mm}  p{25mm} <\raggedright }
\underline{Column 1} & \underline{Column 2} \\
Text & more text \\
Text with footnote\footnotemark{} & ?? \\
\end{tabular}
\end{table}
\end{mdframed}\footnotetext{I want this footnote to be at the bottom, and in Arabic numbering!}

This should be footnote number three\footnote{The third footnote}, but it is footnote number two.

\end{document}

Edit: Some kind of hack to the original marcos. Two new marcos \myfootnotemark,\myfootnotetext have been defined to function similar to the original one. However it will update the footnote counter when the \myfootnotetext used. In order to make the superscript footnote number in main content to correctly typed, some temp counters have been defined.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{float}
\usepackage{framed}
\usepackage{tcolorbox}
\usepackage{enumitem}
\usepackage{tablefootnote} %allows footnotes in tables to appear outside the table
%%table packages
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{mdframed}
\newcounter{myfn}
\newcounter{tpmyfn}
\makeatletter
\def\myfootnotemark{%
   \@ifnextchar[\@xfootnotemark
     {\stepcounter{myfn}%
      \setcounter{tpmyfn}{\value{footnote}+\value{myfn}}%
      \protected@xdef\@thefnmark{\thetpmyfn}%
      \@footnotemark}}
      
\def\myfootnotetext{%
     \@ifnextchar [\@xfootnotenext
       {\stepcounter{footnote}\setcounter{myfn}{0}\protected@xdef\@thefnmark{\thempfn}%
    \@footnotetext}}
\makeatother

\begin{document}
If I have footnote in the text\footnote{The first footnote} it gets put at the bottom of the page. But if my footnote is inside the \fbox{mdframed} environment, then the footnotes don't appear.

\begin{mdframed}
\begin{table}[H]
\hspace{-5mm}
\begin{tabular}{p{35mm}  p{25mm} <\raggedright }
\underline{Column 1} & \underline{Column 2} \\
Text & more text \\
Text with footnote\myfootnotemark & some text \\
Text with footnote\myfootnotemark & some text \\
\end{tabular}
\end{table}
\end{mdframed}\myfootnotetext{one}\myfootnotetext{two}

This should be footnote number three\footnote{The third footnote}, but it is footnote number two.

\end{document}

enter image description here

4
  • Thanks for this reply. Unfortunately, I don't think this will work if I want more than one footnote in my table. I just tried this code with two footnotes, and it made them both footnote 3 (i.e. I now have two footnotes at the bottom of my page that are both numbered 3). I suppose one could write \footnotetext[2]{second footnote} and \footnote[3]{third footnote}, but then I have to manually update these numbers if I include any footnotes earlier in the document...
    – Sam Y.
    Commented May 31, 2022 at 21:36
  • @Sam I update my answer to include a solution.
    – Tom
    Commented May 31, 2022 at 23:17
  • Thanks for all this effort!
    – Sam Y.
    Commented Jun 1, 2022 at 1:38
  • @Sam You are welcome
    – Tom
    Commented Jun 1, 2022 at 1:39
1

OK, so I think I figured out a way to do it. It is based on an answer by @Bernard in this post. It works for framed, but strange things happen if I try to merely include the code \usepackage{mdframed}! If I include this in the preamble (without changing anything else), I get an error when the compiler comes to the first footnote in the table. Strange!

Code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{float}
\usepackage{framed}
\usepackage{footnote}
\usepackage{etoolbox}

\BeforeBeginEnvironment{framed}{\savenotes}
\AfterEndEnvironment{framed}{\spewnotes}



\begin{document}
If I have a footnote in the text\footnote{The first footnote} it gets put at the bottom of the page. But if my footnote is inside the \fbox{framed} environment, then the footnotes don't appear.

\begin{framed}
\begin{table}[H]
\hspace{-5mm}
\begin{tabular}{p{35mm}  p{25mm} <\raggedright }
\underline{Column 1} & \underline{Column 2} \\
Text & more text \\
Text with footnote two\footnote{footnote 2} & ?? \\
Text with footnote three\footnote{footnote 3} & more text\\
\end{tabular}
\end{table}
\end{framed}

Now to test with footnotes outside of the `framed` environment: footnote number four\footnote{footnote 4}.

\end{document}
1
  • Such a nice suggestion, using mdframed.sty
    – MadyYuvi
    Commented Feb 26 at 6:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .