# How to put footnotes in the page where they belong in a mdframed environment

I have a large bunch of text in a mdframed environment, that span more than one page.

As it seems reading the documentation, the mdframed environment put every footnotes at the end of the frame, by design.

Is there a way to put each footnotes at the bottom of the page where it belongs, remaining inside the frame? I know it should be possible, using maybe the \footnotemark and \footnotetext commands, but the mdframed internals are too complicated for me...

Here a code sample that shows the default behaviour:

\documentclass[]{report}
\usepackage{lipsum}
\usepackage{mdframed}

\begin{document}

\begin{mdframed}

\lipsum[1]
\lipsum[2]\footnote{can I appear in the first page inside the box?}
\lipsum[1]
\lipsum[1]
\lipsum[3]

\end{mdframed}

\end{document}

-
It's quite a problem: mdframed must know how much space is available on the page; and the footnote may or may not end in that page, depending on where it falls in the framed material. I think that some clever trick as done in bigfoot could solve the problem, but it's quite intricated. –  egreg Jun 12 '12 at 15:07
@egreg, you are right, but only if we want the footnote to appear in the right page outside the frame. I'm looking for a way to do it with the footnote inside the frame, so basically you have to put the entire page in the frame (meaning entire_page = text + possible footnote). This should be more simple, maybe! I'll check the bigfoot package, thx –  pjcairo Jun 12 '12 at 20:07
It's quite a problem: mdframed must know how much space is available on the page; and the footnote may or may not end in that page, depending on where it falls in the framed material. I think that some clever trick as done in bigfoot could solve the problem, but it's quite intricated.