Confusion about syntax making formulae page-breakable

Hello! To make a formula page-breakable, currently the syntax is

#show math.equation: set block(breakable: true)

as described in Make block equations breakable by EpicEricEE · Pull Request #4226 · typst/typst · GitHub .

Why isn’t it

#set math.equation(breakable: true)

? If breakable is a parameter of math.equation, it would be more easy to adjust this setting for individual equations.

This is due to one of Typst’s design principles:

Power through Composability: There are two ways to make something flexible: Have a knob for everything or have a few knobs that you can combine in many ways. Typst is designed with the second way in mind. We provide systems that you can compose in ways we’ve never even thought of. TeX is also in the second category, but it’s a bit low-level and therefore people use LaTeX instead. But there, we don’t really have that much composability. Instead, there’s a package for everything (\usepackage{knob}).

Equations are not what you break; equations are rendered in blocks, and blocks can be made breakable. It may seem counterintuitive when you get started (because you need to learn about show-set), but in the long run this makes the system easier to learn because there’s fewer things to learn in total: breakable is only present on block, not raw, figure, equation, …

(that’s not 100% true; for example, there’s table.cell.breakable. I assume if the team found a way, they’d prefer to also get rid of this.)

You may ask/argue, if all of these had their own breakable property, wouldn’t it still effectively be the same amount of learning required, because it’s consistent anyway? I guess, but then the following:

#set block(breakable: true)

would instead need to be written like this:

#set block(breakable: true)
#set math.equation(breakable: true)
#set raw(breakable: true)
#set figure(breakable: true)

… and worse: if a new element was added, the code would become outdated. Once we get custom elements, it would be simply impossible to write a rule that makes all things breakable, because you can’t know all breakable things to begin with.

Making everything breakable may not be desirable anyway, but I’m treating this as a placeholder for other customizations—say, #show link: set text(font: ...) vs. #set link(font: ...)— where the same arguments hold. You end up with more options if you make the features you provide composable, and yet there are fewer features in total to learn about.

1 Like

So a block equation has a hidden block in it?

That’s not what I expected. In the value I don’t see any blocks.

As a fun experiment, you can add #set block(stroke: 0.5pt + red) to the top of your document and see a whole lot of blocks being highlighted in red: in headings, grids and other places.

2 Likes