quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.95k stars 326 forks source link

fig-align in YAML doesn't work #4315

Closed abichat closed 11 months ago

abichat commented 1 year ago

Bug description

Hello,

I try to center all figures in my document with a YAML argument so I tried the generic option fig-align

---
title: "Untitled"
format: html
fig-align: center
---

```{r}
knitr::opts_chunk$get("fig.align")

But it is not used. However, with the "old" syntax

title: "Untitled" format: html knitr: opts_chunk: fig.align: center



the figures are aligned correctly. Is this the desired behavior? Thanks

RStudio Version 2022.12.0+353 (2022.12.0+353)
Mac OS 13.1

### Checklist

- [X] Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- [X] Please [format your issue](https://quarto.org/bug-reports.html#formatting-make-githubs-markdown-work-for-us) so it is easier for us to read the bug report.
- [X] Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- [X] Please document the operating system you're running. If on Linux, please provide the specific distribution.
cscheid commented 1 year ago

Easy repro here:

---
title: "Untitled"
format: html
knitr: 
  opts_chunk:
    fig.align: center
---

```{r}
plot(1:10)
cscheid commented 1 year ago

I think the issue is that we support this on a per-cell basis but not at the document level. (It still feels like a bug to me because this passes validation and our schemas autocomplete it.)

cscheid commented 1 year ago

Here's more context. It is possible to get quarto to respect fig-align globally, but it will currently only do so if it detects that a code cell is a figure. In quarto parlance, a figure is (again, currently!) interpreted fairly strictly. It needs a label and a caption. So the following works:

---
title: "Untitled"
format: html
fig-align: center
---

```{r}
#| label: fig-1
#| fig-cap: A caption
plot(1:10)


With that said, we agree that our "figure" options should work more generally (esp. `fig-align`, `fig-dpi`) for any images, so we'll fix this before 1.3 is out. Thanks for the report!
cscheid commented 1 year ago

This turns out to be pretty delicate with its interaction with our figure discovery code. It will all get changed in 1.4, so I'm pushing this.

cscheid commented 11 months ago

This is fixed on main.

jtr13 commented 1 month ago

This still isn't working for me. I have the latest version of Quarto (1.5.57).

mcanouil commented 1 month ago

This still isn't working for me. I have the latest version of Quarto (1.5.57).

@jtr13 Please open a new issue referencing this one (after trying the pre-release version if possible) and please provide a fully reproducible example, i.e., "This still isn't working for me." is not something we can use or work on unfortunately.

See https://github.com/quarto-dev/quarto-cli/issues/4315#issuecomment-1426023371 which does work at least in the pre-release.

jtr13 commented 1 month ago

Thanks for the explanation. I see there's already one open with the same issue: https://github.com/quarto-dev/quarto-cli/issues/9800