将bookdown移植到distill::distill_article不支持theorem环境。

huangapple go评论90阅读模式
英文:

Porting bookdown to distill::distill_article doesn't support theorem environment

问题

尝试在R distill::article中实现定理环境。按照Rmarkdown和Bookdown书籍以及R Markdown Cookbook中的说明进行操作。

我发现,定理环境在以下情况下可以正常处理:

  1. bookdown::html_document2:
  2. base_format: rmarkdown::html_document

  1. bookdown::html_document2:
  2. base_format: pagedown::html_paged

然而,对于distill_article,它不起作用。有人知道为什么不起作用吗?

以下是一个最小的可复现示例。

  1. ---
  2. title: "将bookdown功能移植到Rmarkdown"
  3. author: "Bookdown Rmarkdown"
  4. output:
  5. bookdown::html_document2:
  6. base_format: distill::distill_article
  7. ---
  8. # 定理
  9. ```{theorem, name="毕达哥拉斯定理"}
  10. 对于一个直角三角形,如果$c$表示斜边的长度,
  11. $a$和$b$表示另外两边的长度,我们有
  12. $$a^2 + b^2 = c^2$$。
  1. <details>
  2. <summary>英文:</summary>
  3. 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)
  4. I found that theorem environments were processed well for

bookdown::html_document2:
base_format: rmarkdown::html_document

  1. and

bookdown::html_document2:
base_format: pagedown::html_paged

  1. However, it doesn&#39;t work for `distill_article`. Anyone knows why it doesn&#39;t work?
  2. The following is a minimal reproducible example.
  3. ````rmarkdown
  4. ---
  5. title: &quot;Port the bookdown features to Rmarkdown&quot;
  6. author: &quot;Bookdown Rmarkdown&quot;
  7. output:
  8. bookdown::html_document2:
  9. base_format: distill::distill_article
  10. ---
  11. # Theorems
  12. ```{theorem, name=&quot;Pythagorean theorem&quot;}
  13. For a right triangle, if $c$ denotes the length of the hypotenuse
  14. and $a$ and $b$ denote the lengths of the other two sides, we have
  15. $$a^2 + b^2 = c^2.$$
  1. </details>
  2. # 答案1
  3. **得分**: 3
  4. 在检查`distll_article.R`中的代码后,我认为我找出了为什么定理没有显示的原因。默认情况下,在`distll_article`中,`knitr_options$opts_chunk$echo`被分配了值`FALSE`,我认为这会隐藏定理环境,因为它被定义为bookdown中的代码块。要切换该值,只需在YAML头之后添加以下代码块即可。
  5. ```{r setup, include=FALSE}
  6. knitr::opts_chunk$set(echo = TRUE)
  7. ```
  8. <details>
  9. <summary>英文:</summary>
  10. 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.
  1. knitr::opts_chunk$set(echo = TRUE)
  1. </details>

huangapple
  • 本文由 发表于 2020年1月6日 23:53:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/59615126.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定