r - xaringan:添加带有宏的自定义 Latex 文件

标签 r r-markdown mathjax xaringan

例如,是否可以导入 Latex 宏文件

\newcommand{\Xcal}{\mathcal{X}

这样我就可以在 $...$ 之间使用它如 $\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$

enter image description here

使用 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
---

关于r - xaringan:添加带有宏的自定义 Latex 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55277391/

相关文章:

rmarkdown 设置 kable 的位置

R Plot_ly 列出在 .Rmd R-Studio 运行模式下绘制多个图,但在针织时不绘制

javascript - Next.js 上的 MathJax

mathjax - 在语句的同一行显示 MathJax 表达式

R:包含列表的列表

r - 如何从 .Call 返回结构数组到 R 中的 C 共享库

r - 如何修改 R 中条形图的图例?

python - Snakemake - 在调用外部脚本之前加载集群模块

knitr - 用 ggvis 将 RMarkdown 编织到 Word

html - 是否可以像使用 jqMath 那样使用 MathJax 将 HTML 放入 TeX/MathML 中?