Search code examples
rquartoreveal.js

Code location in column layout in Quarto revealjs


I am trying to use the output-location: column option in a Quarto reveal.js presentation.

One problem arises when there are multiple outputs from the same chunk, in which case only the first part of the code is shown on the left side, and the other part continues below the first output.

Is there a way to put all code on the right side, and all output on the left?

Reproducible example:

---
format: revealjs
---

## A title

```{r}
#| output-location: column
#| echo: true
1:10

10:1 #This should be on the left side
```

I would like all code to be on the left side, and all output on the right.

enter image description here


Solution

  • You can add #| results: hold to your code block options to hold all text output to the end of the chunk, e.g.:

    ---
    format: revealjs
    ---
    
    ## A title
    
    ```{r}
    #| output-location: column
    #| results: hold
    #| echo: true
    1:10
    
    10:1 #This should be on the left side
    ```
    

    This gives:

    slides