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

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

ラベルや参考文献への参照。

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

#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).

補足をカスタマイズするには、 @intro[Chapter]のように、参照の後に角括弧でコンテンツを追加します。

カスタム

参照のshowルールを書く場合、 参照のelementフィールドを通じて参照先の要素にアクセスできます。 ただし、Typstがまだそれを発見していない場合、elementは存在していてもnoneになる可能性があるため、 常にコード内でそのケースを処理する必要があります。

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

#show ref: it => {
  let eq = math.equation
  let el = it.element
  if el != none and el.func() == eq {
    // Override equation references.
    link(el.location(),numbering(
      el.numbering,
      ..counter(eq).at(el.location())
    ))
  } else {
    // Other references as usual.
    it
  }
}

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

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

target
label
RequiredPositional
Positional parameters are specified in order, without names.

参照されるべき対象ラベル。

これは、ドキュメント内で定義されたラベルや、 参考文献リストの参照キーである場合があります。

supplement
none auto content function
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

参照の補足。

If the form is set to "normal":

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.

Default:auto

View example
#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
str
Settable
Settable parameters can be customized for all following uses of the function with a set rule.

The kind of reference to produce.

Default:"normal"

View example
#set page(numbering: "1")

Here <here> we are on
#ref(<here>, form: "page").
Preview