0

I'm trying to create various slides in xaringan presentation using the option results='assis' of knitr, but it doesn't work.

I have use the following code:

    ---
    title: "Presentation"
    author: ""
    date: ""
    output:
      xaringan::moon_reader:
        lib_dir: libs
        nature:
          highlightStyle: github
          highlightLines: true
          countIncrementalSlides: false
    ---

    ```{r, results='asis'}
    for (i in 1:3) {  
      cat("---", "\n")
      cat("## Slide", i, "\n")
      cat("Hello", i)
      cat("\n")
    }
   '''

I expect the output to be 3 pages, but the actual output is one page. I have also tried asis_output instead of cat.

andre
  • 141
  • 1
  • 6

1 Answers1

1

You nearly had it. Change

cat("---", "\n")

to

cat("---\n")

The former adds a space between --- and \n and in xaringan/remark.js there should be no space after --- otherwise it becomes a horizontal rule.

Emi
  • 3,514
  • 8
  • 11