![引用使用 algpseudocode 的算法中的一行](https://linux22.com/image/460107/%E5%BC%95%E7%94%A8%E4%BD%BF%E7%94%A8%20algpseudocode%20%E7%9A%84%E7%AE%97%E6%B3%95%E4%B8%AD%E7%9A%84%E4%B8%80%E8%A1%8C.png)
当我想使用 algpseudocode 引用某一行时,单击给出的链接会将\ref
我发送到算法的开头,而不是将我发送到相关的行。
您是否知道是否存在实现第二种行为的方法 (我知道算法就是这种情况)? 如果是,该怎么做?
例子:
\documentclass{article}
\usepackage{algorithm, algpseudocode}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
% linkcolor=teal,
% filecolor=blue,
% citecolor=cyan,
% urlcolor=violet,
}
\begin{document}
\begin{algorithm}
\caption{My algorithm}
\label{algo:example}
\begin{algorithmic}
\State \label{line:1} Lots of line...
\State Line 2
\State Line 3
\State Line 4
\State Line 5
\State Line 6
\State Line 7
\State Line 8
\State Line 9
\State \label{line:10}Line 10
\end{algorithmic}
\end{algorithm}
Line \ref{line:1} and \ref{line:10} reference different lines but both point to the beginning of the algorithm when I click on the links.
\end{document}