Skip to content

Crossref metadata breaks renderings theme switching in knitr and jupyter #14168

@mcanouil

Description

@mcanouil

I have:

  • searched the issue tracker for similar issues.
  • installed the latest version of Quarto CLI.
  • formatted my issue following the Bug Reports guide.

Bug description

Using cross-reference options (label, fig-cap, tbl-cap) together with cell renderings: [light, dark] behaves inconsistently across engines and output structures.
In multiple cases Quarto emits need 2 cell-output-display for renderings ...; got 0, and renderings are not applied.
There is also an existing fixture note that tbl-cap with renderings is unsupported for a knitr + gt table (tests/docs/smoke-all/dark-mode/gt-capcross.qmd).
fig- and tbl- cross-references don't behave quite the same.

From:

The documentation states it does not work well, but maybe it should do it more prominently with a callout.

(weirdly, I did not find any issue tracking this, thus this one)

Steps to reproduce

Run each file with quarto render <file>.qmd --to html.

  1. knitr example:
---
title: "Knitr table + crossref + renderings"
format:
  html:
    theme:
      light: cosmo
      dark: darkly
engine: knitr
---

```{r}
#| label: tbl-knitr-renderings
#| tbl-cap: "Knitr table caption"
#| renderings: [light, dark]
knitr::kable(head(mtcars, 3))
knitr::kable(head(iris, 3))
```

See @tbl-knitr-renderings.
  1. julia example:
---
title: "Julia figure + crossref + renderings"
format:
  html:
    theme:
      light: cosmo
      dark: darkly
engine: julia
---

```{julia}
#| label: fig-julia-renderings
#| fig-cap: "Julia display caption"
#| renderings: [light, dark]
display("light rendering")
display("dark rendering")
```

See @fig-julia-renderings.
  1. jupyter example:
---
title: "Jupyter figure + crossref + renderings"
format:
  html:
    theme:
      light: cosmo
      dark: darkly
engine: jupyter
---

```{python}
#| label: fig-jupyter-renderings
#| fig-cap: "Jupyter figure caption"
#| renderings: [light, dark]
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9])
plt.show()

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [9, 4, 1])
plt.show()
```

See @fig-jupyter-renderings.

Actual behavior

  • Ran from /Users/mcanouil/Projects/quarto-dev/quarto-playground with QUARTO_PYTHON=/Users/mcanouil/Projects/quarto-dev/quarto-playground/.venv/bin/python.
  • knitr table example renders, but logs (W) need 2 cell-output-display for renderings light,dark; got 0.
  • jupyter figure example also renders, and logs the same warning.
  • In both outputs above, renderings is present in attributes, but light-content and dark-content classes are not applied to outputs.
  • Because those classes are missing, both variants are shown together rather than switching by theme.
  • Repository fixture tests/docs/smoke-all/dark-mode/gt-capcross.qmd also documents that combining tbl-cap with renderings loses caption support.
  • Julia example in this project failed before execution due project manifest version mismatch (expected 1.12.4, actual 1.12.5).

Expected behavior

  • renderings: [light, dark] should be applied when cross-reference options are present, without warnings.
  • Captions and cross-reference targets should be preserved.
  • Theme switching should show only the matching rendering variant.
  • Behaviour should be consistent across knitr, jupyter, and julia for comparable output structures.

Your environment

  • IDE: CLI terminal.
  • OS: macOS (Darwin).

Quarto check output

Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/mcanouil/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.8.3: OK
      Dart Sass version 1.87.0: OK
      Deno version 2.4.5: OK
      Typst version 0.14.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: 651075ed4fd5551058628a14ac994f60ba9a4caa
      Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin

[✓] Checking tools....................OK
      TinyTeX: v2026.02
      VeraPDF: 1.28.2
      Chromium: (not installed)
      Chrome Headless Shell: (not installed)

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

[✓] Checking Chrome Headless....................OK
      Using: Chrome from QUARTO_CHROMIUM
      Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

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

[✓] Checking R installation...........OK
      Version: 4.5.2
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
      knitr: 1.50
      rmarkdown: 2.30

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

[✓] Checking Python 3 installation....OK
      Version: 3.14.0
      Path: /Users/mcanouil/Projects/quarto-dev/quarto-playground/.venv/bin/python
      Jupyter: 5.9.1
      Kernels: python3, uv, julia-1.12

[✓] Checking Julia installation...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcrossrefdark-modedark mode and switching between light and dark modesengines-juliaAnything related to Julia engineengines-jupyterAnything related to Jupyter engineengines-knitrAnything regarding knitr engines

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions