So I just moved from listings to minted, as listings had super annoying problems with lines showing up when the background color is set to dark. Minted, on the other hand, is annoying as there doesn't seem to be an easy way to define my own styles, except in python, but how would I achieve this in Overleaf?

2 Answers 2


I'm afraid this is not possible in Overleaf. You can load a custom lexer from a .py file without installing it, but unfortunately there isn't a way to load a Pygments style from a local .py file, without installing it or registering it as a plugin at the system level—this is not possible on Overleaf's compile servers.

If you have a requirement to use a custom style with Pygments, you'll need to install your own TeX distribution to compile on your own system.

  • Aw man! Thanks 😊
    – Zorobay
    Jun 9, 2020 at 14:58

It can be done. For example, I have a custom lexer for a language called Portugol, so I upload the lexer with the name PortugolStudioLexer.py (the name is arbitrary). Then, you can start the minted environment using

\begin{minted}{PortugolStudioLexer.py:PortugolStudioLexer -x}


You can also create your own commands with minted interface:

\setminted[PortugolStudioLexer.py:PortugolStudioLexer -x]{linenos}
\newmint[portugol]{PortugolStudioLexer.py:PortugolStudioLexer -x}{}
\newminted[portugolcode]{PortugolStudioLexer.py:PortugolStudioLexer -x}{
    tabsize=2, obeytabs}
\newmintinline[portugolinline]{PortugolStudioLexer.py:PortugolStudioLexer -x}{}
\newmintedfile[portugolfile]{PortugolStudioLexer.py:PortugolStudioLexer -x}{tabsize=2, obeytabs}
\newcommand{\portugolitem}{\portugolfile[linenos = false, xleftmargin = 2em]}

So you get the command \portugol, \portugolinline, \portugolcode and the environment portugolcode.

  • @PaulGessler FYI, this new answer seems to have found a solution for Over´eaf. Apr 14 at 22:41
  • It looks like this is a lexer only, not a style, unless I'm missing some context about the contents of PortugolStudioLexer.py. Apr 15 at 14:20
  • Just realized I misunderstood the question while I was searching. Thought he was talking about a custom lexer. Apr 16 at 13:05

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.