7

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

Is it possible to use JetBrains Mono’s ligatures? Thank you!

Marco87
  • 173

1 Answers1

9

This font defines its ligatures in the calt feature, so \setmonofont{JetBrains Mono}[Contextuals=Alternate] will give you what you want. E.g,

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmonofont{JetBrains Mono}[Contextuals=Alternate]
\begin{document}
\texttt{</ \#? ]\#}
\end{document}

output

Note that TeX ligatures are not on by default for typewriter fonts. So if you want TeX’s ligature for, say, em dashes rather than the ligature defined by JetBrains, use \setmonofont{JetBrains Mono}[Contextuals=Alternate,Ligatures=TeX].

Thérèse
  • 12,679
  • 1
    :-) What strange symbols. What's their use? :-) +1 – Sebastiano Jun 01 '20 at 22:11
  • 1
    @Sebastiano Just for fun, I guess, a typographer’s practice of the virtue of eutrapelia. – Thérèse Jun 01 '20 at 22:30
  • Thank you very much for your explanation...after I have searched the word "eutrapelia" that I not know :-( εὐτραπελία=εὖ + τρέπω : Aristotele). – Sebastiano Jun 01 '20 at 22:33
  • It works! But, I do not understand why it does not work inside lstlisting environment. Is there a solution? – Marco87 Jun 02 '20 at 01:27
  • @Marco87 From the codeanatomy package? I’ve never used it, but give me a day (it’s time for bed here), and I’ll try to figure it out. – Thérèse Jun 02 '20 at 01:32
  • @Thérèse Thank you very much! – Marco87 Jun 02 '20 at 03:32
  • @Marco87 I just played with it and don’t understand the problem. The reason must have to do, not with fontspec, but with the inner workings of either codeanatomy or listings, neither of which I’ve used before. I suggest you ask a new question, referring to this one and asking how to make the solution here work with the lstlisting environment. Include a small, compilable example of your use of the environment — an example where the expected ligatures are missing —, and someone who knows those packages well will probably be able to help you. – Thérèse Jun 02 '20 at 03:40
  • I will do so. Thank you very much @Thérèse! – Marco87 Jun 02 '20 at 14:01