Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using the algorithm-package and would like to name my algorithms without any generated prefix. So I would like to remove "Algorithm #" as prefix from my caption, but still keep the list of algorithms listing the captions.

I have two minimal working examples, each one doing only a part of the required job.

\documentclass[11pt]{article}

\usepackage{caption}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}
\caption*{My Algorithm}
\end{algorithm}

\listofalgorithms

\end{document}

This removes the caption prefix, but the algorithm is not included in the list.

\documentclass[11pt]{article}

\usepackage{caption}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}
\floatname{algorithm}{}
\caption{My Algorithm}
\end{algorithm}

\listofalgorithms

\end{document}

This removes the caption prefix partially, (the number "1" still remains), but the algorithm is included in the list.

share|improve this question
    
What about the number in the list of algorithms? –  egreg Feb 6 '13 at 23:52
    
@egreg After using the solution with labelformat=empty the prefix is removed, but the number stays in the list-of-algorithms. Which is exactly what I want :) –  mtsz Feb 7 '13 at 0:07
1  
I don't think it makes much sense: if the number is missing next to the caption, you can't refer to algorithms by numbers and those in the list point to nothing. If you want to remove them, just add \renewcommand{\thealgorithm}{} after \usepackage{algorithm}. –  egreg Feb 7 '13 at 0:11
    
Ok thanks. I've just tried it, it looks like there is something missing :-) ... but I keep it for the moment, now I know how to tweak that bit! –  mtsz Feb 7 '13 at 0:16
add comment

2 Answers

up vote 5 down vote accepted

Here's one possibility, defining a format with the help of the caption package:

\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{algorithm}

\DeclareCaptionFormat{myformat}{#3}
\captionsetup[algorithm]{format=myformat}

\begin{document}

\begin{algorithm}
\caption{My Algorithm}
\end{algorithm}
\listofalgorithms

\end{document}

enter image description here

As egreg has pointed out, the caption package already offers the empty format, so there's no need to define a new one:

\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{algorithm}

\captionsetup[algorithm]{labelformat=empty}

\begin{document}

\begin{algorithm}
\caption{My Algorithm}
\end{algorithm}
\listofalgorithms

\end{document}
share|improve this answer
    
@Gonzalo Thanks a lot, it works perfectly! –  mtsz Feb 7 '13 at 0:01
add comment

In the second MWE, add the algorithm to the list explicitely using \addcontentsline.

\documentclass[11pt]{article}

\usepackage{caption}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}
\caption*{My Algorithm}
\addcontentsline{loa}{algorithm}{My Algorithm}
\end{algorithm}

\listofalgorithms

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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