Package {equatags}


Type: Package
Title: Equations to 'XML'
Version: 0.3.0
Description: Provides function to transform latex math expressions into format 'HTML' or 'Office Open XML Math'. The 'XML' result can then be included in 'HTML', 'Microsoft Word' documents or 'Microsoft PowerPoint' presentations by using a 'Markdown' document or the R package 'officer'.
License: MIT + file LICENSE
BugReports: https://github.com/ardata-fr/equatags/issues
Depends: R (≥ 4.0.0)
Imports: katex, xml2, xslt
Suggests: testthat (≥ 3.0.0)
Config/roxygen2/version: 8.1.1
Config/testthat/edition: 3
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2026-11-08 14:57:46 UTC; davidgohel
Author: David Gohel [aut, cre], ArData [cph]
Maintainer: David Gohel <david.gohel@ardata.fr>
Repository: CRAN
Date/Publication: 2026-11-08 15:30:02 UTC

'MathJax' equation as 'HTML' or 'MathML'.

Description

Get 'HTML' or 'MathML' XML codes corresponding to the rendering of 'MathJax' equations.

Usage

transform_mathjax(
  x,
  to = "html",
  display = FALSE,
  strict = "ignore",
  rpr = NULL
)

Arguments

x

MathJax equations

to

output format, one of 'html' or 'mml'

display

should the equation be in display (TRUE) or inline mode (FALSE, by default)

strict

KaTeX option.If "ignore" (default), allow features that make writing LaTeX convenient. Other options are "warn" or "error". This happens E;G;, when you use accented characters in your equations.

rpr

run properties to apply to the 'Office Open XML Math' equations, used only when to = "mml": a ⁠<w:rPr>⁠ element for 'Microsoft Word' or an ⁠<a:rPr>⁠ element for 'Microsoft PowerPoint', as a string; the namespace declaration can be omitted. It sets for example the size or the color of the equations, that otherwise get the default values of the document. One value for all equations or one value per equation, NA for none. With NULL (default), no run properties are written.

Value

a character vector that contains 'html' or 'mml' codes corresponding to the equations.

Examples

x <- c("(ax^2 + bx + c = 0)",
       "x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}.")
z <- transform_mathjax(x = x, to = "html")
cat(z, sep = "\n\n")
z <- transform_mathjax(x = x, to = "mml")
cat(z, sep = "\n\n")

# equations at 16 points in a Word document
z <- transform_mathjax(
  x = x, to = "mml",
  rpr = "<w:rPr><w:sz w:val=\"32\"/><w:szCs w:val=\"32\"/></w:rPr>"
)
cat(z, sep = "\n\n")