Skip to content
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

Rmarkdown fails to render in pdf_document with last latex version #1691

Closed
cderv opened this issue Nov 10, 2019 · 2 comments
Closed

Rmarkdown fails to render in pdf_document with last latex version #1691

cderv opened this issue Nov 10, 2019 · 2 comments
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Nov 10, 2019

I think this error is the cause of rstudio/tinytex#152

There were some bugs recently with graphicx and grffile in last latex version. This has been reported in pandoc and upstream. See jgm/pandoc#5848 (comment).

Changes has been made in pandoc templates now by removing package grffile.
jgm/pandoc@4d5fd9e

I wonder if we need to do the same with rmarkdown included template. 🤔
There was also other modification in pandoc template since pandoc 1.17 - it could be an opportunity to update it. What do you think ?

Here is a reproductible example (if you have the environment correctly set up :) )

dir.create(tmp_dir <- tempfile())
xfun::write_utf8(c(
  '---',
  'title: "Untitled"',
  'output: pdf_document',
  '---',
  '',
  '## R Markdown',
  '',
  '```{r pressure, echo=FALSE}',
  'plot(pressure)',
  '```'
), file.path(tmp_dir, "test.Rmd"))
# not working
rmarkdown::render(file.path(tmp_dir, "test.Rmd"),
                  output_options = list(latex_engine = "pdflatex"))
#> processing file: test.Rmd
#> output file: test.knit.md
#> "C:/PROGRA~3/CHOCOL~1/bin/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.tex --template "C:\Users\chris\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine pdflatex --variable graphics=yes --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in" --variable "compact-title:yes"
#> tlmgr search --file --global "/grffile.sty"
#> Warning in parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)): Failed
#> to find a package that contains grffile.sty
#> ! LaTeX Error: File `grffile.sty' not found.
#> 
#> ! Emergency stop.
#> <read *>
#> Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
# not working
rmarkdown::render(file.path(tmp_dir, "test.Rmd"), 
                  output_options = list(latex_engine = "lualatex"))
#> processing file: test.Rmd
#> output file: test.knit.md
#> "C:/PROGRA~3/CHOCOL~1/bin/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.tex --template "C:\Users\chris\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine lualatex --variable graphics=yes --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in" --variable "compact-title:yes"
#> tlmgr search --file --global "/grffile.sty"
#> Warning in parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)): Failed
#> to find a package that contains grffile.sty
#> ! LaTeX Error: File `grffile.sty' not found.
#> 
#> ! Emergency stop.
#> <read *>
#> Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
# not working either
rmarkdown::render(file.path(tmp_dir, "test.Rmd"), 
                  output_options = list(latex_engine = "xelatex"))
#> processing file: test.Rmd
#> output file: test.knit.md
#> "C:/PROGRA~3/CHOCOL~1/bin/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.tex --template "C:\Users\chris\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine xelatex --variable graphics=yes --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua" --variable "geometry:margin=1in" --variable "compact-title:yes"
#> tlmgr search --file --global "/grffile.sty"
#> Warning in parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)): Failed
#> to find a package that contains grffile.sty
#> ! LaTeX Error: File `grffile.sty' not found.
#> 
#> ! Emergency stop.
#> <read *>
#> Error: Failed to compile test.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See test.log for more info.
fs::file_delete(fs::dir_ls(tmp_dir, glob = "*.Rmd", invert = TRUE))

# modify template ---

# get template
file.copy(system.file("rmd/latex/default-1.17.0.2.tex", package = "rmarkdown"), to = tmp_dir)
#> [1] TRUE

xfun::gsub_file(file.path(tmp_dir, "default-1.17.0.2.tex"), 
                pattern = "\\usepackage\\{graphicx,grffile\\}",
                replacement = "\\usepackage{graphicx}")
# include new template
rmarkdown::render(file.path(tmp_dir, "test.Rmd"), output_options = list(template = "default-1.17.0.2.tex"))
#> processing file: test.Rmd
#> output file: test.knit.md
#> "C:/PROGRA~3/CHOCOL~1/bin/pandoc" +RTS -K512m -RTS test.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test.tex --template default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua"
#> 
#> Output created: test.pdf
list.files(tmp_dir)
#> [1] "default-1.17.0.2.tex" "test.pdf"             "test.Rmd"            
#> [4] "test.tex"
unlink(tmp_dir, recursive = TRUE)

xfun::session_info(c("rmarkdown", "tinytex"))
#> R version 3.6.1 (2019-07-05)
#> Platform: x86_64-w64-mingw32/x64 (64-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Locale:
#>   LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252   
#>   LC_MONETARY=French_France.1252 LC_NUMERIC=C                  
#>   LC_TIME=French_France.1252    
#> 
#> Package version:
#>   base64enc_0.1.3 digest_0.6.22   evaluate_0.14   glue_1.3.1     
#>   graphics_3.6.1  grDevices_3.6.1 highr_0.8       htmltools_0.4.0
#>   jsonlite_1.6    knitr_1.25      magrittr_1.5    markdown_1.1   
#>   methods_3.6.1   mime_0.7        Rcpp_1.0.2      rlang_0.4.1    
#>   rmarkdown_1.16  stats_3.6.1     stringi_1.4.3   stringr_1.4.0  
#>   tinytex_0.16    tools_3.6.1     utils_3.6.1     xfun_0.10      
#>   yaml_2.2.0     
#> 
#> Pandoc version: 2.7.3
tinytex::tlmgr("--version")
#> tlmgr --version
tlmgr revision 52585 (2019-10-31 19:26:15 +0100)
tlmgr using installation: C:/Users/chris/AppData/Roaming/TinyTeX
TeX Live (http://tug.org/texlive) version 2019

Created on 2019-11-10 by the reprex package (v0.3.0)

@yihui
Copy link
Member

yihui commented Nov 11, 2019

Should be fixed now. Thanks for the report!

yihui added a commit that referenced this issue Nov 25, 2019
…become a legacy package, and won't be available in future versions of TeX Live)"

This reverts commit 1f63943.

The fix is no loner necessary since the grffile package is back: rstudio/tinytex#152 (comment)
@github-actions
Copy link

github-actions bot commented Nov 3, 2020

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants