0

I'm having trouble displaying latex maths symbols inline in a notebook:

---
title: "R Notebook"
output:
  html_document:
    df_print: paged
---

```{r, echo=F, message=F, warning=F, results="asis"}
cat("Latex attempt 1: $x = 5$ \n\n") # Works
cat("Latex attempt 2: $x > 5$ \n\n") # Works
cat("Latex attempt 3: $x \\leq 5 $ \n\n") # \leq doesn't render and whole equation fails
cat("Latex attempt 4: $$x \\leq 5 $$ \n\n") # Works with equation on next line
```

html output: enter image description here

How can I display inline 'less than or equal to' sign in the second last entry?

Note that for the purposes of this question I would like to use results="asis" in the chunk.

conor
  • 1,204
  • 1
  • 18
  • 22
  • Why do you want to write this plain text into a R-chunck? You can write it just inline with `Latex attempt $x \leq 5 $ ` without a chunck. – J_F Oct 25 '17 at 10:56
  • This is just an example, but in my actual code the latex output is is part of a loop in `R` that must be executed with `results="asis"` for reasons described here https://stackoverflow.com/questions/36373630/how-to-create-a-loop-that-includes-both-a-code-chunk-and-text-with-knitr-in-r/36381976#36381976 – conor Oct 25 '17 at 21:38

0 Answers0