How to remove lines around raw text block?

Please see image:

I wish:

  • START is not spaced from the paragraph by a line
  • AB and CD is spaced by a line.
  • XYZ is not spaced from the paragraph by a line

Also the raw behavior is weird, try adding a blank line below XYZ, there will be no change in output document. But adding another line will, but now “two lines in raw” is “one line in output raw”, this is not counting the line I wish to remove.

Thank you.

This is the source code:

#lorem(40)

#par(leading: 0.4em)[
```
START
 _   _      _ _        __        __         _     _ _ 
| | | | ___| | | ___   \ \      / /__  _ __| | __| | |
| |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | |
|  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_(_)
This is test, hello you
are not the man.
AB
```
]
```
CD
 _   _      _ _        __        __         _     _ _ 
| | | | ___| | | ___   \ \      / /__  _ __| | __| | |
| |_| |/ _ \ | |/ _ \   \ \ /\ / / _ \| '__| |/ _` | |
|  _  |  __/ | | (_) |   \ V  V / (_) | |  | | (_| |_|
|_| |_|\___|_|_|\___/     \_/\_/ \___/|_|  |_|\__,_(_)
This is test, hello you
are not the man.
XYZ
```
#lorem(40)

Oh no the markdown ruined my source code.
Please see source code here: https://pastebin.com/FGLpiTPz

These spaces come from block spacing that is automatically added before and after all kinds of blocks, including these code blocks. You can configure them with the spacing, above and below properties of the block element. To remove this spacing, you can use a show-set rule and set the values to the same value used as the paragraph’s leading (by default 0.65em):

#show raw.where(block: true): set block(
  above: 0.65em,
  below: 0.65em
)

You can’t currently use the spacing property in this case, as paragraphs themselves are also blocks and their block spacing would override the custom spacing you set. This may change with the next Typst version though.

With the above, the additional spacing vanishes, so as you already found out, you then need to append two line breaks in the raw block to end the resulting code with an empty line.

1 Like

Eric Thank you for the reply Im very noob. I put your code in, but it shows (IMAGE)


Please help

Also ABCD part is big typo from me, so it’s good thats its that way.
Thank you.

Oh sorry, the parameters are called above and below and not before and after!

1 Like