I am using the minted package to highlight source code and also to add a list of listings. My code already looks like it should:
\begin{listing}[hb]
\inputminted[frame=single,linenos]{c}{code/hello_world.c}
\caption{Hello World in C}
\label{hello_world_c}
\end{listing}
I used the following commands to change the autoref name and the caption name:
\providecommand*{\listingautorefname}{Qc.}
\addto\captionsngerman{\renewcommand{\listingscaption}{Qc.}}
I also removed the chapter counter in the list of listings with the following commands:
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{listing}{chapter}
Now I insert the list of listings like this:
\addcontentsline{toc}{chapter}{Quellcodeverzeichnis}
\renewcommand{\listoflistingscaption}{Quellcodeverzeichnis}
\listoflistings
\clearpage
And my list of listings looks like this:
But instead I would like it to look like this:
I already tried inserting the name with
\renewcommand{\cftlistingpresnum}{Qc.~}
But I get the following error: LaTeX Error: \cftlistingpresnum undefined.
I also tried using \usepackage[newfloat]{minted}
but then the commands that worked before are undefined:
LaTeX Error: \listingscaptionundefined.
LaTeX Error: \listoflistingscaptionundefined.
I use ShareLaTeX for compiling my files.
I read that the babel package might cause some problems, here is a list of packages I also use:
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[chapter]{minted}
\usepackage{etoolbox}
\usepackage[decimalsymbol=comma]{siunitx}
\usepackage[german,algosection,boxed]{algorithm2e}
\usepackage[onehalfspacing]{setspace}
\usepackage[titles]{tocloft}
\usepackage{caption}
\usepackage{enumitem}
\usepackage{graphics}
\usepackage{graphicx}
\usepackage{here}
\usepackage{hyperref}
\usepackage{pdflscape}
\usepackage{pstricks}
\usepackage{subcaption}
\usepackage{thmbox}
Edit: Here is my minimal working example:
\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[chapter]{minted}
\usepackage{etoolbox}
\usemintedstyle{vs}
\usepackage[titles]{tocloft}
\usepackage{hyperref}
\usepackage{caption}
\usepackage{subcaption}
% ----------------------------------------------------------------
% Settings of Quellcodeverzeichnis
% ----------------------------------------------------------------
\usepackage{chngcntr}
\counterwithout{listing}{chapter}
% Doesn't work: LaTeX Error: \cftlistingpresnum undefined.
% \renewcommand{\cftlistingpresnum}{Qc.~}
\addto\captionsngerman{\renewcommand{\listingscaption}{Qc.}}
\providecommand*{\listingautorefname}{Qc.}
% ----------------------------------------------------------------
% Table of contents
% ----------------------------------------------------------------
\begin{document}
\tableofcontents
\clearpage
% ----------------------------------------------------------------
% Quellcodeverzeichnis
% ----------------------------------------------------------------
\phantomsection
\addcontentsline{toc}{chapter}{Quellcodeverzeichnis}
\renewcommand{\listoflistingscaption}{Quellcodeverzeichnis}
\listoflistings
\clearpage
% ----------------------------------------------------------------
% Content
% ----------------------------------------------------------------
\chapter{LaTeX-Template}
\label{ch:anhang}
My Hello World C program is right here: \autoref{hello_world_c}
\begin{listing}[hb]
\begin{minted}[frame=single,linenos]{c}
#include<stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
\end{minted}
\caption{Hello World in C}
\label{hello_world_c}
\end{listing}
\clearpage
\end{document}
Any suggestions would be greatly appreciated.
Best Answer
I was able to solve my problem with the help of this answer: Customizing the list of listings from minted
Here is my result: