I am writing up lecture notes for a class and it gets quite long and has many theorems, lemmas, etc. I would like to know how to get the numbering of these environments to reset at the start of each section. As it is now, these environments are getting numbered in the hundreds at it looks bad. Below are all the relevant parts of my preamble. I have looked into this a non-trivial amount and asked the professor whose class the notes came from for help and the best we got is including "\numberwithin{equation}{section}" in the preamble. This did not solve the problem unfortunately. Is there a simple fix so that theorems in section n are numbered n.1, n.2, etc.?

\geometry{tmargin=.75in, bmargin=.75in, lmargin=.75in, rmargin = .75in}  
\title{Ma 121a Lecture Notes}
\author{Instructor: Dr. Professor\\ Notes written by Me}
\date{Academic Year 2019-2020}
\section*{Lecture 1}
This is Definition 1.1.
This is definition 1.2.
\section*{Lecture 2}
This is Theorem 2.3. But I would like it to be Theorem 2.1.

The above is a MWE. What follows below is the preamble I load in separately as a .sty file using \usepackage{preamble}. The MWE will not work without the preamble.

  • To elaborate a little more, we also had issues with numbering across sections, for example a theorem in section would be say Theorem 1.50, but we fixed this partially by adding "\addtocounter{section}{1}" after each new section. Now it would read Theorem 4.50, but if it is the first theorem in section 4, I would want it to be numbered Theorem 4.1.
    – PhysMath
    Jul 1, 2020 at 2:26
  • Is this helpful?
    – dwolfeu
    Jul 1, 2020 at 7:06
  • Please provide an MWE that we can process. Having deleted the \usepackage{preamble} line I get that \geometry is undefined. I haven't bothered to try anything else after that. --- GOM Jul 1, 2020 at 17:28
  • 1
    @PhysMath You have shown the code for your preamble.sty but you have shown no code for the body of the document --- no \section, no theorems, lemmas, etc. Your MWE should start with \documentclass... and end with \end{document} that we can process that shows your problem. We can make wild guesses as to what you have done, but they will be wild and probably nothing to do with what you have actually done. Jul 2, 2020 at 17:36
  • 1
    Don't do \section*{title} and \addtocounter{section}{1}! Use \section if there is numbering involved. At least use \stepcounter{section}. Jul 2, 2020 at 23:56

1 Answer 1


You already have


so the theorem counter will be reset for every numbered section, but not for unnumbered sections even when the section counter gets a value assigned. As a minimal change, replace




which resets the theorem counter and has the added benefit that you can use \label and \ref to refer to other lectures.

On the other hand, it looks like you really do have numbered sections, but don't want the formatting used by regular sections. I suggest you switch to the numbered \section command and omit any explicit setting of the section counter. Declare


This inserts the word "Lecture" before the section number, rather than following it. Of course you don't want the word in the theorem number, so you would redefine that to skip \thesection and use \arabic{section} directly. At each lecture declare a section without title


This handles resetting the theorem counter, displays the lecture title as you wanted, allows rearrangement without manual editing, allows explanatory titles for lectures

\section{Welcome class} % for lecture 1

It gives cross referencing, and potential for a table of contents.

If you make a table of contents, put this redefinition in preamble.sty:

 \sbox\@tempboxa{#1 }%

because the standard definition does not like section "numbers" as wide as "Lecture 2".

  • 1
    This is excellent, thanks! Works as advertised.
    – PhysMath
    Jul 3, 2020 at 5:54

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.