Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
\crefname{listing}{Quelltext}{Quelltext} works. I don't know why the package decided to use listing instead of lstlisting. –  egreg Dec 8 '12 at 21:30
add comment

1 Answer

up vote 9 down vote accepted

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

share|improve this answer
    
Thank you so much :) –  Matthias Dec 9 '12 at 0:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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