I am trying to include a code-chunk as part of a list in R markdown, and while it is recognized correctly on knit, RStudio no longer recognizes it as a code chunk. Take the following example:
1. List item 1
a. Sub-list item A
sub-paragraph 1
sub-paragraph 2
```{r}
prop <- function (x) {
(x + 1)*(8 - x)
}
```
$\therefore f(X) = \frac{(x + 1)(8 - x)}{120}$
On knit, the code chunk is recognized, run, properly indented, and further paragraphs in the list are also recognized:
However, in RStudio, the code chunk is no longer recognized:
Unindenting the chunk to either 2 tabs or 0 tabs lets the chunk be recognized, but also breaks the list:
code not indented, further paragraphs not recognized as part of the list

Is there a way to include a r chunk in a list such that it's recognized by RStudio, but also as a block in the list?

