How to change line spacing in raw/code blocks?

I can set a block of code with monospace font and simple #raw or codly package.
I can modify the properties of this with a #text - font, font size, horizontal spacing, etc.
However, I seem to be unable to adjust the spacing between lines - I tried with #par(leading), but that does not seem to do anything?

How do I set spacing between lines with raw/codly blocks?

Thanks!
M

1 Like

You can combine these rules with a show-set rule like this: #show raw.where(block: true): set par(leading: ..).

Thank for the comment. However, I’m not sure I understand. I have one specific block that has a lot of content that I want smaller and tighter:

  #text(size: 0.7em)[
  ```
  hellohello
  typsttypst
  ```
  ]

…how do I add this here?

Show-rules are only applied within their scope, so you can move that show-rule inside the square brackets of #text and it will only apply in there.

That does not work - no change :-/
Maybe because of codly?

Hey @MasterM, welcome to the forum! I’ve changed your question post’s title to better fit our guidelines: How to post in the Questions category

For future posts, make sure your title is a question you’d ask to a friend about Typst. :wink:

Yes: applying #show raw.where(block: true): set par(leading: 2cm) (for example) does have an effect over unmodified raw blocks, but the codly package completely rewrites how raw blocks work, rendering that show rule ineffective.

I’ve looked around and Codly 1.0.0 does not appear to support changing line spacing: you can configure inset with #codly(inset: 1cm) for example, but that changes not only inset between lines but also between the text and the left and right borders.

It seems that the upcoming Codly 1.1.0 will support this: it appears to support syntax such as #codly(inset: (top: 1cm, bottom: 1cm)) from a quick look at the code, which would allow you to change only the vertical inset, effectively changing line spacing. However, it is currently unreleased. You could copy the (currently unreleased) code from its repository if you need it: GitHub - Dherse/codly

1 Like

Great find!
See also this bug inset adds space between lines not just around the border · Issue #27 · Dherse/codly · GitHub

A workaround is to wrap this specific block with
#no-codly[ …]

Thanks for the help!
I’m still learning typst… :-)

1 Like