LaTeX forum ⇒ GeneralAdding "List of Equations" into an existing latex style sty

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

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

Postby abuhawa » Mon Feb 15, 2021 4:00 am

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.
%%%%%   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.
\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 634 times
list of equation.png
list of equation.png (117.96 KiB) Viewed 634 times

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

Postby abuhawa » Mon Feb 15, 2021 4:49 pm

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

%%%%%   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: 178
Joined: Fri Jan 03, 2020 2:39 pm

Postby Bartman » Mon Feb 15, 2021 7:06 pm

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

Postby abuhawa » Tue Apr 06, 2021 4:05 pm

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 139 times

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

Postby abuhawa » Tue Apr 06, 2021 5:11 pm

I have found the solution.Add the following
\setlength{\cftmyequationsnumwidth}{2.5em}% Width of equation number in List of Equations


The overall code in the style (*.sty) file:
%%%%%   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/173102/table-of-equations-like-list-of-figures


Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests