From 6bd79d62a6a6519dd63f6f6a1ff1c10211f52a53 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 05:50:32 +0000 Subject: [PATCH 1/2] Initial plan From 358bc6f0f4eab8cbf9e424d5693f893df9d83ff0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 22 Jan 2026 08:20:28 +0000 Subject: [PATCH 2/2] Add demo of LaTeX math notation in roxygen2 with $$ syntax Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com> --- R/example_function.R | 26 ++++++++++++++++++++++++-- man/example_function.Rd | 30 ++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/R/example_function.R b/R/example_function.R index 962aade8..e147b336 100644 --- a/R/example_function.R +++ b/R/example_function.R @@ -1,6 +1,28 @@ -#' Example Function +#' Example Function with Mathematical Notation #' -#' This is an example function that demonstrates basic functionality. +#' This is an example function that demonstrates basic functionality and +#' various ways to include mathematical notation in roxygen2 documentation. +#' +#' # Mathematical Notation in roxygen2 +#' +#' ## Using `\eqn{}` for inline math (works in all formats) +#' +#' The median is a measure of central tendency where \eqn{x_{0.5}} represents +#' the value that splits the data in half. +#' +#' ## Using `\deqn{}` for display equations (works in all formats) +#' +#' The sample median for odd \eqn{n} is defined as: +#' \deqn{m = x_{(n+1)/2}} +#' +#' ## Using `$$` for display math (HTML/pkgdown only, requires roxygen2 >= 7.0.0) +#' +#' For even sample sizes, the median is the average of the two middle values: +#' $$m = \frac{x_{(n/2)} + x_{(n/2+1)}}{2}$$ +#' +#' ## Using `$` for inline math (HTML/pkgdown only, requires roxygen2 >= 7.0.0) +#' +#' In general, the median minimizes $\sum_{i=1}^{n} |x_i - m|$. #' #' @param x A numeric vector #' diff --git a/man/example_function.Rd b/man/example_function.Rd index 497dea06..74cb7b4b 100644 --- a/man/example_function.Rd +++ b/man/example_function.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/example_function.R \name{example_function} \alias{example_function} -\title{Example Function} +\title{Example Function with Mathematical Notation} \usage{ example_function(x) } @@ -13,8 +13,34 @@ example_function(x) The median of the input vector } \description{ -This is an example function that demonstrates basic functionality. +This is an example function that demonstrates basic functionality and +various ways to include mathematical notation in roxygen2 documentation. } +\section{Mathematical Notation in roxygen2}{ +\subsection{Using \verb{\eqn{}} for inline math (works in all formats)}{ + +The median is a measure of central tendency where \eqn{x_{0.5}} represents +the value that splits the data in half. +} + +\subsection{Using \verb{\deqn{}} for display equations (works in all formats)}{ + +The sample median for odd \eqn{n} is defined as: +\deqn{m = x_{(n+1)/2}} +} + +\subsection{Using \verb{$$} for display math (HTML/pkgdown only, requires roxygen2 >= 7.0.0)}{ + +For even sample sizes, the median is the average of the two middle values: +$$m = \frac{x_{(n/2)} + x_{(n/2+1)}}{2}$$ +} + +\subsection{Using \code{$} for inline math (HTML/pkgdown only, requires roxygen2 >= 7.0.0)}{ + +In general, the median minimizes $\sum_{i=1}^{n} |x_i - m|$. +} +} + \examples{ example_function(c(1, 2, 3, 4, 5)) }