Why does using layout() mess with the spacing between paragraphs, and how do i prevent this?

Hi all,

I’m trying to create a function that requires the use of the layout function.

In my specific document i want to remove the space between two paragraphs. This I can do using the above and below parameters of block.

When i use these blocks without layout this gives the expected result.

When i add a function call that uses layout(size => {body}) it adds space between the 2 blocks.

See the entire code below:

#let simple-function1(body) = layout(size => {body})
#let simple-function2(body) = layout(size => {body})

#let my-background = rgb("#099CACAA")
#let my-title-block = block(below: 0pt,inset:(y:1em,left:0pt,right:1em),fill:my-background,text(fill:white,"Profile"))
#let my-profile-content = block(above: 0pt,inset:(y:1em,x:0pt),fill:my-background,stroke:0pt,text(fill:white,lorem(60)))


#my-title-block
#my-profile-content

#simple-function1(my-title-block)
#simple-function2(my-profile-content)

this results in:

How can i use layout and still be able to remove the space between my-title-block and my-profile-content?

Any help is appreciated.

Hi, I think layout adds its own block so you need to change the default block spacing before the layout call:

#let simple-function(body) = {
  set block(spacing: 0pt)
  layout(size => {body})
}

Alternatively, you can add weak vertical spacing (of size zero) to remove the unwanted spacing:

#let simple-function(body) = layout(size => body) + v(0pt, weak: true)
2 Likes

thanks @sijo,
The set block did the trick.

1 Like