[Tex/LaTex] Use autoref with minted and its listing environment


I would like to use autoref from the hyperref package to create a reference to a floating listing as provided by minted. This code


\chapter{My chapter}
Take a look at the code in \autoref{lst:mylisting}.
  \caption{My listing}

should produce something like Listing 1.1 with a link around it.
I don't want to use Listing~\ref{lst:mylisting}, because it wouldn't be consistent with all the other links produced by autoref.

Any ideas?

Best Answer

The trick is to define a macro called \listingname or \listingautorefname which stores the name hyperref should use for the reference. In your case, adding the line


produces correct references.