[Tex/LaTex] lstlistoflistings isn’t showing the lstlistingname

listingstable of contents

I've actually a problem with my document.

I redefined the listing for my ruby code:

\usepackage{listings}
\renewcommand\lstlistingname{Quellcode}
\lstloadlanguages{Ruby}
\lstset{%
basicstyle=\small\ttfamily\color{black},
commentstyle = \ttfamily\color{red},
keywordstyle=\ttfamily\color{blue},
stringstyle=\color{orange},
backgroundcolor=\color{grey},
columns=fullflexible}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}

And redefined the lstlistoflistings.

\renewcommand\lstlistlistingname{Quellcodeverzeichnis}
 \addcontentsline{toc}{section}{Quellcodeverzeichnis}
 \lstlistoflistings
 \newpage

But the lstlistoflistings isn't showing the name, only the number of the lst.

Here is the actually lstlistoflistings:

enter image description here

Can anyone help me and show me how I can get the lstlistingname (Quellcode)
in every line of lstlistoflistings?

Thanks

UPDATE:

Here a MWE:

\documentclass[12pt, a4paper, oneside]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[ngerman]{babel}
\usepackage[hidelinks=true]{hyperref}
\usepackage[final]{pdfpages}

\definecolor{grey}{gray}{0.9}

\usepackage{listings}
\renewcommand\lstlistingname{Quellcode-Ausschnitt}
\lstloadlanguages{Ruby}
\lstset{%
basicstyle=\small\ttfamily\color{black},
commentstyle = \ttfamily\color{red},
keywordstyle=\ttfamily\color{blue},
stringstyle=\color{orange},
backgroundcolor=\color{grey},
columns=fullflexible}

\usepackage{color}
\usepackage{xcolor}

\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}

\usepackage{geometry}
\geometry{a4paper, top=25mm, left=25mm, right=25mm, bottom=20mm, headsep=10mm, footskip=12mm}

\begin{document}

 \renewcommand\lstlistlistingname{Quellcodeverzeichnis}
 \addcontentsline{toc}{section}{Quellcodeverzeichnis}
 \lstlistoflistings
 \newpage

  \begin{lstlisting}[language=Ruby, caption=StatusCalculator Initialize, label=initialize]
  def initialize(project_id)
    @project = Project.find(project_id)
  end
  \end{lstlisting}

\end{document}

Best Answer

You can add this code to your document before calling \lstlistoflistings (e.g. in the preamble):

\let\oldlstlistoflistings\lstlistoflistings
\renewcommand{\lstlistoflistings}{%
  \begingroup%
  \let\oldnumberline\numberline%
  \renewcommand{\numberline}{\lstlistingname~\oldnumberline}%
  \oldlstlistoflistings%
  \endgroup}

and you will have:

enter image description here

Note that this code is adapted from the one in an answer of Werner, which addressed the same thing for the \listofalgorithms command.

Related Question