typst / typst

A new markup-based typesetting system that is powerful and easy to learn.
https://typst.app
Apache License 2.0
29.16k stars 792 forks source link

Add flush element #4141

Closed bluebear94 closed 3 days ago

bluebear94 commented 2 weeks ago

See #4134.

MDLC01 commented 2 weeks ago

I think this should be mentioned on the documentation for place as well.

tingerrr commented 2 weeks ago

Hey there, this looks great, I figured I'd give it my two cents:

I think this fits better as a sub-element of place as this primarily interacts with place(float: true) elements and nothing else. Similar to figure.caption, it makes no sense to define caption by itself.

I also think this should be included in the default heading show rule, here's my thinking:

bluebear94 commented 2 weeks ago

I think this fits better as a sub-element of place as this primarily interacts with place(float: true) elements and nothing else. Similar to figure.caption, it makes no sense to define caption by itself.

I disagree. figure.caption is namespaced within figure because it’s present within a figure element. flush, on the other hand, is not (usually) used within a place element.

I also think this should be included in the default heading show rule

I agree with this, though.

tingerrr commented 2 weeks ago

I disagree. figure.caption is namespaced within figure because it’s present within a figure element. flush, on the other hand, is not (usually) used within a place element.

I don't think this distinction matters all that much in this case, the semantic relationship is still there, a flush element on its own is useless, it's only useful when used with place(float: true) elements, a subset of place elements at large. assert.eq is also scoped within assert, but used "outside" of it, as it's not an element of course, but it is semantically related to assert (as well as other examples of function scopes).

PgBiel commented 2 weeks ago

I took a quick look, and at first I think this should work with figure.placement too (please add tests for that), which would, in theory, oppose the argument that this would exclusively affect place. However, I'm also a bit torn on whether this (relatively) small feature should warrant another name in the global namespace. Maybe it's not too bad since #4038 got merged, but worth considering.

Personally I'd be ok with something like #place.flush(), but I'd like to see other suggestions as well.

tingerrr commented 2 weeks ago

I took a quick look, and at first I think this should work with figure.placement too (please add tests for that), which would, in theory, oppose the argument that this would exclusively affect place.

Well, the implementation of figure simply wraps itself in a place if it has a non-none placement field.

bluebear94 commented 2 weeks ago

Another thing to note is that ‘flush’ has another plausible meaning in the context of typesetting (‘not sticking out’), so perhaps putting it in place’s namespace might be preferable.

laurmaedje commented 2 weeks ago

My first instinct was also that it should maybe be moved into the place namespace.

laurmaedje commented 6 days ago

I also think this should be included in the default heading show rule

I'm not so sure about this. In a two-column paper, you might have lots of short sections and figures should float past them, I think.

Do we know what LaTeX does by default?

cc: LaTeX and Paper guru @Enivex

Enivex commented 6 days ago

I also think this should be included in the default heading show rule

I'm not so sure about this. In a two-column paper, you might have lots of short sections and figures should float past them, I think.

Do we know what LaTeX does by default?

cc: LaTeX and Paper guru @Enivex

I don't think LaTeX does anything special here. Flushing figures for every heading seems problematic to me.

PgBiel commented 5 days ago

I think we shouldn't force flushing on all headings by default (should be opt-in through show rules).

I additionally don't remember this being the case in LaTeX when I last used it (...which was a long while ago, so take that with a grain of salt :smile:)

tingerrr commented 5 days ago

Yeah, that probably makes sense, in the end it also makes opting out easier.

laurmaedje commented 3 days ago

Thanks!