Knitr / markdown: how to display math equations in vignettes created by CRAN?

In the package, I have several vignettes that use mathematical notation, for example:

This vignette illustrates the ideas behind solving systems of linear equations of the form $\mathbf{A x = b}$
where 

- $\mathbf{A}$ is an $m \times n$ matrix of coefficients for $m$ equations in $n$ unknowns
- $\mathbf{x}$ is an $n \times 1$ vector unknowns, $x_1, x_2, \dots x_n$
- $\mathbf{b}$ is an $m \times 1$ vector of constants, the "right-hand sides" of the equations

When I compile a vignette using R Studio ( Ctrl+ Shift+ K), it displays correctly in the HTML file, regardless of whether it is viewed in the R Studio viewer or in the browser.

enter image description here

However, when the package is passed to CRAN, and the vignettes are created there from the original package, the math does not display correctly, but displays as markup,

enter image description here

What do I need to add to my YAML header so that vignettes created outside of R Studio display math correctly? Currently, I use only the standard header:

---
title: "Solving Linear Equations"
author: "Me"
date: "'r Sys.Date()'"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Solving Linear Equations}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

pandoc R Studio -

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS linear-equations.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output pandoc8141d044063.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template "C:\R\R-3.2.5\library\rmarkdown\rmd\h\default.html" --css "C:\R\R-3.2.5\library\rmarkdown\rmarkdown\templates\html_vignette\resources\vignette.css" --mathjax --variable "mathjax-url:https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --highlight-style pygments 

, YAML, --self-contained --standalone?

+5
1

, . - CRAN, . Ctrl + Shift + K , vignette() RStudio .

, , HTML . , , RShowDoc(), . , , RShowDoc() , vignette().

0

Source: https://habr.com/ru/post/1656612/


All Articles