2

After compiling this code with the lualatex-engine, the approx-symbol isn't printed. I can't understand why. Somebody can help me please ?

\documentclass[lualatex, utf8]{beamer}

\usepackage{stix2}
\usepackage[T1]{fontenc}

\begin{document}
  \begin{frame}
    \[ Re \approx 10^8 \]
  \end{frame}
\end{document}
2
  • 1
    Unrelated: AFAIK fontenc should not be used with xelatex or lulatex
    – daleif
    Jan 22, 2020 at 11:01
  • with the fontspec package or without it, the matter is the same Jan 22, 2020 at 13:09

1 Answer 1

5

With Modern Fonts

If you’re running LuaLaTeX, you can use unicode-math. This supports Unicode and all TrueType and OpenType fonts, and wipes out a lot of the technical debt LaTeX owes to the 1980s. For example, fonts needing to pack all their math symbols into a limited number of 256-character math alphabets and doing that in different ways. I personally recommend that you use the modern tools whenever you can, and the legacy fonts whenever you have to.

\documentclass{beamer}

\usepackage{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont[Scale=1.0]{STIX Two Text}
\setmathfont{STIX Two Math}

\begin{document}
  \begin{frame}
    \[ Re \approx 10^8 \]
  \end{frame}
\end{document}

OpenType font sample

I also removed some package options that you no longer need. (LaTeX 3 already makes UTF-8 the default input encoding, and the class can detect which engine it’s running on.)

You can change the text font to whatever you please, or define a separate \setsansfont. See the documentation of fontspec if you want the details.

It’s also possible to use a font of your choice for variable names in math mode, along with the symbols from your math font, with the range= option of \setmathfont. See the documentation of unicode-math for the details.

With Legacy 8-Bit Fonts

The problem here was that beamer tries to substitute some of the fonts in the document. If you run pdffonts on the PDF file you get, you’ll see that it’s trying to use LMSans (Latin Modern Sans) instead of STIX Two. The class detects certain font packages, as well as unicode-math, and changes its behavior to be compatible with them. However, stix2 is not one of those packages (as of 2020).

You therefore need to turn these substitutions off with professionalfonts:

\documentclass[professionalfonts]{beamer}

\usefonttheme{professionalfonts}
\usepackage[T1]{fontenc}
\usepackage{stix2}

\begin{document}
  \begin{frame}
    \[ Re \approx 10^8 \]
  \end{frame}

\end{document}

Type1 font sample

You can load whatever other fonts you want after stix2. If you want to stick to sans-serif fonts as the default, for example, you can \renewcommand*\familydefault{\sfdefault} or load a font package with a [sfdefault] option.

4
  • I ran the code, but my normal text is not in the STIX2 font (even though I have run \setmainfont[Scale=1.0]{STIX Two Text} and I am running LuaLaTeX on the latest MikTeX distribution. I have a MWE here. Can you help me? Thanks in advance. Mar 7, 2022 at 5:13
  • 1
    @SudipSinha It would be better to post this as a question on this site. The comment system is not really designed for that.
    – Davislor
    Mar 7, 2022 at 5:17
  • Thanks @davislor; I'll keep it in mind for the future. I just figured out the solution to my question. I had to use \usefonttheme{serif}. The details are in this answer. I'll keep this here in case anyone has the same issue. Mar 7, 2022 at 5:26
  • 1
    @SudipSinha professionalfonts, like in my answer, should work as well. I had thought that a Beamer doc using unicode-math shouldn’t need iit.
    – Davislor
    Mar 7, 2022 at 5:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .