Take the 2-minute tour ×
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.

I am very new to LaTeX.

I am inserting a listing as follows:

\lstinputlisting[float=hk,
                 caption=My Caption comes here, 
                 captionpos=b,
                 label=MyLabel]{media/MyFile.xml}

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?

share|improve this question
    
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
1  
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
show 1 more comment

1 Answer

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.
share|improve this answer
add comment

Your Answer

 
discard

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.