I am starting to use Pygments, via the LaTeX minted package. My goal is to typeset Python code using the highlighting scheme used in JupyterLab, or something close to that. Starting with the default style, I have managed to get close to what I want by adding modifications to the LaTeX file, as described here: https://topanswers.xyz/tex?q=8045#a7657 But, I am stuck on the highlighting of some of the Python keywords, specifically "continue", "del", "global" and "in".
As far as I can tell, none of these words are highlighted using any of the standard keyword tokens, and I have managed to deduce the following:
"continued" is highlighted as Name.Class
"global" and "in" are highlighted as Name.Namespace
But, I haven't been able to figure out how "del" is handled.
My goal here is to highlight all of the Python keywords in the same way (bold green). I'm sure that there is a lot that I still don't understand about how pygments works, and any guidance would be greatly appreciated!
Here is an example of what I am trying to do, with the full set of Python keywords in the minted environment.
\documentclass[letterpaper,12pt,fleqn]{article}
\usepackage{minted}
\setminted{escapeinside=@@}
%\setmintedinline{style=bw}
%\newcommand{\lstinline}[1]{\mintinline{py}{#1}}
% Customize minted syntax higlighting
\makeatletter
\AddToHook{env/MintedVerbatim/before}{
% Keyword (k)
\@namedef{PYG@tok@k}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.70,0.00}{\bfseries ##1}}}
% Keyword.Const (kc) False, True, None
\@namedef{PYG@tok@kc}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.70,0.00}{\bfseries ##1}}}
% Keyword.Namespace (kn): import, from
\@namedef{PYG@tok@kn}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.70,0.00}{\bfseries ##1}}}
\@namedef{PYG@tok@gp}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.70,0.00}{\bfseries ##1}}}
% Operator (o)
\@namedef{PYG@tok@o}{\def\PYG@tc##1{\textcolor[rgb]{0.50,0.00,0.80}{\bfseries ##1}}}
% Operator.Word (ow) and, or, not, is
\@namedef{PYG@tok@ow}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.70,0.00}{\bfseries ##1}}}
%String.Doc (sd) triple quoted for doc strings
\@namedef{PYG@tok@sd}{\def\PYG@tc##1{\textcolor[rgb]{0.70,0.00,0.00}{##1}}}
%String.Interpol (si) curly braces
\@namedef{PYG@tok@si}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.00,0.00}{##1}}}
% Name.Function (nf)
\@namedef{PYG@tok@nf}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
% Name.Class (nc)
\@namedef{PYG@tok@nc}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
% Name.Namespace (nn)
\@namedef{PYG@tok@nn}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.00,0.00}{##1}}}
% Name.Exception (ne) Error messages
\@namedef{PYG@tok@ne}{\def\PYG@tc##1{\textcolor[rgb]{0.80,0.25,0.22}{##1}}}
% String.Single (s1) String in single quotes
\@namedef{PYG@tok@s1}{\def\PYG@tc##1{\textcolor[rgb]{0.00,0.00,0.00}{##1}}}
}
\begin{document}
\begin{minted}[frame=single]{python}
False None True and as
assert async await break class
continue def del elif else
except finally for from global
if import in is lambda
nonlocal not or pass raise
return try while with yield
\end{minted}
\end{document}
Thanks, David
deluses\@namedef{PYG@tok@nf}{\def\PYG@tc##1{\textcolor[rgb]{1.00,0.00,1.00}{##1}}}