0

I use \setcounter command to reset the algorithm number. However, when I use \ref command to quote this algorithm, the displayed number is inconsistent to the number in the title of the algorithm. How can I solve this issue?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\usepackage[linesnumbered,ruled,vlined]{algorithm2e}

\begin{document}

\setcounter{algocf}{2}
\begin{algorithm}
\label{alg}
\caption{An algorithm}
1111
\end{algorithm}

Algorithm \ref{alg}.

\end{document}

enter image description here

zbh2047
  • 103

0 Answers0