Skip to content

Support fraction as block height #4220

Closed

Description

@sijow

Description

It would be nice to have block(height: 1fr) just work, at least for non-breakable blocks. Currently it throws an error because fractional height is not supported. A workaround proposed on discord is

#context place(block(
    height: (locate(<end>), here()).map(l=> l.position().y).fold(
        l=> r=> l - r,
        (f, r)=> f(r),
    ),
    width: 100%,
    fill: red,
))
#v(1fr)<end>
#pagebreak(weak: true)

which is not easy to come up with.

Using 1fr in a single-cell grid doesn't work because of #2571.

Other workarounds involving computations with the current location and page margin are not ideal since it's difficult to get the current margin in a way that works in all cases (margin: auto, margin: 1cm, margin: (left: 1cm) and the worst: margin: 1em).

Use Case

A typical use case is to make an element use the remaining space on a page (see here, here and here). For example I wanted to draw a grid with cetz in the space remaining under a question (to emulate grid paper).

Activity

  1. added
    feature request
    on May 22, 2024
  2. added
    layout
    on May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestlayout

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions