# Equation numbering does not continue correctly in Latex

In my thesis, I have a problem when I want to refer to equations. Reference is basically happening based on section or subsections numbering in three digits (e.g. 1-1-1). Also, if I have more than one equation in the same subsection, all are shown by the same number! (1.1.2 in the following example!)! The number beside each equation is correctly shown, however, as (1-1) or (1-2) or ... . I want the equation number in the text be shown sequentially as 1-1, 1-2, 1-3, 1-4, ... .

Here is my minimal working example:

\documentclass[11pt,oneside,english,singlespacing,parskip,headsepline]{MastersDoctoralThesis}

\usepackage{mathtools}

\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin0pt}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother

\begin{document}
\chapter{Chapter 1}
\section{Section1}
\subsection{Subsection 1-1}

\mathleft
\label{eq:KE_Energy} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy} is kinetic energy.

\subsection{Subsection 1-2}

\mathleft
\label{eq:KE_Energy2} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy2} is kinetic energy.

\mathleft
\label{eq:KE_Energy3} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy3} is kinetic energy.

\section{Section2}
\subsection{Subsection 2-1}

\mathleft
\label{eq:KE_Energy4} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy4} is kinetic energy.

\end{document}


An here is the output:

• Please provide a MWE that can be used by others to replicate your problem. Nov 30, 2018 at 12:51
• The equation numbering in LaTeX is always correct. It's your configuration that is incorrect. In this example you do not need the aligned environment. If you include a complete minimal working example we can tell you how to fix your configuration.
– user30471
Nov 30, 2018 at 12:58
• I would expect that your \mathleft and \mathcenter commands break amsmath, where did you find those definitions? Nov 30, 2018 at 13:16
• @mah65, I believe the problem might be with your .cls file. I compiled your MWE exactly as you gave it except I used the book document class instead of your custom class file, and I was unable to replicate your problem. When I compiled with the book class, the \ref and \label numbering for the equations matched. Dec 2, 2018 at 23:34
• @MasonMalone: Thanks for your help. That is correct, although the hyperlink to equation is ruined. Anyways, I have to use thesis style, and should solve the problem in this environment. I don't know what modification I should apply in the .cls file. Dec 2, 2018 at 23:51

The \mathleft and \mathcenter commands defined in the preamble break amsmath removing all use of them restores the correct numbering.

\documentclass[11pt,oneside,english,singlespacing,parskip,headsepline]{MastersDoctoralThesis}

\usepackage{mathtools}

\makeatletter
%\newcommand{\mathleft}{\@fleqntrue\@mathmargin0pt}
%\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother

\begin{document}
\chapter{Chapter 1}
\section{Section1}
\subsection{Subsection 1-1}

%\mathleft
\label{eq:KE_Energy} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy} is kinetic energy.

\subsection{Subsection 1-2}

%\mathleft
\label{eq:KE_Energy2} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy2} is kinetic energy.

%\mathleft
\label{eq:KE_Energy3} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy3} is kinetic energy.

\section{Section2}
\subsection{Subsection 2-1}

%\mathleft
\label{eq:KE_Energy4} \begin{aligned} & \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\ \end{aligned}

Equation \ref{eq:KE_Energy4} is kinetic energy.

\end{document}

• This seems to work. But this brings all the equations to the middle (centring). How to keep them in the left side? Dec 3, 2018 at 0:05
• @mah65 use the documented fleqn option to the documentclass or to amsmath or mathtools package Dec 3, 2018 at 0:06
• @mah65 did you write this \mathleft command or was it suggested in some tutorial somewhere? Dec 3, 2018 at 0:07
• I think I found it somewhere in this forum when I wanted to align left the equations. I don't exactly remember. Dec 3, 2018 at 0:08
• @mah65 well it's completely wrong, so if you recall where it came from try to ping the author to get it changed:-) Dec 3, 2018 at 0:09

Following the previous answer, I modified the packages as following:

\usepackage[fleqn]{mathtools}
\makeatletter
\newcommand{\mathleft}{\@fleqntrue\@mathmargin0pt}
\newcommand{\mathcenter}{\@fleqnfalse}
\makeatother
\setlength{\mathindent}{0cm}


(Changes are the first and last lines). This solved the problem, and no other modification is necessary.