-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theorem environments no longer work in LaTeX/PDF output with Pandoc >= 2.7.3 #883
Comments
For anyone reading this issue and has the same problem, please: remotes::install_github('yihui/knitr') |
Sorry to trouble you - I tried your fix and it did not work for me (just to confirm and make sure I did not screw up anything, my |
Thanks for the report @tchevri. I can reproduce. As it bugged me, I spend all my spare time from the last two days trying to understand what is wrong with the fix. After some times, I started again from the beginning not considering the current fix and I think I found the issue.
@yihui I did a few checks, and I think this comes from our recent See this reprex: the environment is created from a Div, only if I activate our filter. test_in <- tempfile()
test_out <- tempfile(fileext = ".tex")
xfun::write_utf8(
'<div class="definition">something</div>',
test_in
)
# using last pandoc
rmarkdown::pandoc_version()
#> [1] '2.9.2.1'
# by default, pandoc does not create an environment from a Div
rmarkdown::pandoc_convert(test_in, to = 'latex', from = "html",
output = test_out, verbose = TRUE)
#> "C:/Users/chris/scoop/shims/pandoc" +RTS -K512m -RTS "C:\Users\chris\AppData\Local\Temp\RtmpG6BPN2\file5e8052eb5c38" --to latex --from html --output "C:\Users\chris\AppData\Local\Temp\RtmpG6BPN2\file5e8089c27a9.tex"
xfun::read_utf8(test_out)
#> [1] "something"
# with our filter, an environment is created from a div
rmarkdown::pandoc_convert(test_in, to = 'latex', from = "html",
output = test_out, verbose = TRUE,
options = rmarkdown:::pandoc_lua_filters("latex-div.lua"))
#> "C:/Users/chris/scoop/shims/pandoc" +RTS -K512m -RTS "C:\Users\chris\AppData\Local\Temp\RtmpG6BPN2\file5e8052eb5c38" --to latex --from html --output "C:\Users\chris\AppData\Local\Temp\RtmpG6BPN2\file5e8089c27a9.tex" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua"
xfun::read_utf8(test_out)
#> [1] "\\begin{definition}" "" "something"
#> [4] "" "\\end{definition}"
unlink(c(test_in, test_out)) Created on 2020-06-21 by the reprex package (v0.3.0.9001) Reprex using pandoc 2.6test_in <- tempfile()
test_out <- tempfile(fileext = ".tex")
xfun::write_utf8(
'<div class="definition">something</div>',
test_in
)
# using last pandoc
rmarkdown::find_pandoc(version = "2.6")
#> $version
#> [1] '2.6'
#>
#> $dir
#> [1] "C:/Users/chris/scoop/shims"
rmarkdown::pandoc_version()
#> [1] '2.6'
# by default, pandoc does not create an environment from a Div
rmarkdown::pandoc_convert(test_in, to = 'latex', from = "html",
output = test_out, verbose = TRUE)
#> "C:/Users/chris/scoop/shims/pandoc" +RTS -K512m -RTS "C:\Users\chris\AppData\Local\Temp\RtmpwzE4uh\file3abc7b856d08" --to latex --from html --output "C:\Users\chris\AppData\Local\Temp\RtmpwzE4uh\file3abc420185c.tex"
xfun::read_utf8(test_out)
#> [1] "something"
# with our filter, an environment is created from a div
rmarkdown::pandoc_convert(test_in, to = 'latex', from = "html",
output = test_out, verbose = TRUE,
options = rmarkdown:::pandoc_lua_filters("latex-div.lua"))
#> "C:/Users/chris/scoop/shims/pandoc" +RTS -K512m -RTS "C:\Users\chris\AppData\Local\Temp\RtmpwzE4uh\file3abc7b856d08" --to latex --from html --output "C:\Users\chris\AppData\Local\Temp\RtmpwzE4uh\file3abc420185c.tex" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua"
xfun::read_utf8(test_out)
#> [1] "\\begin{definition}" "" "something"
#> [4] "" "\\end{definition}"
unlink(c(test_in, test_out)) Created on 2020-06-21 by the reprex package (v0.3.0.9001) Reading the filter, I can confirm that the filter add a latex environment for each div with a class. I think the fix should be either
What do you think ? |
…e Pandoc version, just don't write the <div> when the output format is LaTeX, because rmarkdown will apply its Pandoc filter to convert any div to a LaTeX environment
@cderv I'm still hesitating on if the remotes::install_github('yihui/knitr') Thanks! |
Aaron A King (1): add engine for c++ to be compiled by 'R CMD SHLIB' (#1832) Carson Sievert (2): Support for ragg::agg_png device (#1834) Pass options to showtext() (#1847) Christophe Dervieux (1): fix #1845: correctly pass the dev.args option to the ragg_png device (#1846) Ellis Hughes (1): fix #1838: format() columns individually for non-matrix objects in kable() (#1827) Randy Lai (1): sql engine: check if there is more than one element in the first column (#1837) Salim B (1): improve documentation (#1835) Yihui Xie (44): start the next version forgot to update news in 4a50ee68 the argument `error` of `include_graphics()` takes value from the global R option `knitr.graphics.error` by default fix the issue reported by @XiangyunHuang at https://d.cosx.org/d/421249 allow users to customize the `sep` argument of the cat engine only use the echo option to control whether a chunk is included in the output via the `asis` engine for the dot and asy engines, first create the output file under the current working directory, then move it to the actual figure path roxygenize and bump version don't update texlive when there are multiple plots in a chunk, create labels by separateing labels and numbers with dashes roxygenize (after #1835) and bump version suggest ragg (amend #1834) support the chunk option dev.close = FALSE, and plan to drop the package option global.device = TRUE in future always restore par() if the package option global.par = TRUE indicate if a device is open by the package option dev.open set the package option dev.open outside chunk_device(), and after chunk_device() has been called successfully use a single argument `options` in chunk_device() since all other arguments are already in it don't deprecate the package option global.device, because it is actually quite complicated to implement a global device with a chunk option... the dev.close option won't work for child documents (e.g. this example failed: https://travis-ci.org/github/yihui/knitr/jobs/677962281) put the on.exit() call after when a new device has been opened (no need to store the device number in opts_knit) on exit, store par() in global.pars before the device is closed in a later on.exit() call pass the dpi option to showtext::showtext_opts(): yixuan/showtext#33 (comment) not sure if it matters, but set the dpi before showtext_begin() fix rstudio/bookdown#883: for LaTeX output in bookdown, do not write <div class="environment"> for Pandoc >= 2.7.3, because such a div would be converted to a LaTeX environment travis-ci.org -> .com add a markdown_mode argument to parse_block(), so parse_block() does not have to rely on opts_knit$get('out.format'), and users can specify if the document is in the markdown mode do not cache texlive not sure why LaTeX fails; try my own version of TeX Live instead include the content of the code chunk in the error message, to make it easier to find the chunk label that was duplicated in the document add a new function kables() to create a table containing multiple tables that are individually created from kable() c() all ... arguments in create_label(), instead of assuming that each of ... is of length 1 or 0 amend ea7f3070ef42989d0ccc945eadfdd3c2454d0740: use dashes before fig numbers in the labels consistently in other output formats besides HTML move the R implementation of base64 encoding to the xfun package, and use xfun::base64_uri() instead of the unexported markdown:::.b64EncodeFile() a news item for 76fef5b9c535afa244989732b53cc8dfb7ffb471 the first step for #1864: warn if markdown is not a dependency of the package containing vignettes based on the knitr::knitr engine amend 6907b428572c130982f6b3d6c91a164a15b94a30 to fix rstudio/bookdown#883 (comment): regardless of the Pandoc version, just don't write the <div> when the output format is LaTeX, because rmarkdown will apply its Pandoc filter to convert any div to a LaTeX environment close #1862: add an empty line after each bib entry in write_bib() factor out the code to get the env var _R_CHECK_PACKAGE_NAME_, and add a function to check if the package being checked is lower or equal to a version make sure the current knitr submission is safe on CRAN; will remove the hacks once arsenal and skimr are updated on CRAN check against oldrel, release, and devel versions of R on Travis do not use matrix and jobs together, but only use jobs change \link[pkg]{function} to pkg::\link{function} because R-devel now warns against the former usage: rename the job for help links to packages that are not hard dependencies, both the package name and the topic name have to be specified in \link[pkg:topic]{function} CRAN release v1.29 atusy (1): fix #1788 and also fix #1817: change the default table format from Pandoc's simple tables to pipe tables for R Markdown documents (#1830)
I am still searching if there is a way to apply lua filer only on fenced div, and not explicit |
I just reverted rstudio/rmarkdown@14127ac with rstudio/rmarkdown@b2cff70. I'll update the R Markdown Cookbook soon.
I feel this may not be possible. Pandoc's parser treats them as identical:
|
Shouldn't we also revert the change in knitr that closed this issue ? <div class="environment"> won't be converted to latex environment anymore. |
Pandoc can treat them differently if one disables the |
@cderv It doesn't matter. I mean yihui/knitr@6907b42 doesn't hurt, although it is no longer necessary. @RLesur Thanks for the tip! |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Because Pandoc converts
<div class='foo'></div>
to\begin{foo}\end{foo}
now.I'm a little surprised that no one has reported it so far. Perhaps this feature is rarely used by anyone... Anyway, this is a nasty bug and needs to be fixed soon.
https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#theorems
The text was updated successfully, but these errors were encountered: