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.

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
share|improve this question

1 Answer 1

up vote 15 down vote accepted

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}

enter image description here

share|improve this answer
    
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

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.