# How to renumber a theorem environment with mdframed package?

I have the next document, which compiles fine.

I want to change the numbering of theorems according to the number of section or chapter (view image).

I wrote:

\newmdtheoremenv{theo}{Theorem}[section]


But I get error.

What should I change in the header?

 \documentclass[12pt,twoside,openright]{book}

\usepackage[framemethod=tikz]{mdframed}
\usepackage{mathtools}

\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newrobustcmd\ExampleText{%
An \textit{inhomogeneous linear} differential equation has the form
\begin{align}
L[v ] = f,
\end{align}
where $L$ is a linear differential operator, $v$ is
the dependent variable, and $f$ is a given non-zero
function of the independent variables alone.}

\begin{document}

\newcounter{theo}[section]
\newenvironment{theo}[1][]{%
\stepcounter{theo}%
\ifstrempty{#1}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo};}}
}%
{\mdfsetup{%
frametitle={%
\tikz[baseline=(current bounding box.east),outer sep=0pt]
\node[anchor=east,rectangle,fill=blue!20]
{\strut Theorem~\thetheo:~#1};}}%
}%
\mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
linewidth=2pt,topline=true,
frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
\begin{mdframed}[]\relax%
}{\end{mdframed}}

\begin{theo}[Inhomogeneous Linear]
\ExampleText
\end{theo}

\begin{theo}
\ExampleText
\end{theo}

\end{document}


• What do you mean exactly? Writing Theorem 2.1 for the 1st theorem of section 2, or just resetting theorem numbering at each new section? – Bernard Jan 17 '16 at 3:19
• Werner thank you very much. I wrote \renewcommand{\thetheo}{\thechapter.\arabic{theo}} } just above \ begin {theo} .. and it worked perfectly :) – mathsalomon Jan 17 '16 at 4:50
• @Bernard Yes that's exactly what I want. But I solved thanks anyway. – mathsalomon Jan 17 '16 at 5:02
• @Werner I have one last question: How to write code latex in these comment boxes ?, these codes you left highlighted in gray. Thanks. – mathsalomon Jan 17 '16 at 5:13

\renewcommand{\thetheo}{\thechapter.\arabic{theo}}% ...for chapter prefix

\renewcommand{\thetheo}{\thesection.\arabic{theo}}% ...for section prefix

together with \refstepcounter instead of just \stepcounter. This allows you to use \label and later \reference the theorem.