Is there any way to prevent the listings package from leaving unsightly gaps in the frame when using breaklines=true. I'm just \lstinputlisting some code, placing it in a shadowbox frame and letting listings wrap the longer lines. This sometimes causes breaks in the frame (where a line has been split). I've seen other tex.stackexchange users encounter this problem when embedding maths (or other commands that use more than the expected line height); I'm not attempting anything as exotic. Is this a bug in Listings?

  • I am sure you will not the last person who will encounter such an issue. It would be helpful if you composed a small compilable MWE that illustrated the problem so that it might help others in the future. Since you have actually discovered the solution, this should be fairly easy. This might also explain why no answer appeared either, as it is difficult to fix a problem without first being able to reproduce it. Nov 20, 2012 at 20:01

1 Answer 1


Who knows if anyone will ever find this useful, but here goes. I discovered the answer to my problem of the frame becoming broken. It was caused by having spaces in front of keywords in my custom language definition. The gaps always corresponded with where a line had been broken and a keyword was the first item on the remainder of the wrapped line. By ensuring that there were no spaces and only commas between my keywords I rectified the issue.

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.