1

I'm writing a presentation using beamer and the metropolis theme. The intro of my document looks like this:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usefonttheme{serif}
\usetheme[progressbar=foot]{metropolis}

My initial googling and reading of questions here on Stack suggests that the combination of fontenc and inputenc in that order should allow me to use Unicode glyphs supported by my font. In this case the font is Fira which I verified does have the glyphs I want to write.

The problem is that when I type "₂" (subscript 2) into my .tex file and compile it using LuaTeX the resulting PDF has nothing where the "₂" should be. If I use \textsubscript{2} instead the character appears (or rather a character appears, I'm guessing it's not actually the Unicode glyph "₂"). How can I get the Unicode character to appear in the PDF?

5
  • It's always worth checking that your editor actually saves your file as utf8 - I assume you have?
    – Chris H
    Mar 15, 2017 at 7:30
  • 1
    The use of fontenc, inputenc and lmodern in your snippet doesn't look as if you really know how to load a font with lualatex and how luatex differ from pdflatex. Do you use fontspec to load your font? Mar 15, 2017 at 7:33
  • 1
    if you are using luatex don't use fontenc in particular don't use \usepackage[T1]{fontenc} which specifies that there are only 256 characters, which do not include subscripts, in the font. also don't use \usepackage[utf8]{inputenc} which just makes a warning saying do not use the package, and does nothing at all in luatex. Mar 15, 2017 at 7:45
  • Ulrike, and David, you're both right in that I don't really understand what the different packages are doing and why they're included. I commented them out and it still renders fine (minus the subscript) with lualatex as you suggested. The Unicode subscript glyph is still not appearing though. The answer below solves it by removing the serif font theme, but ideally I'd still like to have a serif font and the subscript glyphs.
    – labarna
    Mar 15, 2017 at 20:02
  • Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. Mar 18, 2017 at 17:57

1 Answer 1

5

The metropolis theme defines its fonts, but you're overriding them with the instruction

\usefonttheme{serif}

If you don't get an error message such as

! Package inputenc Error: Unicode char ₂ (U+2082)
(inputenc)                not set up for use with LaTeX.

it means you are running either XeLaTeX or LuaLaTeX.

The code should be like

\documentclass{beamer}
\usetheme[progressbar=foot]{metropolis}

\begin{document}

\begin{frame}
\frametitle{Test}

This has a subscript₂
\end{frame}

\end{document}

which produces

enter image description here

If you want to use pdflatex, then you have to teach it what the subscript 2 should do and load the FiraSans package.

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usetheme[progressbar=foot]{metropolis}
\usepackage{FiraSans}

\DeclareUnicodeCharacter{2082}{\textsubscript{2}}

\begin{document}

\begin{frame}
\frametitle{Test}

This has a subscript₂
\end{frame}

\end{document}

enter image description here

1
  • Thanks, that was a perfect explanation of what was going wrong. Is there a way to use a serif font with the theme and still be able to use the subscript numbers?
    – labarna
    Mar 15, 2017 at 20:01

You must log in to answer this question.

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