【发布时间】:2020-12-25 11:47:04
【问题描述】:
我正在尝试使用mathjaxr 在 R 包的文档中包含一些 LaTeX 方程。我用的是\mjdeqn{latex}{ascii}和mjeqn{latex}{ascii},例如:
\mjdeqn{\operatorname{P} \left( \operatorname{H_0} | x \right) = \left( 1 + \frac{1 - \pi_0}{\pi_0} \, \frac {1}{\operatorname{B}_{01} \left( x \right) } \right) ^{-1}}{P(H_0 | x) = (1 + ((1 - pi_0) / pi_0) * (1 / B_01(x)))^(-1)}
- html 文档完美呈现(带有
?foo以及包的pkgdown网站)。 -
mathjaxr::preview_rd("foo", type = "html")也可以渲染。 - ascii 版本在 shell 上呈现没有问题。
但是当我尝试渲染 pdf 手册时出现错误:
mathjaxr::preview_rd("bfactor_to_prob", type = "pdf")
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
unable to run pdflatex on 'Rd2.tex'
LaTeX errors:
! Undefined control sequence.
<argument> \operatorname
{P} \left ( \operatorname {H_0} | x \right ) = \lef...
l.36 ...}_{01} \left( x \right) } \right) ^{-1}}{}
! Undefined control sequence.
<argument> ...ratorname {P} \left ( \operatorname
{H_0} | x \right ) = \left...
l.36 ...}_{01} \left( x \right) } \right) ^{-1}}{}
! Undefined control sequence.
<argument> \operatorname
{B}_{01} \left ( x \right )
l.36 ...}_{01} \left( x \right) } \right) ^{-1}}{}
! Undefined control sequence.
<argument> \operatorname
{B}_{01} \left ( x \right )
l.38 ...\operatorname{B}_{01} \left( x \right) }{}
is a Bayes factor if favo...
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
unable to run pdflatex on 'Rd2.tex'
LaTeX errors:
! Undefined control sequence.
<argument> \operatorname
{P} \left ( \operatorname {H_0} | x \right ) = \lef...
l.36 ...}_{01} \left( x \right) } \right) ^{-1}}{}
! Undefined control sequence.
<argument> ...ratorname {P} \left ( \operatorname
{H_0} | x \right ) = \left...
l.36 ...}_{01} \left( x \right) } \right) ^{-1}}{}
! Undefined control sequence.
<argument> \operatorname
{B}_{01} \left ( x \right )
l.36 ...}_{01} \left( x \right) } \right) ^{-1}}{}
! Undefined control sequence.
<argument> \operatorname
{B}_{01} \left ( x \right )
l.38 ...\operatorname{B}_{01} \left( x \right) }{}
is a Bayes factor if favo...
Error in running tools::texi2pdf()
The file /var/folders/np/vk9nrhgx06zbfp3tqkrsn7km0000gn/T/RtmpKg4l2G/bfactor_to_prob.pdf does not exist.
devtools::build_manual 和 R CMD build 也会给出同样的错误。 R CMD check 成功,R CMD check --as-cran gives 这个注释:
Package has help file(s) containing install/render-stage \Sexpr{} expressions but no prebuilt PDF manual.
如mathjaxr documentation 中所列,我有:
- 在说明文件的
imports字段中包含mathjaxr - 在说明文件的 RdMacros 字段中包含
mathjaxr - 使用
mathjaxr在每个函数的@description部分中包含\loadmathjax - 将
@import mathjaxr添加到命名空间
【问题讨论】: