12

I want to set the caption for referenced listings:

\documentclass{scrbook}

\usepackage{listings}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\crefname{lstlisting}{Quelltext}{Quelltext}
\Crefname{lstlisting}{Quelltext}{Quelltext}

Ref: \ref{test}.
Cref: \vref{test}.
\clearpage
\begin{lstlisting}[caption={Test},label={test}]
test
\end{lstlisting}

\end{document}

According to another post, I'd expect Quelltext 1 but it prints listing 1.

What is wrong?

Matthias
  • 1,729
  • 1
    \crefname{listing}{Quelltext}{Quelltext} works. I don't know why the package decided to use listing instead of lstlisting. – egreg Dec 08 '12 at 21:30

1 Answers1

14

Use

\crefname{listing}{Quelltext}{Quelltext}
\Crefname{listing}{Quelltext}{Quelltext}

There is an alias from lstlisting to listing, but apparently it doesn't work.

\documentclass{scrbook}

\usepackage{listings}
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\crefname{listing}{Quelltext}{Quelltext}
\Crefname{listing}{Quelltext}{Quelltext}

Ref: \ref{test}.
Cref: \vref{test}.
\clearpage
\begin{lstlisting}[caption={Test},label={test}]
test
\end{lstlisting}

\end{document}

enter image description here

egreg
  • 1,121,712