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:


But I get error.

What should I change in the header?

Thanks in advance.



 An \textit{inhomogeneous linear} differential equation has the form
 L[v ] = f,
 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.}


 \tikz[baseline=(current bounding box.east),outer sep=0pt]
 {\strut Theorem~\thetheo};}}
 \tikz[baseline=(current bounding box.east),outer sep=0pt]
    {\strut Theorem~\thetheo:~#1};}}%

 \begin{theo}[Inhomogeneous Linear]



this is the output of my tex file

  • 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
  • 2
    Either use \renewcommand{\thetheo}{\thechapter.\arabic{theo}} or \renewcommand{\thetheo}{\thesection.\arabic{theo}} together with \refstepcounter instead of just \stepcounter. – Werner Jan 17 '16 at 3:35
  • 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

Either use

\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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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