quarto-dev / quarto-dev/quarto-cli

Cross-references on unnumbered pages fail (PDF) or are mislabeled (HTML)

Open
#5,946 8 comments 0 reactions 1 assignee View on GitHub

@cscheid is already working on this.

Since Jun 16, 2023.

crossref enhancement
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Bug description

I have a book with a couple of prefaces : https://resampling-stats.github.io/resampling-with/python-book . I want the chapter numbers to start at the first chapter, so the preface pages are .unnumbered.

I want one preface to crossreference the other, but the links are mislabeled in HTML, and fail to resolve in PDF. Is there a way of doing these crossreferences?

See below for a minimal reproducer.

Steps to reproduce
git clone https://github.com/matthew-brett/test-quarto
cd test-quarto
quarto render .  --to html

In the HTML rendering you will see that the crossreferences to the unnumbered prefaces resolve correctly to the page, but get labeled with "Chapter 1" and "Chapter 2", although the contents give no number to the prefaces, and label the first (subsequent) chapter with 2.

For PDF rendering:

quarto render . --to pdf

I get:

WARNING (/Users/mb312/dev_trees/quarto-cli/src/resources/filters/./crossref/refs.lua:110) Unable to resolve crossref @sec-pre1
WARNING (/Users/mb312/dev_trees/quarto-cli/src/resources/filters/./crossref/refs.lua:110) Unable to resolve crossref @sec-pre2
WARNING (/Users/mb312/dev_trees/quarto-cli/src/resources/filters/./crossref/refs.lua:110) Unable to resolve crossref @sec-pre2
WARNING (/Users/mb312/dev_trees/quarto-cli/src/resources/filters/./crossref/refs.lua:110) Unable to resolve crossref @sec-pre1
WARNING (/Users/mb312/dev_trees/quarto-cli/src/resources/filters/./crossref/refs.lua:110) Unable to resolve crossref @sec-pre1

and indeed, the references to the preface unnumbered sections appear as e.g. ?@sec-pre1. etc.

Expected behavior

The cross-references should resolve to the correct location rather than failing, in the PDF build.

In both cases, the cross-reference label could be the unnumbered document title plus numbering or even section title, as in (in my reproducer) Preface 2; section 1 or even Preface 2; Preface 2 subsection.

Actual behavior

See above. Cross-reference to unnumbered sections fails with warning in PDF build. In HTML build, cross-references point to the correct document and location, but as mislabeled with e.g. "Chapter 1" or "Chapter 2" when the contents give other documents as being chapter 1 and chapter 2.

Your environment

Macos Ventura 12.4
Latest quarto-cli commit 1f3581304

Quarto check output
$ quarto check 

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.2: OK
      Dart Sass version 1.55.0: OK
      Deno version 1.33.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      Path: /Users/mb312/dev_trees/quarto-cli/package/dist/bin

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

[✓] Checking Python 3 installation....OK
      Version: 3.10.11
      Path: /Users/mb312/.virtualenvs/resampling-with/bin/python3
      Jupyter: 5.3.0
      Kernels: python3, ir

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

[✓] Checking R installation...........OK
      Version: 4.3.0
      Path: /opt/homebrew/Cellar/r/4.3.0_1/lib/R
      LibPaths:
        - /Users/mb312/Library/R/arm64/4.3/library
        - /opt/homebrew/lib/R/4.3/site-library
        - /opt/homebrew/Cellar/r/4.3.0_1/lib/R/library
      knitr: 1.42
      rmarkdown: 2.21

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

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.