3

I would like to use JetBrains Mono font in my document, in order to write some code with lstlisting environment. I’m using lualatex and memoir class. I’m using TeX Live 2020 on Windows 10.

Is it possible to use JetBrains Mono’s ligatures inside a lstlisting environment? Thank you!

This is not a duplicate of the similar question Use JetBrains Mono ligatures in a document (LuaLaTeX).

Marco87
  • 173
  • Did more experiments, and found that options like Color=red and Scale=2 are respected where Contextuals=Alternate is not. Found the line \let\do\lst@do@noligs \verbatim@nolig@list in listings.sty, and that looks like the culprit. But I don’t know what to do about it. – Thérèse Jun 02 '20 at 16:12
  • I will try to write to the package author. @Thérèse, thank you for your help! – Marco87 Jun 02 '20 at 19:31
  • Just found https://tex.stackexchange.com/q/485981, which seems very relevant to your problem. – Thérèse Jun 04 '20 at 01:29

1 Answers1

5

Thank you very much @Thérèse! I found the solution in this question. With the following in the preamble it works:

\usepackage{fontspec}
\setmonofont{JetBrains Mono}[
    Contextuals = Alternate,
    Ligatures = TeX,
]

\usepackage{listings}
\lstset{
    basicstyle = \ttfamily,
    columns = flexible,
}
\makeatletter
\renewcommand*\verbatim@nolig@list{}
\makeatother

@Thérèse, actually you found the solution. If you write an answer I will mark it as correct answer.

Marco87
  • 173