Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display ``` in knitr chunks?

I'm generating a knitr (focusing on .Rmd files) manual for a project and wanted to embed a code chunk that actually displays the " ``` " marks as well as the internal chunk syntax. E.g.

``` {r sample, eval= FALSE}

Code example

```

So basically the exact visual you see above. Any thoughts on how to do this?

like image 295
HJT Avatar asked Dec 05 '16 00:12

HJT


2 Answers

You can do this by using four spaces before your code as follows:

So this:

enter image description here

Becomes this:

enter image description here

There also is this SO-meta discussion on how to escape this backtick in Markdown

like image 191
Rentrop Avatar answered Nov 11 '22 15:11

Rentrop


If you mean how to display the three backticks, the answer is "indent by 4 spaces" (see Pandoc's four-space rule)". If you mean how to display a literal knitr code chunk, the answer has been given by knitr FAQ #8.

like image 3
Yihui Xie Avatar answered Nov 11 '22 14:11

Yihui Xie