quarto-dev / quarto-dev/quarto-cli
Cross-reference link to chapter file in a book works in HTML but not in PDF
Nobody has claimed this yet.
- 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 using a cross-reference link to a chapter [chapter](chapter.qmd), the link does not work correctly in PDF. That is, it end up being an \href{chapter.qmd}, instead of \ref{chapter} in the generated LaTeX. This is at odds with the documentation, which states that
Using the source file as the link target ensures that links will be resolved correctly both for HTML output and for formats that produce a single file (e.g. PDF or MS Word).
Steps to reproduce
index.qmd:
# Preface {.unnumbered}
This is a Quarto book.
To learn more about Quarto books visit <https://quarto.org/docs/books>.
Using a simple link to [the introduction file](intro.qmd) does *not* work in PDF, but an explicit cross-reference using [the reference](#sec-intro) does work.
intro.qmd
# Introduction {#sec-intro}
This is a book created from markdown and executable code.
See @knuth84 for additional discussion of literate programming.
_quarto.yml
project:
type: book
book:
title: "Test cross-references"
author: "Norah Jones"
date: "8/27/2025"
chapters:
- index.qmd
- intro.qmd
format:
pdf:
keep-tex: true
Actual behavior
The link [the introduction file](intro.qmd) is translated into \href{intro.qmd} in the generated LaTeX. This in turns lead to a hyperlink in the PDF to the qmd file, not to the chapter in the generated PDF.
Expected behavior
It should generate LaTex that does something like \hyperref[sec-intro], as it does when using the explicit reference [the reference](#sec-intro). That way, it leads to a hyperlink within the PDF.
Your environment
- OS: Linux freedom 6.14.0-27-generic #27~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 22 17:38:49 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
- VScode: 1.102.0
Quarto check output
Quarto 1.7.33
[✓] Checking environment information...
Quarto cache location: /home/vtraag/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
Pandoc version 3.6.3: OK
Dart Sass version 1.85.1: OK
Deno version 1.46.3: OK
Typst version 0.13.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
Version: 1.7.33
Path: /opt/quarto/bin
[✓] Checking tools....................OK
TinyTeX: (not installed)
Chromium: (not installed)
[✓] Checking LaTeX....................OK
Using: Installation From Path
Path: /usr/local/texlive/2024/bin/x86_64-linux
Version: 2024
[✓] Checking Chrome Headless....................OK
Using: Chrome found on system
Path: /usr/bin/google-chrome
Source: PATH
[✓] Checking basic markdown 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....Traceback (most recent call last):
File "/opt/quarto/share/jupyter/jupyter.py", line 21, in <module>
from notebook import notebook_execute, RestartKernel
File "/opt/quarto/share/jupyter/notebook.py", line 20, in <module>
from nbclient import NotebookClient
ModuleNotFoundError: No module named 'nbclient'
[✓] Checking Jupyter engine render....OK
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by rendering the sample book from index.qmd, intro.qmd, and _quarto.yml to PDF with keep-tex enabled. Compare the generated LaTeX for the intro.qmd link with the explicit cross-reference, and confirm that the source-file link resolves to the chapter anchor rather than the qmd file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, latex, markdown
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100