2

I have the following MWE

\documentclass[runningheads]{llncs}

\usepackage{algorithm}
\usepackage{algorithmic}

\begin{document}

\begin{algorithm}[H]
\caption{BLAH}
\begin{algorithmic}[1]
\REQUIRE $Input$
\ENSURE $A$.
\STATE Set $A$
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[H]
\renewcommand{\thealgorithm}{}
\floatname{algorithm}{Not an algorithm but want the layout}
\caption{BLEH} 
\begin{algorithmic}[1]
\REQUIRE $Input$
\STATE Compute $B$
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[H]
\caption{BLAH}
\begin{algorithmic}[1]
\REQUIRE $Input$
\STATE Compute $B$
\end{algorithmic}
\end{algorithm}

\end{document}

which produces this this where the third entity is titled Algorithm 3 but I want it to be titled Algorithm 2. How do I achieve this?

EDIT I don't want to use any other algorithm environment.

2

Step down the counter:

\documentclass{article}

\usepackage{algorithm}
\usepackage{algorithmic}

\newcommand{\altcaption}[1]{%
  \addtocounter{algorithm}{-1}%
  \renewcommand\thealgorithm{\unskip}%
  \floatname{algorithm}{#1}%
  \caption
}

\begin{document}

\begin{algorithm}[H]
\caption{BLAH}
\begin{algorithmic}[1]
\REQUIRE $Input$
\ENSURE $A$.
\STATE Set $A$
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[H]
\altcaption{Not an algorithm but want the layout}{BLEH} 
\begin{algorithmic}[1]
\REQUIRE $Input$
\STATE Compute $B$
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[H]
\caption{BLAH}
\begin{algorithmic}[1]
\REQUIRE $Input$
\STATE Compute $B$
\end{algorithmic}
\end{algorithm}

\end{document}

enter image description here

  • 1
    @User525412790 I made a small change to remove the added space. – egreg Nov 27 '18 at 18:29
  • What's the change? I don't see anything different. – Rudra Nov 27 '18 at 18:33
  • @User525412790 \renewcommand\thealgorithm{\unskip} – egreg Nov 27 '18 at 18:36
  • Oh I guess I saw the modified version directly. – Rudra Nov 27 '18 at 18:37

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.