注意 当サイトは、Typst v0.12.0 公式ドキュメントを、日本語コミュニティが非公式に翻訳したものです。誤訳・未訳・古い情報が含まれている可能性があるため、公式ドキュメント との併用を推奨します。このサイトの内容に誤りを発見された方は、GitHubリポジトリまでご報告を頂けましたら幸いです。我々のコミュニティにご興味のある方は、ぜひ非公式Discordサーバー「くみはんクラブ」にご参加ください。
Warning: This site provides an unofficial translation of the Typst v0.12.0 documentation by the Japanese Community. Please note that there may be some inaccuracies, untranslated sections or outdated information. We highly recommend referring to the latest official documentation as well. If you find any errors in the content, please let us know through our GitHub repository. If you are interested in our community, feel free to join our unofficial Discord server, “Kumihan Club.”
Typst ドキュメント日本語版

box Element
Element functions can be customized with set and show rules.

An inline-level container that sizes content.

All elements except inline math, text, and boxes are block-level and cannot occur inside of a paragraph. The box function can be used to integrate such elements into a paragraph. Boxes take the size of their contents by default but can also be sized explicitly.

Example

Refer to the docs
#box(
  height: 9pt,
  image("docs.svg")
)
for more information.
Preview

引数
Parameters are the inputs to a function. They are specified in parentheses after the function name.

width
auto relative fraction
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The width of the box.

Boxes can have fractional widths, as the example below demonstrates.

Note: Currently, only boxes and only their widths might be fractionally sized within paragraphs. Support for fractionally sized images, shapes, and more might be added in the future.

Default:auto

View example
Line in #box(width: 1fr, line(length: 100%)) between.
Preview

height
auto relative
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The height of the box.

Default:auto

baseline
relative
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

An amount to shift the box's baseline by.

Default:0% + 0pt

View example
Image: #box(baseline: 40%, image("tiger.jpg", width: 2cm)).
Preview

fill
none color gradient pattern
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The box's background color. See the rectangle's documentation for more details.

Default:none

stroke
none length color gradient stroke pattern dictionary
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The box's border color. See the rectangle's documentation for more details.

Default:(:)

radius
relative dictionary
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

How much to round the box's corners. See the rectangle's documentation for more details.

Default:(:)

inset
relative dictionary
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

How much to pad the box's content.

Note: When the box contains text, its exact size depends on the current text edges.

Default:(:)

View example
#rect(inset: 0pt)[Tight]
Preview

outset
relative dictionary
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

How much to expand the box's size without affecting the layout.

This is useful to prevent padding from affecting line layout. For a generalized version of the example below, see the documentation for the raw text's block parameter.

Default:(:)

View example
An inline
#box(
  fill: luma(235),
  inset: (x: 3pt, y: 0pt),
  outset: (y: 3pt),
  radius: 2pt,
)[rectangle].
Preview

clip
bool
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

Whether to clip the content inside the box.

Clipping is useful when the box's content is larger than the box itself, as any content that exceeds the box's bounds will be hidden.

Default:false

View example
#box(
  width: 50pt,
  height: 50pt,
  clip: true,
  image("tiger.jpg", width: 100pt, height: 100pt)
)
Preview

body
none content
Positional
Positional parameters are specified in order, without names.
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The contents of the box.

Default:none