anchor-sections configuration only allows true or false to opt-out adding anchor in a document. We don't have currently some more specific configuration to target one of the selector. In particular, sections and figures are dealt the same.
We could offer some more control over this in the future, like
More configuration
anchor-sections:
headings: false
or exposing the opt-out through .no-anchor class.
It can work with heading today, but really hard to set on computed figure because using cell option classes: no-anchor will set on the div.cell and not on the div.quarto-figure
Originally posted by **royfrancis** July 11, 2024
### Description
A code chunk with a label creates a clickable anchor. This is usually fine and nice to have.
![Screenshot 2024-07-11 at 17 18 21](https://github.com/quarto-dev/quarto-cli/assets/5083500/19a7a32f-0e40-483d-b815-40eba69c5a05)
But sometimes, with interactive graphics, it can conflict with existing elements.
![Screenshot 2024-07-11 at 17 28 39](https://github.com/quarto-dev/quarto-cli/assets/5083500/bf81e08a-7f80-424e-b8b6-6a6971b5b30a)
`anchor-sections: false` disables anchors for the whole document. Is it possible to disable anchors selectively by chunk? Or enable anchors for headings, but disable for figures?
An example document
Click here
````
---
title: Anchor conflict
format: html
---
## ggplot
```{r}
#| label: fig-ggplot
#| fig-cap: A ggplot figure
library(ggplot2)
data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(10, 11, 12, 13, 14))
p <- ggplot(data = data,aes(x = x,y = y))+
geom_point()
p+labs(title="A ggplot figure")
```
## ggiraph
```{r}
#| label: fig-ggiraph
#| fig-cap: A ggiraph figure
library(ggiraph)
p1 <- p+labs(title="A ggiraph figure")
girafe(ggobj = p1) |>
girafe_options(opts_toolbar(saveaspng = TRUE))
```
## plotly
```{r}
#| label: fig-plotly
#| fig-cap: A plotly figure
library(plotly)
plot_ly(data, x = ~x, y = ~y, type = 'scatter', mode = 'markers') |>
layout(title = list(text = "A plotly figure", x = 0.1))
```
````
`quarto 1.5.54`
anchor-sections
configuration only allowstrue
orfalse
to opt-out adding anchor in a document. We don't have currently some more specific configuration to target one of the selector. In particular, sections and figures are dealt the same.https://github.com/quarto-dev/quarto-cli/blob/00c5b5b79a0ba69ef53edc77261ba63ef47728bc/src/format/html/format-html.ts#L709-L731
We could offer some more control over this in the future, like
.no-anchor
class. It can work with heading today, but really hard to set on computed figure because using cell optionclasses: no-anchor
will set on thediv.cell
and not on thediv.quarto-figure
Opening this to track idea. Motivation: See https://github.com/quarto-dev/quarto-cli/discussions/10274#discussioncomment-10023421 - the current situation creates conflict with interactive figure that could already have some content exactly at the same place as the anchor we add
Discussed in https://github.com/quarto-dev/quarto-cli/discussions/10274
Click here
```` --- title: Anchor conflict format: html --- ## ggplot ```{r} #| label: fig-ggplot #| fig-cap: A ggplot figure library(ggplot2) data <- data.frame(x = c(1, 2, 3, 4, 5), y = c(10, 11, 12, 13, 14)) p <- ggplot(data = data,aes(x = x,y = y))+ geom_point() p+labs(title="A ggplot figure") ``` ## ggiraph ```{r} #| label: fig-ggiraph #| fig-cap: A ggiraph figure library(ggiraph) p1 <- p+labs(title="A ggiraph figure") girafe(ggobj = p1) |> girafe_options(opts_toolbar(saveaspng = TRUE)) ``` ## plotly ```{r} #| label: fig-plotly #| fig-cap: A plotly figure library(plotly) plot_ly(data, x = ~x, y = ~y, type = 'scatter', mode = 'markers') |> layout(title = list(text = "A plotly figure", x = 0.1)) ``` ````