Skip to main content

fit-to-height

Fit content to specified/remaining height.

Example: #utils.fit-to-height[BIG]

Parameters

height : length | fraction | relative    default: 1fr

The height to fit the content to. For example, height: 50% will fit the content to half of the slide height. If given as a fraction, it will be based on the available height after everything else is evaluated, similar to how fractional lengths behave for table column widths. Default is 1fr which means to fit the content to the full available rest height.

width : length | fraction | relative    default: auto

Will determine the width of the content after scaling. So, if you want the scaled content to fill half of the slide width, you can use width: 50%.

prescale-width : length | fraction | relative    default: none

Allows you to make Typst's layout assume that the given content is to be laid out in a container of a certain width before scaling. For example, you can use prescale-width: 200% assuming the slide's width is twice the original.

grow : bool    default: true

Indicates whether the content should be scaled up if it is smaller than the available height. Default is true.

shrink : bool    default: true

Indicates whether the content should be scaled down if it is larger than the available height. Default is true.

reflow : bool    default: true

Whether to allow text reflow when scaling with auto width. Default is true. Only works when width is auto and the body contains text.

force-height : bool    default: false

Whether to force the content to occupy the full height and not have it fill the available width. Only matters when reflow is true and width is auto. By default false. When text is reflowed, it makes sense to use as much width as possible and not force the content to be as tall as possible. Lines are naturally discrete and thus so are the possible scaling factors to fit the lines to the available height. Forcing the height may lead to the text not occupying the available width.

body : content

The content to fit. If two positional arguments are given, this will be height instead.

..args : arguments

For convenience and compatibility with older versions, passing in height as a positional argument is still supported. If two positional arguments are given, the first one is the width and the second one is the body.

Returns: content