# [Tex/LaTex] \autoref does not capitalize initial character in sentence when referencing label in listings environment

capitalizationcross-referencinglistings

I have defined the following

\providecommand*{\lstnumberautorefname}{line}


and within my text

\begin{lstlisting}
|\label{sdd_1}|<sqlCallStatistics>YES</sqlCallStatistics>
\end{lstlisting}


When I now use in my text

xxx. \autoref{sdd_1}


then I receive the following output :

xxxx. line 1


xxxx. Line 1


\autoref doesn't do automatic capitalization, as the following example illustrates:

\documentclass{article}
\usepackage{listings}
\usepackage{hyperref}

\providecommand*{\lstnumberautorefname}{line}

\begin{document}

\section{Test}\label{sec:test}
\autoref{sec:test} and a period before the reference. \autoref{sec:test}
\begin{lstlisting} [escapeinside=||,numbers=left]
<sqlCallStatistics>YES</sqlCallStatistics>|\label{sdd_1}|
\end{lstlisting}

\autoref{sdd_1}  and a period before the reference. \autoref{sdd_1}

\end{document}


You could use the cleveref package to have \cref (for lower case) and \Cref (for upper case):

\documentclass{article}
\usepackage{listings}
\usepackage{cleveref}

\begin{document}

\begin{lstlisting} [escapeinside=||,numbers=left]
<sqlCallStatistics>YES</sqlCallStatistics>|\label{sdd_1}|
\end{lstlisting}

\cref{sdd_1}  and a period before the reference. \Cref{sdd_1}

\end{document}


Edit: As MWin123 commented: By default \cref turns only the number "1" into a hyperlink, while \autoref makes the whole "line 1" a clickable link. Fortunately there's an option nameinlink for it, i.e., you can use \usepackage[nameinlink]{cleveref}