S Lazy-H
  • Home
  • About
  • Posts
  • Contact
  • Slide Rules
  • A Biker’s Tale

Tabs in Quarto

R Programming
Quarto
Author

Sam Hutchins

Published

March 23, 2024

Looking through elements of the new Quarto (J. J. Allaire et al. 2022), I stumbled across a tidbit on using tabs in a post, etc. This is basically a markdown enhancement using the structure ::: {.panel-tabset} to start the tabbed section and ::: to end the tabbed section.

Interestingly, creating a tab in a post is surprisingly simple. And the contents in a particular tab can be any normal R content. I tried the same structure using rmarkdown (J. Allaire et al. 2023), but it simply listed the headings and ignored the tab creation elements.

There are other ways tabs can be presented. More information is found here. So, just for fun, let’s create some tabs and insert content in each.

  • Tab with an Image
  • Tab with Data
  • Tab with Plot
  • Tab with Formula

Here we have a tab with an embedded image.

Image.
  A      B C      D      E       F Length
A 0 239.15 0   0.00   0.00 120.140 359.29
B 0   0.00 0   0.00   0.00   0.000   0.00
C 0 123.76 0 117.57   0.00 146.085 387.42
D 0 222.19 0   0.00   0.00   0.000 222.19
E 0   0.00 0 148.42   0.00   0.000 148.42
F 0   0.00 0   0.00 150.76   0.000 150.76

This tab shows a matrix created using a R code chunk.

This tab uses a R code chunk to create a plot.

Here we have a formula displayed.

Xe=(XbT×RL12e−3)3

The bare-bones code to do the above is vastly simple and elegant and is shown here:

::: {.panel-tabset}
### Tab Title 1
This is tab 1 text.

### Tab Title 2
This is tab 2 text.

### Tab Title 3
This is tab 3 text.
:::

And here is what it looks like:

  • Tab Title 1
  • Tab Title 2
  • Tab Title 3

This is tab 1 text.

This is tab 2 text.

This is tab 3 text.

And that’s it! God Bless!

References

Allaire, J. J., Charles Teague, Carlos Scheidegger, Yihui Xie, and Christophe Dervieux. 2022. “Quarto.” https://doi.org/10.5281/zenodo.5960048.
Allaire, JJ, Yihui Xie, Christophe Dervieux, Jonathan McPherson, Javier Luraschi, Kevin Ushey, Aron Atkins, et al. 2023. Rmarkdown: Dynamic Documents for r. https://CRAN.R-project.org/package=rmarkdown.
© S Lazy-H 2019 - 2025