List of Equations / Table of Equations

After finding Table of Equations and http://www.latex-community.org/forum/viewtopic.php?f=5&t=428, I set about making a List of Equations for my document. The catch here is that we already have a working draft and its hundreds of pages and contains dozens of equations.

The above links describe how to use tocloft to add the List of Equations, but both require following each equation with a tag such as \myequations{Display name}. To avoid having to add this for all of our equations, I redefined equation to automatically include our \myequations{} command:

\let\oldequation = \equation
\let\endoldequation = \endequation
\renewenvironment{equation}{
\begin{oldequation}
}{
\end{oldequation}
\myequations{\@currentlabelname}
}


I proceeded with the tocloft-specific code which is directly based on the above links, ending with:

\usepackage{tocloft}
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}

% myequation takes in its display name
\newcommand{\myequations}[1]{

% display name is printed


Then all \equations will appear automatically in the List of Equations. That's great, but there is one problem:

Each \equations displayed name in the List of Equations is not its own \label (eg. "Torque") but instead is the name of the \subsection in which it appears (such that dozens of equations have the name of "DC Motor Operation," etc.)

Any ideas? What can I replace \@currentlabelname with to drop in the name of the \label for the equation? A simple one looks like this:

$$\tau=F\times r \label{eq:Torque}$$


FWIW, I am actually doing this in Lyx but that doesn't seem to be the source of my problems. In fact, if there is a more elegant solution for Lyx, I'm all ears.

Thanks!

Example in LaTeX:

\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{amsmath}
\usepackage[unicode=true, pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
{hyperref}

\makeatletter
\numberwithin{equation}{section}

% we use this for our refernces as well
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}

% redefinition of \equation for convenience
\let\oldequation = \equation
\let\endoldequation = \endequation
\renewenvironment{equation}{
\begin{oldequation}
}{
\end{oldequation}
\myequations{\@currentlabelname}
}

% try to make a List of Equations,
% error is most likely in the @currentlabelname above
\usepackage{tocloft}
\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{
\setlength{\cftmyequationsnumwidth}{3em}

\makeatother

\begin{document}
\tableofcontents{}
\listofmyequations

\section{Brushless Motor Fundamentals}
\subsubsection{DC Motor Operation}
Torque is generated in DC motors from the magnetic force,
also known as the Lorentz force, which is produced when an
electric current is passed through a coil in a magnetic field.
This force is given by \ref{eq:Force}.

$$F=q[E+(v\times B)] \label{eq:Force}$$
where F is the force perpendicular to the coil,
E is the electric field in the coil,
v is the velocity of the charged particles in the coil,
and B is the magnetic field. From mechanics, torque is

$$\tau=F\times r\label{eq:Torque}$$
If the electrical force in \ref{eq:Force} is ignored,
and the remaining magnetic force is used in \ref{eq:Torque},
with the assumption that v is perpendicular to B, we find that
$$\tau=qvBrsin\theta \label{eq:Magnetic}$$

\end{document}


[FIXED - Thank you Mike Renfro] Equations 2.1 - 2.9 display correctly in the List of Equations but after the equation number hits 2.10 the last digit ('ones' digit) overlaps with the beginning of the display name.

• let me see if I understand your problem: you want to use the string that you write in the argument of \label as the entry for the new list of equations, but stripping out the eq: prefix used in \label? For example, if you have \label{eq:Torque} then just Torque should be placed in the list of equations? Mar 26, 2011 at 22:30
• below I added a solution which removes "eq:" from the new list. Mar 27, 2011 at 1:36
• Would it be possible (how?) to refer to an (optional) \caption for equations? Because purpose of \label is kind of different. Mar 31, 2019 at 17:10

Here's a modified version of Lev Bishop's code; I used the xstring package to remove the string "eq:" from the labels:

\documentclass[english]{article}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\usepackage{amsmath}
\usepackage{tocloft}
\usepackage{xstring}
\usepackage[unicode=true, pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
{hyperref}

\makeatletter
\numberwithin{equation}{section}

% we use this for our refernces as well
\AtBeginDocument{\renewcommand{\ref}[1]{\mbox{\autoref{#1}}}}

% redefinition of \equation for convenience
\let\oldequation = \equation
\let\endoldequation = \endequation
\AtBeginDocument{\let\oldlabel = \label}% \AtBeginDocument because hyperref redefines \label
\newcommand{\mynewlabel}[1]{%
\StrBehind{#1}{eq:}[\Str]% remove "eq:" from labels
\myequations{\Str}\oldlabel{#1}}
\renewenvironment{equation}{%
\oldequation
\let\label\mynewlabel
}{\endoldequation}

\newcommand{\listequationsname}{List of Equations}
\newlistof{myequations}{equ}{\listequationsname}
\newcommand{\myequations}[1]{%
\setlength{\cftmyequationsnumwidth}{3em}

\makeatother

\begin{document}
\tableofcontents
\listofmyequations

\section{Brushless Motor Fundamentals}
\subsubsection{DC Motor Operation}
Torque is generated in DC motors from the magnetic force,
also known as the Lorentz force, which is produced when an
electric current is passed through a coil in a magnetic field.
This force is given by \ref{eq:Force}.
$$F=q[E+(v\times B)] \label{eq:Force}$$
where $F$ is the force perpendicular to the coil,
$E$ is the electric field in the coil,
$v$ is the velocity of the charged particles in the coil,
and $B$ is the magnetic field. From mechanics, torque is
$$\tau=F\times r \label{eq:Torque}$$
If the electrical force in \ref{eq:Force} is ignored,
and the remaining magnetic force is used in \ref{eq:Torque},
with the assumption that $v$ is perpendicular to $B$, we find that
$$\tau=qvBrsin\theta \label{eq:Magnetic}$$

\end{document}

• This doesn't work when you use underscores in your labels. It results in an error for the first equation using underscores in its label: ! Missing $inserted. <inserted text>$ <to be read again> _ <argument> ...stname }{\numberline {2.1.1}example_ matrix_universe}\hyper@lin... \l@myequations ...\@nameuse {cftmyequationsfont}#1 }\nobreak \@nameuse {cftmy... ... The error message goes on for a bit more. It's too long for a comment. How to fix? Mar 27, 2016 at 15:38
in equation \ref{Boole's inequality} becomes an equality.

\end{document}


I couldn't come up with a minimal working example in regular LaTeX yet.

As for (2), try setting \cftmyequationsnumwidth to a larger value (see tocloft manual, section 2.3).

• is there any way to attach a minimal working example? Mar 26, 2011 at 20:48
• @gnirts: If you have to attach the example, it's not minimal. ;-) Mar 26, 2011 at 20:51
• I added \setlength{\cftmyequationsnumwidth}{3em} and that works great, thank you! I also updated the original post with a working example Mar 26, 2011 at 21:51