【发布时间】:2021-02-07 23:50:16
【问题描述】:
习惯上以斜体显示数学 (the tradition dates to Ancient Greece)。但是对于非正式的演示,我真的不喜欢它的外观。我正在尝试使用我自己的字体进行数学显示,或者至少摆脱斜体。在 YAML 中使用 mathfont: my-math-font 和 latex_engine: xelatex 更改 pdf_document: 的数学字体很简单,但对于 HTML 输出,它被证明更复杂。
显然,MathJax 用于通过 Pandoc 渲染方程。我已经尝试通过外部 CSS 文件添加 CSS 规则,或者直接在 YAML 下方添加 this stackoverflow question 中的建议。显然 Pandoc 将 .math { } 类应用于所有 MathJax 表达式......但是我不太了解 CSS,因此证明正确的参数很困难。据我所知,我的额外 CSS 规则只是被忽略了,因为当我在 R Studio 中编织时斜体仍然存在。
我希望有人有解决方案?这是我正在使用的代码的最小示例;要复制它,只需将其复制粘贴到 .Rmd 文件中并使用ctrl + shift + k 编织:
---
title: "How to change math font for HTML output?"
output:
html_document
---
```{css}
.math {
font-family: Sans-Serif;
font-style: normal;
}
```
This math equation is still rendered with italics: $\rho~=~\frac{m_{water}}{m_{oven-dry~soil}}$
【问题讨论】: