【发布时间】:2019-08-12 03:05:02
【问题描述】:
是否可以导入 Latex 宏文件,例如
\newcommand{\Xcal}{\mathcal{X}
这样我就可以在$...$ 和$\Xcal$ 之间使用它?
【问题讨论】:
标签: r r-markdown mathjax xaringan
是否可以导入 Latex 宏文件,例如
\newcommand{\Xcal}{\mathcal{X}
这样我就可以在$...$ 和$\Xcal$ 之间使用它?
【问题讨论】:
标签: r r-markdown mathjax xaringan
是的,这似乎有效:
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: {
Macros: {
Xcal: "{\\mathcal{X}}",
water: "{H_2O}"
}
}
});
</script>
$\water$
$\Xcal$
在脚本标签上使用type=text/x-mathjax-config 很重要,因此 mathjax 会找到该块。定义宏的详细信息
MathJax 可以在here找到。
另一种方法是使用 before_body YAML 选项包含定义:
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
includes:
before_body: local.html
---
【讨论】:
MathJax 允许您定义宏。在 Xaringan 中,您只需将宏放在双美元符号中即可。
---
title: "Presentation Ninja"
subtitle: "⚔<br/>with xaringan"
author: "Yihui Xie"
date: "2016/12/12 (updated: `r Sys.Date()`)"
output:
xaringan::moon_reader:
lib_dir: libs
nature:
highlightStyle: github
highlightLines: true
countIncrementalSlides: false
---
$$\newcommand{\Xcal}{\mathcal{X}}$$
# Math Macros
You can define your own macros by putting them in double dollars signs.
```
$$\newcommand{\Xcal}{\mathcal{X}}$$
```
This symbol $\Xcal$ is a calligraphic X.
【讨论】: