So when I


the output will look somewhat like this:

Algorithm 1: Baseline

So obviously, there IS a counter, already.


\autoref{ALG_baseline} is simply linked to with a number.

will result int

[1] is simply linked to with a number.

How can I make autoref output

[Algorithm 1] is ...


  • 1
    \newcommand{\algorithmautorefname}{Algorithm}, assuming that the counter is named algorithm. Please post a compilable document, not just fragments.
    – user31729
    Jun 7, 2016 at 12:23

2 Answers 2


\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


will provide hyperref with the correct information.





\autoref{ALG_baseline} is simply linked to with a number.


enter image description here

Please note, that cleveref package provides a similar feature, however, the names must be setup as well, with \crefname{algorithm}{algorithm}{algorithms} etc.


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.)


Later on, we find


This means, that ALG@line is (very likely) the line number counter.

However, it's a 'hidden' counter, due to @ usage in the name!

  • Thank you. You say "the algorithm environment has a counter of the same name". How/Where do I find this information? Where would I find the name of the line-counter mentioned in its documentation? mirror.utexas.edu/ctan/macros/latex/contrib/algorithms/…
    – User1291
    Jun 7, 2016 at 12:39
  • 1
    @User1291: Look for \newcounter statements in the .sty file or have a look on the .log file , see my edits to my answer at the end, please
    – user31729
    Jun 7, 2016 at 12:45
  • 1
    +1. The cleveref package has known about the algorithm package since version 0.17. (Current version: 0.19 or so.) Both \Cref{ALG_baseline} and\cref{ALG_baseline} work right away -- no need for \crefname{algorithm}{algorithm}{algorithms}, etc.
    – Mico
    Jun 7, 2016 at 13:15
  • 1
    @Mico: Thanks, I should have looked into cleveref.cfg The better, others do not have to define the \crefname then
    – user31729
    Jun 7, 2016 at 15:05

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.