\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[]{algorithm2e}
\usepackage[hidelinks]{hyperref}
\begin{document}
\section{Introduction}
\begin{algorithm}[H]
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
Then compute
\begin{equation}
a= b + c
\end{equation}
}{
Compute
\begin{equation} d = e + f \end{equation}
}
}
\caption{My Code}
\label{lovely_algo}
\end{algorithm}
\autoref{lovely_algo} is my algorithm. But this sentence is not grammatically correct. A in the algorithm should be capitalized.
\end{document}
这是一个简单的算法。我使用 hyperref + autoref 来引用它,这是我首选的引用方法。
不过我希望算法里的A全都大写,不然有些地方会有语法错误。
有办法实现这个吗?
答案1
恐怕\autoref
不会大写。您可以改用cleveref
包。它有自己的等价于\autoref
in \cref
,您可以通过使用来获得大写变体\Cref
:
\Cref{lovely_algo} is my algorithm. But this sentence is not grammatically
correct. A in the algorithm should be capitalized.
cleveref
之后加载hyperref
以确保它们能够很好地协同工作。