Show rule for termlist terms?

Hello. I want content to be justified, but not termlist terms. I hope to set this by a show rule, but is it possible to set a show rule for specific arguments of a function?

When u feel something wrong with typst built-in functions and their paremeters, do NOT try to modify them (such as via external set/show rule). Instead, do the functions urself (via definition section of a function from typst doc) !

#set page(columns:2)
#set par(justify:true)

/ Axiom i1: o oo ooo oooo ooooo oooooo ooooooo oooooooo
/ Axiom i2: oooooooo ooooooo oooooo ooooo oooo ooo oo o

#show terms.item: it => {
  par(justify:false, hanging-indent:2em)[
    #strong(it.term)
    #box[ ]
    #it.description]}

/ Axiom i1: o oo ooo oooo ooooo oooooo ooooooo oooooooo
/ Axiom i2: oooooooo ooooooo oooooo ooooo oooo ooo oo o
1 Like

When you try to customize something, do NOT try to use markup block by default. See Create a dedicated section on dangers of using square brackets carelessly (multi-line) · Issue #6844 · typst/typst · GitHub.


The provided image does not show the default styling of terms, but there is hanging-indent, so I guess it’s not that hard to do. To disable par.justify for terms, you just need to use a show-set rule:

#set par(justify: true)
#set terms(hanging-indent: 0pt)
#show terms: set text(hyphenate: false)

#lorem(20)

/ Some Term: #lorem(20)
/ Term: #lorem(20)

#show terms: set par(justify: false)

/ Some Term: #lorem(20)
/ Term: #lorem(20)

But if you want to just keep term without justification:

#show terms: it => {
  set text(hyphenate: false)
  for (i, it) in it.children.enumerate() {
    let spacing = if i == 0 { (:) } else { (above: 0.65em) }
    // let spacing = if i == 0 { (:) } else {
    //   let value = if it.spacing != auto { spacing } else {
    //     if it.tight { par.leading } else { par.spacing }
    //   }
    //   (above: value)
    // }
    show: block.with(width: 100%, ..spacing)
    box(strong(it.term)) + terms.separator + it.description
  }
}
2 Likes