3

As a minimal example I would want to highlight the following code:

(new Thread(() -> {
    System.out.println("Hello");
})).start(); 

Given the MWE:

\documentclass{article}
\usepackage{minted}
\usemintedstyle{borland}

\begin{document}

\begin{minted}{Java}
(new Thread(() -> {
    System.out.println("Hello");
})).start();
\end{minted}

\end{document}

I get something like this:

where for some reasons, the field variables/functions are highlighted in red. I would like to remove this "highlighting-rule" or however it is being called.

Therefor I've been searching the minted docs(minted docs), but couldn't find any option to change the color of field variables
I've also been searching the pygment docs (pygment docs), but couldn't figure out yet what token identifiers belong to which specific rule.

I would be happy if I could stick to minted, as it is simple and seems to be quite smart, but also, if that's even possible, I would prefer answers using options that I can pass to the \begin.. environment.

  • 1
    Welcome to TeX.SE. It would be helpful if you composed a fully compilable minimal working example (MWE) including \documentclass and the appropriate packages that sets up the problem. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – user36296 Apr 2 at 17:30
  • Thank you so much for your hint! I'll do my best to remember for the next time. – Marcel H. Apr 2 at 17:38
  • 1
    The relevant line in borland.pygstyle seems to be \expandafter\def\csname PYGborland@tok@na\endcsname{\def\PYGborland@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}} -- however I don't yet know how to influence this colour from within the document. – user36296 Apr 2 at 19:20
  • wow, thanks a lot! actually putting that line before \begin{document} was all I needed, as I wanted to change the behavior globally! if you want, you can post your answer so I can accept it :) – Marcel H. Apr 2 at 19:36
  • Can you write a self-answer instead? – user36296 Apr 2 at 19:42
2

thanks to samcarter, I found out that adding the line \expandafter\def\csname PYGborland@tok@na\endcsname{\def\PYGborland@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}} before \begin{document} already did what I wanted (though not quite sure why)

\documentclass{article}
\usepackage{minted}
\usemintedstyle{borland}

\expandafter\def\csname PYGborland@tok@na\endcsname{\def\PYGborland@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}

\begin{document}

\begin{minted}{Java}
(new Thread(() -> {
    System.out.println("Hello");
})).start();
\end{minted}

\end{document}

The output,as intended, is:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.