Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label fig-xxx for knitr::include_url #5718

Closed
xtimbeau opened this issue May 27, 2023 · 9 comments
Closed

label fig-xxx for knitr::include_url #5718

xtimbeau opened this issue May 27, 2023 · 9 comments
Assignees
Labels
Milestone

Comments

@xtimbeau
Copy link

xtimbeau commented May 27, 2023

Bug description

fig-xxx for an included_url (such as an interactive graph or a leaflet map) is not accepted as a figure by quarto (bookdown seems to work that way https://bookdown.org/yihui/rmarkdown-cookbook/include-url.html).

More generally it would be nice to allow user to include any content (if aware) as a figure or a table
(a table can sometime be rendered as an image ?).

here is a reprex:

---
title: "fig"
format: html
editor: visual
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

here is a map [@fig-map], working as expected, but html saved is not a figure [@fig-maphtml]

```{r}
#| label: fig-map
#| fig-cap: a leaflet interactive map
leaflet::leaflet() |> leaflet::addTiles()
```

```{r}
#| label: fig-maphtml
#| fig-cap: a leaflet interactive map
leaflet::leaflet() |> leaflet::addTiles() |> htmlwidgets::saveWidget("map.html")
knitr::include_url("map.html")
```
the end.

Steps to reproduce

No response

Expected behavior

No response

Actual behavior

No response

Your environment

No response

Quarto check output

No response

@xtimbeau xtimbeau added the bug Something isn't working label May 27, 2023
@mcanouil
Copy link
Collaborator

Thanks for the report!

Could you format your example to be reproducible? Thanks.

You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````).

````qmd
---
title: "Reproducible Quarto Document"
format: html
---

This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.

```{r}
plot(cars)
```

The end.
````

@xtimbeau
Copy link
Author

I think I got it right !

@mcanouil mcanouil added crossref triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. labels May 28, 2023
@mcanouil
Copy link
Collaborator

What you want to achieve, i.e., forcing content to be seen by Quarto as a figure is not currently possible, but Quarto team is working on cross-reference for 1.4 which should allow this in the future.

@mcanouil mcanouil added enhancement New feature or request and removed bug Something isn't working labels May 28, 2023
@mcanouil
Copy link
Collaborator

mcanouil commented May 29, 2023

Meanwhile, here is a workaround:

---
title: "fig"
format: html
editor: visual
---

## Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.

here is a map, working as expected, but html saved is not a figure [@fig-maphtml]

::: {#fig-maphtml}

```{r}
htmlwidgets::saveWidget(leaflet::addTiles(leaflet::leaflet()) , "map.html")
knitr::include_url("map.html")
```

a leaflet interactive map

:::

the end.

@xtimbeau
Copy link
Author

xtimbeau commented May 29, 2023 via email

@cderv
Copy link
Collaborator

cderv commented May 30, 2023

More generally it would be nice to allow user to include any content (if aware) as a figure or a table
(a table can sometime be rendered as an image ?).

@mcanouil I think Figure Divs is the answer to this, and not just a workaround. Do you think there should be more ?

Otherwise, I think we can close

@mcanouil
Copy link
Collaborator

I think that's a general solution yes.

I said "workaround" because of a comment by @cscheid about cross-reference resdesign/refactoring which should allow to force anything to be read as anything for cross-reference, i.e., in this case, "html" as a "figure".
Partly, why I triaged this to him.
I let him decide 😇

@cscheid
Copy link
Collaborator

cscheid commented May 30, 2023

I said "workaround" because of a comment by @cscheid about cross-reference resdesign/refactoring which should allow to force anything to be read as anything for cross-reference, i.e., in this case, "html" as a "figure".

Thanks, and I agree. There's too many open issues that are related to this (see the fifth bullet item in #4944); I'm going to leave this one open, and check back when those features are ready to see if they solve this issue.

@cscheid cscheid removed the enhancement New feature or request label May 30, 2023
@cscheid cscheid added this to the v1.4 milestone May 30, 2023
@cderv cderv removed the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label May 31, 2023
@cscheid
Copy link
Collaborator

cscheid commented Dec 14, 2023

Ok, this style of crossreferenceable element is now documented and advertised, so we're good with closing this.

@cscheid cscheid closed this as completed Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants