rstudio - 针织/ Markdown : how to render math equations in vignettes built by CRAN?

标签 rstudio knitr r-markdown pandoc mathjax

在一个包中,我有几个使用数学符号的小插图,例如:

This vignette illustrates the ideas behind solving systems of linear equations of the form $\mathbf{A x = b}$
where 

- $\mathbf{A}$ is an $m \times n$ matrix of coefficients for $m$ equations in $n$ unknowns
- $\mathbf{x}$ is an $n \times 1$ vector unknowns, $x_1, x_2, \dots x_n$
- $\mathbf{b}$ is an $m \times 1$ vector of constants, the "right-hand sides" of the equations

当我使用 R Studio (Ctrl+Shift+K) 编译小插图时,无论是在 R Studio 查看器还是浏览器中查看,它都会在 HTML 文件中正确呈现。

enter image description here

然而,当包被提交给 CRAN 并构建小插图时 那里从源包中,数学未正确呈现,但显示为标记,

enter image description here

是否需要在 YAML header 中添加一些内容,以便在 R Studio 之外构建的小插图能够正确呈现数学?目前,我只使用标准标题:
---
title: "Solving Linear Equations"
author: "Me"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Solving Linear Equations}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

生成的 pandoc来自 R Studio 的命令是
"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS linear-equations.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc8141d044063.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\R\R-3.2.5\library\rmarkdown\rmd\h\default.html" --css "C:\R\R-3.2.5\library\rmarkdown\rmarkdown\templates\html_vignette\resources\vignette.css" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments 

也许我需要添加一个对应于 --self-contained 的 YAML 选项或 --standalone ?

最佳答案

多年后发布,以防其他用户有同样的问题。我注意到在我的小插图中渲染方程的问题相同——不是在 CRAN 上,只是在本地托管的包中。 Ctrl + Shift + K 呈现良好,但查看 vignette() RStudio 帮助面板中的公式渲染效果不佳。

我认为这只是帮助面板没有完全呈现 HTML 的问题。如果我在浏览器中查看打包的小插图,例如使用 RShowDoc() ,那么方程没问题。所以也许用户应该被定向到 RShowDoc()vignette() 更频繁.

关于rstudio - 针织/ Markdown : how to render math equations in vignettes built by CRAN?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39837816/

相关文章:

r - 在 Windows 7 上找不到对象 pdflatex

r - 无法通过CRAN安装opencpu

r - 为什么我的图表没有显示在 RStudio 的 "Plots" Pane 中?

删除/隐藏针织 Markdown->pandoc 图下方的图形标题

r - 新的R-Studio版本0.98.932删除.md文件-如何防止?

r - 在 HTML kable 表中打印换行符

r - RStudio 中的 "large vectors"是什么?

RStudio 错误 : "In .HTMLsearch(query) : Unrecognized search field:"

r - 如何避免硬编码文件路径?

pdf - RMarkdown 中的 Stargazer 输出 - 我的非法字符是什么?