matze / mtheme

A modern LaTeX Beamer theme
6.36k stars 841 forks source link

Font error (xelatex) #201

Closed twsh closed 8 years ago

twsh commented 8 years ago

I have the latest version of Metropolis from CTAN (1.1) and Fira Sans downloaded from www.fontsquirrel.com/fonts/fira-sans

I get the following warning when I do $ latexmk -xelatex foo.tex:

LaTeX Font Warning: Font shape `OT1/FiraSansLight(0)/m/n' undefined
(Font)              using `OT1/cmr/m/n' instead on input line 92.

This looks a bit like https://github.com/matze/mtheme/issues/187 but I'm using xelatex not lualatex.

rchurchley commented 8 years ago

Based on your error message, it looks like XeLaTeX can't find any of the Fira Sans fonts you have downloaded. (This is different from #187, where only the italics didn't work.) A couple questions to try to get to the bottom of your issue:

  1. Is your problem specific to the Metropolis theme? Try compiling the following minimal example with XeLaTeX:

    \documentclass{article}
    \usepackage{fontspec}
    \setmainfont{Fira Sans}
    
    \begin{document}
     Lorem ipsum dolor sit amet.
    \end{document}

    This should compile without any warnings. If you get the same problem, it means XeLaTeX can't find the Fira Sans font.

  2. Is Fira Sans available to other programs (e.g. Word, LibreOffice) on your computer? This should be the case if the fonts are installed properly.
twsh commented 8 years ago

@rchurchley Fira Sans is available to LibreOffice. Your MWE compiles fine. My presentation is set in Fira Sans. So xelatex can find Fira Sans. I still get the error, however. Presumably it's caused by something else in my file (generated by Pandoc). I haven't been able to track down what it is yet.

rchurchley commented 8 years ago

Interesting. Just to make sure it is a problem with your file and not the theme, does a minimal Beamer presentation using Metropolis compile correctly?

\documentclass{beamer}
\usetheme{metropolis}
\begin{document}
  \begin{frame}
    Lorem ipsum dolor sit amet.
  \end{frame}
\end{document}
twsh commented 8 years ago

@rchurchley That compiles fine. So it's something that the Pandoc template adds. Also, the line which the message refers to seems to correspond to the first occurrence of \section.

rchurchley commented 8 years ago

Curious. How about these examples, then?

\documentclass{beamer}
\usetheme{metropolis}
\begin{document}
  \section{Introduction}
  \begin{frame}
    Lorem ipsum dolor sit amet.
  \end{frame}
\end{document}
\documentclass{beamer}
\usetheme{metropolis}
\begin{document}
  \begin{frame}
    \Large\bfseries Lorem ipsum dolor sit amet.
  \end{frame}
\end{document}
\documentclass{beamer}
\usetheme{metropolis}
\begin{document}
  \begin{frame}
    \Large Lorem ipsum dolor sit amet.
  \end{frame}
\end{document}
twsh commented 8 years ago

Those are all fine. I made a markdown file like this:

# Section one

## Lorem

Lorem ipsum dolor sit amet.

I did pandoc --to beamer --variable=theme:metropolis --standalone -o foo.tex foo.md && latexmk -xelatex foo and got the error. The .tex file produced by Pandoc is here: https://gist.github.com/twsh/509bdbea254a12fa1c219a759d98eafa

I will try to find out exactly what in there causes the error when I have some time.

rchurchley commented 8 years ago

Thanks for the info! It looks like the problem line added by Pandoc is

\usepackage{lmodern}

which is not necessary when using a custom font. Removing this line gets rid of the warning.

matze commented 8 years ago

Well, I guess this should then reported upstream over at the Pandoc repository. It's obviously not possible to not load any font-related package.

twsh commented 8 years ago

@rchurchley Thanks! Yes, that's it.

@matze I have opened an issue: https://github.com/jgm/pandoc-templates/issues/190

aehm03 commented 8 years ago

I experienced the same error when using \usepackage[T1]{fontenc} I just deleted it from the preamble because I had just copied it from another .tex document where it was important to ensure proper line breaks with german umlaute(?). This won't be a big deal in a presentation I guess.

jajupmochi commented 2 months ago

I experienced the same error when using \usepackage[T1]{fontenc} I just deleted it from the preamble because I had just copied it from another .tex document where it was important to ensure proper line breaks with german umlaute(?). This won't be a big deal in a presentation I guess.

It works for me as well, but why? Moreover, the font is changed after removing the command. Is there a way to solve this?