I just found that you can add tikz code to a piece of Rmarkdown code when changing the engine option:
--- output: html_document --- Some picture ```{r,engine='tikz'} \begin{tikzpicture} \draw (0,0) circle (2cm); \end{tikzpicture} ```
The problem is that the picture is pixelated and the scale is not respected. One way to solve this problem is to change the extension of the output of the picture (in pdf format), as well as the width and height with the parameters of the fragment (for example, equal to 3 inches):
```{r,engine='tikz',fig.ext='pdf',fig.width=3} \begin{tikzpicture} \draw (0,0) circle (2cm); \end{tikzpicture} ```
I'm sure there are better solutions, but this is an easy way to use tikz code to output html.
source share