3 VS Code Snippets, to make writing in Quarto even easier! 🔨
Today, I bring you something hands-on: 3 snippets to implement figures in Quarto with ease. Cross-referencing, captions and all.
I love writing, programming and analysing data.
Quarto allows me to combine all three, for example in VS Code.
Today, I bring you something hands-on: 3 snippets to implement figures in Quarto with ease. Cross-referencing, captions and all.
These 3 snippets include: r-figure
, r-figure-subplot2
and r-figure-subplot3
. You can find them at the end of this article.
r-figure
simply implements a single figure, while the other two snippets implement 2-figure and 3-figure subplots respectively. The 2-figure subplot looks something like this in your paper:
Simply type e.g. figure
hit tab to execute the Snippet, type in a label name for your figure, hit tab, write a caption for your figure, hit tab, and implement your plot object (e.g. a ggplot2 object when using R).
"r-figure": {
"prefix": "figure",
"body": [
"@fig-${1:label}",
"```{r}",
"#| label: fig-${1:label}",
"#| fig-cap: \"${2:caption}\"",
"${3:ggplot_object}",
"```",
],
"description": "implement a function including caption and reference"
},
"r-figure-subplot2": {
"prefix": "figure-subplot2",
"body": [
"@fig-${1:label}",
"```{r}",
"#| label: fig-${1:label}",
"#| fig-cap: \"${2:caption}\"",
"#| layout-ncol: ${3:2}",
"#| fig-subcap: ",
"#| -$4",
"#| -$5",
"${6:ggplot_object}",
"```",
],
"description": "implement a function including caption and reference"
},
"r-figure-subplot3": {
"prefix": "figure-subplot3",
"body": [
"@fig-${1:label}",
"```{r}",
"#| label: fig-${1:label}",
"#| fig-cap: \"${2:caption}\"",
"#| layout-ncol: ${3:3}",
"#| fig-subcap: ",
"#| -$4",
"#| -$5",
"#| -$6",
"${7:ggplot_object}",
"```",
],
"description": "implement a function including caption and reference"
}