quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.75k stars 306 forks source link

FR: Uniform Cross-Reference Styling #3440

Closed SHogenboom closed 1 year ago

SHogenboom commented 1 year ago

Bug description

I've noticed that the styling of cross-references (e.g., to chapters) differs for HTML and PDF output. I'm using R Studio with R version 4.2.2. Running Quarto 1.2.258 on a Windows computer.

Minimal Reproducible Example:

---
title: "HTML / PDF Cross-Rerefence Test"

# CROSS-REFERENCING
number-sections: true

# STYLING
format:
  html:
    theme: cosmo
  pdf:
    documentclass: scrreprt
    toc-title: "Inhoud"
    toc-depth: 2
    link-citations: true
---

# This would be Chapter 1 {#sec-chap-1}

# This would be Chapter 2

With a link to @sec-chap-1

Output: HTML image

Output: PDF image

Expected Behavior: I would expect the PDF link to include the 'Section' - which is what is what is currently happening in the HTML styling. Underlining the link would also be nice for clearer visibility, but not necessary (could perhaps be achieved through custom css). At the moment with only the numbers as links it is very hard for readers to recognize that there is in fact a link!

Checklist

cscheid commented 1 year ago

That's "by design". PDF crossrefs are rendered according to the LaTeX format template that is used (and the standard PDF format uses that style). You'll unfortunately need to know some LaTeX to fix it, and this stackoverflow post might be a good starting point

SHogenboom commented 1 year ago

@cscheid Thanks for the quick reply! Perhaps my lack of LaTeX knowledge is failing me here... but I feel the issue would be caused before reaching the LaTeX phase. I can see why changing LaTeX settings - like the stackoverflow post you referred to - would change how the hyperlink looks (i.e., underlining the link). However, the word 'Section' in the PDF is not a hyperlink. Therefore changing the styling would only change the 1 and not include the word 'Section' into the link - which is what I'm looking for.

cscheid commented 1 year ago

The conversion of the reference to "Section 1" is also part of LaTeX, though. (you'll need to learn about formats and crossref support in addition. Sorry, I didn't mean to imply my answer was comprehensive!)

cscheid commented 1 year ago

See also #1095, #2356, #1771, #2439. In Quarto 1.4's new crossref system, these are all instances of the same bug: we want to control the "label" of a crossref in a uniform way.

That might not be feasible given the restrictions of targeting multiple output formats that have their own crossref implementations like typst and latex, but that's the goal. I'm going to mark this as a duplicate and use the other issues to track the work.