TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
The skip you see is the skip between caption and content. You can remove it with \captionsetup[lstlisting]{...,skip=0pt}. – Axel Sommerfeldt Jan 22 '13 at 18:52
Awesome, thanks! – Pragmatick Jan 23 '13 at 11:56

Switching comment to answer:

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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