How can I work around move apparently making blocks unbreakable?

Hello everyone !

I am creating my own template where I have environments which look like this:

where the background of the environment extends until the limit of the page

This is done by having a block which takes the width + 2*margin inside a move which moves the block on the left by margin:

#let environment(body, name: "Environment", subtitle: none, counter: auto, follows: false, boxed: true, margin: 2.5cm, scheme: light) = [
  #v(10pt)

  #move(block(
    width: 100% + 2*margin,
    inset: (left: margin, right: margin, top: 1em, bottom: 1em),
    fill: scheme.env.bg,
    stroke: (top: scheme.env.stroke, bottom: scheme.env.stroke),
    breakable: true,
    text(fill: scheme.env.fg)[
      #place(
        block(
          fill: scheme.env.bg,
          inset: .4em,
          radius: .2em,
          stroke: scheme.env.title-stroke,
        )[
          #text(
            name + if counter != none { " " + count(counter, follows) } + if subtitle != none { ":" },
            weight: if not follows { "bold" } else { "regular" },
            style: if follows { "italic" } else { "normal" },
            fill: scheme.env.fg
          )
          #if cite != none {
            subtitle
          }
        ],
        dx: -3em, dy: -1.8em
      )
    
      #body
    ]),
  dx: -margin)
]

But, this obviously makes the environment unbreakable, which create issues with long proofs:

My ideas on how to solve this would be:

  • To have the background being managed by a #place, which would be extremely hacky.
  • To have the page’s margin set to 0 and applying an inset to everything else.
  • ???

I wanted to ask the community to see if anyone had any other better solution or tips on how to proceed !

Hi @LyesSaadi,

I didn’t try it with your example as it does not work standalone, but I think it should work if you replace move with pad, with on the left -margin and on the right positive margin.

pad(
  left: -margin,
  right: margin,
  ...
)

Indeed ! Didn’t think of that ! Thanks ! It works like a charm !

Now the only thing remaining I’d like to solve would be to try having it extends the background to the end of the page when it crosses pages:

Or maybe having it redisplay the title on the upper border ?

But, at this point, I’m just bickering :stuck_out_tongue:.