How to fully control visualization of a glossary in glossarium?

Hello!

I am using the package glossarium to define a nomenclature. I need to define other “glossaries” later, such as “acronyms”, but for now what I have is:

#import "@preview/unify:0.6.0": unit
#import "@preview/glossarium:0.5.1": make-glossary, register-glossary, print-glossary, gls, glspl
#show link: set text(fill: rgb(160,20,40))
#show: make-glossary

#let entry-list = (
  // Physics Variables (Group A)
  (
    key: "g",
    short: $g$,
    long: "Gravitational Constant",
    description: unit("meter per second squared"),
    group: "Physics Variables",
  ),
  (
    key: "H",
    short: $H$,
    long: "Wave height",
    description: unit("meter"),
    group: "Physics Variables",
  ),
  (
    key: "D",
    short: $D$,
    long: "Water depth",
    description: unit("meter"),
    group: "Physics Variables",
  ),
  (
    key: "lambda",
    short: $λ$,
    long: "Wave length",
    description: unit("meter"),
    group: "Physics Variables",
  ),
  (
    key: "T",
    short: $T$,
    long: "Period",
    description: unit("second"),
    group: "Physics Variables",
  ),

  // SPH Variables (Group B)
  (
    key: "delta-p",
    short: $Δ p$,
    long: "Initial particle distance. Also denoted as Dp or dp",
    description: unit("meter"),
    group: "SPH Variables",
  ),
  (
    key: "h",
    short: $h$,
    long: "Smoothing length",
    description: unit("meter"),
    group: "SPH Variables",
  ),
  (
    key: "c",
    short: $c$,
    long: "Speed of sound",
    description: unit("meter per second"),
    group: "SPH Variables",
  ),
  (
    key: "V",
    short: $V$,
    long: "Volume",
    description: unit("meter cubed"),
    group: "SPH Variables",
  ),
  (
    key: "rho",
    short: $ρ$,
    long: "Density",
    description: unit("kg/m^3"),
    group: "SPH Variables",
  ),
  (
    key: "p",
    short: $p$,
    long: "Pressure",
    description: unit("Pa"),
    group: "SPH Variables",
  ),
  (
    key: "m",
    short: $m$,
    long: "Mass",
    description: unit("kg"),
    group: "SPH Variables",
  ),
  (
    key: "u",
    short: $bold(u)$,
    long: "Velocity",
    description: unit("m/s"),
    group: "SPH Variables",
  ),
  (
    key: "x",
    short: $bold(x)$,
    long: "Position",
    description: unit("meter"),
    group: "SPH Variables",
  ),
  (
    key: "gamma",
    short: $Γ$,
    long: "Dissipation",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "omega",
    short: $Ω$,
    long: "Domain",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "domega-xi",
    short: $d Ω_x_i$,
    long: "Volume of particle i at position " + $bold(x)_i$,
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "omega-V",
    short: $∂Ω_V$,
    long: "Volume of support domain",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "omega-S",
    short: $∂Ω_S$,
    long: "Surface of support domain",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "W",
    short: $W$,
    long: "Smoothing Kernel",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "A",
    short: $A$,
    long: "Arbitrary property for SPH estimation",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "gamma-adiabatic",
    short: $γ$,
    long: "Adiabatic Index",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "Pi",
    short: $Π$,
    long: "Modeled Viscosity",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "epsilon",
    short: $ε$,
    long: "Numerical constant used in artificial viscosity to avoid dividing by zero",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "kappa",
    short: $κ$,
    long: "Scaling constant used to determine size of smoothing kernel radius",
    description: [],
    group: "SPH Variables",
  ),
  (
    key: "L2-norm",
    short: $||bold(x)_i - bold(x)_j||$,
    long: [L#super[2]-norm],
    description: [],
    group: "SPH Variables",
  ),
)
#register-glossary(entry-list)
// Your document body
#print-glossary(
  show-all: true,
 entry-list
)

It generates:

But I need it to generate this:

So basically I need to:

  • Remove bold description text
  • Set units to the right
  • Sort entries such that entries with units go to the top for a neater look

I think this should be possible, I am just very uncertain on how to overload show in this case

Kind regards

Hello @AhmedSalih,
this would require many changes in the print-glossary arguments. I suggest to look at user-print-glossary to make it return a table instead!
A good start would be the following

#print-glossary(
  show-all: true,
  user-print-glossary: (entries, groups, ..) => {
    table(
      columns: 3,
      stroke: 0pt,
      ..for group in groups {
        (
          table.cell(group, colspan: 3),
          ..for entry in entries.filter(x => x.group == group) {
            (
              entry.short,
              entry.long,
              entry.description
            )
          }
        )
      }
    )
  },
  entry-list
)

Afterwards, depending on whether you need other features of glossarium, you would need to recover them in some way.

2 Likes

Thank you so much! I did not know it was so easy, I could not find that kind of example in the library. I am so happy right now, typst, has so much potential, so much opportunity in simplicity!

I will try to modify it to match my needs exactly, but already so close.

Kind regards

1 Like

You can also take a look at other packages. Searching for acro, or glo should give you some good results.