Conversation
Updated unequivocal-ams/lib.typ to add sticky blocks around headings. Updated unequivocal-ams/template/main.typ to demonstrate sticky headings. With the previous template, the "REFERENCES" heading is orphaned. With the new template, it is no longer orphaned. To see the updated behavior, you'll need to point the import to the lib.typ file directly, instead of loading from @Preview.
|
Thank you for the fix. Can you just revert the changes made to |
| set align(center) | ||
| set text(size: normal-size) | ||
| smallcaps[ | ||
| block(sticky: true, smallcaps[ |
There was a problem hiding this comment.
A block but without sticky: true should be enough since there is a built-in show heading: set block(sticky: true).
There was a problem hiding this comment.
You are correct, wrapping in a plane block achieves the same effect. I'll make this change.
| let styled = if it.level == 2 { strong } else { emph } | ||
| styled(it.body + [. ]) | ||
| h(7pt, weak: true) | ||
| block(sticky: true, { |
There was a problem hiding this comment.
The block breaks the intent of the level 2+ headings being run-in. Moreover, with the v(11pt, weak: true) and similar being inside of the block now, the spacing is not the same as before (though I cannot test it right now). Overall, the change set feels not well-tested to me.
Unfortunately, I just noticed, the run-in style was already previously broken in 019502e. :/
There was a problem hiding this comment.
I agree. Moving the vertical space outside of the block restores the prior spacing while preserving the sticky effect.
Not sure about the intent of the horizontal space at the end of the block. Should this be outside the block as well. Do you have an example that demonstrates the intended effect?
There was a problem hiding this comment.
The intended effect can be observed by reverting 019502e. The heading is supposed to be run-in, i.e. in line with the following text. The h is supposed to add a little space between heading and contents.
It should look roughly like this:
end of the previous paragraph ...
A section. And here are its contents.
There was a problem hiding this comment.
This run-in style is fundamentally incompatible with using a block. But it's also inherently sticky, so that shouldn't be an issue per se.
Making headings sticky to avoid orphaned headings.
Typst headings are wrapped in sticky blocks by default to avoid orphaned headings. The show rule that configures the AMS style headings access the body element directly, which removed the sticky behavior. This updates adds a sticky block into the show rule to restore the default behavior. This technique is recommended in the Typst documentation: https://typst.app/docs/reference/model/heading/
Changes:
Updated unequivocal-ams/lib.typ to add sticky blocks around headings.
Updated unequivocal-ams/template/main.typ to demonstrate sticky headings. With the previous template, the "REFERENCES" heading is orphaned. With the new template, it is no longer orphaned. To see the updated behavior, you'll need to point the import to the lib.typ file directly, instead of loading from @Preview.