Skip to content

Conversation

@haenoe
Copy link

@haenoe haenoe commented Oct 17, 2025

First of all: thank you very much for providing and maintaining this awesome library! I hope I can help improve it a little bit.

There is one thing that trips me up with every document that I write, which includes an outline/index of figures/... at the start.
When I want to reference a glossary item in the elements that are matched by the outlines target query, the fact that Typst renders the outline first means that the internal counting that glossarium does is off.

For example, if I have the following stupid example (simplified)...

#outline(target: figure)

Another @B2B @SaaS...

#figure(
    [*the logo of a company*],
    caption: [Logo of another @B2B @SaaS],
)

..the problem arises that the long version of "B2B" is not used when the term is actually used for the first time. Also it feels bad to have a mismatch between the caption/heading/... displayed in the outline and the actual caption/heading/....

problem

I have also added another example which demonstrates the before/after

Before After
without-modifications with-modifications

The fix I provide feels a bit hacky, though it seems to work for the things I have tested (see also the example).
If anyone has a better idea, I am welcome to change the implementation and discuss more -- feel free to also create an issue.

Cheers!

let is-first = if __glossary_outline_entry_target.get() == none {
is-first(entry.at(KEY))
} else {
__glossary_counts.at(__glossary_outline_entry_target.get()).at(key, default: 0) == 0
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short remark: this is basically copied from is-first. probably makes sense to just extend the is-first function to take a location() as a parameter :D

@quachpas
Copy link
Collaborator

Thank you @haenoe I'll take a look when I have time. Might take a while though because I'm quite busy at the moment. So don't worry if I don't answer within the month.

About the implementation itself, I'll have to take a deeper look because it's quite tricky to be honest. This issue is recurring with the way I am counting usages. I believe the best solution would be simply to reuse the trick for printing for the glossary in the first place in a show rule for the outline.

@quachpas
Copy link
Collaborator

quachpas commented Dec 24, 2025

Hi @haenoe, how would you feel about something like this instead? This controls the "long" option in sub-show rules. I feel like, that should solve your issue.

On a higher level, you are right to point out that using glossarium in captions and stuff shouldn't "count", which is why I think it would be better implemented as global options instead of a dynamic query. Tell me what you think, I'll update my version if needed.

See 6d001f2

#show: make-glossary.with(
  always-long: none,
  outline-always-long: true,
  figure-caption-always-long: false,
  heading-always-long: true,
)

@quachpas
Copy link
Collaborator

I'll be closing this in favor of #175

@quachpas quachpas closed this Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants