Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 22, 2026

This PR adds a comprehensive demonstration of LaTeX math formatting in roxygen2 documentation for R packages.

Changes Made

  • New Function: Created math_demo() function in R/math_demo.R that demonstrates various LaTeX math formatting techniques in roxygen2 documentation
  • Documentation Examples: The function showcases:
    • Display equations using \deqn{} (quadratic formula)
    • Inline math using \eqn{} (Greek letters, variables, expressions)
    • Mathematical notation including summation, integrals, matrix multiplication
    • Proper text fallbacks for non-LaTeX output formats
  • Implementation: The function implements a working quadratic equation solver that handles real and complex roots
  • Unit Tests: Added comprehensive tests in tests/testthat/test-math_demo.R covering all scenarios (two real roots, one repeated root, complex roots, error handling)
  • Documentation: Generated man/math_demo.Rd with properly formatted LaTeX math expressions
  • Spelling: Updated inst/WORDLIST to include "Roxygen" and "roxygen"

Testing

  • ✅ All 17 unit tests pass
  • ✅ Linting clean (no errors)
  • ✅ R CMD check passes with 0 errors, 0 warnings, 0 notes
  • ✅ Code review feedback addressed (floating-point comparison fix)
  • ✅ No security vulnerabilities detected

The implementation provides a practical example for developers who want to include mathematical notation in their R package documentation using LaTeX syntax, following the tidyverse style guide and using roxygen2 with Markdown syntax.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add demo of formatted math in Roxygen header with LaTeX</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

@d-morrison
Copy link
Member

@copilot try again

Copy link
Contributor Author

Copilot AI commented Jan 22, 2026

@copilot try again

Done! I've added a comprehensive demo function showing LaTeX math formatting in Roxygen documentation. The math_demo() function demonstrates:

  • Display equations with \deqn{} (quadratic formula)
  • Inline math with \eqn{} (Greek letters, variables)
  • Various mathematical notation (summation, integrals, matrices)
  • Proper text fallbacks for non-LaTeX output

All tests pass, linting is clean, and R CMD check succeeds. Commits: 2d35334, 8c2172a

Example output:

math_demo(1, -5, 6)  # Two real roots
[1] 3 2

math_demo(1, 2, 5)   # Complex roots
[1] -1+2i -1-2i

The documentation shows proper LaTeX rendering in help files with equations like the quadratic formula, discriminant notation, and Greek letters.

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:

  • cdnjs.cloudflare.com
    • Triggering command: /opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R -e pkgdown::build_reference_index() (dns block)
  • 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 formatted math in Roxygen header with LaTeX Jan 22, 2026
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.

Add demo of formatted math in Roxygen header with LaTeX

3 participants