0

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

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{preamble}
\usepackage{listings}
\usepackage{enumitem}
\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}
\numberwithin{equation}{section}
\begin{document}
\maketitle
\vspace{.25in}
\section*{Lecture 1}
\addtocounter{section}{1}
\begin{definition}
This is Definition 1.1.
\end{definition}
\begin{definition}
This is definition 1.2.
\end{definition}
\section*{Lecture 2}
\addtocounter{section}{1}
\begin{theorem}
This is Theorem 2.3. But I would like it to be Theorem 2.1.
\end{theorem}

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.

\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{wasysym}
\usepackage{verbatim}
\usepackage{bbm}
\usepackage{graphics}
\usepackage{geometry}
\usepackage{latexsym}
\usepackage{epsfig}
\usepackage{bm}
\usepackage{xspace}
\usepackage{times}
\usepackage{listings}
\usepackage{color}
\usepackage{tikz}
\usetikzlibrary{graphs,graphs.standard}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{fact}[theorem]{Fact}
\newtheorem{notation}[theorem]{Notation}
\newtheorem{observation}[theorem]{Observation}
\newtheorem{conjecture}[theorem]{Conjecture}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
SescoMath
  • 177
  • 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. – SescoMath Jul 01 '20 at 02:26
  • Is this helpful? – dwolfeu Jul 01 '20 at 07: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 – Peter Wilson Jul 01 '20 at 17:28
  • @PeterWilson I have clarified and updated the question. – SescoMath Jul 01 '20 at 20:54
  • @dwolfeu the link you provided is not helpful, the correction they propose there is to use \newtheorem{theorem}{Theorem}[section], which I am already using and does not fix the numbering problem. I agree that it seems like it should. – SescoMath Jul 01 '20 at 20:56
  • I am a little confused, as \numberwithin{equation}{section} and \newtheorem{theorem}{Theorem}[section] do seem like they should produce the desired behaviour (as far as I have understood it). Perhaps you could manually typeset some minimal desired output so that we can see exactly what you mean (like here)? The MWE should also include some minimal text body, not just the preamble. – dwolfeu Jul 02 '20 at 06:33
  • 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. – Peter Wilson Jul 02 '20 at 17:36
  • @PeterWilson sorry I didnt know what a MWE was. I believe what I have now should be a MWE. – SescoMath Jul 02 '20 at 22:51
  • 1
    Don't do \section*{title} and \addtocounter{section}{1}! Use \section if there is numbering involved. At least use \stepcounter{section}. – Donald Arseneau Jul 02 '20 at 23:56

1 Answers1

2

You already have

\newtheorem{theorem}{Theorem}[section]

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

\addtocounter{section}{1}

with

\refstepcounter{section}

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

\renewcommand\thesection{Lecture~\arabic{section}}
\renewcommand\thetheorem{\arabic{section}.\arabic{theorem}}

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

\section{}

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:

\renewcommand\numberline[1]{%
\begingroup
 \sbox\@tempboxa{#1 }%
 \ifdim\wd\@tempboxa<\@tempdima
  \wd\@tempboxa=\@tempdima
 \fi
 \usebox\@tempboxa
\endgroup
}

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