Exponents not displaying properly in R documentation files

I am trying to create documentation for my R function and having trouble with mathematical formatting. I want to show an exponent like 3^{y} using the \eqn{3^{y}} command in my documentation file. However, when I build my package and check the help file, the exponent appears as regular text instead of being superscripted.

I checked the R extensions manual which mentions that dpois.Rd shows proper mathematical notation examples. But when I actually look at the Poisson distribution help page using ?dpois, I don’t see any superscripted text there either.

Is this normal behavior or am I missing something in my setup? I expected the mathematical expressions to render with proper formatting.

# My session details
sessionInfo()
# R version 2.11.1 (2010-05-31)
# Platform: i386-apple-darwin9.8.0
# Locale: en_US.UTF-8

This happens because R’s math rendering works differently depending on where you’re viewing it. Your \eqn{3^{y}} syntax is right, but what you see changes based on the viewer. Console help can’t handle LaTeX markup - it’s plain text only. When you build PDF docs or use HTML help, the math notation displays properly. Also, if you’re making PDFs, make sure LaTeX tools are installed since R needs external processors for math rendering. That dpois example probably does the same thing - looks good in HTML/PDF but shows as plain text in console.

This isn’t a bug - it’s just how R works. The console help system can’t render LaTeX markup, so your \eqn{3^{y}} syntax looks broken there even though it’s correct.

I hit the same wall documenting my package’s statistical functions. It really depends on who’s using your docs. If they’re viewing help in RStudio or browsers, the HTML system renders math beautifully. But console users get raw LaTeX code.

What worked for me: use both \eqn{} for proper rendering AND plain text in parentheses for console folks. So you’d have something like the LaTeX followed by “(3 to the power of y)” or whatever makes sense.

Your math formatting will look perfect in PDFs and HTML docs anyway, which is where most people expect to see properly formatted equations.

Had this exact problem with our data pipeline docs. R’s console viewer is just terrible for this stuff, but I found a way around it.

I ditched the whole R help system headache and automated everything instead. Built a workflow that pulls function definitions, grabs the roxygen comments, converts math to MathJax, and pushes clean HTML docs to our internal wiki automatically. Every time the code changes, docs update too.

No more guessing if your exponents will show up right or dealing with different viewers breaking your formatting. Just consistent, properly rendered docs through a web interface that actually works.

I also automated package building and testing to catch doc issues before users see them. Way better than fighting with the console help system.

Automation tools are perfect for this kind of workflow - makes everything bulletproof and saves tons of manual formatting time.

This happens because R 2.11.1 is too old. Your version came out before they fixed a bunch of LaTeX rendering issues in later releases. The \eqn{3^{y}} syntax looks right, but older R builds often can’t handle math rendering properly - even in HTML mode. I’ve hit this same problem working with legacy packages on old R versions. The math markup builds fine but breaks when rendering across different formats. Upgrading R usually fixes it since newer versions work better with LaTeX processors. Also check if you’ve got LaTeX installed on your system - R needs external tools for math typesetting in docs.

yeah, this is totally normal. r’s console help viewer can’t handle math formatting - it’s just plain text. your \eqn{} syntax is right, but you won’t see it render unless you view the docs in html or pdf. open rstudio’s help pane or use the html help system to see your exponents display properly.

This happens because of how R displays help text. When you use ?dpois in the console, you’re getting plain text that can’t show math formatting. Try help(dpois, help_type="html") instead. This opens the help page in your browser where the LaTeX math notation renders properly with superscripts and formatting. You can also run help.start() to launch R’s HTML help system in your browser. Your \eqn{3^{y}} syntax is right - you just need the HTML viewer to see it formatted. Console help has always been stuck with plain text.