Graphics, Figures & TablesHyphen Separator After Item Number in the List of Algorithms (Algorithm2e)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
maroquio
Posts: 1
Joined: Fri Apr 10, 2020 6:15 pm

Hyphen Separator After Item Number in the List of Algorithms (Algorithm2e)

Post by maroquio »

Hello.
I'm not having success in trying to put a hyphen between the item number and the caption of the algorithm in the "List of Algorithms" page. Currently, the list is:

1 Function to create an ARP object A;
2 Function to create an ARP object B;
3 Function to create an ARP object C;
...

But I need it to be:

1 - Function to create an ARP object A;
2 - Function to create an ARP object B;
3 - Function to create an ARP object C;
...

Please, I need help. This is for my Ph.D. thesis and the deadline is very close.
Thanks in advance.

Recommended reading 2024:

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

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

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Hyphen Separator After Item Number in the List of Algorithms (Algorithm2e)

Post by Bartman »

Why don't you show us a Infominimal working example of what you've tried so far?

With a standard class and without another package, you could implement the customization as follows:

Code: Select all

\documentclass{article}
\usepackage{algorithm2e}

\let\oldlistofalgorithms\listofalgorithms
\let\oldnumberline\numberline% Store \numberline
\newcommand{\algnumberline}[1]{#1 -- }
\renewcommand{\listofalgorithms}{%
    \let\numberline\algnumberline% Update \numberline
    \oldlistofalgorithms
    \let\numberline\oldnumberline% Restore \numberline
}

\begin{document}
\listofalgorithms
\begin{algorithm}
    \caption{Algorithm caption}
\end{algorithm}
\end{document}
I have the impression, that a dash is more appropriate. However, if you need to use a hyphen, change the source code accordingly.

The source of the source code used.
Post Reply