How to merge Adjacent Blocks, or Adjacent Show Rule Targets?

I am trying to achieve something like this. One page with a fancy box around both columns and a central border between them.
Everything that goes off the page gets a similar fancy box so you can tell it goes with the original content.

#set page(width: 300pt, height: 300pt, margin: 10pt, columns: 2)
#figure(placement:top,scope:"parent",[
  #text(size:18pt, "TITLE")
  #place(top+center, dy:40pt, line(length: 80%, angle:90deg, stroke:red))  
])
#place(top+left, float:false, [
  #box(stroke:red, width:280pt, height: 240pt, outset: 4pt)
])
#let carr = ()
#for idx in range(10) {
  carr.push(block(width:100%, height:100pt, breakable: false, stroke:blue,[Content #idx]))
}

#for c in carr.slice(0,4) {
  c
}
#block(width: 100%, stroke:red, outset: 4pt, [
#for c in carr.slice(4) {
  c
}
])

I have figured out how to apply styling to just the items that are on the following pages using a show rule, but I would like to merge the blocks so you get a consistent border.

#set page(width: 300pt, height: 300pt, margin: 20pt, columns: 2)
//#let p = counter("_page")
//#context p.update(here().position().page)
#show label("_c"): it => {
//      if(it.location().page() != p.get().at(0)){
      box(stroke:red+2pt, outset:12pt, it)
//    } else {
//      box(it)
//    }
}
#let content_array = (box(width:100pt, [Value]),)*3
#for (idx,c) in content_array.enumerate() {
  block([#c #label("_c")])
}

If I could place a single block around all the content with labels that meet the condition, that would work. Because it’s done by for loop, I know the content that meets the condition will always be sequential, with nothing else in-between.

Hey @Tetragramm, 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, please make sure your title is a question you’d ask to a friend about Typst. :wink:

1 Like

Hi there! Welcome to the forum.
To be honest I’m not really sure if I understood your question correctly, but I think the grid function might be what you are looking for.
An example would be:

#grid(
  columns: 2,
  rows: 2,
  stroke: blue,
  inset: 1em,
  lorem(150),
  lorem(170),
  lorem(100),
  lorem(110) 
)

The inset is needed to get some distance between the grid element border and the text.
The parameter gutter can add distance between the cells. You can also specify gutter for just the rows or just the columns using “column-gutter” or “row-gutter”.
If this didn’t answer your question or you have a follow up question, don’t hesitate to ask again.

I’m afraid you did not understand the question. At 4 months old, the project has long since moved on from this problem (which I suspect to be not possible with the current typst).

If you are simply curious about solving it, I suggest starting by looking at the sample code that produces the desired layout manually. That is not something that can be done with a single grid.