Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

Demonstrates the various ways to include mathematical notation in roxygen2 documentation, including both cross-format compatible syntax and HTML-only LaTeX notation.

Changes Made

  • Enhanced example_function.R: Added comprehensive examples showing different mathematical notation approaches in roxygen2 comments:
    • \eqn{} for inline math (works in all output formats: HTML, PDF, man pages)
    • \deqn{} for display equations (works in all output formats)
    • $$ for display math (HTML/pkgdown only, requires roxygen2 >= 7.0.0)
    • $ for inline math (HTML/pkgdown only, requires roxygen2 >= 7.0.0)
  • Updated documentation: Generated corresponding .Rd file showing how each notation is processed

Important Notes

The $$ and $ LaTeX notation work beautifully for HTML output (pkgdown sites) where they render with MathJax/KaTeX, but they generate R CMD check warnings for PDF/man page generation because raw LaTeX macros aren't recognized outside of \eqn{}/\deqn{} tags.

For maximum compatibility across all documentation formats, use \eqn{} and \deqn{}. Use $$ and $ notation when targeting primarily HTML documentation.

Testing

  • ✅ Documentation generated successfully with devtools::document()
  • ✅ Package check run to validate behavior and identify limitations
  • ⚠️ Expected warnings for $$ notation in R CMD check (HTML-only feature)
Original prompt

add a demo of some formatted math in an roxygen header, using latex


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@d-morrison
Copy link
Member

@copilot try again

@d-morrison
Copy link
Member

@copilot can we use the $$ LaTeX notation in roxygen2 comments?

@codecov-commenter
Copy link

codecov-commenter commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Files with missing lines Coverage Δ
R/example_function.R 100.00% <ø> (ø)

Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot can we use the $$ LaTeX notation in roxygen2 comments?

Yes, you can use $$ for display math and $ for inline math in roxygen2 comments (requires roxygen2 >= 7.0.0 with markdown enabled).

Important limitations:

  • $$ notation works great for HTML output (pkgdown sites, rendered with MathJax/KaTeX)
  • It causes R CMD check warnings for PDF/man pages because LaTeX macros aren't recognized in raw $$ blocks
  • For cross-format compatibility, use \eqn{} (inline) and \deqn{} (display) instead

I've added a demonstration in commit 358bc6f showing both approaches. The $$ syntax is preserved in the .Rd file and will render beautifully on your pkgdown site, but you'll see warnings during package checks.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cran.rstudio.com
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R --no-restore --no-echo --args nextArgrpt_0.0.0.9002.tar.gznextArg--as-crannextArg--timingsnextArg--no-manual (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Add demo of formatted math in Roxygen header with LaTeX Add demo of mathematical notation in roxygen2 comments Jan 22, 2026
@github-actions
Copy link
Contributor

📖 https://ucd-serg.github.io/rpt/preview/pr15
Preview documentation for this PR (at commit 21d2e95)

@github-actions
Copy link
Contributor

PR Preview Action v1.8.1-1-g6f3a89d

QR code for preview link

🚀 View preview at
https://UCD-SERG.github.io/rpt/pr-preview/pr-15/

Built to branch gh-pages at 2026-01-30 01:08 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants