#How to fill vertical space in pages whenever possible

1 messages · Page 1 of 1 (latest)

mighty pumice
#

I have tried

#show heading: it => [#v(1fr) #v(1.3em) #it]

to introduce extra stretch at headings at least, but that also ends up introducing that stretch on pages that end in a pagebreak / the last page; unless I also add a #v(1000fr) at the end.
Is there some way to check how "full" a page is to switch between doing this and just leaving it be? Because I'd prefer that even over the "depends on pagebreaks / last page" thing that LaTeX does with \flushbottom (as far as I understand it)

Solution (thanks to PgSuper):

#show heading: it => [#v(1fr, weak:true) #v(1.3em) #it]

(didn't actually work, my tests were just broken)

Actual solution:

#let sequence = [abc #v(100fr)].func()
#let styled = [#set par(justify: true); foo].func()
#let addlastpage = (this, x) => if x.func() == sequence {
  [
    #for i in x.children.slice(0, x.children.len() - 1) {
      i
    }
    #this(this, x.children.last())
  ]
} else if x.func() == styled {
  styled(this(this, x.child), x.styles)
} else {
  [#x #v(1000fr)]
}

#show: x => addlastpage(addlastpage, x)

#show pagebreak: it => [#v(1000fr) #it]
#show heading: it => if it.level == 1 { [#pagebreak() #it] } else { [#v(1fr) #v(20pt) #it] }
lapis nacelle
#

perhaps you're looking for #v(1fr, weak: true)?

mighty pumice
#

Yup, that appears to mimic the behaviour I've seen in LaTeX. Thanks!

#

Which leaves the potential feature of somehow "checking" the used vertical space of a page / clamping a #v(1fr) between two values potentially, does something like that exist?

lapis nacelle
#

not atm

mighty pumice
#

layout seems to give me the page size, not the size of the page contents

lapis nacelle
#

but also checking the used vertical space is a bit of a problem

lapis nacelle
#

disclaimer: I wrote that function

#

:p

#

I tried to make it give that info too

mighty pumice
lapis nacelle
#

but it's... complicated

#

actually the compiler does keep track of how much space is available

#

but it's not a very consistent value because it actually considers the entire page

mighty pumice
#

Though at least the way I'd use it, it would be stable [since I'd check if more than x% is used, and stretch if yes - and if it's stretched it's 100% used; so it ends up working out] LOL

lapis nacelle
#

not "up to you"

#

so thats the first problem

#

the second problem is what you're thinking of, in the sense that you might create a somewhat circular dependency

#

to calculate #v(1fr), it uses that free space value it keeps track of, but to calculate based on the free space, well, you'd depend on the free space to determine the free space

#

that's kind of the weird stuff you do when using introspection features in Typst, hence why they are generally avoided unless no other option exists

#

and in particular I asked Laurenz , the main compiler maintainer, about it, and he was like, well, this would make it impossible to introduce future "smarter" behavior on pagebreak so yea

#

:p

#

though I guess "clamping" it doesnt sound that bad? idk

mighty pumice
lapis nacelle
mighty pumice
#

(typesetting suddenly became very interesting to me.... AFTER I wrote my bachelors thesis for some reason LMAO, I hope my questions aren't bothersome / annoying!)

lapis nacelle
#

either way I guess theres still room for discussion in that regard but for now it sounds a bit hard

lapis nacelle
mighty pumice
#

But yeah; thanks for your help & provided context!

#

🫀

lapis nacelle
#

i'll ping @last sundial in case he has some further input to give

mighty pumice
#

(I honestly really like a good amount of the design choices typst has taken so far [including the automatic reruns for stabilization, where in LaTeX it's just.... running the command a bunch which will take a lot of time], I think I'm going to retypeset my bachelors thesis in that just to see how that'll end up - I'm guessing much more sane than some of the stuff I did in LaTeX with macros....)

lapis nacelle
#

running the command a bunch which will take a lot of time
LaTeX does have automatic runs too through latexmk

#

I used that a lot in the past

#

but yeah it's slooow

#

😂

mighty pumice
#

Yeah; they just take a while LOL

lapis nacelle
#

yup

#

typst got it right with incrementality

mighty pumice
#

They take even longer if you add a bunch of external stuff that needs to run, like for building the glossary as an example

#

But tbf the end result looks very nice!

lapis nacelle
#

yeah lol

#

and worry not that we (contributors and also maintainers) are continuously making Typst better

#

you can take a look at #1175885362065834105 to see all the topics being formally discussed atm, related to improving Typst

#

in particular, im working at #1182377294682128445

#

but of course, it's not only the compiler which can make Typst better, but also packages, so yeah we're bound to just get more and more packages over time which hopefully try to solve little problems like those

mighty pumice
# lapis nacelle and worry not that we (contributors and also maintainers) are continuously makin...

Oh, I have definitely seen that!
No offense, but when I first found out about typst, I didn't really consider it ready for any usage and expected it to probably not pan out super well in comparison to the well entrenched LaTeX ecosystem (also iirc there was some missing feature, I think tables or something?)

Buuuut I was proven wrong in my pessimistic outlook! It actually does look very usable right now, and the few things where I'm not 100% sold yet [based on judging feature sets] are just minor nitpicks that wouldn't stop me from switching LOL

#

I'm very impressed!

mighty pumice
#

But it seems doable

lapis nacelle
#

you mean changing the syntax highlighting in the middle of a raw block?

mighty pumice
#

Yeah
My approach would be just... reading the innards of the raw block & constructing raw blocks split at the start & end of the highlighted block, such that the highlighted block can receive extra styling of some sort

#

Well, not changing highlighting necessary, but adding a box around it for example, or whatever might fit the current needs [including actual different highlighting than the normal syntax highlighting would do]

#

WAIT, I just realised... the weak: true didn't solve it, I forgot to remove the #v(1000fr) in my test :(

terse quartz
mighty pumice
#

OOOKAY, I finally figured out a solution

#

It's terrible though