math symbols in R markdown to beamer with xelatex and lualatex

The following minimal example works correctly within RStudio to generate a pdf beamer slide

---
output:
  beamer_presentation:
    latex_engine: "pdflatex"
---

##

\[
Z \not\!\perp\!\!\!\perp X
\]

Unfortunately it generates an error when using lualatex or xelatex engines (as for example below)

---
output:
  beamer_presentation:
    latex_engine: "lualatex"
---

##

\[
Z \not\!\perp\!\!\!\perp X
\]

The generated error is

! Missing { inserted.
<to be read again> 
\mskip 
l.100 \end{frame}

Any insights about what the problem might be and how to fix it?

It seems the issue comes from the \! after \not - I don't know why. If I remove it, it compiles ok. But not symbol is no more centered.

You would need to search in the LaTeX world why this cause an issue in beamer, and see if you can find another way to write the not independant symbol.

This is a LaTeX issue unfortunately - I don't think we can do much in R for that.

Thanks for looking into it, indeed centering is exactly what I was trying to achieve. I will follow your advice and see if I can find a solution through the LaTeX community.

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.