how to change the syntax for inline references? #12379
-
DescriptionHow to Customize Cross-reference Syntax in QuartoProblem DescriptionWhen rendering qmd files to docx using Quarto, the default cross-reference syntax displays figure and table numbers as:
This default format may not meet specific documentation requirements, especially in academic or technical writing where hierarchical numbering is often preferred. Desired OutputI would like to customize the numbering format for figures and tables to follow different hierarchical structures. For example: Option 1: Chapter-based Numbering
Option 2: Section and Subsection-based Numbering
Current ChallengesAfter reviewing the Quarto documentation, I found that:
Is there a way to customize the cross-reference syntax in Quarto to achieve these hierarchical numbering formats? This would be particularly useful for:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Questions
Any guidance or suggestions would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
-
Have you looked at the documentation and other threads dealing with exactly this question?
Looking at the documentation and other threads before asking a question can save a lot of time to many people, including yourself. |
Beta Was this translation helpful? Give feedback.
-
Dear developers, I'm a Quarto beginner. First, I want to thank you for your work - Quarto has made writing papers and reports much more convenient, and now I can hardly work without it. These days, I've been trying to solve cross-referencing numbering issues. The parameters in the English documentation don't fully meet my needs, and this problem remains unresolved. I'll report the basic process. Since this was my first time asking questions on GitHub, I may have missed some basic information, please excuse me. Here's the supplementary information:
My goal is to achieve the following cross-reference numbering format in docx:
I want this numbering format for both initial declarations and subsequent references. Here's my test text:
After reading your comments, I reviewed this webpage again: I found a parameter that could partially meet my needs, which I had previously misunderstood and overlooked. So I set my YAML to: ---
crossref:
chapters: true
--- Now I get the following result: The numbering format is:
Now I'm one step closer to my goal. I can accept not having section numbers, but I want the delimiter between chapter numbers and item numbers to be "-" instead of ".". After trying title-delim and appendix-delim parameter, I confirmed they cannot achieve my goal. |
Beta Was this translation helpful? Give feedback.
-
so I render .native doc:
After examining the native intermediate file, I found:
If I could modify this string, I could achieve my goal. Before that, I needed to test how it's read. So I wrote a Lua script to read the Link class and modify the intermediate file to meet my requirements. local inner_delim = "-"
function Para(el)
print("Para function called")
print("el:", el)
return nil
end
function Link(el)
-- Print basic information about the link element
print("Link function called")
print("\n--- Link Information ---")
print("Is cross-reference:", el.classes[1] == "quarto-xref")
print("content:", el.content)
return nil
end However, something strange happened - the Link class wasn't being read. When I checked the Lua output, I found that the Link function wasn't being called, although the Para function was. So I examined the Para content:
I discovered that there was no Link class within the Para class because they had all been converted to Cite class, and the content didn't contain reference numbers. I'm not sure how to proceed from here. |
Beta Was this translation helpful? Give feedback.
You are really in deep waters here.
Cross-reference is a custom Quarto thing that uses special nodes (i.e.,
FloatRefTarget
).FloatRefTarget