5
votes

Hey I'm trying to use some latex in an R markdown file but I'm getting this error:

Try other LaTeX engines instead (e.g., xelatex) if you are using pdflatex. For R Markdown users, see https://bookdown.org/yihui/rmarkdown/pdf-document.html

Error: Failed to compile M5_collab.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See M5_collab.log for more info. In addition: There were 33 warnings (use warnings() to see them) Execution halted

I've checked out the bookdown website and I've installed tinytex

install.packages("tinytex")

Can someone let me know what's going wrong? How can I solve this?

Thank you

1
If you're using RStudio, when you go to Tools > Global Options > Sweave, there's a preference for what typesetting system to use. What does it say, and what options do you see? - Gregor Thomas
@Gregor hey thanks for the reply, it was on pdflatex at first and then I tested xelatex and that didn't work too. - JKong
Is your issue specific to the document you are working on, or is it general? For example, if you open a new Rmd document with the default template and compile to PDF, does it work? - Gregor Thomas
yes I've used Rmarkdown before and I'm able to make PDF's. I think the issue is something to do with Latex and pdf on my computer?? I just knitted the document and it worked for HTML. - JKong
Installing the tinytex package does not guarantee a working TeX installation. You either have to install TeXLive/MikTeX/MacTeX separately or TinyTeX using ` tinytex::install_tinytex()`. - Ralf Stubner

1 Answers

6
votes

I had the same problem as you.

In my case I wanted to generate a pdf file and received this message you received.

I solved the problem of defining latex_engine as follows:

---
title: "Report"
output:
  pdf_document:
    latex_engine: xelatex
---