I am very new to LaTeX.

I am inserting a listing as follows:

                 caption=My Caption comes here, 

media is my project directory where all my files and images are stored. One of those files is MyFile.xml which is a code snippet.

The problem is the caption of this listing is very close to it. I would like to add some spacing between the two of them.

Any pointers?

  • Try \lstinputlisting[belowskip=4ex, ...] – Daniel Jun 27 '12 at 13:43
  • Hi Daniel, Thank you for your reply. I tried your recomondation but noticed the spacing between the listing(plus its caption) and the paragraph following the listing is affected. Still couldn't move the caption away from the listing vertically. Thank you once again though. Any ideas? – Vishal Jun 28 '12 at 9:34
  • 2
    abovecaptionskip did it for me :D!! – Vishal Jun 28 '12 at 9:55
  • @Daniel could you perhaps write up your comment as an answer so that we can close this question? – Seamus Jun 28 '12 at 12:48
  • @Seamus: Sure, done. – Daniel Jul 1 '12 at 21:46

The documentation of the listing package lists a number of key-val options to affect the spacing between the listing, its caption, and the surrounding material:

  • aboveskip=<dim>, belowskip=<dim> (default: \medskipamount) specify the vertical space above (respectively, below) the listing including its caption.
  • abovecaptionskip=<dim>, belowcaptionskip=<dim> (default: \smallskipamount) specify the vertical space above (respectively, below) the listing's caption. Depending on \captionpos=<t|b> either one has to be used to increase the vertical space between the listing and its caption.

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.