1

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

Please help me solve this problem. Thanks


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
\begin{equation}
\label{eq:KE_Energy}
\begin{aligned}
& \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\
\end{aligned}
\end{equation}

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

\subsection{Subsection 1-2}

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

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

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

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

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

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

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

\end{document}  

An here is the output:

enter image description here

enter image description here

David Carlisle
  • 757,742
mah65
  • 113
  • 3
    Please provide a MWE that can be used by others to replicate your problem. – Raven Nov 30 '18 at 12:51
  • 2
    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. –  Nov 30 '18 at 12:58
  • 2
    I would expect that your \mathleft and \mathcenter commands break amsmath, where did you find those definitions? – David Carlisle Nov 30 '18 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. – Mason Malone Dec 02 '18 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. – mah65 Dec 02 '18 at 23:51
  • @DavidCarlisle: I removed \newcommand{\mathcenter}{@fleqnfalse}. It did not solve the problem. – mah65 Dec 02 '18 at 23:53
  • @Raven ....... I added MWE. – mah65 Dec 02 '18 at 23:55
  • @Andrew ....... I added MWE. – mah65 Dec 02 '18 at 23:55
  • you still have \mathleft – David Carlisle Dec 02 '18 at 23:56

2 Answers2

1

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
\begin{equation}
\label{eq:KE_Energy}
\begin{aligned}
& \langle KE \rangle = \frac{1}{2} \langle mv^{2} \rangle \\
\end{aligned}
\end{equation}

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

\subsection{Subsection 1-2}

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

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

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

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

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

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

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

\end{document}  
David Carlisle
  • 757,742
  • This seems to work. But this brings all the equations to the middle (centring). How to keep them in the left side? – mah65 Dec 03 '18 at 00:05
  • @mah65 use the documented fleqn option to the documentclass or to amsmath or mathtools package – David Carlisle Dec 03 '18 at 00:06
  • @mah65 did you write this \mathleft command or was it suggested in some tutorial somewhere? – David Carlisle Dec 03 '18 at 00:07
  • I think I found it somewhere in this forum when I wanted to align left the equations. I don't exactly remember. – mah65 Dec 03 '18 at 00:08
  • @mah65 well it's completely wrong, so if you recall where it came from try to ping the author to get it changed:-) – David Carlisle Dec 03 '18 at 00:09
  • Probably, here: https://tex.stackexchange.com/questions/148838/indentation-of-left-aligned-equations-flalign-without-fleqn – mah65 Dec 03 '18 at 00:11
0

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.

mah65
  • 113