I am wondering if anyone has this experience or advise me any solutions. RStudio just failed to knit rmd file to PDF and it took me several hours to find out that the knitr::kable function is the reason that RStudio failed to knit to PDF. If I replace knitr::kable with print(), then RStudio can knit to PDF.
Here are error code:
! Use of \x doesn't match its definition.
\LT@array [#1]#2->\UseTaggingSocket
{tbl/init}\@kernel@refstepcounter {table...
l.6889 }{}
Error: LaTeX failed to compile
Here are rmarkdown code:
knitr::kable(cars)
Windows TinyTex
RStudio: 2023.12.0 Build 369
R version 4.3.3 (2024-02-29 ucrt)
The error code comes from "Render". It used to work, but suddenly it didn't work yesterday, and it still doesn't work today.
To produce a reproducible example, I manually created a new R Markdown file in RStudio, "New File" --> "R Markdown", and then replace summary(cars) with knitr::kable(cars).
Please let me know if you need any more information from my system.
Here are are error codes
processing file: test_kable.Rmd
"E:/Software/R/RStudio/resources/app/bin/quarto/bin/tools/pandoc" +RTS -K512m -RTS test_kable.knit.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output test_kable.tex --lua-filter "E:\Software\R\R-4.3.3\library\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "E:\Software\R\R-4.3.3\library\rmarkdown\rmarkdown\lua\latex-div.lua" --embed-resources --standalone --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in"
output file: test_kable.knit.md
! Use of \x doesn't match its definition.
\LT@array [#1]#2->\UseTaggingSocket
{tbl/init}\@kernel@refstepcounter {table...
l.6889 }{}
Error: LaTeX failed to compile test_kable.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test_kable.log for more info.
Execution halted
This may not be very helpful, but I just did what you said: used the R Markdown template and changed summary to knitr::kable and it worked fine. That suggests there might be something wrong with your installation rather than your code.