-
html_document()
andhtml_document_base()
gains themath_method
argument to support all the math rendering engines from Pandoc: "mathjax", "katex", "mathml", "webtex", and "gladtex". For backward compatibility, themathjax
argument still works and will take precedence overmath_method
, but we recommend using the newmath_method
argument instead of themathjax
argument, and the latter could be deprecated in the future.You can specify a math engine via
math_method
as an engine name, e.g.,output: html_document: math_method: katex
or provide both a name and a URL (for
mathjax
,katex
andwebtex
):output: html_document: math_method: engine: mathjax url: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js
For
math_method = "katex"
, KaTeX CDN will be inserted in version 0.15.2 by default (from jsdelivr). A custom URL toward another CDN can be passed asurl
.For
math_method = "webtex"
, it will default to inset SVG usinghttps://latex.codecogs.com/svg.image?
. Usehttps://latex.codecogs.com/png.image?
for PNG. See https://latex.codecogs.com for supported options (dpi, background, ...).Most HTML output format using
html_document()
orhtml_document_base()
as based format should benefit from this new feature.
See?rmarkdown::html_document()
for details (thanks, @atusy, #1940). -
github_document()
also gains themath_method
argument set to"webtex"
by default so that LaTeX equations can be rendered in the Github Markdown document as images. Previously, LaTeX equations were not rendered. Setmath_method = NULL
to deactivate. -
Added support for katex R package as a math engine with
math_method = "r-katex"
in HTML documents. This method offers server-side rendering of all the equations, which means no JS processing is needed in the browser as with usual KaTeX or MathJaX methods. (thanks, @jeroen, #2304). -
anchor_sections
can now be easily customized usingstyle
ordepth
element foranchor_sections
. For example:output: html_document: anchor_sections: style: symbol # use symbol style ("hash", "symbol", "icon") depth: 2 # max depth to apply anchor on (default to max which is 6)
Customizing using a CSS rule is still possible. Detailed explanation and examples have been added to the help page
?html_document
. -
Improved the highlighting mechanism in formats that supports
highlight
argument:- It is now possible to pass a custom theme file
.theme
inhighlight
argument for customizing the syntax highlighting style used by Pandoc. - In addition to Pandoc's own supported themes, two more themes are bundled in the package:
highlight: arrow
a theme optimized for accessibility and color constrast (thanks to @apreshill), andhighlight: rstudio
to mimic the RStudio editor theme. - For HTML output only, added optional downlit support in
html_document()
for R syntax highlighting and autolinking. Usehighlight_downlit = TRUE
to activate it (same argument as in distill). This features require the downlit package.
- It is now possible to pass a custom theme file
-
Templates for
html_document()
andioslides_presentation()
gained a new CSS rule to display single line<summary>
content inline (rstudio/rstudio#10589). -
md_document()
gained a newstandalone
argument, which isFALSE
by default unlesstoc = TRUE
. This allows to output authors, date and other metadata per the Pandoc's template. Due to limitation in how Pandoc is handling metadata blocks in its extensionsyaml_metadata_block
,preserve_yaml = TRUE
now deactivate any extension to let rmarkdown directly handle the keeping of YAML block - this means it does not setstandalone = TRUE
by default. Meanwhile,github_document()
gained thepreserve_yaml
argument (thanks, @florisvdh, #2297). -
Added
available_templates()
to list all the templates from a specific package that can be used withrmarkdown::draft()
. -
Following support in Pandoc 2.15,
powerpoint_presentation()
gained aincremental
argument as other slide formats. As a reminder, settingincremental = TRUE
will make lists to display incrementally. See more in Pandoc's MANUAL. -
Added support for Pandoc's
dir
variable in HTML templates. This is the second Language Variables afterlang
. -
Added a global option
rmarkdown.html_dependency.header_attr
(TRUE
by default). It can be set toFALSE
to opt-out the HTML dependencyhtml_dependency_header_attrs()
in documents based onhtml_document_base()
(thanks, @salim-b rstudio/bookdown#865, @maelle r-lib/downlit#1538). -
Rendering using
runtime: shiny_prerendered
orruntime: shinyrmd
now natively supports custom templates. Previously since 2.8, developers had to add a special comment,<!-- HEAD_CONTENT -->
, conditionally toshiny-prerendered
variable. (See also NEWS from 2.8 for the previous behavior). The new behavior inserts required special comment<!-- HEAD_CONTENT -->
as a last element of$header-includes$
. If templates rely on the old behavior and require some contents between$header-includes$
and<!-- HEAD_CONTENT -->
, consider including them with$header-includes$
(thanks, @atusy, @gadenbuie #2249). -
A shiny prerendered document with only a empty server context does not error anymore. Document will be rendered with a empty server function and
server.R
file will be ignored. To useserver.R
, no server context should be present in the Rmd document (thanks, @jcheng5, #2305). -
Fixed a regression with rendering
shiny_prerendered
document (thanks, @aronatkins, @gadenbuie, #2218). -
Fixed an issue in
beamer_presentation()
whereheader-includes
would be overwritten byincludes = list(in_header =)
(thanks, @samcarter, #2294). Same fix as forpdf_document()
(#1359). -
Fixed broken links to section headers when
number_sections = TRUE
is specified inmd_document
andgithub_document
(thanks, @atusy, #2093). -
draft()
now works withdevtools::load_all()
and testthat when used in other packages. -
Lua Filters: Added two more functions in
shared.lua
for other package to use:- Added
type()
function backward compatible following Pandoc 2.17 changes. - Added
print_debug()
for easier logging during debug.
- Added