0

I would like to change the appearance of the caption of a code snippet that I have created with minted and listing. However, using \captionsetup[listing]{<options>} does not change anything. Does someone know how to change the caption setup in a listing/minted environment so that the caption is closer to the code?

Here is a working example:

\documentclass[a4paper,oneside,11pt]{report}
\usepackage{listing}
\usepackage[chapter]{minted}
\usepackage{caption}
\usepackage{hyperref}
\usepackage{blindtext}

\setminted{frame=single}

\captionsetup[listing]{belowskip=-10pt} % --> is not working

\begin{document}

\blindtext

\begin{listing}[!h]
    \begin{minted}{c}
    int main() {
    printf("hello, world");
    return 0;
    }
    \end{minted}
\caption{test code 2}
\label{code:2}
\end{listing}

\blindtext

\end{document}
  • You should not use \usepackage{listing} and instead \usepackage[newfloat,chapter]{minted}, see the answer on the related question https://tex.stackexchange.com/a/256796 for an example. – Marijn Mar 14 '19 at 22:11
  • Thanks for this idea. It is, however, not possible to load the newfloat option as \listingscaption and \listoflistingscaption are then undefined and produce an error. – berlinesther Mar 15 '19 at 05:40
  • 1
    In that case you might try https://tex.stackexchange.com/a/261048. – Marijn Mar 15 '19 at 10:16
  • Perfect, this solution solved my problem. Thanks. – berlinesther Mar 27 '19 at 09:33

0 Answers0