Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I've discovered what appears to be a bug in the mdframed package. My goal was to use a package which allows me to create shaded theorem environments which span multiple pages (thmtools does not allow this). Run this minimal example:

\documentclass{memoir}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{blindtext}

\newmdtheoremenv{theorem}{Theorem}

\begin{document}
\chapter{Hello}
\marginpar{\vspace*{9pt}\chapnumfont\thechapter}  % COMMENT IN/OUT

\begin{theorem}
\blindtext[2]
\end{theorem}

\begin{theorem}
\blindtext[3]
\end{theorem}
\end{document}

When the marked line is commented out, then the theorems render as expected -- that is, the second theorem spans the first and second page. However, when the marked line is commented in, then the two theorems are generated on separate pages. The marked line simply adds in the chapter number on the side.

BadGood

Does anybody know the source of the bug? Moreover, is there a way to work around this? I want the theorems to span the pages, as the package was designed!

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

Although I don't know exactly what's going on, I don't think it's a bug in mdframed, but a bad interaction of \marginpar. As a workaround you can use \marginnote from the marginnote package:

\documentclass{memoir}
\usepackage[english]{babel}
\usepackage{amsthm}
\usepackage{mdframed}
\usepackage{marginnote}
\usepackage{blindtext}

\newmdtheoremenv{theorem}{Theorem}

\begin{document}
\chapter{Hello}
\marginnote{\chapnumfont\thechapter}

\begin{theorem}

\blindtext[2]
\end{theorem}

\begin{theorem}
\blindtext[3]
\end{theorem}
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.