quarto presentation code line numbers

You encounter an issue because you are using a Quarto format specific option code-line-numbers in usual knitr chunk option syntax. Quarto chunk options have dash in their name and R does not support dash in variable name unless you add specific quote. So this would work

## Code 2

```{r, echo=TRUE, eval=FALSE, `code-line-numbers` = "1"}
1
1:2
```

However, with Quarto, it is better to use the syntax using special comment #|, as it will be more portable between computation engine, and it is easier with Quarto specific options.

## Code 2

```{r, echo=TRUE, eval=FALSE}
#| code-line-numbers: 1
1
1:2
```

you can also set echo and eval in the YAML part of the chunk

Hope it helps

2 Likes