mdframed icon indicating copy to clipboard operation
mdframed copied to clipboard

nesting mdframed with footnotes:

Open marcodaniel opened this issue 13 years ago • 2 comments

The following example demonstrates the behavior:

\documentclass{article}
\usepackage[bottom,para]{footmisc}
\usepackage{fancyvrb,xcolor}
\usepackage{mdframed}

\definecolor{TitleColor}{RGB}{118,177,0}
\definecolor{VerbatimColor}{RGB}{204,204,204}


\newenvironment{topic}
 {\begin{mdframed}
   [topline=false,
    bottomline=false,
    rightline=false,
    leftline=true,
    linewidth=2,
    linecolor=TitleColor,
    rightmargin=0pt,
    innerrightmargin=0pt,
    innertopmargin=0pt,
    innerbottommargin=0pt,
    innerleftmargin=2pt]
 }
 {\end{mdframed}}

\let\OriginalVerbatim=\Verbatim
\let\endOriginalVerbatim=\endVerbatim

\renewcommand{\Verbatim}[1][]{%
  \par\addvspace{1ex}
  \mdframed
    [backgroundcolor=VerbatimColor,
     hidealllines=true,
     skipbelow=1ex,
     innertopmargin=.2ex,
     innerbottommargin=.2ex,
     leftmargin=0pt]
  \OriginalVerbatim[#1]%
}
\renewcommand{\endVerbatim}{%
   \endOriginalVerbatim
   \endmdframed
}

\begin{document}
\begin{topic}
\textbf{Sample}

foo\footnote{first footnote in outer frame}

\begin{Verbatim}[commandchars=\\\{\}]
bar\footnote{footnote in inner frame}
baz
\end{Verbatim}

fubar\footnote{other footnote in outerframe}

\end{topic}


\end{document}

The inner footnote is placed wrong

marcodaniel avatar Nov 25 '12 10:11 marcodaniel

The problem is related to the standard definition of footnotes inside minipage. The example below demonstrates it:

\documentclass{article}
\usepackage[framemethod=tikz]{mdframed}

\begin{document}
some text \footnote{a}

\fbox{%
\begin{minipage}{.6\linewidth}
some test \footnote{first inside}

\fbox{%
\begin{minipage}{.5\linewidth}
some test \footnote{first inner inside}
\end{minipage}}

some test \footnote{second inside}
\end{minipage}}
\end{document}

marcodaniel avatar Nov 25 '12 10:11 marcodaniel

I think this problem is solved in tcolorbox, maybe there's a way to solve this in mdframed too? I use mdframed exclusively, and I would like to stick to this.

sleepymalc avatar Nov 05 '23 19:11 sleepymalc