Thank you ever so much! The code you provided was the key I needed to get to my final resolution. I used VS Code with the integrated Claude assistant API to help me make a few small changes and formatting/styling modifications, until it produced the following desired result:
#import "@preview/glossarium:0.5.6": *
#let my-custom-print-glossary(
entry-list,
show-all: true,
disable-back-references: false,
enable-group-pagebreak: false,
user-group-break: linebreak()
) = {
// Your custom logic here
for entry in entry-list {
// Custom styling for each part with hanging indent
par(
first-line-indent: 0pt,
hanging-indent: 0em,
spacing: 12pt
)[
// Short form - apply your styling
#text(weight: "bold")[#entry.key#h(.3em)]
// Long form - apply italic styling
#if "long" in entry {
// Check if this is from list-a (already formatted) or list-b (needs formatting)
if type(entry.long) == content {
// This is from list-a, already formatted
entry.long
} else {
// This is from list-b, needs formatting
if "description" in entry and entry.description != [] {
emph(entry.long) + [: ] + entry.description
} else {
emph(entry.long) + [.]
}
}
}
]
}
}
#let list-original = (
(
key: "Foo",
long: ("Lorem", "Ipsum"),
description: ([Comment A1], [Comment A2])
),
(
key: "Bar",
long: ("Dolor",),
description: ([Comment B],)
),
)
#let list-a = list-original.map(
x => for (i, y) in x.long.enumerate() {((
key: y,
long: x.key,
description: if x.description.at(i) != [] { x.description.at(i) + [.] } else { [] }
),)}
).flatten().sorted(key: entry => entry.key)
#let list-b = list-original.map(
x => (
key: {x.key},
long: {
let pairs = x.long.zip(x.description).map(pair => {
let term = pair.at(0)
let desc = pair.at(1)
if desc != [] {
emph(term) + [: ] + desc
} else {
emph(term)
}
})
if x.long.len() == 1 {
pairs.join([]) + [.]
} else {
pairs.join([; ]) + [.]
}
},
description: []
)
).sorted(key: entry => entry.key)
#show: make-glossary
#register-glossary(list-a)
#register-glossary(list-b)
=== English to Latin
#my-custom-print-glossary(list-a, show-all: true)
=== Latin to English
#my-custom-print-glossary(list-b, show-all: true)
Many thanks again, @quachpas, both the package and for your help in customising it above!
