![tcolorbox 用于源代码(从文件读取)和下部的输出(从文件读取)](https://linux22.com/image/354259/tcolorbox%20%E7%94%A8%E4%BA%8E%E6%BA%90%E4%BB%A3%E7%A0%81%EF%BC%88%E4%BB%8E%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%EF%BC%89%E5%92%8C%E4%B8%8B%E9%83%A8%E7%9A%84%E8%BE%93%E5%87%BA%EF%BC%88%E4%BB%8E%E6%96%87%E4%BB%B6%E8%AF%BB%E5%8F%96%EF%BC%89.png)
我正在寻找一种方法来使用 tcolorbox 排版文件中的一些源代码,并将其输出(从文件中读取)在同一框的下部,但我在文档中找不到如何执行此操作。这可能吗?如何执行?
答案1
答案2
如果您想使用\newtcbinputlisting
,一个可能的解决方案是使用listing and comment
,其中comment
输入结果文件:
\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}