Is it possible to import a Latex macro file, for instance
\newcommand{\Xcal}{\mathcal{X}
so that I can then use it between $...$
as $\Xcal$
?
Is it possible to import a Latex macro file, for instance
\newcommand{\Xcal}{\mathcal{X}
so that I can then use it between $...$
as $\Xcal$
?
是的,这似乎有效:
---
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$
在 script 标签上使用很重要type=text/x-mathjax-config
,因此 mathjax 会找到该块。有关在 MathJax 中定义宏的详细信息,请参见此处。
另一种方法是使用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.