Looking to display several lines of code in my report as one block, the same way that code is displayed on Stack Exchange. For inline code I've been using \tikzhl
and \texttt
:
\usepackage{tikz}
\newcommand*{\tikzhl}[1]{\tikz[baseline=(X.base)]
\node[fill=black!10] (X) {#1};}
This seems a good solution for code integrated in paragraphs:
But for several lines as their own paragraph it is not ideal:
What I would like to do is have it appear as the following with one bounding grey box:
Found 20 valid images for calibration
DIM=(1920, 1080)
K=np.array([[1374.9140598345757, 0.0, 996.2559942548266], [0.0, 1376.7481511557473, 541.0310811091442], [0.0, 0.0, 1.0]])
D=np.array([[-0.017077674858759682], [-0.30267173652198426], [1.7521950786149205], [-3.054359786737165]])
Adding a new line where it is wider than the page margins if possible, although I can do this manually if not possible.
Thanks in advance. Using Texmaker with MiKTeX 2.9.
listings
andminted
specifically for this purpose. TikZ should not be used in this case.tcolorbox
withlistings
library.