Line numbering in algorithmic
The line number in algorithmic
(from the algorithms
bundle) is governed by the counter ALC@line
. The following MWE defines \setalglineno{<num>}
which allows you to modify the number of any line in your algorithmic
:
\documentclass[12pt]{beamer}
\usepackage{algorithmic,algorithm,float}
\renewcommand\thealgorithm{}
\newcommand{\setalglineno}[1]{%
\setcounter{ALC@line}{\numexpr#1-1}}
\begin{document}
\begin{frame}[t, fragile]
\frametitle{...}
\begin{algorithm}[H]
\caption{...}
\begin{algorithmic}[1]
\setalglineno{2}% Set following line number to 2
\STATE ...
\end{algorithmic}
\end{algorithm}
\end{frame}
\end{document}
In fact, \setalglineno{<num>}
sets ALC@line
to <num>-1
, since the algorithm is set in a list, where each line counter is incremented before it is set. So, technically, to obtain a line numbered 2, you need to set the counter value to 1.
A similar setup would be used within the algpseudocode
(or equivalent) environments offered by algorithmicx
. For these you have to use ALG@line
instead of ALC@line
though.