Home Comments Thread
New Thread

Generate A Verbatim Code Chunk or Inline R Expression in knitr Output | /en/2017/11/knitr-verbatim-code-chunk/

giscus giscus 2023-01-03 20:53:00

Generate A Verbatim Code Chunk or Inline R Expression in knitr Output

When you write a code chunk or inline expression in a knitr source document (e.g., R Markdown), and it is parsed and evaluated, you won’t be surprised. That is what knitr is supposed to do. Then …

https://yihui.org/en/2017/11/knitr-verbatim-code-chunk/

2 Comments

JMLuther JMLuther 2023-01-03 20:53:01

thanks, very helpful.
The Rmd text editor in RStudio does not handle this new ````{verbatim} option very well- it works (eg the html output is perfect), but the document formatting is messed up; the inline code highlighting (eg mine in dark mode uses white to indicate text, yellow for code) and the Rmd outline pane is messed up (would add a screenshot but cannot here).
(R 4.2.1, RStudio 2022.12.0 build 353, on windows 10; knitr 1.4.1)

yihui yihui 2023-01-04 19:14:28

I never use dark themes so I haven't noticed this before. Just tried a dark theme and you are right:

image

This is an RStudio IDE problem. You may file an issue there: https://github.com/rstudio/rstudio/issues

Alternatively, you can use the visual editor: https://rstudio.github.io/visual-markdown-editing/

JMLuther JMLuther 2023-01-04 20:58:35

I think it also causes an issue in other themes, but I'm so accustomed to seeing the text/code formatting using my preferences I can't interpret the others very well.

I'm filing an issue at RStudio, thanks!

Sign in to join the discussion

Sign in with GitHub