# Listings package split frame when the page ends

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"?

• This is a duplicate of tex.stackexchange.com/questions/162684/…, even though it can't be closed as such. Apr 3 '14 at 22:46
• This question appears to be off-topic because it is a feature request for the listings package. Apr 3 '14 at 22:46
• Why is this an off-topic question?
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. 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.
– user11232
Apr 4 '14 at 0:32

It is possible with tcolorbox.

\documentclass{article}
\usepackage{tcolorbox,listings}
\usepackage[textheight=2in]{geometry}
\lstdefinestyle{mystyle}{
basicstyle=\ttfamily,
numbers=left,
numberstyle=\tiny,
numbersep=5pt
}
\tcbuselibrary{listings,skins,breakable}
\newtcblisting{mycode}{
arc=0mm,
top=0mm,
bottom=0mm,
left=3mm,
right=0mm,
width=\textwidth,
boxrule=1pt,
colback=blue!20,
listing only,
listing options={style=mystyle},
breakable
}

\begin{document}
\begin{mycode}
abc def {

xyz

some

again some

Some again
\end{mycode}
\end{document}


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

• Thank you for your answer! I will check if it solves my problem.
• @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. :)