0

My question is about adding a properly formatted \listofalgorithms (and later \listoflistings) to the pittetd class.

I don't think it's possible to \renewcommand on \listofalgorithms to get consistent formatting (or is it?), so I'm trying to duplicate some of the \listoffigures and \listoftables code. Here is what I have so far:

\newcommand\listofalgos{\clearpage
  \typeout{List of Algorithms}%
  \@ifundefined{@outlinefile}{}{%
    \hypertarget{prelim.7}{}%
    \protected@write\@outlinefile{}{%
      \protect\BOOKMARK
      [0][]{prelim.7}{LIST OF ALGORITHMS}{}%
      \protect\begingroup\protect\makeatletter
      \protect\prepare@bookmarks7
      \protect\@input{\jobname.loa}
      \protect\endgroup}}
  \null\vskip 1in
  {\normalfont\bfseries\centering
    LIST OF ALGORITHMS\par}
  \par\vspace{54\p@}%
  \@starttoc{loa}\newpage%
  \@enable{preface}{the first chapter}}

The problems are now that

  • there isn't proper spacing between the caption text and the page number,
  • there shouldn't be paragraph-style indentation for each entry, and
  • each entry isn't on a new line:

enter image description here

Is there a problem with the loa file?

\defcounter {refsection}{0}\relax
\contentsline {algorithm}{\numberline {1}{\ignorespaces Backpropagation for computing weight updates in a fully-connected neural network, going over one line}}{1}{algorithm.1}
\defcounter {refsection}{0}\relax
\contentsline {algorithm}{\numberline {2}{\ignorespaces Static linear response approach within fragment-localized formalism.}}{3}{algorithm.2}
\defcounter {refsection}{0}\relax
\contentsline {algorithm}{\numberline {3}{\ignorespaces Continuation of algorithm\nobreakspace {}\ref {alg:solve-linear-response}}}{4}{algorithm.3}

It should look like the following (ignore the different coloring, that's just hyperref):

enter image description here

Can it be simplified in a manner similar to the following?

\renewcommand{\listalgorithmname}{LIST OF ALGORITHMS}
\renewcommand{\listofalgorithms}{\listof{algorithm}{\listalgorithmname}}
  • What is wrong with the above code (placed after \let\l@figure\l@table in pittetd.cls)?
  • Is there a similar approach for a \listoflistings?
0

As far as I can tell, there is nothing wrong with the solution in the question, except that it's missing something. This answer helped me figure it out. While the solution that doesn't involve modifying a cls/dtx file is the float patch, the underlying solution is to directly inherit the table format:

\newcommand*\l@table{\@dottedtocline{1}{1.5em}{\@floatl}}

by using

\let\l@algorithm\l@table

Here is the resulting code:

\newcommand\listoflistings{\clearpage
  \typeout{List of Listings}%
  \@ifundefined{@outlinefile}{}{%
    \hypertarget{prelim.8}{}%
    \protected@write\@outlinefile{}{%
      \protect\BOOKMARK
      [0][]{prelim.8}{LIST OF LISTINGS}{}%
      \protect\begingroup\protect\makeatletter
      \protect\prepare@bookmarks8
      \protect\@input{\jobname.lol}
      \protect\endgroup}}
  \null\vskip 1in
  {\normalfont\bfseries\centering
    LIST OF LISTINGS\par}
  \par\vspace{54\p@}%
  \@starttoc{lol}\newpage
  \@enable{preface}{the first chapter}}
\newcommand\listofalgos{\clearpage
  \typeout{List of Algorithms}%
  \@ifundefined{@outlinefile}{}{%
    \hypertarget{prelim.9}{}%
    \protected@write\@outlinefile{}{%
      \protect\BOOKMARK
      [0][]{prelim.9}{LIST OF ALGORITHMS}{}%
      \protect\begingroup\protect\makeatletter
      \protect\prepare@bookmarks9
      \protect\@input{\jobname.loa}
      \protect\endgroup}}
  \null\vskip 1in
  {\normalfont\bfseries\centering
    LIST OF ALGORITHMS\par}
  \par\vspace{54\p@}%
  \@starttoc{loa}\newpage
  \@enable{preface}{the first chapter}}
\let\l@algorithm\l@table

The list of listings already seems to be formatted appropriately.

These provide \listofalgos and \listoflistings rather than \listofalgorithms and \listlistoflistings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.