0

I'm trying to use Verdana as the math font in beamer slides written in Markdown and rendered with pandoc using XeLaTeX as the PDF engine. As specifying Verdana with pandoc's mathfont option directly doesn't seem to have any effect, I tried resorting to the mathastext LaTeX package. While the latter takes care of the letters, digits are not rendered with Verdana. According to this post, mathastext needs to be loaded before fontspec to properly render the digits with the desired font; however, I'm not sure how to do that with pandoc. The following example raises an Option clash for package fontspec error, which suggests that fontspec is being loaded before the lines in the header-includes option:

---
mainfont: Verdana
header-includes: |
    \usepackage{mathastext}
    \usepackage[no-math]{fontspec}
---

## Test

This is an equation: $E = m c^2$

Any thoughts as to how to address the above scenario to properly render everything in Verdana?

1
  • 1
    If you want to load mathastext you need to edit the tempate. You can get the default from pandoc with pandoc -D latex > mytemplate.latex, edit that file and and call pandoc with the option --template=mytemplate.latex
    – DG'
    Apr 16, 2021 at 7:18

2 Answers 2

1

Without a MWE, I’m not sure exactly what you’re looking for, but here is an example of a beamer slide with the math font set to Verdana. You want unicode-math for this.

\documentclass[professionalfonts]{beamer}
\usepackage{mathtools}
\usepackage{unicode-math}

\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{Verdana}[Scale=1.0]
\setmathrm{Verdana}[Ligatures={Common,TeX}] % Needed to fix the font scaling.
\setsansfont{Verdana}
\setmathfont{Fira Math} % The most-consonant math font as of 2021
\setmathfont{Verdana}[range=up]
\setmathfont{Verdana Bold}[range=bfup]
\setmathfont{Verdana Italic}[range=it]
\setmathfont{Verdana Bold Italic}[range=bfit]

\newcommand\upi{\symup{i}}
\newcommand\upe{\symup{e}}

\begin{document}
\begin{frame}
\frametitle{The Euler Identities}
\begin{align*}
  \upe^{\upi x} &= \cos{x} + \upi \sin{x} \\
  \upe^{\upi \uppi} + 1 &= 0
\end{align*}
\end{frame}
\end{document}

Verdana sample

1
  • Thanks - this is what I was trying to do, albeit within Markdown via pandoc.
    – lebedov
    Apr 16, 2021 at 14:15
1

Here is how to use Davislor's solution with pandoc (verified with pandoc 2.13 and TeXLive 2021 on MacOS 10.15.7). One evidently needs to take advantage of pandoc's raw_attribute extension to prevent parts of the LaTeX from being incorrectly parsed:

---
header-includes: |
    ```{=latex}
    \usepackage{mathtools}
    \usepackage{unicode-math}
    \defaultfontfeatures{Scale=MatchLowercase}
    \setmainfont{Verdana}[Scale=1.0]
    \setmathrm{Verdana}[Ligatures={Common,TeX}]
    \setsansfont{Verdana}
    \setmathfont{Fira Math}
    \setmathfont{Verdana}[range=up]
    \setmathfont{Verdana Bold}[range=bfup]
    \setmathfont{Verdana Italic}[range=it]
    \setmathfont{Verdana Bold Italic}[range=bfit]
    ```
classoption: professionalfonts
---

## Test

This is an equation: $E = m c^2$

You must log in to answer this question.

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