[Tex/LaTex] List of Equations in standard list style

equationsindentationtable of contentstocloft

I'm using this solution to generate a list of equations.

Running my minimal example below, there are two points I want to change:

[A] Using the standard "list of" style, means: using the same spaces after the caption and indent the entries like the list of figures.

[B] Use a seperate variable as the Caption instead of the label

\documentclass[
    pdftex,
    listof=totoc,
]{scrreprt}

\usepackage{amsmath}
\usepackage{xstring}
\usepackage{tocloft}
\usepackage{blindtext}
\usepackage[demo]{graphicx}

\makeatletter
\numberwithin{equation}{chapter}

% 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]{%
      \addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsnumwidth}{3em}

\makeatother

\begin{document}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 1}
    \label{fig:1}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 2}
    \label{fig:2}
\end{figure}
\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 3}
    \label{fig:3}
\end{figure}

\blinddocument

\begin{equation}
1 + 1 = 2
\label{eq:first}
\end{equation}

\begin{equation}
2 + 2 = 4
\label{eq:second}
\end{equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 4}
    \label{fig:4}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 5}
    \label{fig:5}
\end{figure}

\listoffigures
\listofmyequations

\end{document}

Best Answer

This approach answers only your question [A] (see below for a complete solution).

Replace the line

\setlength{\cftmyequationsnumwidth}{3em}

with

\setlength{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}

so to match the corresponding definitions for \listoffigures in tocloft.sty:

\setlength{\cftfigindent}{1.5em}
\setlength{\cftfignumwidth}{2.3em}

MWE:

\documentclass[
    pdftex,
    listof=totoc,
]{scrreprt}

\usepackage{amsmath}
\usepackage{xstring}
\usepackage{tocloft}
\usepackage{blindtext}
\usepackage[demo]{graphicx}

\makeatletter
\numberwithin{equation}{chapter}

% 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]{%
      \addcontentsline{equ}{myequations}{\protect\numberline{\theequation}#1}}
\setlength{\cftmyequationsindent}{1.5em}
\setlength{\cftmyequationsnumwidth}{2.3em}

\makeatother

\begin{document}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 1}
    \label{fig:1}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 2}
    \label{fig:2}
\end{figure}
\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 3}
    \label{fig:3}
\end{figure}

\blinddocument

\begin{equation}
1 + 1 = 2
\label{eq:first}
\end{equation}

\begin{equation}
2 + 2 = 4
\label{eq:second}
\end{equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 4}
    \label{fig:4}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 5}
    \label{fig:5}
\end{figure}

\listoffigures
\listofmyequations

\end{document} 

Output:

enter image description here


A different approach can be used to achieve both [A] and [B].

I don't like this one very much, but here it is.

We use the package float and declare the Equation environment to be a new floating environment.

So, replace all the stuff between \makeatletter ... \makeatother with:

\newfloat{Equation}{htbp}{equ}[chapter]
\newcommand{\listequationsname}{List of Equations}

At this point you can use equations inside Equation in this way:

\begin{Equation}[!htb]
\centering
\begin{equation}
1 + 1 = 2
\end{equation}
\caption{First equation}
\label{eq:first}
\end{Equation}

and to print the List of Equations you have to write the line:

\listof{Equation}{\listequationsname}

instead of

\listofmyequations

MWE:

\documentclass[
    pdftex,
    listof=totoc,
]{scrreprt}

\usepackage{amsmath}
\usepackage{xstring}
\usepackage{float}
\usepackage{blindtext}
\usepackage[demo]{graphicx}

\newfloat{Equation}{htbp}{equ}[chapter]
\newcommand{\listequationsname}{List of Equations}

\begin{document}

\begin{Equation}[!htb]
\centering
\begin{equation}
0 + 0 = 0
\end{equation}
\caption{Zeroth equation}
\label{eq:zeroth}
\end{Equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 1}
    \label{fig:1}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 2}
    \label{fig:2}
\end{figure}
\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 3}
    \label{fig:3}
\end{figure}

\blinddocument

\begin{Equation}[!htb]
\centering
\begin{equation}
1 + 1 = 2
\end{equation}
\caption{First equation}
\label{eq:first}
\end{Equation}

\begin{Equation}[!htb]
\centering
\begin{equation}
2 + 2 = 4
\end{equation}
\caption{Second equation}
\label{eq:second}
\end{Equation}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 4}
    \label{fig:4}
\end{figure}

\begin{figure}[!htb]
    \centering
        \includegraphics[width=5cm,height=4.5cm]{image1}
      \caption{figure 5}
    \label{fig:5}
\end{figure}

\listoffigures
\listof{Equation}{\listequationsname}

\end{document} 

Output:

enter image description here