quarto-dev / quarto-dev/quarto-cli

Cross-reference to custom cross-ref divs containing code-listing will cause misformed construction of listing if it contains an annotated code line

Open
#14,673 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug code-annotation crossref lua
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

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

When a custom reference type is set up to contain a code listing, and if that listing contains an annotated line, the listing output is malformed.

  1. The codeblock itself is placed above the div's title-row; and the title-row is followed directly by the annotation-section.
  2. Cross-refs will link to the div's title-row (correct).

Some additional observations not fully captured in compiled reprex:

  • If an annotation line exists but no code-line is tagged for it, the cross-reference works correctly - but line-annotation fails. THe listings-block is assembled properly.
  • If a code line is tagged, but its corresponding annotation does not exist, cross-reference fails (is replaced with ??), and the codeblock renders, but not as listing (and thus the listings caption is missing)
    (Note: I have not tested if this occurs in default listings as well, just noticed during this writeup)
  • if both are configured 'correctly'; the issue as explained above occurs.

Further information can be found in the repository's README. .tex-intermediates are provided.

Steps to reproduce

Reprex, some additional details, and compiled outputs are found under https://github.com/Gewerd-Strauss/quarto-issue-cannot-crossref-to-custom-annotated-custom-listing

Actual behavior

Cross-referencing a custom cross-ref containing a validly-configured code-annotation results in the cross-referenced cell to be misorganised. The codeblock is placed above the listing caption line, the annotation is placed below the listing caption line. The hyperlink links to the caption line, below the codeblock and above the line annotations.

Expected behavior

Cross-referencing to a custom cross-ref containing an annotated code-block should not fail or misrender. The cross-reference should point to the start of the div, the codeblock itself should be placed properly, even if the layouting of the annotated block is modified.

Your environment
  • Linux Mint 22.2 (Ubuntu 24.04 LTS)

  • Vs Code version:

    gewerd-strauss@gewerdstrauss-B650E-AORUS-PRO-X-USB4:/mnt/data/Repositories/linux-only$ code --version
    1.127.0
    4fe60c8b1cdac1c4c174f2fb180d0d758272d713
    x64
    
Quarto check output
gewerd-strauss@gewerdstrauss-B650E-AORUS-PRO-X-USB4:/mnt/data/Repositories/linux-only$ quarto check
Quarto 1.10.14
[✓] Checking environment information...
      Quarto cache location: /home/gewerd-strauss/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.8.3: OK
      Dart Sass version 1.87.0: OK
      Deno version 2.7.14: OK
      Typst version 0.14.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.10.14
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2026.04
      Chromium (deprecated): 869685
            (Run "quarto install chrome-headless-shell" to replace)
      Chrome Headless Shell: 150.0.7871.24
      VeraPDF: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /home/gewerd-strauss/.TinyTeX/bin/x86_64-linux
      Version: 2026

[✓] Checking Chrome Headless....................OK
      Using: Chrome Headless Shell installed by Quarto
      Path: /home/gewerd-strauss/.local/share/quarto/chrome-headless-shell/chrome-headless-shell-linux64/chrome-headless-shell
      Version: 150.0.7871.24

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

[✓] Checking R installation...........OK
      Version: 4.6.1
      Path: /usr/lib/R
      LibPaths:
        - /home/gewerd-strauss/R/x86_64-pc-linux-gnu-library/4.6
        - /usr/local/lib/R/site-library
        - /usr/lib/R/site-library
        - /usr/lib/R/library
      knitr: 1.51
      rmarkdown: 2.31

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.3
      Path: /usr/bin/python3
      Jupyter: 5.3.2
      Kernels: python3

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

[✓] Checking Julia installation...
gewerd-strauss@gewerdstrauss-B650E-AORUS-PRO-X-USB4:/mnt/data/Repositories/linux-only$ 

(julia check does not print anything, not sure why)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction repository and its README, then render the supplied custom cross-reference containing an annotated code listing with Quarto CLI. Compare the rendered output with the provided .tex intermediates; done means the code block, caption, annotations, and cross-reference target are correctly ordered and rendered.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, latex
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.