Equations in r package documentation do not work

冷暖自知 提交于 2019-12-12 01:09:40

问题


I'm using roxygen2 for my package description and I want to have mathematic equations in my documentation. For example I want to write n_{u} like a formula. When I write \eqn{n_{u}} in @details nothing happens but the text is italic. I document the package with control, shift and d and then i push "Clean and rebuild". Did I forget anything?


回答1:


This is expected behaviour. The R documentation format doesn't have "real" equations like you might get from Mathjax or another fully-fledged Latex engine; it uses a basic representation that just copies your equation text but sets it in italics. Think of it as more akin to code, rather than mathematical notation.




回答2:


\eqn{n_u} is for the PDF documentation.

Write that instead:

\ifelse{html}{\out{n<sub>u</sub>}{\eqn{n_u}}

The syntax is:

\ifelse{html}{\out{HTML CODE}}{\eqn{LATEX-LIKE CODE}{ASCII}}

with {ASCII} optional is for the text documentation. HTML CODE is for the HTML documentation, and LATEX-LIKE CODE is for the PDF documentation.



来源:https://stackoverflow.com/questions/54998615/equations-in-r-package-documentation-do-not-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!