@Bastián Olea Herrera Hi! Sorry for hijacking this question, but I was having this same problem and your answer worked for me! However, it's failing to actually print the plots. I'm using ggsurvminer and trying to print the plots from a list, like this:
```{r config, include=FALSE}
newslide <- function(content) {
code <- deparse(substitute(content))
cat(sep = "\n",
knitr::knit_child(
quiet = TRUE,
text = c("```{r dpi=600, warning=FALSE, message=FALSE, echo=FALSE, results='asis', escape = TRUE}", #the r
code,
"```")
)
)
}
```
```{r latex, echo=FALSE, results = 'asis', escape = "TRUE"}
for (cat in category){
plot1 <- plot_list[[cat]]$plot
newslide(
content = {
cat("\\begin{multicols}{2}\n")
cat("\\noindent\n")
print(table1_latex)
cat("\\columnbreak\n")
cat("\\begin{center}\n")
print(plot1)
cat("\n")
cat("\\end{center}\n")
cat("\\end{multicols}\n")
}
)
}
```
I'm getting this error message:
! Missing $ inserted.
<inserted text>
$
l.561 <!-- -->
Do you know what could be causing this? Thanks!