Quarto: link a word in one qmd document to a word in a different qmd document

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:

  1. chapter.qmd
  2. 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:

  1. Removing the glossary terms from the PDF table of contents if I use method 1, or
  2. Making the links active and adjusting the font styling in the PDF version of the book if I use method 2, or
  3. 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

The issue was solved by someone on SO using definition lists.

1 Like

FYI Several related issue and discussions in Quarto

I also know about some R package that could help

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.