5

In a xaringan presentation I want to show how to put R Code in an R Markdown document. Which leads me to the dangerous waters of verbatim R Markdown in an xaringan (R Markdown) document.

Displaying verbatim inline code works as long as there is no R code chunk on a later slide. If there is a code chunk later on, all slide separation following the verbatim inline code break. They are displayed as horizontal lines. If I remove the code chunk and leave everything else untouched, the slide separation works again properly.

I read #7 in the knitr FAQ and the mentioned blog post as well as stuff on stackoverflow and R Views. I have no idea what confuses xaringan.

Content of test_verbatim.Rmd document:

---
title: "Verbatim Inline Code"
output: xaringan::moon_reader
---
# Before

empty

---
# Current

This will show a verbatim inline R expression `` `r
1+1` `` in the output.

---
# After

An R Code Chunk breaks the slide separator. Without the chunk, slide separation works. Even an inline R expression is okay.

```{r}
1 + 1
```

---

I want separate slides (Before, Current & After) with verbatim R Markdown and R code chunks but get horizontal lines on the slide Current instead of slide separation.

Yihui Xie
  • 28,913
  • 23
  • 193
  • 419
rnuske
  • 83
  • 7
  • 2
    This is reproducible to me, and sounds like a bug of remark.js: https://github.com/gnab/remark – Yihui Xie May 06 '19 at 18:45
  • 1
    Thanks a lot for reproducing! I just looked at xaringan and obviously looked to short. Code fenced by more than one backtick (e.g. using ' instead backtick here 'code') in a line (without newlines) throws remark.js off. So the same bug occurs if one writes ''code'' or '' 'code' ''. – rnuske May 07 '19 at 08:47
  • Hi, I have the same issue but I don't understand how to solve it (quite new in the xaringan !): how did you finally manage? thanks! – sargg Dec 10 '19 at 18:25
  • I didn't manage at all. I think in one case I included a picture of verbatim markdown – rnuske Jan 06 '20 at 16:04
  • Have you tried escaping the verbatim backticks with: \\` ? –  Sep 08 '21 at 22:06

0 Answers0