Footnotes in a verbatim environment that also appear in (or just below) that environment

I require a verbatim like environment that allows footnotes and, in addition, displays the footnote text in that environment (as opposed to the page) or just below the environment floating with it.

I have got the following.

\documentclass[a4paper,10pt]{book}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{bera}

\newenvironment{MyVerb}[1]
{\endVerbatim}

\begin{document}

An apple a day....

\begin{MyVerb}{Blah}
Blah.
Blah@footnote{Blah.} blah.
Blah.
\end{MyVerb}

...keeps the doctor away.

\end{document}


The footnote numbers appear but the footnote text appears neither on the page nor in the environment. I would like the footnote bodies to appear inside the "boxed" verbatim environment (as opposed to the page).

The footnotes need not be verbatim nor even appear directly in the verbatim environment itself, but they must appear at the bottom of the box around the verbatim.

Two versions:

FOOTNOTE BELOW BOX

Putting it in a minipage seems to nearly satisfy the requirement, except the footnote is immediately below the box, not inside of it. I personally think this is how it should be. Note, however, that minipage footnote symbols are alphabetic, not numeric.

\documentclass[a4paper,10pt]{book}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{bera}

\newenvironment{MyVerb}[1]
{\endVerbatim}

\begin{document}

An apple a day....

\bigskip\noindent\begin{minipage}{\textwidth}
\begin{MyVerb}{Blah}
Blah.
Blah@footnote{Blah.} blah.
Blah.
\end{MyVerb}
\end{minipage}
\smallskip

...keeps the doctor away.
\end{document}


FOOTNOTE WITHIN BOX

Because this uses an \fbox, the border appearance can be changed with \fboxrule and \fboxsep.

\documentclass[a4paper,10pt]{book}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{bera}
\usepackage{xcolor,stackengine}
\newenvironment{MyVerb}[1]
{\par
\medskip
\noindent
\setbox0=\hbox\bgroup
\minipage{\dimexpr\textwidth-2\fboxsep-2\fboxrule\relax}%
\Verbatim[commandchars=@\{\}]%
}{%
\endVerbatim
\endminipage%
\egroup
\stackengine{-\dimexpr.1pt+\fboxrule\relax}{\fbox{\copy0}}%
\par
\bigskip}
\begin{document}
An apple a day....
\begin{MyVerb}{Blah}
Blah. dsklfdkf dskljfd flk sdkfjl sdjfkldsfj
Blah@footnote{Blah.} blah.
Blah.
\end{MyVerb}
...keeps the doctor away.
\end{document}


• much appreciated – fundagain Apr 3 at 19:07
• @KJO Thank you. – fundagain Apr 3 at 19:07
• @fundagain Made a small change, to prevent verbatim text from being covered up by white box of \header. – Steven B. Segletes Apr 3 at 19:09
• Looks beautiful! – fundagain Apr 3 at 19:11