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 want to do something like:

\begin{algorithm*}
\caption{My unnumbered algorithm}
% etc. etc.
\end{algorithm*}

or

\begin{algorithm}
\nonumbercaption{My unnumbered algorithm}
% etc. etc.
\end{algorithm}

Of course, the above is not LaTeX, just wishful thinking. What can I do to get an unnumbered algorithm with a caption?

Actually, the specific motivation is that I've split an algorithm in the middle since it's too long (using algorithmicx's \algstore); I want the second part to have a caption saying it's the second part, but I don't want it to have a new algorithm number.

share|improve this question
add comment

3 Answers

up vote 7 down vote accepted

If I understand your question correctly, you could use the \caption* command from the caption package to typeset the caption without label; a little example:

\documentclass{article}
\usepackage{caption}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}
\begin{algorithm}
  \caption{A test algorithm (Part I)}
  \begin{algorithmic}[1]
  \Procedure {BellmanKalaba}{$G$, $u$, $l$, $p$}
  \ForAll {$v \in V(G)$}
  \State $l(v) \leftarrow \infty$
  \EndFor
  \algstore{bkbreak}
  \end{algorithmic}
\end{algorithm}

\begin{algorithm}
  \caption*{A test algorithm (Part II)}
  \begin{algorithmic}[1]
  \algrestore{bkbreak}
  \State $p(i) \leftarrow v_j$
  \State $l’(i) \leftarrow min$
  \State $changed \leftarrow l \not= l’$
  \EndProcedure
  \end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

share|improve this answer
add comment

I suggest using the \ContinuedFloat command from the caption package instead and marking the second part as "continued":

\documentclass{article}

\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{caption}

\begin{document}

\begin{algorithm}
  \caption{Test}
  \begin{algorithmic}
    \State $i \gets 42$
    \algstore{test}
  \end{algorithmic}
\end{algorithm}

\begin{algorithm}
  \ContinuedFloat
  \caption{Test (cont.)}
  \begin{algorithmic}
    \algrestore{test}
    \State $j \gets 24$
  \end{algorithmic}
\end{algorithm}

\end{document}

Result

See the caption manual if you want the label, not caption, text to hold the "(continued)" word.

share|improve this answer
    
Hmm, even better than Gonzalo's suggestion, which also works. Having the bolded 'Algorithm X.Y' is a plus. –  einpoklum Oct 29 '11 at 22:36
    
Of course, this is just for my specific motivation. In general, not everything is a \ContinuedFloat... so I have to accept Gonzalo's answer. –  einpoklum Oct 29 '11 at 22:50
add comment

To follow on @Gonzalo's answer, I would duplicate the caption of the second (continued) part of the algorithm in full (using \caption*). Credit to him for the answer:

enter image description here

\documentclass{article}
\usepackage{caption}% http://ctan.org/pkg/caption
\usepackage{algorithm}% http://ctan.org/pkg/algorithm
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx

\begin{document}
\begin{algorithm}
  \caption{BellmanKalaba algorithm} \label{alg:first}
  \begin{algorithmic}[1]
  \Procedure {BellmanKalaba}{$G$, $u$, $l$, $p$}
  \ForAll {$v \in V(G)$}
  \State $l(v) \leftarrow \infty$
  \EndFor
  \algstore{bkbreak}
  \end{algorithmic}
\end{algorithm}

\begin{algorithm}
  \caption*{\textbf{Algorithm~\ref{alg:first}}\ BellmanKalaba algorithm (continued)}
  \begin{algorithmic}[1]
  \algrestore{bkbreak}
  \State $p(i) \leftarrow v_j$
  \State $l’(i) \leftarrow min$
  \State $changed \leftarrow l \not= l’$
  \EndProcedure
  \end{algorithmic}
\end{algorithm}
\end{document}

With a little work it would probably be possible to supply modify \caption so that an additional argument to \caption* could be the previous algorithm label, so as to produce the above result automatically.

share|improve this answer
    
Yes, this is a good option. –  Gonzalo Medina Oct 30 '11 at 0:23
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.