2

What is the idiomatic way to include dynamically numbered equations in the vignette for an R package? I see that there are options with pandoc-crossref and bookdown. I created my vignette using usethis::use_vignette() and trying to find a combination of yaml header and equation-writing that works. Is there a way to add dynamically updated numbers to equations written like $$y = mx+b$$ ?

I'd love an answer that includes the YAML header and an example equation. So far I have

---
title: "using_mypackage"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{using_mypackage}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
something about my first equation

$$y = mx+b \tag{1}$$

I also see that this option works great when the output is set to pdf_document instead of html_vignette; if there's a way to make that work across output types that would be perfect.

Thanks!

Michael Roswell
  • 1,300
  • 12
  • 31
  • Maybe package [mathjaxr](https://cran.r-project.org/package=mathjaxr) can be of help, it allows for [MathJax](https://www.mathjax.org/) in R documentation. – Rui Barradas Feb 03 '21 at 15:23
  • @RuiBarradas, I'd love to avoid additional dependencies in this package, do I need mathjax? It seems like the .rmd parsing of latex equations is adequate for a vignette for the most part, especially if I can solve this piece. Thanks! – Michael Roswell Feb 03 '21 at 15:26
  • See also https://github.com/r-lib/pkgdown/issues/323 – Michael Roswell Jun 16 '21 at 12:31

0 Answers0