# Autoref's inserted text has not the correct case

I'm using the \autoref tag which comes with the package hyperref for referencing my algorithms, figures etc. I read that it automatically adjusts the reference text's case, but it won't work with my setup. When I compile the code, everything (page, text, link) is correctly put, except the case like in the following example:

As it can be seen in Figure 9.7, this [...]

Remark: there may be something wrong with my setup - links to text sections (like chapter, section, subsection) and also floating environments like "algorithm" (algorithm2e.sty) do have the correct case. The case is wrong when refering to Figures and Equations.

-
Note that it is quite conventional usage to use capital when referring to figures, so it isn't really "wrong" just different. It also avoids the problem of sentence starting. –  David Carlisle May 17 '12 at 16:37

## migrated from meta.tex.stackexchange.comNov 29 '11 at 20:48

This question came from our discussion, support, and feature requests site for users of TeX, LaTeX, ConTeXt, and related typesetting systems.

hyperref.sty indeed includes the following code snippet (with names sometimes, but not always in uppercase):

\def\HyLang@english{%
\def\equationautorefname{Equation}%
\def\footnoteautorefname{footnote}%
\def\itemautorefname{item}%
\def\figureautorefname{Figure}%
\def\tableautorefname{Table}%
\def\partautorefname{Part}%
\def\appendixautorefname{Appendix}%
\def\chapterautorefname{chapter}%
\def\sectionautorefname{section}%
\def\subsectionautorefname{subsection}%
\def\subsubsectionautorefname{subsubsection}%
\def\paragraphautorefname{paragraph}%
\def\subparagraphautorefname{subparagraph}%
\def\FancyVerbLineautorefname{line}%
\def\theoremautorefname{Theorem}%
\def\pageautorefname{page}%
}


Solution: Redefine the "offending" name macros.

\documentclass{article}

\usepackage{hyperref}

\renewcommand*{\figureautorefname}{figure}

\begin{document}

\begin{figure}
\centering
\rule{1cm}{1cm}
\caption{foo}\label{fig:foo}
\end{figure}

As shown in \autoref{fig:foo}~\dots

\end{document}


-
Thank you @lockstep, that did the trick for the lowercase-case. BUT when a reference is at the start of a sentence, it's not set uppercase. As far as I know autoref should realize this and set the corresponding case, right? –  Eric Nov 30 '11 at 12:57
@Eric: I'm afraid no. LaTeX can't detect sentence starts automatically; to switch to uppercase manually, you should have a look at the cleveref package and its \cref and \Cref commands. –  lockstep Dec 1 '11 at 0:39
Why the last code does not work when the package 'babel' is load... Thanks in advance –  Gitano Jan 22 '13 at 14:52
@Gitano See tex.stackexchange.com/questions/82993/… –  lockstep Jan 22 '13 at 15:46

As indicated by lockstep you can use cleveref to have control over case. Simply load cleveref, but make sure to load it after hyperref, and use \cref for lower case cross-references and \Cref for upper case cross-references. Other than being able to handle cases cleveref can handle ranges of labels and more languages than \autoref.

Here is an example on how to use it:

\documentclass{article}

\usepackage{mwe}
\usepackage{hyperref}
\usepackage{cleveref}% Has to be loaded after hyperref

\begin{document}

\begin{figure}
\centering
\includegraphics[width=.48\linewidth]{example-image-a}
\caption{foo}\label{fig:foo}
\end{figure}

As shown in \cref{fig:foo}~\dots

\Cref{fig:foo} shows~\dots

\end{document}


Note that if you want cross-reference links to include the name, e.g. "fig. 1" and not only "1", you have to load cleveref with the option nameinlink. Also note that if you want it to not abbreviate cross-reference names, e.g. "figure 1" and not "fig. 1", you have to load cleveref with the option noabbrev.

-