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?

  • 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


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

% Define the Python highlighter

    \verbinput (-) #1.py

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



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