I use bookdown to generate documents in both html and PDF. How could I use results from inline R code in theorem and example environments?
Here is what I tried:
---
title: "Test"
output:
bookdown::pdf_book:
toc: false
html_document:
toc: false
---
```{r}
a <- 2
b <- 3
```
If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$.
```{theorem}
If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$.
```
```{example}
If $a = `r a`$ and $b = `r b`$, then $a + b = `r a + b`$.
```
r paste0("'''{example}\n")
r paste0("If $a = ", a, "$ and $b = ", b, ", then $a + b = ", a + b, "$.\n")
r paste0("'''")
I can't find how to make it work with the ```. – Sig