2

I have a document in which I declare a thm environment using amsthm, and then I decorate these theorem using \surroundwithmdframed from mdframed package. In addition, I have the amsmath for other purposes.

In my theorems, I include the proof using the standard proof environment (from amsthm). This proof environment begins the proof with a "Proof. " heading and closes with a square (\qed).

I this context, when I write a theorem starting with a math environment (\[...\]), the proof heading (i.e. "Proof. ") is not printed. Even more surprising, the "Proof. " heading is moved at the begining of the following (non-thm) environment.

For instance, in the following example, the proof of Theorem 1 should read "Proof. Trivial. \qed". However, the "*Proof. *" is moved just before the "Centered." after.

\documentclass{article}
\usepackage{mdframed}
\usepackage{amsmath}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\mdfdefinestyle{thm-frame}{}
\surroundwithmdframed[style=thm-frame]{thm}

\begin{document}

\begin{thm}
    \[\forall P\cdot P\]
    \begin{proof}
            Trivial.
    \end{proof}
\end{thm}
\begin{thm}

\end{thm}
\begin{center}
    Centered.
\end{center}
\end{document}

enter image description here


Notice that:

  • if any of the 3 packages is removed (and the file is modified accordingly, e.g. by removing the \surroundwithmdframed), the problem does not occur anymore
  • if the theorem does not begin with a \[ ... \] math environment (e.g. a \(...\) math environment or a sentence), the problem does not occur
  • this is, by far, the strangest behavior of LaTeX I encountered so far...
3
  • 1
    Why do you have the proof inside the thm, they are two separate things.
    – daleif
    Jan 27, 2020 at 14:50
  • 1
    I would suggest not to nest a proof environment within a thm environment, and simply use an outer mdframed environment which encloses both the theorem and its proof.
    – Bernard
    Jan 27, 2020 at 14:51
  • The reason proofs are nested in theorem is mainly historical. I don't have a strong opinion on this, but the original reason is that I was told, more or less, that theorems are nothing without their proof, hence proof should go with their theorem.
    – Bromind
    Jan 27, 2020 at 15:03

1 Answer 1

5

I suggest to drop mdframed. It has bugs and is no longer maintained. Use tcolorbox instead:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}

\usepackage{tcolorbox}
\tcbuselibrary{theorems,skins,breakable}

\tcolorboxenvironment{thm}{
enhanced jigsaw,colframe=cyan,interior hidden,
breakable,before skip=10pt,after skip=10pt }


\begin{document}

\begin{thm}{}
    \[\forall P\cdot P\]
    \begin{proof}
            Trivial.
    \end{proof}

\end{thm}
\begin{thm}

\end{thm}
\begin{center}
    Centered.
\end{center}
\end{document}

enter image description here

1
  • Nice, I'll apply the change before accepting the answer ;-)
    – Bromind
    Jan 27, 2020 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .