GeneralAdding "List of Equations" into an existing latex style sty

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
abuhawa
Posts: 4
Joined: Sat Feb 13, 2021 8:26 am

Adding "List of Equations" into an existing latex style sty

Post by abuhawa »

I am catching up with Latex, but this one really annoyed me. I was provided with the standard *.sty file and the main.tex which I attached here.

The standard sty file does not contain page for "List of Equations." By following the guide from https://latex.org/forum/viewtopic.php?t=428 I managed to generate the page by adding the following code into the *.sty file.

Code: Select all

%%%%%   List of Equations
\renewcommand{\listequationsname}{\normalsize\normalfont\centering\vspace*{-0.5in} LIST OF EQUATIONS}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}\par}
\addcontentsline{toc}{section}{LIST OF EQUATIONS} 
\listofmyequations
\fi
In the main.text and chapters, I have each equation with \myequations label.

Code: Select all

\begin{equation}
\frac{D\rho}{Dt}+\rho(\bigtriangledown \cdot \overrightarrow{\rm V}) = 0
\label{eqn:conversation of mass}
\end{equation}
\myequations{conversation of mass}

Where $\rho$ is density, $V$ is velocity and, $\bigtriangledown$ is gradient operator.

\begin{equation}
\rho \frac{DV}{Dt} = -\bigtriangledown P + \rho g + \mu \bigtriangledown^{2}V
\label{eqn:conservation of momentum}
\end{equation}
\myequations{conservation of momentum}
I would like to ask the following:

1. How do I add the word Equation to each of the equation on the "List of Equations" page.
2. Why the page number is the same xiv for List of Figures and List of Equations?
Attachments
ToC.png
ToC.png (92.02 KiB) Viewed 4824 times
list of equation.png
list of equation.png (117.96 KiB) Viewed 4824 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

abuhawa
Posts: 4
Joined: Sat Feb 13, 2021 8:26 am

Adding "List of Equations" into an existing latex style sty

Post by abuhawa »

I finally nailed it, miss several line of codes to make into a new page.

Code: Select all

%%%%%   List of Equations
		 \iffigurespage
\newcommand{\listequationsname}{\normalsize\normalfont\centering\vspace*{-0.5in} LIST OF EQUATIONS}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{Equation \protect\numberline{\theequation} #1}\par} %add the word "Equation"
	\clearpage %this is to add new page
	\phantomsection %this is to add new page, without these command, the page will be the same as the previous
\addcontentsline{toc}{section}{LIST OF EQUATIONS} 
\listofmyequations
\fi
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Adding "List of Equations" into an existing latex style sty

Post by Bartman »

With your approach, the indentation of this list no longer matches the indentation of the other lists if the text entered needs more than one line.

The command \newlistof creates, among other things, the command \cftXpresnum (X serves as a placeholder), which can prepend the word to any list entry. The necessary informations can be found in sections 2.3 and 2.4 of the documentation of tocloft.
abuhawa
Posts: 4
Joined: Sat Feb 13, 2021 8:26 am

Adding "List of Equations" into an existing latex style sty

Post by abuhawa »

Bartman wrote:With your approach, the indentation of this list no longer matches the indentation of the other lists if the text entered needs more than one line.

The command \newlistof creates, among other things, the command \cftXpresnum (X serves as a placeholder), which can prepend the word to any list entry. The necessary informations can be found in sections 2.3 and 2.4 of the documentation of tocloft.
I encountered exactly what you said. You can see below.
Any recommendation or alternative method?
Attachments
toc-equation.png
toc-equation.png (96.14 KiB) Viewed 4329 times
abuhawa
Posts: 4
Joined: Sat Feb 13, 2021 8:26 am

Adding "List of Equations" into an existing latex style sty

Post by abuhawa »

I have found the solution.Add the following

Code: Select all

\setlength{\cftmyequationsnumwidth}{2.5em}% Width of equation number in List of Equations
The overall code in the style (*.sty) file:

Code: Select all

%%%%%   List of Equations
		 \iffigurespage
\newcommand{\listequationsname}{\normalsize\normalfont\centering\vspace*{-0.5in} LIST OF EQUATIONS}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\addcontentsline{equ}{myequations}{Equation \protect\numberline{\theequation} ##1}\par}
\setlength{\cftmyequationsnumwidth}{2em}% Width of equation number in List of Equations
	\clearpage %this is to add new page
	\phantomsection %this is to add new page, without these command, the page will be the same as the previous
\addcontentsline{toc}{section}{LIST OF EQUATIONS} 
\listofmyequations
\fi
Credit to:
https://tex.stackexchange.com/questions ... of-figures
Post Reply