Is it possible to set fractional to follow container size?

The provided example doesn’t look like a real use case, and has several issues. The biggest one, is that the left outer column is wider than the 3 on the right. Also, why use stack in grid?

A better way would be to join the left manual column with 3 on the right row-wise:

#grid(
  columns: 4,
  ..array
    .zip(
      (
        rect(fill: aqua),
        none,
        rect(fill: navy),
      ),
      cells.chunks(3),
    )
    .flatten(),
)

#grid(
  columns: 4,
  ..(rect(fill: aqua), none, rect(fill: navy)).zip(cells.chunks(3)).flatten(),
)

Other methods
#layout(size => grid(
  columns: 2,
  grid(
    rect(fill: aqua),
    v(size.height - (measure(rect()).height + page.margin) * 2),
    rect(fill: navy),
  ),
  grid(columns: 3, ..cells),
))

#grid(
  columns: 2,
  grid(
    rect(fill: aqua),
    hide(rect()),
    rect(fill: navy),
  ),
  grid(columns: 3, ..cells),
)

Because grid is a flexible container, you can’t get its final size without measuring it beforehand. There are some hacks with place and labeled metadata to then put something together, but that is very complex and hard to understand/work with. “Follow” doesn’t give a concrete explanation of what behavior is expected. You can do box(width: 1fr) to stretch it 1 line wide, or use h(1fr) between text to put them into opposite corners. That is possible and common practice in some use cases.

2 Likes