[英]Is it possible to create a code block of pseudocode in R Markdown/knitr?
我尝试过使用反引号和波浪号,但它们需要语言。 我只想要一个带有突出显示背景的纯文本代码块。
使用eval=FALSE
和tidy=FALSE
直到达到关键字(如if
,后续代码将在.Rmd
文件和输出PDF中以颜色突出显示。 不通过选项指定语言会删除背景突出显示输出中的代码的功能。
```{r, eval=FALSE,tidy=FALSE}
loop through each species
loop through each measurement of the current species
if measurement ...
etc.
```
这里有一些示例代码可以很好地呈现给HTML。 它还可以正确呈现Word和PDF。
---
title: "Untitled"
output: html_document
---
Here is some plain text.
Next, let's write some pseudo code. Note that you don't _have_ to specify a language if using plain backticks.
```
object <- [some kind of calculation]
```
If you set `eval = FALSE` you can get the highlighted background
```{r, eval = FALSE}
object <- [some kind of calculation]
Note that this; is not valid R code
```
You may find it interesting that your example works just fine for me.
```{r, eval=FALSE}
loop through each species
loop through each measurement of the current species
...
etc.
```
使用tidy = FALSE
```{r, tidy=FALSE, eval=FALSE, highlight=FALSE }
pseudocode
```
编辑:添加突出显示,以防您统一颜色
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.