autoref for algorithms
\autoref
does only work completely with a corresponding \....autorefname
macro, i.e. \sectionautorefname
etc.
hyperref
extracts the reference information from its specific label information, where the relevant counter name is stored as well.
This means, if the counter is named foo
, \fooautorefname
must exist -- otherwise it's ignored (and a warning shipped to the console).
The algorithm
environment has a counter of the same name, so
\newcommand{\algorithmautorefname}{Algorithm}
will provide hyperref
with the correct information.
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage{hyperref}
\newcommand{\algorithmautorefname}{Algorithm}
\begin{document}
\begin{algorithm}
\caption{Baseline}\label{ALG_baseline}
%\begin{algorithmic}[1]
%
%\end{algorithmic}
\end{algorithm}
\autoref{ALG_baseline} is simply linked to with a number.
\end{document}
Please note, that cleveref
package provides a similar feature, however, the names must be setup as well, with \crefname{algorithm}{algorithm}{algorithms}
etc.
Update
This addresses the comment by the O.P. about detecting names of counters.
An excerpt of the .log
file:
The counter definitions are written to the .log
file as c@foo=\countY
, where Y
is the number of a free counter register and not really important (apart from few exceptions.)
\@float@every@algorithm=\toks16
\c@algorithm=\count88
Later on, we find
\c@ALG@line=\count89
\c@ALG@rem=\count90
\c@ALG@nested=\count91
\ALG@tlm=\skip43
\ALG@thistlm=\skip44
\c@ALG@Lnr=\count92
\c@ALG@blocknr=\count93
\c@ALG@storecount=\count94
\c@ALG@tmpcounter=\count95
\ALG@tmplength=\skip45
This means, that ALG@line
is (very likely) the line number counter.
However, it's a 'hidden' counter, due to @
usage in the name!
I took me half an our to figure out that I had to use \renewcommand{} instead of just \newcommand to overwrite the hyperref default algorithm name.