How to customize or remove the dash in block quotes?

#quote(attribution: "John Doe", block: true)[
  Lorem ipsum dolor sit amet.
]

is rendered as

Lorem ipsum dolor sit amet.
                                    <em dash> John Doe

Is it possible to customize that em dash? For example:

  • to remove the space character next to it, so that it will be —John Doe
  • to remove the em dash, so that it will be simply John Doe
  • to replace the em dash with the en dash

Hello,
You might be interested in reading about show rules. You can pretty much do anything if you set your mind to it in Typst.
In this case, customizing the behaviour of quote.attribution is relatively straightforward.

  • The attribution must be aligned opposite of the text direction, hence we use end
  • Your request concerns exclusively block quotes, so the show rule must be show quote.where(block:true), see where.
  • Afterwards, we just reconstruct the original block quote.
    • The width of the box by default is set to auto, so we must use width: 100%
    • There is padding in the original block quote, so we can pad the content using inset: 1em
    • We take into account the original quotes parameter and simply write on different lines the body, and the attribution.

See the code below!

P.S.: don’t hesitate to change your post title to fit the guidelines, see How to post in the Questions category

#quote(attribution: "John Doe", block: true)[
  Lorem ipsum dolor sit amet.
]

#show quote.where(block: true): it => {
  let attribution = if it.attribution != none { 
    align(end, [--- #it.attribution])
    align(end, [---#it.attribution])
    align(end, [#it.attribution])
    align(end, [-- #it.attribution])
  }
  block(
    width: 100%,
    inset: 1em, 
    if it.quotes == true [ 
      #quote(it.body) 
      #attribution
    ] else [ 
      #it.body 
      #attribution
    ]
  ) 
}

#quote(attribution: "John Doe", quotes: false, block: true)[
  Lorem ipsum dolor sit amet.
]

3 Likes

@quachpas gave the right answer I think. But if you’re looking for a quick fix for some quotes, and these quotes don’t use the em-dash in the body, you can use the following:

#show quote: it => {
  show sym.dash.em: sym.dash.en
  it
}

This replaces the em-dash with an en-dash, but you can also add spaces or whatever. But it’s a hack since it will also affect em-dashes in the quote body.

2 Likes