Skip to content

How to use the same math font in HTML and PDF? #12257

Answered by benkeks
benkeks asked this question in Q&A
Discussion options

You must be logged in to vote

I've now found out through which hoops to jump in order to make the XeLaTeX/PDF-output look akin to LaTeX's original PDF style / MathJax:

This is generated from:

---
title: "Reproducible Quarto Document"
pdf-engine: xelatex
html-math-method: katex
format:
    pdf:
        mathfont: NewCMMath-Regular.otf
        include-in-header:
            text: |
                \DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n}
                \setmathfont{Linux Libertine O}[range={\varnothing}]
---

$$\mathcal P (\mathbb N) ≠ \varnothing$$

Tricks:

  • Use NewCMMath as math font. (This fixes most symbols that I cared about... The ℕ in the example.)
  • Use the original mathcal symbols from computer modern by \…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cderv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
themes Related to HTML theming or any other style related issue (like highlight-style) math any issue related to math support in specific formats
2 participants