2

I'm getting (re)acquainted with babel and lualatex for multi-lingual documents. I know I can set individual font families with, say:

\babelfont[english]{rm}{Latin Modern Roman}

but how do I tell babel to "Use all of the classic TeX default font families for all font modes/styles" (including small caps, sans serif, etc.)? I thought I would tell it something having to do with "Computer Modern", but apparently there is no lualatex-usable font with a similar name.

Notes:

  • I don't mind it being multiple commands.
  • I use TeXLive 2019 (on Devuan Beowulf ~= Debian Buster).
10
  • latin modern (the default in lualatex) is essentially an updated computer moderm but there are other opentype computer modern eg Computer Modern Unicode and the new New Computer Modern. (you could use literally the traditional 7bit cmr10.tfm but that would be somewhat unusual choice as it would disable most luatex features, apart from Lua access) – David Carlisle Jun 22 at 19:49
  • @DavidCarlisle: I'm fine with any of those. But the question is mostly how do I tell luatex and babel to use one of them. And of course which one of them I should choose. – einpoklum Jun 22 at 19:51
  • wel for latin modern just do nothing, that is the default – David Carlisle Jun 22 at 19:51
  • for CMU or NEWCM see Davislor's answer which is pretty comprehensive – David Carlisle Jun 22 at 20:11
  • 2
    It will use latin modern unless you explicitly change fonts to use something else just as pdflatex uses computer modern unless you change fonts, there is no difference. choosing a language ideally has no effect on font choice at all. Obviously in legacy encodings for pdflatex you need to switch encoding to LGR for Greek or T2 for Cyrillic etc but that's less of an issue with Unicode. – David Carlisle Jun 23 at 10:30
4

Also define \babelfont{sf} and \babelfont{tt}. For example:

\usepackage[greek,english]{babel}
\usepackage{fontspec}

\babelfont{rm}
          {CMU Serif}
\babelfont{sf}
          {CMU Sans Serif}
\babelfont{tt}
          {CMU Typewriter Text}

You will want to set most options with \defaultfontfeatures after \usepackage{fontspec} and before \babelfont, for example,

\documentclass{article}
\usepackage[greek.ancient,english]{babel}
\usepackage{fontspec}

\defaultfontfeatures[NewComputerModern]{
   UprightFont = {NewCM10-Regular},
   ItalicFont = {NewCM10-Italic},
   BoldFont = {NewCM10-Bold},
   BoldItalicFont = {NewCM10-BoldItalic},
   % Can define SizeFeatures to use NewCM08-* here.
   Extension = {.otf} }

\babelfont[english]{rm} % Language=Default suppresses a harmless warning.
          [Ligatures=Common, Language=Default]{NewComputerModern}
\babelfont[greek]{rm}
          [Language=Default]{NewComputerModern}

\begin{document}
Homer’s \textit{\foreignlanguage{greek}{Ὀδύσσεια}} begins,
“\foreignlanguage{greek}{ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς
μάλα πολλὰ πλάγχθη}.”
\end{document}

You can also define rm, sf and tt fonts per language, e.g.:

\usepackage[english]{babel}
\usepackage{fontspec}

\babelprovide[import=ar]{arabic}

\defaultfontfeatures{ Scale=MatchUppercase,
                      Ligatures=TeX }

\babelfont{rm}
          [Scale=1.o]{Libertinus Serif}
\babelfont[arabic]{rm}
          {Amiri}
\babelfont{tt}
          {Libertinus Mono}
\babelfont[arabic]{tt}
          {ALM Fixed}
10
  • So, the second part of your answer is valid of course, not relevant to my question (I mean, I already knew that). About the first part: Will this influence the math fonts at all? Or are those independent of what I do with babelfont? – einpoklum Jun 22 at 20:55
  • Ok, this doesn't work. With \babelfont{rm}{CMU Serif} I get: Package fontspec Warning: Language 'English' not available for font 'CMUSerif' with script 'Latin'. – einpoklum Jun 22 at 21:58
  • And if I try \defaultfontfeatures[NewComputerModern]{etc etc, I get: Undefined control sequence. \defaultfontfeatures. – einpoklum Jun 22 at 22:00
  • 1
    @einpoklum Sorry, the monospace Computer Modern Unicode font should have been Computer Modern Typewriter Text. Fixed now. – Davislor Jun 22 at 22:23
  • 1
    @einpoklum Make sure to \usepackage{fontspec} after babel and before \defaultfontfeatures. The command is from there. – Davislor Jun 22 at 22:24

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.