rmarkdown文档中乳胶内部的r块
我正在尝试在以下rmarkDown文档中在乳胶代码中进行R块运行:
---
title: "Untitled"
output: pdf_document
date: '2022-05-20'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, results = "hide")
```
\begin{enumerate}
\item
{
```{r}
x <- 2+3
x
```
}
\end{enumerate}
输出为:
但我想要:
编辑:我希望对R块进行评估(但结果隐藏)及其代码。同时,我找到了这个解决方案,但是也许有一个更简单的解决方案: https://tex.stackexchange.com/questions/questions/210003/how-can-can-i-nest-a-nest-a-code-code-code-chunk-within-an-enumerate-enumerate-environment - 使用R-MarkDow
I am trying to get an R chunk run inside LaTeX code in the following rmarkdown document:
---
title: "Untitled"
output: pdf_document
date: '2022-05-20'
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, results = "hide")
```
\begin{enumerate}
\item
{
```{r}
x <- 2+3
x
```
}
\end{enumerate}
The output is:
But I want:
Could you please help me?
EDIT: I want the R chunk to be both evaluated (but result hidden) and its code shown. I have meanwhile found this solution, but maybe there is a simpler one: https://tex.stackexchange.com/questions/210003/how-can-i-nest-a-code-chunk-within-an-enumerate-environment-when-using-r-markdow
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你需要这个吗?请参阅此处参见 https://bookdown.org/yihui/rmark-rmarkdown-cook/raw-cookbook/raw-cookbook/raw-cookbook/raw-cookbook-raw-cook-raw--raw--raw--raw--raw--raw-cook-raw--raw--cook- latex.html
You need this? See here https://bookdown.org/yihui/rmarkdown-cookbook/raw-latex.html
在以下任何示例中,您都可以替换双返回而不是
\\
。如果您想仅显示这些表达式,则不要将其放在代码块中:
这将产生:
< img src =“ https://i.sstatic.net/ajzst.png” alt =“在此处输入图像说明”>
否则,如果您想评估内联表达式,请使用backticks和
r :
生产:
最后,您当然可以结合这两个概念来显示表达式并通过此操作来评估该值:
如果您的表达式更复杂在您的乳胶外进行评估。
更新
为了简单的表达方式,您可以做类似的事情:
In any of the following examples, you can substitute a double return instead of
\\
.If you are wanting to just show those expressions then do not put it in a code chunk:
This will produce:
Otherwise, if you want to evaluate an inline expression use backticks and
r
:Which produces:
Lastly, you can of course combine these two concepts to show the expression and evaluate the value by doing this:
If your expression is more complex, I would recommend having the code chunk outside of your LaTeX for evaluation.
Update
For simpler expressions you could do something like:
同时,我发现了这一点:使用r markdown?,如何在枚举环境中嵌套代码块?,它启发了以下解决方案:
Meanwhile, I found this: How can I nest a code chunk within an enumerate environment when using R Markdown?, which inspires the following solution: