3

In the code below, counters defined by mdframed seem to not be accessible to ntheorem environments which is problematic but ntheorem counters can be read by mdframed. I could not find a work around and it looks like this limitation is not referenced anywhere.

\documentclass[fleqn,11pt]{book}
\usepackage{amsmath}
\usepackage[amsmath]{ntheorem}
\usepackage[ntheorem,framemethod=TikZ]{mdframed}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\newmdtheoremenv{theorem}{Theorem}    % uncomment this line
\newtheorem{theorem}{Theorem}[chapter] % comment this line
\newtheorem{definition}[theorem]{Definition}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
text text text text text text text text text text text text  
\begin{definition}[Definition]
text text text text text text text text text text text text  
\end{definition}
text text text text text text text text text text text text  
\begin{theorem}[Theorem]
text text text text text text text text text text text text  
\end{theorem}
text text text text text text text text text text text text  
\end{document} 
1
  • 1
    The main idea of the implementation was the following syntax: \newmdtheoremenv{theorem}{Theorem} % uncomment this line \newmdtheoremenv{definition}[theorem]{Definition} I didn't realize your combination. Nov 26, 2011 at 23:56

2 Answers 2

8

It seems a "bug" at least in the documentation. Just switch the declarations:

\newtheorem{definition}{Definition}
\newmdtheoremenv{theorem}[definition]{Theorem}

Or declare a "dummy" theorem environment and define all in terms of this one:

\newtheorem{dummy}{dummy}[chapter]
\newmdtheoremenv{theorem}[dummy]{Theorem}
\newtheorem{definition}[dummy]{Definition}

(this might be useful for properly issuing \theoremstyle declarations).

\newtheorem{dummy}{dummy}[chapter]

\newmdtheoremenv{theorem}[dummy]{Theorem}

\theoremstyle{definition}
\newtheorem{definition}[dummy]{Definition}
3

EDIT

In the development status of mdframed the bug is fixed:

mdframed on github


Here is a solution with the package xparse. At the moment the solution isn't implemented in the current version of mdframed.

\documentclass[fleqn,11pt]{book}
\usepackage{amsmath}
\usepackage[amsmath]{ntheorem}
\usepackage[ntheorem,framemethod=TikZ]{mdframed}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xparse}
\RenewDocumentCommand\newmdtheoremenv{O{} m o m o }{
 \ifboolexpr{ test {\IfNoValueTF {#3}} and test {\IfNoValueTF {#5}} }%
    {\newtheorem{#2}{#4}}{%
     \IfValueTF{#3}{\newtheorem{#2}[#3]{#4}}{}%
     \IfValueTF{#5}{\newtheorem{#2}{#4}[#5]}{}%
    }%
  \BeforeBeginEnvironment{#2}{%
     \begin{mdframed}[#1]}%
  \AfterEndEnvironment{#2}{%
     \end{mdframed}}%
}

\newmdtheoremenv{theorem}{Theorem}    % uncomment this line
%\newtheorem{theorem}{Theorem}[chapter] % comment this line
\newtheorem{definition}[theorem]{Definition}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
text text text text text text text text text text text text  
\begin{definition}[Definition]
text text text text text text text text text text text text  
\end{definition}
text text text text text text text text text text text text  
\begin{theorem}[Theorem]
text text text text text text text text text text text text  
\end{theorem}
text text text text text text text text text text text text  
\end{document} 

You must log in to answer this question.

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