注意 当サイトは、Typst v0.11.1 公式ドキュメントを、日本語コミュニティが非公式に翻訳したものです。誤訳・未訳・古い情報が含まれている可能性があるため、公式ドキュメント との併用を推奨します。このサイトの内容に誤りを発見された方は、GitHubリポジトリまでご報告を頂けましたら幸いです。我々のコミュニティにご興味のある方は、ぜひ非公式Discordサーバー「くみはんクラブ」にご参加ください。
Warning: This site provides an unofficial translation of the Typst v0.11.1 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 ドキュメント日本語版

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

Raw text with optional syntax highlighting.

Displays the text verbatim and in a monospace font. This is typically used to embed computer code into your document.

Example

Adding `rbx` to `rcx` gives
the desired result.

What is ```rust fn main()``` in Rust
would be ```c int main()``` in C.

```rust
fn main() {
    println!("Hello World!");
}
```

This has ``` `backticks` ``` in it
(but the spaces are trimmed). And
``` here``` the leading space is
also trimmed.
Preview

Syntax

This function also has dedicated syntax. You can enclose text in 1 or 3+ backticks (`) to make it raw. Two backticks produce empty raw text. This works both in markup and code.

When you use three or more backticks, you can additionally specify a language tag for syntax highlighting directly after the opening backticks. Within raw blocks, everything (except for the language tag, if applicable) is rendered as is, in particular, there are no escape sequences.

The language tag is an identifier that directly follows the opening backticks only if there are three or more backticks. If your text starts with something that looks like an identifier, but no syntax highlighting is needed, start the text with a single space (which will be trimmed) or use the single backtick syntax. If your text should start or end with a backtick, put a space before or after it (it will be trimmed).

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

text
str
RequiredPositional
Positional parameters are specified in order, without names.

The raw text.

You can also use raw blocks creatively to create custom syntaxes for your automations.

View example
// Parse numbers in raw blocks with the
// `mydsl` tag and sum them up.
#show raw.where(lang: "mydsl"): it => {
  let sum = 0
  for part in it.text.split("+") {
    sum += int(part.trim())
  }
  sum
}

```mydsl
1 + 2 + 3 + 4 + 5
```
Preview

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

Whether the raw text is displayed as a separate block.

In markup mode, using one-backtick notation makes this false. Using three-backtick notation makes it true if the enclosed content contains at least one line break.

Default:false

View example
// Display inline code in a small box
// that retains the correct baseline.
#show raw.where(block: false): box.with(
  fill: luma(240),
  inset: (x: 3pt, y: 0pt),
  outset: (y: 3pt),
  radius: 2pt,
)

// Display block code in a larger block
// with more padding.
#show raw.where(block: true): block.with(
  fill: luma(240),
  inset: 10pt,
  radius: 4pt,
)

With `rg`, you can search through your files quickly.
This example searches the current directory recursively
for the text `Hello World`:

```bash
rg "Hello World"
```
Preview

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

The language to syntax-highlight in.

Apart from typical language tags known from Markdown, this supports the "typ" and "typc" tags for Typst markup and Typst code, respectively.

Default:none

View example
```typ
This is *Typst!*
```

This is ```typ also *Typst*```, but inline!
Preview

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

The horizontal alignment that each line in a raw block should have. This option is ignored if this is not a raw block (if specified block: false or single backticks were used in markup mode).

By default, this is set to start, meaning that raw text is aligned towards the start of the text direction inside the block by default, regardless of the current context's alignment (allowing you to center the raw block itself without centering the text inside it, for example).

Default:start

View example
#set raw(align: center)

```typc
let f(x) = x
code = "centered"
```
Preview

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

One or multiple additional syntax definitions to load. The syntax definitions should be in the sublime-syntax file format.

Default:()

View example
#set raw(syntaxes: "SExpressions.sublime-syntax")

```sexp
(defun factorial (x)
  (if (zerop x)
    ; with a comment
    1
    (* x (factorial (- x 1)))))
```
Preview

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

The theme to use for syntax highlighting. Theme files should be in the in the tmTheme file format.

Applying a theme only affects the color of specifically highlighted text. It does not consider the theme's foreground and background properties, so that you retain control over the color of raw text. You can apply the foreground color yourself with the text function and the background with a filled block. You could also use the xml function to extract these properties from the theme.

Default:none

View example
#set raw(theme: "halcyon.tmTheme")
#show raw: it => block(
  fill: rgb("#1d2433"),
  inset: 8pt,
  radius: 5pt,
  text(fill: rgb("#a2aabc"), it)
)

```typ
= Chapter 1
#let hi = "Hello World"
```
Preview

tab-size
int
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The size for a tab stop in spaces. A tab is replaced with enough spaces to align with the next multiple of the size.

Default:2

View example
#set raw(tab-size: 8)
```tsv
Year	Month	Day
2000	2	3
2001	2	1
2002	3	10
```
Preview

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.

line

A highlighted line of raw text.

This is a helper element that is synthesized by raw elements.

It allows you to access various properties of the line, such as the line number, the raw non-highlighted text, the highlighted text, and whether it is the first or last line of the raw block.

raw.line() -> content

number
int
RequiredPositional
Positional parameters are specified in order, without names.

The line number of the raw line inside of the raw block, starts at 1.

count
int
RequiredPositional
Positional parameters are specified in order, without names.

The total number of lines in the raw block.

text
str
RequiredPositional
Positional parameters are specified in order, without names.

The line of raw text.

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

The highlighted raw text.