Fix counting when glossary item is referenced inside of outline#169
Fix counting when glossary item is referenced inside of outline#169haenoe wants to merge 2 commits intotypst-community:masterfrom
Conversation
| 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 |
There was a problem hiding this comment.
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
|
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. |
|
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,
) |
|
I'll be closing this in favor of #175 |
|
Hey, thank you very much for taking a look at this. I like that this solution is a lot simpler than mine! Ahh and I think you switched me up with @ AnnsAnns in the changelog ^^' Aaaand happy new year's... for in a few days ;) |
|
Thanks! Can you send a patch to fix the changelog? Sorry about the mix-up! |
|
There you go - no worries: #177 |
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
outlinestargetquery, the fact that Typst renders theoutlinefirst means that the internal counting thatglossariumdoes is off.For example, if I have the following stupid example (simplified)...
..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/....
I have also added another example which demonstrates the before/after
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!