# Referencing line numbers in an algorithm

Referencing figures is simple:

\begin{figure}
\caption{Blah blah blah blah blah}
\label{fig:name}
%shtuff goes here
\end{figure}

See figure~\ref{fig:name}.

I would like to know if it is possible to reference line numbers in an algorithm, e.g.:

\begin{algorithmic}[1]
\State blah1
\State blah2 \label{lst:line:blah2}
\State blah3
\end{algorithmic}

As you can see on line~\ref{lst:line:blah2} \ldots
-

Of course you can; here's a simple example based on your code snippet:

\documentclass{article}
\usepackage{algpseudocode}

\begin{document}

\begin{algorithmic}[1]
\State blah1
\State blah2 \label{lst:line:blah2}
\State blah3
\end{algorithmic}

As you can see on line~\ref{lst:line:blah2} \ldots

\end{document}

-
Oh wow. I didn't even try it out, I just assumed it would be more difficult. Thanks for the confirmation. –  KPthunder Mar 11 '12 at 22:41