matze / mtheme

A modern LaTeX Beamer theme
6.43k stars 846 forks source link

In knitr, can't get metropolis theme to work with \mathbf and greek letters, or with \bm from the bm package #375

Open lfmcmillan opened 4 years ago

lfmcmillan commented 4 years ago

If I try to include \mathbf around greek letters, or try to use the \bm command instead which is actually the better way of producing bold greek letters, I get various errors when trying to compile

Minimal non-working example:


title: Greek symbols, mathbf and bm with Metropolis output: beamer_presentation: theme: "metropolis" latex_engine: xelatex header-includes:

Greek symbols

This $\mathbf{\theta}$ should be a greek symbol using

\mathbf{\theta}

This should be a greek symbol using

\bm{\theta}

Neither works.

lfmcmillan commented 4 years ago

To clarify, $\bm{x}$ also breaks, but $\mathbf{x}$ is ok, but neither works for greek letters

maxnoe commented 3 years ago

@lfmcmillan You should use the package unicode-math together with the mtheme and the font "Fira Math" is especially suited as companion to Fira Sans: https://github.com/firamath/firamath.

With unicode-math you then have to use \symbf{\theta}

Minimal example:

\documentclass[1610]{beamer}

\usefonttheme{professionalfonts}
\usetheme{metropolis}

\usepackage{fontspec}
\setsansfont[BoldFont={Fira Sans SemiBold}]{Fira Sans Book}

\usepackage{amsmath}
\usepackage{amssymb}

\usepackage[
  mathrm=sym,
  math-style=ISO,  % Greek letters also in italics
  bold-style=ISO,  % bold letters also in italics
]{unicode-math}

\setmathfont{Fira Math}
% top is still missing in Fira Math, get it from another font
\setmathfont[range={\top}]{XITS Math}

\begin{document}
  \begin{frame}[t]{Example}
    \begin{align}
      \symbf{\theta} &= (1, 2, 3)^\top \\
    \theta_0 &= 1
    \end{align}
  \end{frame}
\end{document}

There are several other math fonts and you should always set one. Go with "Latin Modern Math" for the "TeX" font.

With Fira Math (and \top from XITS Math):

test

With Latin Modern Math:

test