1

I want to decorate listings with a border and background color.

Specifically I would like a similar appearance to this:

listing created with ConTeXt

How can this be achieved?

1
  • Welcome to TeX.SE! Can you show us a short compilable teX code you have so far?
    – Mensch
    Commented May 23 at 11:46

1 Answer 1

2

This is pretty close to Chapter 2 of the OpTeX manual:

optex manual screenshot

The above is implemented in optex-techdoc.tex, so we can easily adapt it to work with Python:

% Initialization
\fontfam[lm]
\nopagenumbers

% Define the Python highlighter
\load[doc]

\eoldef\printpythonfile#1{{%
    \hisyntax{python}%
    \vitt{#1.py}%
    \verbinput (-) #1.py
}}

% Print the Python file
\printpythonfile \jobname % Replace with the name of the file you want to print

\bye

output

1
  • 1
    Thank you! I completely missed that the listings in the doc had this style.
    – pinsl
    Commented May 27 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .