Some time ago I copied this code from Stackexchange to have a nice gray box at the top of my imported source code which I displayed with listings:
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\lstset{ aboveskip={0.0\baselineskip}, belowskip={0.0\baselineskip} }
The problem is that I have switched to minted to display code but I want to keep the gray title-boxes above the code. Can you help me to get rid of the need of the listings package? Here's an typical document:
\documentclass[a4paper,oneside]{article}
\usepackage{a4wide}
\usepackage[icelandic]{babel}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{minted}
\usemintedstyle{perldoc}
\setlength\partopsep{-\topsep}
\usepackage{listings}
\usepackage{caption}
\usepackage{xcolor}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\lstset{ aboveskip={0.0\baselineskip}, belowskip={0.0\baselineskip} }
\begin{document}
\begin{lstlisting}[caption=\textbf{Title} -- This is the title I want for my code]
\end{lstlisting}
\begin{minted}{java}
public class demo {
public static void main(String[] args) {
System.out.println("My source code.");
}
}
\end{minted}
\end{document}

