英文:
Porting bookdown to distill::distill_article doesn't support theorem environment
问题
尝试在R distill::article中实现定理环境。按照Rmarkdown和Bookdown书籍以及R Markdown Cookbook中的说明进行操作。
我发现,定理环境在以下情况下可以正常处理:
bookdown::html_document2:
base_format: rmarkdown::html_document
和
bookdown::html_document2:
base_format: pagedown::html_paged
然而,对于distill_article
,它不起作用。有人知道为什么不起作用吗?
以下是一个最小的可复现示例。
---
title: "将bookdown功能移植到Rmarkdown"
author: "Bookdown Rmarkdown"
output:
bookdown::html_document2:
base_format: distill::distill_article
---
# 定理
```{theorem, name="毕达哥拉斯定理"}
对于一个直角三角形,如果$c$表示斜边的长度,
$a$和$b$表示另外两边的长度,我们有
$$a^2 + b^2 = c^2$$。
<details>
<summary>英文:</summary>
Trying to implement theorem environment to R distill::article. Followed the instructions from the books on Rmarkdown and Bookdown, and the [R Markdown Cookbook](https://bookdown.org/yihui/rmarkdown-cookbook/figure-number.html)
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.
````rmarkdown
---
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.$$
</details>
# 答案1
**得分**: 3
在检查`distll_article.R`中的代码后,我认为我找出了为什么定理没有显示的原因。默认情况下,在`distll_article`中,`knitr_options$opts_chunk$echo`被分配了值`FALSE`,我认为这会隐藏定理环境,因为它被定义为bookdown中的代码块。要切换该值,只需在YAML头之后添加以下代码块即可。
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
<details>
<summary>英文:</summary>
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.
knitr::opts_chunk$set(echo = TRUE)
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论