Can blocks be linked and overflow into other blocks?

I’ve made an issue about this a while ago:

And they said this is planned, but not possible yet.
(It might be a good idea to react to the issue with :+1: or something to show that this is a wanted feature)


Expanding upon @Andrew’s workaround:

#let split(this, rest) = {
  let this = this
  let rest = rest

  if this.has("text") {
    let (..a, b) = this.text.split()
    this = [#a.join(" ")]
    rest = [#b #rest]
  } else if this.has("body") {
    let (a, b) = split(this.body, rest)
    this = (this.func())(a)
    rest = (this.func())(b)
  } else if this.has("children") {
    let (..a, b) = this.children
    let (ba, brest) = split(b, rest)
    this = { a.join(); ba }
    rest = brest
  } else {
    panic("don’t know how to handle this")
  }

  return (this, rest)
}

#let two-boxes(size: 3cm, text) = {
  let remaining = state("remaining", [])
  set square(size: size)
  square(layout(size => {
    let this = [#text]
    let rest = []
    while measure(this, width: size.width).height > size.height {
      (this, rest) = split(this, rest)
    }
    this
    if par.justify { linebreak(justify: true) }
    remaining.update(rest)
  }))
  rotate(-15deg, square(context remaining.get()))
}

  • This is very fragile
  • It does not handle emph well, as it adds the surrounding this.func() repeatedly, which in the case of emph leads to the overflown words alternating between italics like this.
1 Like