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.

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} 
share|improve this question
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. –  Marco Daniel Nov 26 '11 at 23:56

2 Answers 2

up vote 7 down vote accepted

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}
share|improve this answer

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} 
share|improve this answer

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.