Reputation: 139
I am trying to write a markdown document where I have a chunk of R code within a theorem or example extension.
I assumed I could simply write the theorem extension, starting and ending with ``` and within define an R code chunk starting with ```{r} and ending with ```. As follows:
```{theorem, name="Test"}
Some initial text.
```{r}
a <- 1 + 1
print(a)
And some more text.
However, it seems markdown gets confused, as does stackoverflow, by closing the theorem chunk using the end of the R code block instead of nesting the blocks. Any ideas on how to solve this?
Upvotes: 1
Views: 58
Reputation: 48
You can't nest chunks like that in r-markdown. You'll need to close your first chunk then open a new one for the R chunk.
Upvotes: 1