Skip to content

Commit

Permalink
fix rstudio/bookdown#883: for LaTeX output in bookdown, do not write …
Browse files Browse the repository at this point in the history
…<div class="environment"> for Pandoc >= 2.7.3, because such a div would be converted to a LaTeX environment
  • Loading branch information
yihui committed May 6, 2020
1 parent de81643 commit 6907b42
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.28.6
Version: 1.28.7
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
person("Adam", "Vogt", role = "ctb"),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

- The chunk option `dpi` is correctly passed to `showtext::showtext_opts()` now (thanks, @cpsievert, yixuan/showtext#33).

- Theorem environments in **bookdown** fail to work with Pandoc >= 2.7.3 because of an issue in the `block2` engine of **knitr** (rstudio/bookdown#883).

## MAJOR CHANGES

- When a code chunk generates multiple plots to be placed in figure environments, their figure labels will be of the form `label-i` where `label` is the chunk label, and `i` is the plot number. Previously, the labels were of the form `labeli` (i.e., there was not a dash before the number). If you cross-reference the figures, you need to change the reference keys from `labeli` to `label-i`.
Expand Down
10 changes: 8 additions & 2 deletions R/engine.R
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,16 @@ eng_block2 = function(options) {
h4 = options$html.after %n% ''
h5 = options$html.before2 %n% ''
h6 = options$html.after2 %n% ''
if (is_latex_output() && rmarkdown::pandoc_available('2.7.3')) {
h7 = h8 = '\n'
} else {
h7 = sprintf('<%s class="%s">', h2, type)
h8 = sprintf('</%s>', h2)
}

sprintf(
'\\BeginKnitrBlock{%s}%s%s<%s class="%s">%s%s%s</%s>%s\\EndKnitrBlock{%s}',
type, l1, h3, h2, type, h5, code, h6, h2, h4, type
'\\BeginKnitrBlock{%s}%s%s%s%s%s%s%s%s\\EndKnitrBlock{%s}',
type, l1, h3, h7, h5, code, h6, h8, h4, type
)
}

Expand Down

0 comments on commit 6907b42

Please sign in to comment.