[英]R Markdown document with html/docx output, using LaTeX package bbm?
[英]display math expression as non-italic using R Markdown and HTML output
通常用斜體顯示數學( 傳統可追溯到古希臘)。 但是對於非正式的演示,我不太喜歡它的外觀。 我正在嘗試使用我自己的字體進行數學顯示,或者至少擺脫斜體。 更改 pdf_document 的數學字體很簡單:在pdf_document:
中使用mathfont: my-math-font
和latex_engine: xelatex
,但對於 HTML output,事實證明它更復雜。
顯然,MathJax 用於通過 Pandoc 呈現方程。 我已經嘗試通過外部 CSS 文件添加 CSS 規則,或者直接在 YAML 下面按照這個 stackoverflow 問題中的建議添加規則。 顯然,Pandoc 將 class .math { }
應用於所有 MathJax 表達式......但是我對 CSS 了解不多,因此事實證明很難獲得 arguments 的正確性。 據我所知,我的額外 CSS 規則只是被忽略了,因為當我在 R Studio 中編織時,斜體仍然存在。
我希望有人有解決方案? 這是我正在使用的代碼的一個最小示例; 要重現它,只需復制粘貼到 a.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}}$
這是方法:
---
title: "Change MathJax font"
author: "Stéphane Laurent"
date: "05/11/2020"
output: html_document
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS" : {
availableFonts : ["STIX"],
preferredFont : "STIX",
webFont : "STIX-Web",
imageFont : null
}
});
</script>
$$
\int_0^1 f(x) dx = 0
$$
現在那行不通了。 要使用不同的 fonts,您必須下載它們並使用 MathJax 的本地副本。 我嘗試了所有可用的 fonts,但渲染效果並不適合所有人。
我認為更好的解決方案是使用標准字體並使用\mathrm
:
$$
\mathrm{\int_0^1 f(x) dx = 0}
$$
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.