Is there a way to handle horizontal block offsets over pagebreaks when using inside/outside margins?

So I have a margin style document and most things are working quite well. However, I want to be able to use the full-width for various things. I attached a sample of the document,

  • pink is the text area,
  • blue is the margin area,

To use the full width as text area I have a function which adds a block to the text area with an extended x range. This however places the text incorrectly when the full width text area is broken across pages.

Since one block is broken across alternate pages it causes the same block configuration to be used across both pages.

For right now I think just making the block unbreakable is probably the best. But it would be nice if there was a show rule that would just work on each of the broken instances of a block.

I also noticed that the author of marginilla had a similar not in the manual:

Note: when using an asyymetric page layout with setup.book: true, wideblocks which span across
pagebreaks are messy, because there is no way for the wideblock to detect the pagebreak and adjust ist
position after it.

Which probably means there is not a practical way to handle this quite yet.

1 Like

Just reading up on this due to an interest in blocks vs. pagebreaks (I’d like to style broken blocks a bit differently than unbroken.)

I found that this refers to marginalia – Typst Universe

I have no solution to add… but +1 for a way to make blocks sensitive to pagebreaks.

1 Like

I had some slight success using Meander. Since it allows you to let content flow between separate containers, I thought that might be promising. This is what I came up with:

#set page(paper: "a7")  // small page for testing

#import "@preview/meander:0.4.4"
#set page(margin: (outside: 3cm, inside: 1cm))

#lorem(30)

// for reference: just reproducing the problem

// #[
//   #show: pad.with(right: -2cm)
//   #show: block.with(width: 100%, stroke: 1pt)
//
//   #lorem(40)
// ]

// the Meander attempt
#{
  show: pad.with(right: -2cm)
  meander.reflow({
    import meander: *

    container(height: 2.7cm)  // I didn't manage avoiding the hard-coded height
    content[#lorem(40)]  // the content that flows between pages
    opt.overflow.custom(tt => {
      show: move.with(dx: -2cm)  // move the overflow on the second page according to the inside/outside difference
      tt.styled
    })
  })
}

#lorem(30)

The problem is that my Meander code doesn’t and couldn’t use block.with(width: 100%, stroke: 1pt) like I did in the reproduction. Meander (as far as I understand it) can’t look into the block and understand how to separate its content into two parts, so adding the block makes the whole content one big chunk.

Also, this works if there is a single pagebreak (using overflow); if the block spans two pagebreak, this approach also breaks down.

Nevertheless, maybe someone has an idea for how to get around that limitation, or someone else doesn’t need that styling.

1 Like