# tcolorbox for source code (read from file) and ouput (read from file) in lower part

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
• 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:

\documentclass{article}
\usepackage[many]{tcolorbox}
\usepackage{listings}

\begin{document}
\begin{tcolorbox}
\lstinputlisting{xfp.sty}

\tcblower
\lstinputlisting{xfp.sty}

\end{tcolorbox}
\end{document}


• 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:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{listings}

\newtcbinputlisting{\mylisting}[3][]{%
listing file={#2},
title=A nice listing with results,
listing and comment,
comment={\lstinputlisting{#3}}
#1
}

\begin{document}
\mylisting{368162.tex}{368162.tex}

\end{document}