Dear all,
I was looking for an option to set Quarto options based on the output format being rendered. For instance I would like to echo: true with code folding for html but set echo: false for pdf. Is this even possible?
Dear all,
I was looking for an option to set Quarto options based on the output format being rendered. For instance I would like to echo: true with code folding for html but set echo: false for pdf. Is this even possible?
If you are using R, you can leverage knitr that allows to take some R values for options. It works the same as in R Markdown as this is a knitr feature.
You could use this R chunk option echo = knitr::is_html_output()
With Quarto it would be something like
---
format:
html: default
pdf: default
---
```{r}
#| echo: !expr knitr::is_html_output()
1 + 1
```
Here echo
will be false unless HTML output.
More on this function: 9.1 LaTeX or HTML output | R Markdown Cookbook and knitr::pandoc_to()
function.
However, there is a Quarto way. You need to use Project profiles: Quarto - Project Profiles
It allows you to set different set of metadata for different profiles. You would
format: html
and execute
config with echo: true
format: pdf
and execute
config with echo: false
I let you read these docs and try yourself.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.