I want to change the first number of the line numbering in my algorithm, but how is it done?
This is my example:
\documentclass[12pt]{beamer}
\usepackage{amsmath, amsfonts, amssymb, amsthm}
\usepackage{algorithmic, algorithm}
\usepackage{float}
\renewcommand\thealgorithm{}
\begin{document}
\begin{frame}[t, fragile]
\frametitle{...}
\begin{algorithm}[H]
\caption{...}
\begin{algorithmic}[1]
\STATE ...
\end{algorithmic}
\end{algorithm}
\end{frame}
\end{document}
The first state should be numbered with 2 for example.
Best Answer
The line number in
algorithmic
(from thealgorithms
bundle) is governed by the counterALC@line
. The following MWE defines\setalglineno{<num>}
which allows you to modify the number of any line in youralgorithmic
:In fact,
\setalglineno{<num>}
setsALC@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 byalgorithmicx
. For these you have to useALG@line
instead ofALC@line
though.