Tom*_*ash 7 r knitr r-markdown
我尝试过使用反引号和波浪号,但它们需要语言.我只想要一个带有突出显示背景的纯文本代码块.
使用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.
```
Run Code Online (Sandbox Code Playgroud)
这里有一些示例代码可以很好地呈现给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.
```
Run Code Online (Sandbox Code Playgroud)