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
Extra dependencies aren't always added #721
Comments
Here is a session rendering the above notebook twice, it fails on the second attempt. Running Full console output of `rmarkdown::render("notebook.Rmd")` 3 times> rmarkdown::render("notebook.Rmd")
processing file: notebook.Rmd
|.............. | 20%
ordinary text without R code
|............................ | 40%
label: setup
|.......................................... | 60%
ordinary text without R code
|........................................................ | 80%
label: unnamed-chunk-1
|......................................................................| 100%
ordinary text without R code
output file: notebook.knit.md
/usr/bin/pandoc +RTS -K512m -RTS notebook.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output notebook.tex --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.2/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.2/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in' --include-in-header /tmp/Rtmp1Khcp1/rmarkdown-str126b56c64270c.html
Output created: notebook.pdf
> rmarkdown::render("notebook.Rmd")
processing file: notebook.Rmd
|.............. | 20%
ordinary text without R code
|............................ | 40%
label: setup
|.......................................... | 60%
ordinary text without R code
|........................................................ | 80%
label: unnamed-chunk-1
|......................................................................| 100%
ordinary text without R code
output file: notebook.knit.md
/usr/bin/pandoc +RTS -K512m -RTS notebook.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output notebook.tex --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.2/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.2/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in'
! Undefined control sequence.
<argument> r|>{\raggedleft \arraybackslash
}p{10em}|r|r|l
l.128 ...\raggedleft\arraybackslash}p{10em}|r|r|l}
Error: LaTeX failed to compile notebook.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See notebook.log for more info.
> unloadNamespace("kableExtra")
> rmarkdown::render("notebook.Rmd")
processing file: notebook.Rmd
|.............. | 20%
ordinary text without R code
|............................ | 40%
label: setup
|.......................................... | 60%
ordinary text without R code
|........................................................ | 80%
label: unnamed-chunk-1
|......................................................................| 100%
ordinary text without R code
output file: notebook.knit.md
/usr/bin/pandoc +RTS -K512m -RTS notebook.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output notebook.tex --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.2/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.2/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable 'geometry:margin=1in' --include-in-header /tmp/Rtmp1Khcp1/rmarkdown-str126b54aee94e7.html
Output created: notebook.pdf
Note:
|
Adding |
The fix works for me, but I guess there is a better way to solve this in kableExtra without having to add |
I took a look, and couldn't spot a simple one. |
Some That's a lot of changes to make, but they're all small changes. I might try it and put in a PR. |
…packages()` so users can do it themselves. Fixes #721.
This SO post describes the issue and a workaround. The problem is that the
usepackage_latex()
calls inzzz.R
:kableExtra/R/zzz.R
Lines 5 to 18 in 292f607
kableExtra
is already loaded whenrmarkdown::render()
is called.This would be the typical state if you are calling
rmarkdown::render()
explicitly, rather than having RStudio set up a separate session to call it via theKnit
button.To Reproduce
Try to run this document
test.Rmd
:using
rmarkdown::render("test.Rmd")
in an R session. It might succeed the first time, but the second and following calls will fail with a LaTeX error, because the LaTeXarray
package is not used:A fix for this would be to run the
usepackage_latex()
calls every time akableExtra
function is called; a more efficient fix would be to set a flag when they are run, and check that flag every time. The flag needs to be cleared at the start of aknitr
run.The text was updated successfully, but these errors were encountered: