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 am using the listings package and I want to automatically add a blank line before every listing. Any idea on how to do this?

share|improve this question
up vote 8 down vote accepted

listings has a parameter aboveskip that defines the space above a listing. Set globally by adding \lstset{aboveskip=<length>} to the preamble.

enter image description here


This be a listing.
share|improve this answer
Ah excellent! That worked perfectly for me. I must have missed that in the listings documentation. – jamtur01 Dec 23 '12 at 21:31

The easiest would be to create your own environment that adds the skip:

enter image description here

\usepackage{lipsum,listings}% http://ctan.org/pkg/{lipsum,listings}
   \lstset{#1}% Add more default options here
Here is a listing

The use of \vspace* will insert a skip of \baselineskip (an empty line) even if the listing starts at the top of the page. If you wish to not have this, using \vspace instead should do the trick. As reference, see Adding vertical space at the start of a page.

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.