Trying to implement theorem environment to R distill::article. Followed the instructions from the books on Rmarkdown and Bookdown, and the R Markdown Cookbook
I found that theorem environments were processed well for
bookdown::html_document2:
base_format: rmarkdown::html_document
and
bookdown::html_document2:
base_format: pagedown::html_paged
However, it doesn't work for distill_article. Anyone knows why it doesn't work?
The following is a minimal reproducible example.
---
title: "Port the bookdown features to Rmarkdown"
author: "Bookdown Rmarkdown"
output:
bookdown::html_document2:
base_format: distill::distill_article
---
# Theorems
```{theorem, name="Pythagorean theorem"}
For a right triangle, if $c$ denotes the length of the hypotenuse
and $a$ and $b$ denote the lengths of the other two sides, we have
$$a^2 + b^2 = c^2.$$
```
After checking the codes in distll_article.R, I think that I figured out why the theorem was not display. By default, in distll_article, knitr_options$opts_chunk$echo is assigned with the value FALSE, which I think hides the theorem environment as it was defined as a code chunk in bookdown. To switch the value, adding the following code chunk right after the yaml header will do the work.
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With