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

When I use the listings package with frame in my code the frame "breaks" when the page ends and it is open in the end of the page. I want the frame to be complete with four sides and continue in the next page again with all four frame sides complete. How can I do this? Why does the frame "breaks"?

enter image description here

share|improve this question
This is a duplicate of tex.stackexchange.com/questions/162684/…, even though it can't be closed as such. – Jubobs Apr 3 '14 at 22:46
This question appears to be off-topic because it is a feature request for the listings package. – Jubobs Apr 3 '14 at 22:46
Why is this an off-topic question? – Adam Apr 3 '14 at 22:51
Because it is essentially a feature request for the listings package, and, as such, not really fit for a question on this site. You would be better off contacting the maintainer of listings directly. – Jubobs Apr 3 '14 at 22:53
@Jubobs I just did. But these two are similar and hence one of them may be marked as duplicate IMO. – Harish Kumar Apr 4 '14 at 0:32
up vote 5 down vote accepted

It is possible with tcolorbox.

      listing only,
      listing options={style=mystyle},

abc def {



again some

Some again

enter image description here

The advantage is, with tcolorbox, you can do lot of customisations.

share|improve this answer
Thank you for your answer! I will check if it solves my problem. – Adam Apr 3 '14 at 23:07
I tried it and it works! The only "problem" is that you have to specify how big you want the box to be although I would prefer to adjust automatically with the length of the code. – Adam Apr 4 '14 at 14:43
@Adam There is hbox option but it won't allow you to break across pages. You can try with varwidth and post a new question on that. :) – Harish Kumar Apr 4 '14 at 14:45
I think that someone can use a box as long as the page for the worst case. This seem to solve the previous problem I mentioned! – Adam Apr 4 '14 at 14:53
Also why there is space at the top and at the bottom of the box? How can I make it disappear? – Adam Apr 4 '14 at 15:28

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.