Pablo-Gonzalez-Calderon / showybox-package

A Typst package for creating colorful and customizable boxes
MIT License
50 stars 5 forks source link

breakable showybox with figures #23

Closed Marmare314 closed 11 months ago

Marmare314 commented 11 months ago

Hey, I wanted to include a predefined style for using showybox in lemmify, but I ran into an issue.

I would expect this box to break into the second column, but it does not.

#import "@preview/showybox:2.0.0": showybox
#set page(width: 500pt, height: 100pt, margin: 10pt)
#show: columns.with(2)
#show figure: it => showybox(breakable: true, it.body)
#figure(lorem(50))

image

Using a plain block works fine.

#set page(width: 500pt, height: 100pt, margin: 10pt)
#show: columns.with(2)
#show figure: it => block(breakable: true, stroke: 1pt, it.body)
#figure(lorem(50))

showybox

I find this quite confusing since showybox(breakable: true, lorem(50)) also works fine, so it has to be something about the figure.

Pablo-Gonzalez-Calderon commented 11 months ago

Hmmm. It seems strange to me 🤔

However, I've never tried using a showybox() inside a figure before. Maybe there's some outer block in the showybox (there's, at least, one outer block outside the showybox, used for aligning and spacing around it) that "stops" the breakable behaviour if it's placed inside a non-explicit breakable container --or something like that.

I'm gonna try to fix this during the day.

Thank you for reporting this! 😁

Pablo-Gonzalez-Calderon commented 11 months ago

I'm not really glad of how I found the solution, but I just added the breakable property to any container that could be causing the error, and it worked 😶

To be specific the containers were: outer "align-block" (for setting the correct align of the showybox, given by align option), body's main block (which contains all the body sections), and each body section's block (that, as it names says, contains only one section of the body).

Now this code seems to work perfectly --and all the previous code also works fine, so I think this Issue is solved

#set page(width: 500pt, height: 100pt, margin: 10pt)
#show: columns.with(2)
#show figure: it => showybox(
    title: "Theorem: " + lorem(10),
    breakable: true,
    shadow: (:),
    title-style: (boxed-style:  (:)),
    it.body
)
#figure(lorem(50))

image

Tell me if this works for you now using the version 2.0.1 locally (as it is not yet published in Typst packages' repo), to mark this as closed