As I work on creating a Quarto book, I am looking to link key terms in the book to corresponding definitions in a glossary. The challenge is to ensure that these links function properly in both HTML and PDF formats. Below are some methods I have explored so far.
Let's consider a scenario where my project comprises two files:
chapter.qmd
glossary.qmd
Method 1: Linking to Glossary Headings
To define a term like data frame in the glossary, I converted it into a heading with an assigned ID in glossary.qmd
.
## Data frame {#glossary-data-frame .unnumbered}
I then linked to this heading within the narrative of chapter.qmd
.
We want to define the term [data frame](glossary.qmd#glossary-data-frame) in the glossary.
While effective, having each glossary term listed as a heading can clutter the table of contents in the PDF version, especially with numerous terms.
Method 2: Using Anchor Tags
Inspired by a post on Stack Overflow, I experimented with anchor tags in glossary.qmd
instead of headings. Additionally, I applied CSS styling to enhance the appearance of linked terms in the glossary. Here's an example:
.glossary-term {
font-size: 14pt;
font-weight: bold;
}
<a name="glossary-data-frame">
<span class="glossary-term">
Data frame
</span>
</a>
Once again, I referenced these anchors within the narrative of chapter.qmd
.
We want to define the term [data frame](glossary.qmd#glossary-data-frame) in the glossary.
While this method works well for the HTML version, the functionality of links and CSS styling does not carry over to the PDF version. I'm currently seeking solutions to address this issue.
If you have insights on:
- Removing glossary terms from the PDF table of contents using Method 1,
- Activating links and adjusting font styles in the PDF version when utilizing Method 2, or
- Any alternative approaches that could achieve the desired outcome,
I would greatly appreciate your input and suggestions. Thank you for your time and consideration!
You can also find this question on Posit Community.