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

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

Arranges text, spacing and inline-level elements into a paragraph.

Although this function is primarily used in set rules to affect paragraph properties, it can also be used to explicitly render its argument onto a paragraph of its own.

Example

#set par(
  first-line-indent: 1em,
  spacing: 0.65em,
  justify: true,
)

We proceed by contradiction.
Suppose that there exists a set
of positive integers $a$, $b$, and
$c$ that satisfies the equation
$a^n + b^n = c^n$ for some
integer value of $n > 2$.

Without loss of generality,
let $a$ be the smallest of the
three integers. Then, we ...
Preview

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

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

The spacing between lines.

Leading defines the spacing between the bottom edge of one line and the top edge of the following line. By default, these two properties are up to the font, but they can also be configured manually with a text set rule.

By setting top edge, bottom edge, and leading, you can also configure a consistent baseline-to-baseline distance. You could, for instance, set the leading to 1em, the top-edge to 0.8em, and the bottom-edge to -0.2em to get a baseline gap of exactly 2em. The exact distribution of the top- and bottom-edge values affects the bounds of the first and last line.

Default:0.65em

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

The spacing between paragraphs.

Just like leading, this defines the spacing between the bottom edge of a paragraph's last line and the top edge of the next paragraph's first line.

When a paragraph is adjacent to a block that is not a paragraph, that block's above or below property takes precedence over the paragraph spacing. Headings, for instance, reduce the spacing below them by default for a better look.

Default:1.2em

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

Whether to justify text in its line.

Hyphenation will be enabled for justified paragraphs if the text function's hyphenate property is set to auto and the current language is known.

Note that the current alignment still has an effect on the placement of the last line except if it ends with a justified line break.

Default:false

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

How to determine line breaks.

When this property is set to auto, its default value, optimized line breaks will be used for justified paragraphs. Enabling optimized line breaks for ragged paragraphs may also be worthwhile to improve the appearance of the text.

Default:auto

View example
#set page(width: 207pt)
#set par(linebreaks: "simple")
Some texts feature many longer
words. Those are often exceedingly
challenging to break in a visually
pleasing way.

#set par(linebreaks: "optimized")
Some texts feature many longer
words. Those are often exceedingly
challenging to break in a visually
pleasing way.
Preview

first-line-indent
length
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The indent the first line of a paragraph should have.

Only the first line of a consecutive paragraph will be indented (not the first one in a block or on the page).

By typographic convention, paragraph breaks are indicated either by some space between paragraphs or by indented first lines. Consider reducing the paragraph spacing to the leading when using this property (e.g. using #set par(spacing: 0.65em)).

Default:0pt

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

The indent all but the first line of a paragraph should have.

Default:0pt

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

The contents of the paragraph.

定義
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.

line

A paragraph line.

This element is exclusively used for line number configuration through set rules and cannot be placed.

The numbering option is used to enable line numbers by specifying a numbering format.

View example
#set par.line(numbering: "1")

Roses are red. \
Violets are blue. \
Typst is there for you.
Preview

The numbering option takes either a predefined numbering pattern or a function returning styled content. You can disable line numbers for text inside certain elements by setting the numbering to none using show-set rules.

// Styled red line numbers.
#set par.line(
  numbering: n => text(red)[#n]
)

// Disable numbers inside figures.
#show figure: set par.line(
  numbering: none
)

Roses are red. \
Violets are blue.

#figure(
  caption: [Without line numbers.]
)[
  Lorem ipsum \
  dolor sit amet
]

The text above is a sample \
originating from distant times.
Preview

This element exposes further options which may be used to control other aspects of line numbering, such as its alignment or margin. In addition, you can control whether the numbering is reset on each page through the numbering-scope option.

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

How to number each line. Accepts a numbering pattern or function.

Default:none

View example
#set par.line(numbering: "I")

Roses are red. \
Violets are blue. \
Typst is there for you.
Preview

number-align
auto alignment
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The alignment of line numbers associated with each line.

The default of auto indicates a smart default where numbers grow horizontally away from the text, considering the margin they're in and the current text direction.

Default:auto

View example
#set par.line(
  numbering: "I",
  number-align: left,
)

Hello world! \
Today is a beautiful day \
For exploring the world.
Preview

number-margin
alignment
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The margin at which line numbers appear.

Note: In a multi-column document, the line numbers for paragraphs inside the last column will always appear on the end margin (right margin for left-to-right text and left margin for right-to-left), regardless of this configuration. That behavior cannot be changed at this moment.

Default:start

View example
#set par.line(
  numbering: "1",
  number-margin: right,
)

= Report
- Brightness: Dark, yet darker
- Readings: Negative
Preview

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

The distance between line numbers and text.

The default value of auto results in a clearance that is adaptive to the page width and yields reasonable results in most cases.

Default:auto

View example
#set par.line(
  numbering: "1",
  number-clearance: 4pt,
)

Typesetting \
Styling \
Layout
Preview

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

Controls when to reset line numbering.

Note: The line numbering scope must be uniform across each page run (a page run is a sequence of pages without an explicit pagebreak in between). For this reason, set rules for it should be defined before any page content, typically at the very start of the document.

Default:"document"

View example
#set par.line(
  numbering: "1",
  numbering-scope: "page",
)

First line \
Second line
#pagebreak()
First line again \
Second line again
Preview