[Tex/LaTex] Equation numbering by chapter

equationsnumbering

I am writing my thesis in book environment using Latex. The equation numbers for every chapter start with prefix "1" i.e. the equation numbers in chapter 1 are 1.1, 1.2 etc.; and for chapter 2 they again start by 1.1. 1.2…. My wish is to have the following

Chapter 1
1.1, 1.2,…

Chapter 2
2.1, 2.2,…

Chapter 3
3.1, 3.2,…

(regardless of the sections and subsections)

I have tried many solutions but couldn't get it in a correct way either by default setting of amsmath package or by using chngcntr and counterwithin{}{}. The sample code is also attached hereenter code here. I have wasted many days but to no avail, so would be very thankful if someone can provide with the solution.

\documentclass[12pt]{book}
\hoffset-7mm
\usepackage{amsmath,amsfonts,amssymb, amsthm}

\usepackage{hyperref}
\usepackage{changes}
\usepackage{dsfont}
\bibliographystyle{alpha}
\usepackage{siunitx}
\usepackage{verbatim}

\usepackage[font={it,small}]{caption}% Support for small, `sub' figures and tables
\usepackage{booktabs, makecell, rotating}% <-- added for tables

\newcommand{\gs}[1]{\textcolor{blue}{#1}}
\newcommand{\jm}[1]{\textcolor{red}{#1}}
\newcommand{\af}[1]{\textcolor{blue}{#1}}
\newcommand{\afc}[1]{\textbf{#1}}
\newcommand{\gsc}[1]{\textcolor{red}{#1}}

\usepackage{mathtools}
\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\newcolumntype{P}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\theoremstyle{plain}% Theorem-like structures provided by amsthm.sty
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{proposition}[theorem]{Proposition}

\newtheorem{rules}{Rule}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}

\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\newtheorem{notation}[theorem]{Notation}       

\newcommand{\R}{\mathbb{R}}
\newcommand{\wt}{\widetilde}
\newcommand{\ol}{\overline}

\usepackage{chngcntr}
\counterwithin{equation}{chapter}

\usepackage{enumerate}
\usepackage{float}
\renewcommand{\labelenumi}{\roman{enumi})}
\usepackage{algorithmic}
\usepackage{algorithm}
\renewcommand{\algorithmicrequire}{\textbf{Input:}}
\renewcommand{\algorithmicensure}{\textbf{Output:}}
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
\usepackage{tikz}
\usepackage{subcaption} % Package to add a matrix like picture structure i.e. an mxn frame
\usetikzlibrary{positioning}
\usetikzlibrary{calc} % Libraray for the figures related to instance reductions

\usepackage[acronym, nohypertypes={acronym}, nonumberlist]{glossaries}
\setacronymstyle{long-sc-short}
\makeglossaries
%==================Glossary=========================
\newglossaryentry{U}{name={$U$},description={the set of all things}} 
%==================Acronyms=========================
\newacronym{mci}{MCI}{Minimum Connectivity Inference}
\newacronym{mst}{MST}{Minimum Spanning Tree}
%==================Definitions=========================
\def\np{\mathcal{NP}}
\def\ilp{\textsc{ILP}}
\def\mst{\textsc{MST}}
\def\mci{\textsc{MCI}}
\def\milp{\textsc{MILP}}
\DeclareMathOperator{\conv}{conv}
%======================================================
\addtolength{\textwidth}{18mm}
\addtolength{\textheight}{10mm}
\addtolength{\topmargin}{-10mm}

\begin{document}


\chapter{First chapter}\label{ch:mci-formul}

\section{A section}\label{mst-formul}

\subsection{A subsection}
We give first set of equations:
\begin{align}
\sum_{e\in E} x_e & = m-1, & \label{subeq211a}\\
\sum_{e\in E(S)}x_e & \leq |S|-1, 
&S\subset V, S \neq V, S \neq \emptyset. \label{subeq211b}
\end{align}

\chapter{Second chapter}\label{ch:mod-red}

\section{Section of ch 2}\label{simp-red}

\subsection{subsection of ch 2}

The first variant is as below:
\begin{align}
\sum\limits_{a\in A_i^-(j)}f_a^i - \sum\limits_{a\in A_i^+(j)}f_a^i & =  -1,
&j\in V_i\setminus V^{\max}_i,\, j\neq r_i,  i\in I, \label{subeq411a}
\\
f_{(j,k)}^i+f_{(k,j)}^i&\le(|V^R_i|-1)x_e, &\ e=\{j,k \} \in E(V_i)\setminus E(V^{\max}_i), i\in I, \label{subeq411b}\\
f^i_a & \geq 0, & a \in A(V_i)\setminus A(V^{\max}_i), i\in I. \label{subeq411c} 
\end{align}

\end{document}

Best Answer

Just remove this line (line 57 in the OP code)

\renewcommand{\theequation}{\arabic{section}.\arabic{equation}} 

and you see the equations numbered correctly

enter image description here

Edit:

To include section number as well in the equation numbering, you just add this line in preamble:

\numberwithin{equation}{section}

to get numbering like this:

enter image description here

Related Question