I am using functions described here to render multiple independent R
scripts in a single markdown files. But I am not able to include a formatted equation in those scripts. My .Rmd
file looks like:
---
title: "My title"
author: "Nacho"
output:
bookdown::html_document2:
base_format: rmdformats::downcute
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
join <- function(ls, sep = ", "){
do.call(paste, append(ls, list(sep = sep)))
}
inline_render <- function(script_name){
suppressMessages(capture.output(rmarkdown::render(paste0(script_name, ".R"),
output_format = "rmarkdown::md_document"), file = "tmp"))
cat(join(readLines(paste0(script_name, ".md")), "\n"))
}
```
Here is some text defining the scope of the analysis...
```{r script, echo=FALSE, results='asis'}
inline_render("script")
```
And in my script
I have defined an equation:
#'
#' $$\frac{d_{A}}{dt} = K_{rel}\times A$$
#'
But when this .R
is rendered to .md
, I get this warning:
[WARNING] Could not convert TeX math \frac{A}{dt} = K_{rel}\times A, rendering as TeX
and this is what is what I find in the .md
$$\\frac{d\_{DXD}}{dt} = K\_{rel}\\times A\_{T-DXd}$$
So, when this is rendered to the final .html
I just the plain text ignoring all \*
.
I tried to edit the intermediate .md
file to remove one of the \
but the one remaining seems to be ignored by the cat()
call.
Could anyone help me with this?