简体   繁体   中英

Equations in r package documentation do not work

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?

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.

\\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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM