mdframed 中的脚注:为什么它们不在页面底部?

mdframed 中的脚注:为什么它们不在页面底部?

当我使用mdframed围绕表格的环境时,遇到了两个问题:(1)脚注没有出现在页面底部;(2)脚注用字母标记,而我的文档中其余的脚注都是阿拉伯语。

我尝试使用该tablefootnote包,但收效甚微。我写下了\footnotemark{}我想要的脚注位置,然后将其放在footnotetext[1]{Text I want}mdframed 环境之外。但这似乎是一个非常糟糕的主意,因为如果我在文档中较早的地方添加脚注,我需要手动调整脚注编号。(例如:如果我添加的脚注早于此,我需要返回并更改为footnotetext[1]{Text I want}footnotetext[2]{Text I want}

我附上了一张截图:

在此处输入图片描述

生成屏幕截图的代码如下:

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

答案1

你可以这样做:

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

编辑:对原始马可进行了某种形式的修改。已定义两个新马可\myfootnotemark,其功能与原始马可类似。但是,使用时会更新脚注计数器。为了使正文中的上标脚注编号正确输入,已定义一些临时计数器。\myfootnotetext\myfootnotetext

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

在此处输入图片描述

答案2

好的,我想我找到了一种方法来做到这一点。它基于@Bernard 的回答邮政。它适用于framed,但如果我尝试仅包含代码,就会发生奇怪的事情\usepackage{mdframed}!如果我将其包含在序言中(不更改任何其他内容),当编译器到达表中的第一个脚注时,我会收到错误。奇怪!

代码:

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

相关内容