I'm looking for a way to use tcolorbox to typeset some source code from a file and its output (read from a file) in the lower part of the same box and I can't find how to do this in the documentation. It is possible and how?

  • The source code is LaTeX itself? – user31729 May 4 '17 at 17:58
  • Of course not, it would be too easy. In my case, it's an SQL SELECT statement and I want to show the output of the query but I'd like to use this also for showing C code (or any other programming language) and the output of the program. – Marc Baudoin May 4 '17 at 18:04
  • 2
    Please provide a MWE as a starter then. – user31729 May 4 '17 at 18:05
  • Where is the problem? Can't you do two \lstinputlisting? – Ulrike Fischer May 4 '17 at 18:11
  • This would create two boxes. I'd like to use the upper and lower parts of the same box. – Marc Baudoin May 4 '17 at 18:12

Too long for a comment: There is no problem to use \lstinputlisting inside a tcolorbox:





enter image description here

  • I was so trying to use \newtcbinputlisting that I didn't even think about that. So simple! Thanks. – Marc Baudoin May 4 '17 at 20:53

If you want to use \newtcbinputlisting, a possible solution could be to use listing and comment, where comment inputs the results file:


listing file={#2},
title=A nice listing with results,
listing and comment,



enter image description here

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.