-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heading with cross-reference only causes problem in various formats #12105
Comments
Thanks @mcanouil ! Definitely the problem. I wonder if we can protect againt this somehow by detecting a referenced only label and tweaking the id on the header... 🤔 BTW, same kind of problem with HTML and Typst but less visible
So I really thing we should try to find a clever way to help with that, or at least error early and ask to set an explicit ID. |
If Quarto does do something like adding In my opinion, Quarto should not try to be smart here, instead it should warn or error out asking the user to use an explicit ID if the user really wants to proceed with this. |
My 2¢ as a user:
Thanks both for your prompt replies. |
@mcanouil Do you think in current situation it is easier to guess ID ? I don't think knowing the current ID used for the section is any easier in current situation as you can't guess that what you see in HTML as title, is not used as ID as usual. From my experience, for simple header guessing ID is easy, but for header with special characters or punctuation, it is always tricky to remember what will be the normalization done by Pandoc. So usually, if a user needs the id of a section, then adding an explicit one is recommended. And it is required if one wants to leverage crossreferencin for section: https://quarto.org/docs/authoring/cross-references.html#sections IMO this leading to typst erroring is bad, so we need to make this better. Rgarding easy guessing, we can also try to be clever and tweak the id based on the resulting cross-ref outputs. But IIRC the real problem in all that is Pandoc will use the initial ID no matter what to generate the TOC content. This can lead to problem... Anyhow, this may not be trivial and for now throwing a warning or an error is maybe the only easy way.
@CoryMcCartan I am bit confused by your comments. Cross-references sections with Quarto always require and explicit ID with prefix The auto ID feature comes from Pandoc with its extensions This feature allows to reference to have an id set on all headings, so that adding a table of content works ok. They can also be use with the Markdown link syntax So I don't think quarto.org/docs/authoring/cross-references.html#sections is the place to talk about automatic ID created. We could mention and link to Pandoc docs from Markdown basics on Headings: https://quarto.org/docs/authoring/markdown-basics.html#headings
Yes exactly. The issue here is that two anchors are created as a side effect of the automatic ID feature from Pandoc with Quarto custom syntax for cross reference. IMO this is what we should solve by preventing this conflict. Either erroring early, or doing an automatic adjustment.
Do I understand correctly that your pick to have Quarto "fixing" the idea for you so it just works ? To sum up, this require experiment to really see what improvment could be done, while keeping in mind user experience. Thanks for the discussion !! That really helps thinking process. |
BTW to illustrate @cscheid point in a recent discussion, the problem will be the same with something like this ## Section 1
::: {#prp-one}
It is the case that $1+1=2$.
:::
## Proofs of propositions
### PRP ONE
See @prp-one because This is more complex to solve. This would require knowing all the heading id, and checking there is no overlap with cross referenced ids. Or something like that. Possibly to solve this fully this a linting thing (warn about conflicted ids), or just completely opt out pandoc |
@cderv apologies for the lack of clarity. The two points:
|
Oh I see. We can definitely add a mention to this in crossref section 🤔
I agree with you on this. Thanks for clarification. |
Bug description
When a section heading consists only of a cross-reference, a duplicate
\label{}
is created, leading to an incorrect number and hyperlink displaying in the PDF.Steps to reproduce
Actual behavior
Expected behavior
Produced by replacing final line with
### [Proposition @prp-one]
Your environment
MacOS Sonoma 14.5
Quarto check output
Quarto 1.6.40 [✓] Checking environment information... Quarto cache location: /Users/cmccartan/Library/Caches/quarto [✓] Checking versions of quarto binary dependencies... Pandoc version 3.4.0: OK Dart Sass version 1.70.0: OK Deno version 1.46.3: OK Typst version 0.11.0: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.6.40 Path: /Applications/quarto/bin [✓] Checking tools....................OK TinyTeX: (external install) Chromium: (not installed) [✓] Checking LaTeX....................OK Using: TinyTex Path: /Users/cmccartan/Library/TinyTeX/bin/universal-darwin Version: 2024 [✓] Checking basic markdown render....OK [✓] Checking Python 3 installation....OK Version: 3.9.6 Path: /Library/Developer/CommandLineTools/usr/bin/python3 Jupyter: (None) Jupyter is not available in this Python installation. Install with python3 -m pip install jupyter [✓] Checking R installation...........OK Version: 4.4.0 Path: /Library/Frameworks/R.framework/Resources LibPaths: - /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library knitr: 1.49 rmarkdown: 2.29 [✓] Checking Knitr engine render......OK
The text was updated successfully, but these errors were encountered: