TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

So I am writing a book on Awk programming language, and I have enabled a single frame via \lstset{frame=single}. However, I would like the code within the snippet box to be further away from the frame border. Any ideas how to change the padding of the code within the snippet box? In HTML I'd just do padding: 5px, but I can't figure out how to do it in LaTeX.

share|improve this question
Found it myself \lstset{framesep=10pt} – Peteris Krumins Apr 30 '11 at 1:55
If you've found the solution, you can post and accept an answer to this question. – Andrey Vihrov Apr 30 '11 at 8:10
up vote 8 down vote accepted

Found it myself, it's \lstset{framesep=10pt} and as przemoc suggests in the comments also do \lstset{xleftmargin=10pt,xrightmargin=10pt} to make sure margins don't go outside of margin space.

share|improve this answer
Unfortunately you are wrong here. :) It's not CSS padding equivalent, at least not fully compliant. framesep=X is visually like setting padding-top:X;padding-bottom:X while left and right padding is going over page margins, thus difference is quite substantial, but can be overlooked for small values. To fix it you have to set also xleftmargin=X,xrightmargin=X. – przemoc Jun 15 '11 at 8:18
@przemoc: How to adjust the top and bottom margins as framesep=<value> also modifies the vertical spacing? – xport Aug 8 '11 at 19:50
@xport: Listings package is pretty bad at styling, as things change depending on other settings. I'm not completely sure what you want to achieve, but beside framesep (which isn't useful for margins if you have frame != none and that's why I said about padding earlier) there are aboveskip and belowskip options, set by default to \medskipamount (6.0pt plus 2.0pt minus 2.0pt) that you probably should play with. – przemoc Aug 9 '11 at 18:13

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.