Cross-referencing panels inside a figure created all together (e.g., with gridExtra::grid.arrange
)
#9194
Replies: 2 comments 7 replies
-
If you combine the plots, there are no subfigures, thus Quarto cannot cross-reference what does not exist. See:
---
title: "Quarto Playground"
format: html
---
```{r}
#| label: fig-myfig
#| fig-cap: A figure with multiple panels.
#| fig-subcap: true
#| layout-ncol: 2
df <- data.frame(
id = rep(c("(a) Line", "(b) Parabola"), each = 5),
x = rep(-2:2, 2),
y = c(-2:2, (-2:2)^2)
)
library(ggplot2)
for (iid in unique(df[["id"]])) {
print(
ggplot(subset(df, id == iid)) +
aes(x = x, y = y) +
geom_line()
)
}
``` |
Beta Was this translation helpful? Give feedback.
-
I get it, but how can I create the text "Fig. 1a" if I cannot put the |
Beta Was this translation helpful? Give feedback.
-
Description
I have multi-panel figures created in a quarto document using
gridExtra::grid.arrange
and I want to cross-reference the panels in the figure. For example, if I have the following code:Then I want to include in the document a cross-reference of the sort "Figure 1a". To reference the entire figure, I would put
@fig-myfig
so I would want to do something like@fig-myfiga
, but of course that doesn't work as it doesn't recognize thea
as being separate frommyfig
. I tried using the notation suggested in the quarto documentation of@fig-myfig-1
, but this only works if quarto assembles the figure panels with subcaptions. For many reasons it is much easier for me to letgridExtra::grid.arrange
orfacet_wrap
do the assembling. The only partial solutions I have found is to do@fig-myfig a
or@fig-myfig(a)
, but neither of these is the desired notation for figure panels. I also tried tricking quarto into separatingmyfig
froma
, for example doing@fig-myfig``a
, but these tricks failed or didn't produce what I wanted.Is there a better way to achieve what I want?
Beta Was this translation helpful? Give feedback.
All reactions