05:00
Create a div, span, or non-executable code block with one option from each of the below columns:
{.class attribute="format"}
Class
.content-visible.content-hiddenAttribute
when-format="___"unless-format="___"Format
latex or pdfepubhtml or revealjsmarkdownExamples:
Pairs well with the {{< include >}} shortcode to re-use content without copying/pasting.
Good practice
Use an underscore prefix for included files so they are automatically ignored by a Quarto render of a project (Include shortcode Quarto docs).
Use conditional content divs to control when tabsets are shown.
3-conditional-content.qmd so that the panel-tabset is visible for HTML reports and hidden for all other formats.
Try another way to get the same result.
{.content-visible when-format="html"} is essentially the same as {.content-hidden unless-format="html"}.
05:00
More efficient to not execute code that generates interactive outputs for static reports.
Useful for executing interactive plot code (e.g., plotly or ggiraph) for HTML reports and static ggplot2 code for all other formats.
Useful for executing different code based on a parameter value.
Not currently a feature of Quarto v1.4. Follow along with this GitHub discussion.
Chunk options can use R code for option values with !expr. Learn about the limitations to this YAML βtagβ literal syntax in the Quarto Chunk Options reference.
Get the format of the Pandoc output by including the following in the setup chunk of your .qmd file:
eval: !expr chunk optionUse latex not pdf
format comes from knitr::opts_knit$get("rmarkdown.pandoc.to"). Pandoc uses LaTeX to create PDFs.
Quarto format aliases wonβt work here.
Conditionally execute ggplot2 code for static reports & plotly code for interactive reports.
Open 5-conditional-code.qmd.
In the ggplot2 code chunks and plotly code chunks, fill in the blanks for the eval: option.
eval: option to execute a chunk based on a parameter value rather than the output format?05:00
Use params in !expr: