情報アイコン
情報 / 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%
言語アイコン
翻訳済み

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

ref
要素関数
要素関数
要素関数はsetルールやshowルールでカスタマイズできます。

A reference to a label or bibliography.

Takes a label and cross-references it. There are two kind of references, determined by its form: "normal" and "page".

The default, a "normal" reference, produces a textual reference to a label. For example, a reference to a heading will yield an appropriate string such as "Section 1" for a reference to the first heading. The word "Section" depends on the lang setting and is localized accordingly. The references are also links to the respective element. Reference syntax can also be used to cite from a bibliography.

As the default form requires a supplement and numbering, the label must be attached to a referenceable element. Referenceable elements include headings, figures, equations, and footnotes. To create a custom referenceable element like a theorem, you can create a figure of a custom kind and write a show rule for it. In the future, there might be a more direct way to define a custom referenceable element.

If you just want to link to a labelled element and not get an automatic textual reference, consider using the link function instead.

A "page" reference produces a page reference to a label, displaying the page number at its location. You can use the page's supplement to modify the text before the page number. Unlike a "normal" reference, the label can be attached to any element.

Example

#set page(numbering: "1")
#set heading(numbering: "1.")
#set math.equation(numbering: "(1)")

= Introduction <intro>
Recent developments in
typesetting software have
rekindled hope in previously
frustrated researchers. @distress
As shown in @results (see
#ref(<results>, form: "page")),
we ...

= Results <results>
We discuss our approach in
comparison with others.

== Performance <perf>
@slow demonstrates what slow
software looks like.
$ T(n) = O(2^n) $ <slow>

#bibliography("works.bib")
Preview

Syntax

This function also has dedicated syntax: A "normal" reference to a label can be created by typing an @ followed by the name of the label (e.g. = Introduction <intro> can be referenced by typing @intro).

To customize the supplement, add content in square brackets after the reference: @intro[Chapter].

Customization

When you only ever need to reference pages of a figure/table/heading/etc. in a document, the default form field value can be changed to "page" with a set rule. If you prefer a short "p." supplement over "page", the page.supplement field can be used for changing this:

#set page(
  numbering: "1",
  supplement: "p.",
)
#set ref(form: "page")

#figure(
  stack(
    dir: ltr,
    spacing: 1em,
    circle(),
    square(),
  ),
  caption: [Shapes],
) <shapes>

#pagebreak()

See @shapes for examples
of different shapes.
Preview

If you write a show rule for references, you can access the referenced element through the element field of the reference. The element may be none even if it exists if Typst hasn't discovered it yet, so you always need to handle that case in your code.

#set heading(numbering: "1.")
#set math.equation(numbering: "(1)")

#show ref: it => {
  let eq = math.equation
  let el = it.element
  // Skip all other references.
  if el == none or el.func() != eq { return it }
  // Override equation references.
  link(el.location(), numbering(
    el.numbering,
    ..counter(eq).at(el.location())
  ))
}

= Beginnings <beginning>
In @beginning we prove @pythagoras.
$ a^2 + b^2 = c^2 $ <pythagoras>
Preview

引数
引数
引数は関数への入力値です。関数名の後に括弧で囲んで指定します。

target
必須引数
必須引数
必須引数は、関数を呼び出す際に必ず指定しなければなりません。
位置引数
位置引数
位置引数は順序通りに指定することで、引数名を省略して設定できます。

The target label that should be referenced.

Can be a label that is defined in the document or, if the form is set to "normal", an entry from the bibliography.

supplement
設定可能引数
設定可能引数
設定可能引数は、setルールを用いて設定でき、それ以降で使用するデフォルト値を変更できます。

A supplement for the reference.

If the form is set to "normal":

  • For references to headings or figures, this is added before the referenced number.
  • For citations, this can be used to add a page number.

If the form is set to "page", then this is added before the page number of the label referenced.

If a function is specified, it is passed the referenced element and should return content.

デフォルト値:

auto

右矢印アイコン
例を表示
#set heading(numbering: "1.")
#show ref.where(
  form: "normal"
): set ref(supplement: it => {
  if it.func() == heading {
    "Chapter"
  } else {
    "Thing"
  }
})

= Introduction <intro>
In @intro, we see how to turn
Sections into Chapters. And
in @intro[Part], it is done
manually.
Preview

form
設定可能引数
設定可能引数
設定可能引数は、setルールを用いて設定でき、それ以降で使用するデフォルト値を変更できます。

The kind of reference to produce.

使用可能な文字列値:
  • normal

    Produces a textual reference to a label.

  • page

    Produces a page reference to a label.

デフォルト値:

"normal"

右矢印アイコン
例を表示
#set page(numbering: "1")

Here <here> we are on
#ref(<here>, form: "page").
Preview
原文(英語)を開く
右矢印アイコン

検索