knitr 1.34
NEW FEATURES
-
Added a package option
latex.tilde
so that users can customize the tilde symbol, e.g., you can setknitr::opts_knit$set(latex.tilde = "\\hlopt{\\scriptsize{\\ensuremath{\\sim}}}")
. This is because the default tilde is too high in the PDF output, and it's often more desirable to use a middle tilde instead (thanks, @brry #1992, @jaredlander #492). -
For the
tikz
engine, the class options of thestandalone
document classs can be specified via the chunk optionengine.opts$classoption
(thanks, @XiangyunHuang, #1985). The default value istikz
, i.e.,\documentclass[tikz]{standalone}
is used by default. -
Added the ability to pass additional arguments to
dvisvgm
when using thetikz
engine withfig.ext = "svg"
by usingdvisvgm.opts
inengine.opts
(thanks, @andrewheiss, #2039). Recent versions ofdvisvgm
now allow you to embed fonts into SVG files as base64-encoded WOFF files, sotikz
chunks can embed fonts using like so:```{tikz, fig.ext="svg", engine.opts=list(dvisvgm.opts = "--font-format=woff")}
. -
Added a new
targets
engine (ropensci/targets#503, @wlandau). Details: https://books.ropensci.org/targets/markdown.html. -
The chunk option
cache.globals
can take valuesTRUE
andFALSE
now (in addition to a character vector). WhenFALSE
, it tries to find all symbols in the code chunk, no matter if they are local or global variables. WhenNULL
orTRUE
, it tries to find all global variables (thanks, @knokknok, #1898).
MAJOR CHANGES
-
An error is now thrown when an inline code result is not coercible to character. This has always been the assumed behavior but it happens to be different in certain formats with unknown automatic coercion. This is now enforced to prevent any unexpected output. An inline code expression must evaluate to a character vector or an object coercible by
as.character()
(#2006). -
The markdown package has been moved from
Imports
toSuggests
in knitr'sDESCRIPTION
, which means it is no longer a hard dependency but has become a soft dependency of knitr (#1864). One consequence for package developers is that if you use the vignette engines based on markdown (such asknitr::knitr
), you will have to explicitly declare the (soft) dependency on markdown, because the implicit dependency through knitr is no longer there. -
For R packages that use the
knitr::rmarkdown
engine to build their vignettes,rmarkdown
must be declared as a dependency in the packageDESCRIPTION
(e.g., inSuggests
). Previously, knitr would fall back to using the markdown package to build vignettes if rmarkdown is not declared (#1864, #2020). -
write_bib()
only uses the first URL if multiple are found in a package (#2028).
MINOR CHANGES
-
The attribute
data-external="1"
will be added to<iframe>
s generated byinclude_url()
to prevent Pandoc from embedding the URL as base64 data (thanks, @IndrajeetPatil, https://stackoverflow.com/q/67477667/559676). -
The chunk option
strip.white = TRUE
used to work only when the chunk optioncollapse = FALSE
. Now the two options are independent, i.e.,strip.white
also works whencollapse = TRUE
(thanks, @kbvernon, #2011). -
When building R Markdown vignettes but Pandoc is not available, the vignette engine will emit a message instead of a warning before falling back to using the markdown package.
-
The internal function
is_abs_path()
has been removed. Users (if any) should use the exported functionxfun::is_abs_path()
instead.
BUG FIXES
-
Fix an issue with the RStudio IDE when using
knitr::include_url()
orknitr::include_app()
in interactive Notebook mode. This will no more cause an error but print the list object as is (thanks, @systemnova, #2015). -
Fix a regression with
fig.keep
chunk option used in chunks with only one figure where the figure was not showing in output (thanks, @fmichonneau, #1993). -
Allow vignettes to be tangled (and output compared) in
R CMD check
if they have a corresponding.Rout.save
(thanks, @lentinj, #2018).