注意 当サイトは、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 ドキュメント日本語版

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

Places content relatively to its parent container.

Placed content can be either overlaid (the default) or floating. Overlaid content is aligned with the parent container according to the given alignment, and shown over any other content added so far in the container. Floating content is placed at the top or bottom of the container, displacing other content down or up respectively. In both cases, the content position can be adjusted with dx and dy offsets without affecting the layout.

The parent can be any container such as a block, box, rect, etc. A top level place call will place content directly in the text area of the current page. This can be used for absolute positioning on the page: with a top + left alignment, the offsets dx and dy will set the position of the element's top left corner relatively to the top left corner of the text area. For absolute positioning on the full page including margins, you can use place in page.foreground or page.background.

Examples

#set page(height: 120pt)
Hello, world!

#rect(
  width: 100%,
  height: 2cm,
  place(horizon + right, square()),
)

#place(
  top + left,
  dx: -5pt,
  square(size: 5pt, fill: red),
)
Preview

Effect on the position of other elements

Overlaid elements don't take space in the flow of content, but a place call inserts an invisible block-level element in the flow. This can affect the layout by breaking the current paragraph. To avoid this, you can wrap the place call in a box when the call is made in the middle of a paragraph. The alignment and offsets will then be relative to this zero-size box. To make sure it doesn't interfere with spacing, the box should be attached to a word using a word joiner.

For example, the following defines a function for attaching an annotation to the following word:

#let annotate(..args) = {
  box(place(..args))
  sym.wj
  h(0pt, weak: true)
}

A placed #annotate(square(), dy: 2pt)
square in my text.
Preview

The zero-width weak spacing serves to discard spaces between the function call and the next word.

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

alignment
auto alignment
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.

Relative to which position in the parent container to place the content.

When float is false and no vertical alignment is specified, the content is placed at the current position on the vertical axis.

Default:start

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

Relative to which containing scope something is placed.

The parent scope is primarily used with figures and, for this reason, the figure function has a mirrored scope parameter. Nonetheless, it can also be more generally useful to break out of the columns. A typical example would be to create a single-column title section in a two-column document.

Note that parent-scoped placement is currently only supported if float is true. This may change in the future.

Default:"column"

View example
#set page(height: 150pt, columns: 2)
#place(
  top + center,
  scope: "parent",
  float: true,
  rect(width: 80%, fill: aqua),
)

#lorem(25)
Preview

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

Whether the placed element has floating layout.

Floating elements are positioned at the top or bottom of the parent container, displacing in-flow content. They are always placed in the in-flow order relative to each other, as well as before any content following a later place.flush element.

Default:false

View example
#set page(height: 150pt)
#let note(where, body) = place(
  center + where,
  float: true,
  clearance: 6pt,
  rect(body),
)

#lorem(10)
#note(bottom)[Bottom 1]
#note(bottom)[Bottom 2]
#lorem(40)
#note(top)[Top]
#lorem(10)
Preview

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

The spacing between the placed element and other elements in a floating layout.

Has no effect if float is false.

Default:1.5em

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

The horizontal displacement of the placed content.

Default:0% + 0pt

View example
#set page(height: 100pt)
#for i in range(16) {
  let amount = i * 4pt
  place(center, dx: amount - 32pt, dy: amount)[A]
}
Preview

This does not affect the layout of in-flow content. In other words, the placed content is treated as if it were wrapped in a move element.

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

The vertical displacement of the placed content.

This does not affect the layout of in-flow content. In other words, the placed content is treated as if it were wrapped in a move element.

Default:0% + 0pt

body
content
RequiredPositional
Positional parameters are specified in order, without names.

The content to place.

Definitions
Functions and types and can have associated definitions. These are accessed by specifying the function or type, followed by a period, and then the definition's name.

flush

Asks the layout algorithm to place pending floating elements before continuing with the content.

This is useful for preventing floating figures from spilling into the next section.

place.flush(
) -> content
View example
#lorem(15)

#figure(
  rect(width: 100%, height: 50pt),
  placement: auto,
  caption: [A rectangle],
)

#place.flush()

This text appears after the figure.
Preview