Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clarification for reference styling #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,13 @@ I recommend setting a show rule for the links to that your readers understand th
// links are now blue !
```

It is also possible to apply styling specifically to the glossarium references, like in this example:
It is also possible to apply styling specifically to the glossarium references with a `show ref` rule. Make sure this rule comes **after** `make-glossary`.

This approach only styles references that use `@ref` and `@ref:pl` instead of `gls("ref")` and `glspl("ref)`.

```typ
#show: make-glossary

#show ref: it => {
let el = it.element
if el != none and el.func() == figure and el.kind == "glossarium_entry" {
Expand All @@ -224,5 +229,25 @@ It is also possible to apply styling specifically to the glossarium references,
}
}
```

(Thanks to flokl for the [solution](https://forum.typst.app/t/how-do-you-apply-a-style-to-glossarium-references-that-is-different-to-other-reference-types/2089/2?u=ogre) on the Typst forums).
By adding `else if` clauses for different functions and kinds, each type of reference can be given a different style.

Note that when using the `show ref` rule approach together with a `show link` rule the styling in the `show ref` rule gets overwritten. To avoid this change the `show link` rule to only style `str` links (like website or mailto links).

```typ
#show link: it => {
if type(it.dest) == str {
// Make website or mailto links underlined and gray
set text(fill: gray.darken(80%))
underline(
stroke: (paint: gray, thickness: 0.5pt, dash: "densely-dashed"),
offset: 4pt,
it,
)
} else {
// Other links (like glossarium) as usual
it
}
}
```