I'm creating Quarto book and I would like key terms in the book to link to definitions in a glossary. Additionally, I'd like the glossary to work in both HTML and PDF formats. Here's what I have so far.
For the examples below, assume my project has two files:
chapter.qmd
glossary.qmd
Method 1: Link to glossary headings
Let's say that we want to define the term data frame in the glossary. The first thing I did was turn the word "data frame" into a heading and assign it an ID in glossary.qmd
.
## Data frame {#glossary-data-frame .unnumbered}
Next, I used a hyperlink to reference that heading in the narrative of chapter.qmd
.
We want to define the term [data frame](glossary.qmd#glossary-data-frame) in the glossary.
This works, but because each glossary term is a heading, it appears in the table of contents of the PDF version of the book. Because I may end up with hundreds of terms, that isn't ideal.
Method 2: Use anchor tags
Following this SO post, I tried using anchor tags in glossary.qmd
instead of headings. I also used a little bit of CSS to increase the font size and bold the linked term in the glossary. For example:
.glossary-term {
font-size: 14pt;
font-weight: bold;
}
<a name="glossary-data-frame">
<span class="glossary-term">
Data frame
</span>
</a>
Next, I once again used a hyperlink to reference that anchor in the narrative of chapter.qmd
.
We want to define the term [data frame](glossary.qmd#glossary-data-frame) in the glossary.
That also works fine for the HTML version of the book. However, the links aren't active in the PDF version of the book and none of the CSS styling is applied. I'm not necessarily surprised by that, but I have no idea how to fix it.
So, I'd appreciate guidance on:
- Removing the glossary terms from the PDF table of contents if I use method 1, or
- Making the links active and adjusting the font styling in the PDF version of the book if I use method 2, or
- Some other solution that achieves the result I'm shooting for.
Thanks for your time and consideration!
This question is also posted on Stack Overflow