!LaTex Error in R

Hi, I have this LaTex Error. Tried installed tinytex. I also included latex_engine: xelatex at the top, at the output session. Still failed. Is it because of the β I used in R?

You might need packages for your Latex environment.
Take the latex file that markdown creates and run it by yourself on Latex, there you will be able to see what packages are missing and install them.

Sorry I don't understand. Can you explaining them step by step?

When you make a R markdown file (rmd) with latex output you can choose in options to save the Latex file (tex) it creates. This is the file R-studio is running in your Latex engine.
In case of an error, you can open your Latex software (Lyx, TexStudio, etc...) and run the file by yourself in it. When you do that, it will tell what Latex Packages are missing on your computer, after you install them R-studio will be able to render your PDF output.

Sorry, I do not know how to find the Latex software or run the file. however, I change β to beta. And I solved the first error. Now when try to knit to pdf, I have another error. How should I fix this?

Sorry, I do not know how to find the Latex software or run the file.

You probably will need to install a LaTeX program. @ JonesYaniv suggests a couple. LyX is a rather fancy IDE for LaTeX while TexStudio in a good standard LaTex front-end. Personally, I am fond of TexMaker.

In any case @ JonesYaniv is saying that if you install one of these programs and run the bit of LaTeX code, you should get , if you are missing the needed LaTeX package, a specific message telling you which package you are missing or at least some hint that we can interpret.

Very simple math expression in LaTeX.


Some text. 

I'd suggest going with TexStudio or TexMaker. LyX is great but probably overkill here.

I have not used RMarkdown in a while but in Quarto I have explicit LaTeX calls in YAMAL and you may need the same. Example: the \usepackage{xxx} is an explicit call to load a LaTeX package. It is the LaTeX equivelent of a library(xxx) call.

title: "Authoring"
author: "Anon."
date: 2022-12-25
date-format: iso
number-sections: true
format: pdf
  - \usepackage{lipsum}
  - \usepackage{mhchem}
  - \usepackage{siunitx}
editor: visual

Stupid question but you do define the output in YAMAL as pdf?

This is probably a bit of heresy here but I am not a fan of tinytex. If you have the disc space I'd recommend deleting it and installing a full version of TexLive or MikTex.

Well, your screen shot clearly shows that you are running pandoc with “pdfengine=pdflatex” and not xelatex. Thus, however you specified that xelatex should be used was wrong and my guess is that if you specified it correctly the problem would be solved. :slight_smile:
Can you show us your YAML header in which you specific that xelatex should be used?

Instead of having the following:

β0 is the Intercept
β1 is the coefficient for "treat"...

try the following:

$\beta0$ is the Intercept
$\beta1$ is the coefficient for "treat"...

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.