#Typst equivalent hfill and vfill?

88 messages · Page 1 of 1 (latest)

graceful arch
#

What is the preferred Typst method for this LaTeX behavior: bob \hfill tom?

tired talon
#

#h(1fr)
#v(1fr)

#

if you mean space

graceful arch
#

Yes. Fill horizontal space, so that "bob" is left-aligned and "tom" is right-aligned.

tired talon
#

yeah

#

thats the one

graceful arch
#

awesome! thanks! i didn't realize the fractions worked like that.

tired talon
#

they basically divide the remaining space

#

among themselves

#

but

#

for h, box, v, it's just one element, only one "column"

#

so in practice 1fr just divides the remaining space by 1

graceful arch
#

ok, how would this work in a grid with 2 columns and 2 rows?

#

hm. is there a proper way to format code on discord?

tired talon
#

well, in that case you're better off using #align(left) and #align(right) on the individual cells

tired talon
#

```
stuff
```

graceful arch
#

ah, code fences

#

ok

#
grid(
    columns: 2,
    rows: 2,
    column-gutter: 0.3cm,
    row-gutter: 0.2cm,
    text(size: 10pt)[
      text-cell-1, 
      align(right, text-cell2),
      text-cell-3,
      text-cell-4
    ]
  )
#

i don't think the grid recognizes these as separate cells

tired talon
#

yeah

#

in fact the align etc you wrote has no effect

#

cuz [ ] is content

#

so it's like writing literally into the document

#

{ } is for code

#

so that's a step

#

but also

#

you're still wrapping everything in a single text

graceful arch
#

yeah, i thought so, is there a way to use "set" in a grid context?

tired talon
#

so grid only receives one argument

#

which is that text

tired talon
#

that will restrict the set to that scope

graceful arch
#

ok, that makes sense! thanks for being so helpful!

#

what's the preferred way to pass each "text-cell-1" separately to grid?

graceful arch
#

just to be clear, i did check the docs for grid(), but it wasn't obvious to me

tired talon
#

?render

#grid(columns: 2,
      [hey],
      [bye],
      [ok]
)
graceful arch
#

interesting, so square brackets signal arguments in grid

tired talon
#

no

#

they signal content

#

that's their only purpose

#

note that it's not loading the value from the variable hey

#

it's writing "hey"

#

it's like using "hey" to indicate a string

#

except that [hey] has markup

#

e.g. [*hey*] produces bold

#

and [#grid(...)] produces a grid

#

the thing here is that they are arguments to the grid function

#

separated by commas

#

when you wrote the text()[ ... ] there, only the text() was passed to the grid

graceful arch
#

that makes sense

tired talon
#

because the other things you wrote were arguments to text

graceful arch
#

right

tired talon
#

well , in the way they were written, they were literal text(due to being in [ ... ]), but even if fixed it still wouldnt have worked cuz of that

graceful arch
#

so, the square brackets are keeping the text grouped, so grid knows to send each group to each grid cell

tired talon
#

well

graceful arch
#

ha

tired talon
#

if by grouped you mean like stored or something

#

then i guess so yeah

graceful arch
#

don't kill me, i just learned about this language like 2 hours ago

tired talon
#

dont worry

#

lol

graceful arch
#

ha, ok, thanks for your help!

tired talon
#

no prob 👍

graceful arch
#

this is such a breath of fresh air compared to latex!

tired talon
#

yeah lol I assure you the syntax would have been much uglier

naive talon
tired talon
naive talon
tired talon
#

I think there could be some sort of “other commands” section

#

With things like this

naive talon
#

Good idea. Is there anything else that comes to mind? (i.e. other misc commands)

tired talon
#

oh

#

i just realized \vfill shows up

#

at the very end of the guide

#

but yeah it's a bit hidden in a larger paragraph

#

lol

#

definitely could use some table for that

#

it also shows up with pagebreak so maybe pagebreak could be one such command

#

maybe linebreaks too ( \\ -> \)

#

stuff like that

naive talon
#

I was just thinking about \\ and linebreak(). The guide still lists "no package manager available" so maybe I'll draft a micro-PR and we can fix also the other issues with the current doc page.

tired talon
#

yeah sure, although i guess the guide is technically still correct about that :p

#

so let's see, maybe they will update it when v0.6.0 releases

slim bloom