In an rmarkdown document, I include the reticulate package
```{r , include=FALSE}
library(reticulate)
```
Including a python chunk generates an equation display in the knitted output both for html and pdf.
```{python, results='asis'}
from sympy import *
x = symbols('beta_1')
a = Integral(cos(x)*exp(x), x)
print('$$' + latex(a) + '$$')
```
The displayed output in the rmarkdown, if I execute the current chunk (Ctrl-Shift-Enter) it displays the Latex code in the notebook rather than rendering the equation, however:
Python 3.6.11 (/Users/......)
Reticulate 1.18 REPL -- A Python interpreter in R.
$$\int e^{\beta_{1}} \cos{\left(\beta_{1} \right)}\, d\beta_{1}$$
Since I can't use Rstudio to work interactively with Sympy, I currently use Jupyter and convert to rmarkdown with:
rmarkdown:::convert_ipynb(input = "~/Sympy test.ipynb", output = "sympy_test.Rmd")