4

How is it possible a cross-reference a range of lines in an algorithm? I can cross-reference a single line easily using the simple \label(...) and then \ref(...) to cross-reference it.

For example in the MWE below, how can cite from line 3 to line 5?

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}

\begin{document}

    \begin{algorithm}
    \caption{Test Algo}\label{Test Algo}
    \begin{algorithmic}[1]
        \Procedure{Test Algo}{inputs} %line1
            \State $n \gets$ \textsc{BestApproach}(Inputs) \label{algo1:bestmetric} %line2
            \For{$f \in $ inputs} %line3
                \State x $\gets$ 1  %line4
            \EndFor               %line5
        \EndProcedure             %line6
    \end{algorithmic}
\end{algorithm}    

\end{document}
Bobyandbob
  • 4,899
asm_nerd1
  • 337

0 Answers0