0

I have a MWE (see below, adapted from the Quarto doc), and I am wondering:

  1. Why the label fig-test is not found
  2. Is it possible to automatise the caption with a 'for loop' in the yaml? I found a beginning of answer here but I wonder if the language evolved since then
---
title: "MWE"
lightbox:
  match: auto
format:
  html:
    toc: true
    include-in-header: mathjax.html
    code-fold: true
    df-print: paged
    number-sections: true
    theme:
      light: cerulean
      dark: darkly
    margin: 5% 0;
---
See @fig-test
```{r}
#| label: fig-test
#| fig-cap: 
#|   - Caption for first plot
#|   - Caption for second plot
#| lightbox: 
#|   group: test_group

for (i in 1:2)
    plot(rnorm(100), pch = 19, cex = 0.5)
```

1 Answer 1

0

It seems that for the label to work, it is required to put both a caption and at least one sub-caption. If there is one sub-caption only, then it will be used for the subplots.

This is a MWE that worked for me, with two plots and two sub-captions (although one was already enough to make it work):

---
title: "MWE"
lightbox:
  match: auto
format:
  html:
    toc: true
    include-in-header: mathjax.html
    code-fold: true
    df-print: paged
    number-sections: true
    theme:
      light: cerulean
      dark: darkly
    margin: 5% 0;
---
See @fig-test
```{r}
#| label: fig-test
#| fig-cap: Random plots
#| fig-subcap: 
#|   - Random 1
#|   - Random 2

for (i in 1:2)
    plot(rnorm(100), pch = 19, cex = 0.5)
```
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.