### I have: - [x] searched the issue tracker for similar issues - [x] installed the latest version of [Quarto CLI](https://github.com/quarto-dev/quarto-cli/releases/latest) - [x] formatted my issue following the [Bug Reports guide](https://quarto.org/bug-reports.html) ### 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: ```bash gewerd-strauss@gewerdstrauss-B650E-AORUS-PRO-X-USB4:/mnt/data/Repositories/linux-only$ code --version 1.127.0 4fe60c8b1cdac1c4c174f2fb180d0d758272d713 x64 ``` ### Quarto check output ```bash 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)