R 包:无法使用 mathjaxr 呈现 pdf 手册

R package: Can't render pdf manual using mathjaxr

我正在尝试使用 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)}

但是当我尝试渲染 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_manualR 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我有:

渲染 PDF 时,您在 LaTeX 控制序列中受到限制。好像\operatorname没有被识别。您可能想要将其替换为 html 和 PDF 都接受的,或者使用 \mjteqn\mjtdeqn 宏,您可以在其中为 PDF 指定不同的方程式,html 和 ASCII。