情報アイコン
情報 / Info
当サイトは、Typst GmbHの許諾を得て、日本語コミュニティ「Typst Japan Community」がTypst vdev.3ed92cdeの公式ドキュメントを翻訳したものです。誤訳や古い情報が含まれている可能性があるため、公式ドキュメントとの併用を推奨します。翻訳の改善やサイトの機能向上について、GitHubでのIssueやPull Requestを歓迎します。コミュニティにご興味のある方はDiscordサーバー「くみはんクラブ」にぜひご参加ください。
This site provides a Japanese translation of the Typst vdev.3ed92cde documentation maintained by the "Typst Japan Community" with permission from Typst GmbH. We recommend using this alongside the official documentation. We welcome contributions through Issues and Pull Requests on our GitHub repository for both translation improvements and website enhancements. Feel free to join our Discord server "Kumihan Club".
言語アイコン
翻訳率
21%
言語アイコン
翻訳済み

このページは日本語に翻訳済みです。

relative

A length in relation to some known length.

This type is a combination of a length with a ratio. It results from addition and subtraction of a length and a ratio. Wherever a relative length is expected, you can also use a bare length or ratio.

Relative to the page

A common use case is setting the width or height of a layout element (e.g., block, rect, etc.) as a certain percentage of the width of the page. Here, the rectangle's width is set to 25%, so it takes up one fourth of the page's inner width (the width minus margins).

#rect(width: 25%)
Preview

Bare lengths or ratios are always valid where relative lengths are expected, but the two can also be freely mixed:

#rect(width: 25% + 1cm)
Preview

If you're trying to size an element so that it takes up the page's full width, you have a few options (this highly depends on your exact use case):

  1. Set page margins to 0pt (#set page(margin: 0pt))
  2. Multiply the ratio by the known full page width (21cm * 69%)
  3. Use padding which will negate the margins (#pad(x: -2.5cm, ...))
  4. Use the page background or foreground field as those don't take margins into account (note that it will render the content outside of the document flow, see place to control the content position)

Relative to a container

When a layout element (e.g. a rect) is nested in another layout container (e.g. a block) instead of being a direct descendant of the page, relative widths become relative to the container:

#block(
  width: 100pt,
  fill: aqua,
  rect(width: 50%),
)
Preview

Scripting

You can multiply relative lengths by ratios, integers, and floats.

A relative length has the following fields:

  • length: Its length component.
  • ratio: Its ratio component.
#(100% - 50pt).length \
#(100% - 50pt).ratio
Preview
原文(英語)を開く
右矢印アイコン

検索