I have a document similar to this:

\documentclass[twoside,11pt,titlepage,a4paper]{report} %unterscheidung zwischen gerade und ungerade seite, 11pkt, kp, kp
\usepackage[T1]{fontenc} %inputcodierung
\usepackage[latin1]{inputenc} %inputcodierung
\usepackage[ngerman]{babel} %deutscher sprachschatz, alte rechtschreibung und vor allem -trennung
\usepackage[babel,german=guillemets]{csquotes} %deutsch mit >><<-anführungszeichen
\usepackage{listings} \lstset{numbers=left, numberstyle=\tiny, numbersep=5pt}  %einfache listings
\usepackage{caption}    %bildunterschriften
\usepackage{beramono}   %schriftart für code

\definecolor{javared}{rgb}{0.6,0,0} % for strings
\definecolor{javagreen}{rgb}{0.25,0.5,0.35} % comments
\definecolor{javapurple}{rgb}{0.5,0,0.35} % keywords

         basicstyle=\footnotesize\ttfamily, % Standardschrift
         numberstyle=\tiny,          % Stil der Zeilennummern
         numbersep=9pt,              % Abstand der Nummern zum Text
         tabsize=2,                  % Groesse von Tabs
         extendedchars=true,         %
         breaklines=true,            % Zeilen werden Umgebrochen
         showspaces=false,           % Leerzeichen anzeigen ?
         showtabs=false,             % Tabs anzeigen ?
         showstringspaces=false      % Leerzeichen in Strings anzeigen ?        

\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white, singlelinecheck=false, margin=0pt, font={bf,footnotesize}}

\begin{lstlisting}[caption=My caption]

The resulting PDF looks like this:

enter image description here

You'll notice the strange margin values; I experimented with them until I got (mostly) the result I wanted (caption and bottom line aligning with the text margins left and right). Until recently I only had a b-frame, but now I want a lbr-frame. As you can see, the left and right frame don't get up to the caption but there's a little space left. Any idea how to change that? I got the full document settings here so you can see all the packages I use, if that is any help.

Any advice would be greatly appreciated. If you can get the listing and caption to look like above without all the weird margin settings, even better, but I'd be happy enough if the left and right lines would go up to the box.

  • The skip you see is the skip between caption and content. You can remove it with \captionsetup[lstlisting]{...,skip=0pt}. – user2574 Jan 22 '13 at 18:52

Switching comment to answer:

The skip you see is the skip between caption and content. You can remove it with \captionsetup[lstlisting]{...,skip=0pt}

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.