I'm trying to use mathjaxr
to include some LaTeX equations in the documentation of an R package. I'm using \mjdeqn{latex}{ascii}
and mjeqn{latex}{ascii}
, for example:
\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)}
?foo
and also in the pkgdown
website of the package).mathjaxr::preview_rd("foo", type = "html")
also renders ok.But when I try to render the pdf manuals I get errors:
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
and R CMD build
also give these same errors. R CMD check
succeeds and R CMD check --as-cran gives
this note:
Package has help file(s) containing install/render-stage \Sexpr{} expressions but no prebuilt PDF manual.
As listed in the mathjaxr
documentation I have:
mathjaxr
in the imports
field of the DESCRIPTION filemathjaxr
in the RdMacros field of the DESCRIPTION file\loadmathjax
in the @description
section of each function using mathjaxr
@import mathjaxr
to the NAMESPACEWhen rendering the PDF you are limited in the LaTeX control sequences. It seems that \operatorname
is not recognized. You may either want to replace it for one that is accepted by both html and PDF or to use the \mjteqn
and \mjtdeqn
macros where you can specify different equations for PDF, html and ASCII.