quarto-dev / quarto-cli

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

The filename of a code cell gets centered if it is inside a figure cross-reference #9750

Open cwickham opened 5 months ago

cwickham commented 5 months ago

Bug description

When the filename attribute is used for a code cell inside a figure cross-reference it gets centered, rather than being left-aligned.

Steps to reproduce

---
title: "Code Filename in a Figure"
format: html
---

```{.r filename="R Console"}
1 + 1

::: {#fig-1}

1 + 1

Some R code

:::


### Expected behavior

The filename of the code cell, `R Console`, should be in the same position in both examples.

### Actual behavior

The filename of the code cell, `R Console`, is centered when it is inside the figure, not left-aligned.

<img width="383" alt="Screenshot 2024-05-22 at 2 54 40 PM" src="https://github.com/quarto-dev/quarto-cli/assets/25964/cd36cb48-21a3-4a52-8a8c-96d8c236aef9">

### Your environment

- OS: Mac Sonoma 14.4.1

### Quarto check output

```bash
quarto check
Quarto 99.9.9
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
fatal: not a git repository (or any of the parent directories): .git
      Path: /Users/charlottewickham/Documents/posit/quarto-cli/package/dist/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.03.13
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/charlottewickham/Library/TinyTeX/bin/universal-darwin
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.1
      Path: /Users/charlottewickham/Documents/posit/weekly-log/2024-04-01/.venv/bin/python
      Jupyter: 5.7.2
      Kernels: julia-1.10, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........OK
      Version: 4.3.3
      Path: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources
      LibPaths:
        - /Users/charlottewickham/Library/R/arm64/4.3/library
        - /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library
      knitr: 1.45
      rmarkdown: 2.26

[✓] Checking Knitr engine render......OK
cscheid commented 5 months ago

I recently fixed this issue for floats of type Listing: https://github.com/quarto-dev/quarto-cli/issues/9724

I don't know how easy it'll be to fix this for Figure floats without breaking other parts of our styling. Fundamentally, the problem is that the DOM we emit for code listings doesn't play nicely with the DOM we emit for centering things like captions. We definitely want to fix this, but I'm reluctant to do it late in 1.5.