1

I am working on a LaTeX document using the scrarticle class and the minted package for syntax highlighting. My objective is to have a properly aligned caption with the code listing, similar to the second image linked below. However, my current setup leads to a misaligned caption as shown in the first image.

This is my environment setting:

\documentclass[12pt,oneside]{scrarticle}
\usepackage[ngerman]{babel}
\usepackage{acronym}
\usepackage{enumerate}
\usepackage{a4wide}
\usepackage{minted}
\setminted[python]{breaklines, framesep=2mm, fontsize=\footnotesize, numbersep=5pt}
\usepackage[justification=centering]{caption}


\begin{document}

\begin{listing}
\begin{minted}{python}
# Python code here
\end{minted}
\caption{Beispiel - SuperCode}
\label{listing:supercode}
\end{listing}

\end{document}

What I get is:

enter image description here

What I want is:

enter image description here

I attempted to use the listings package to address this, but it caused an error and the minted environment within the listing was ignored.

1
  • 2
    Unrelated: don't use the a4wide package, it has not been updated size 1994! Use the a4paper class option instead.
    – daleif
    Nov 14, 2023 at 12:10

1 Answer 1

1

You can find examples for changing the caption name in the section "Customizing the listing environment" of the minted manual:

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}

\documentclass[12pt,oneside]{scrarticle}
\usepackage[ngerman]{babel}
\usepackage{minted}
\setminted[python]{breaklines, framesep=2mm, fontsize=\footnotesize, numbersep=5pt}
\usepackage[justification=centering]{caption}

\renewcommand{\listingscaption}{Auflistung}

\begin{document}

\begin{listing}
\begin{minted}{python}
# Python code here
\end{minted}
\caption{Beispiel - SuperCode}
\label{listing:supercode}
\end{listing}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .