Bookdown(proof)定制环境:如何在定制(例如proof)环境中嵌套代码块或内联R,并获得正确的解析?
我想我的问题是一个潜在的,如果不是可能的重复。这个问题已经问了将近3年了,所以无论如何都欢迎更新,尤其是@YiHui的评论:“这在bookdown中是不可能的(至少现在是这样)” 背景:我正在尝试使用@YiHui bookdown包制作一本包含演讲幻灯片的书(请参阅)。这方面的一个关键特性是能够使用条件格式,例如Bookdown(proof)定制环境:如何在定制(例如proof)环境中嵌套代码块或内联R,并获得正确的解析?,r,r-markdown,knitr,pandoc,bookdown,R,R Markdown,Knitr,Pandoc,Bookdown,我想我的问题是一个潜在的,如果不是可能的重复。这个问题已经问了将近3年了,所以无论如何都欢迎更新,尤其是@YiHui的评论:“这在bookdown中是不可能的(至少现在是这样)” 背景:我正在尝试使用@YiHui bookdown包制作一本包含演讲幻灯片的书(请参阅)。这方面的一个关键特性是能够使用条件格式,例如eval=(out\u type==“beamer”)。因此,我面临的问题是能够在bookdown定制环境中添加代码块或内联R代码(请参阅和)。我希望能够正确编译以下内容。有解决办法吗?
eval=(out\u type==“beamer”)
。因此,我面临的问题是能够在bookdown定制环境中添加代码块或内联R代码(请参阅和)。我希望能够正确编译以下内容。有解决办法吗?钩子有用吗?有一种黑客可以迫使pandoc
在latex
环境中进行解析,但我认为它不适用于这里。lua过滤器
会工作吗(我不知道如何使用这个)
顺便说一句,我还惊讶地看到$\digamma$
正确地显示在html
输出中,而不是pdf
输出中,尽管它在tex
文件中被正确解析。amssymb
包被加载,并且它应该在那里定义-我缺少什么
非常感谢您在这方面的帮助。这里是一个MWE-我刚刚从默认的bookdown项目编辑了第4章。您只需将文件03 method.Rmd
的内容替换为以下内容:
# Methods
We describe our methods in this chapter.
So here is a theorem to prove 1+1 = `r 1+1`.
```{theorem, echo=TRUE}
we want to show that in R, 1+1 = 2.
We also wonder why `$\digamma$` ($\digamma$) not showing.
Shows in the html output only, not pdf.
But when I recompile the tex file produced by bookdown - shows up just fine!!
Indeed, is defined correctly from `\usepackage{amssymb}`.
```
```{proof, echo=TRUE}
- If I am not mistaken, I cannot get an Rmarkdown style list to work either in the proof environment.
- Well, this is where i would like to be able to use inline code.
- we use r to compute 1+1: `r 1+1`.
- Does not work.
- Just shows verbatim inline code.
```
使用当前的bookdown开发版本:
remotes::install_github('rstudio/bookdown')
你可以用Pandoc的fenced div写定理,例如
# Methods
We describe our methods in this chapter.
So here is a theorem to prove 1+1 = `r 1+1`.
::: {.theorem}
we want to show that in R, 1+1 = 2.
We also wonder why `$\digamma$` ($\digamma$) not showing.
Shows in the html output only, not pdf.
But when I recompile the tex file produced by bookdown - shows up just fine!!
Indeed, is defined correctly from `\usepackage{amssymb}`.
:::
::: {.proof}
- If I am not mistaken, I cannot get an Rmarkdown style list to work either in the proof environment.
- Well, this is where i would like to be able to use inline code.
- we use r to compute 1+1: `r 1+1`.
- Does not work.
- Just shows verbatim inline code.
:::
但是,请注意,beamer输出还不支持这种新语法。使用子文档是否有效?我还希望类似于
::{.proof}
等的东西可以起作用。::
可以起作用,但不能起作用-它无法提供证明环境,尽管它允许内联表达式,etc-下面的所有内容都能正确解析。是否可以使用此语法设置标签和名称<代码>{.Thermory,name=“重要定理”}似乎不起作用