typst-community / glossarium

Glossarium is a simple typst glossary.
MIT License
35 stars 10 forks source link

Allow printing long only #51

Closed jmigual closed 3 weeks ago

jmigual commented 2 months ago

So, I usually like to write the long form only of a term in figures and places before it's "officially" introduced in the main text. E.g.,

#definition(gls("gosp", long:true))[We define the @gosp as the tuple ...]

#print-glossary(
  (
    (key: "gosp", short: "GOSP", long: "generic operation scheduling problem"),
  )
)

This should generate the text:

Definition 1 (generic operation scheduling problem): We define the generic operation 
scheduling problem (GOSP) as the tuple ...

TLDR: Can we have something similar to the \acrlong command in LaTeX glossaries?

slashformotion commented 2 months ago

you can write this:

#import "@preview/glossarium:0.4.1": *
#show: make-glossary

#let acrlong(ref) = {
  gls(ref, long: true)
}

We define the #acrlong("gosp") as the tuple ...

#print-glossary(
  (
    (key: "gosp", short: "GOSP", long: "generic operation scheduling problem"),
  )
)

image

Let me know if that works for you.

jmigual commented 2 months ago

Hey! Thanks for your reply, unfortunately, this doesn't work because this still inserts the "(GOSP)" at the end of the long command.

In the glossaries package of LaTeX the "acrlong" command always displays the long version without the short and it doesn't change the "first appearance" flag. So, if you type this in LaTeX:

\acrlong{gosp}

\gls{gosp}

You would get:

generic operation scheduling problem

generic operation scheduling problem (GOSP) 

This is the behavior I'm trying to recreate.

jmigual commented 2 months ago

I think I can fix it myself and make a PR with the change

slashformotion commented 2 months ago

I believe you could use the gls-long function to achieve what you want to do but it it only available on the master branch for now

jmigual commented 2 months ago

Yes! That's exactly what I was looking for. I guess I'll have to wait 😊

quachpas commented 3 weeks ago

@jmigual You can now use it with 0.4.2