このページは日本語に翻訳済みです。
ref
ElementElement functions can be customized with set
and show
rules.
set
and show
rules.ラベルや参考文献への参照。
ラベルを指定して、その参照を生成します。
参照のform
には"normal"
と"page"
の2種類があります。
デフォルトの"normal"
参照では、ラベルに対するテキスト形式の参照が作られます。
たとえば見出しへの参照なら、"Section 1"などのような適切な文字列が表示されます。
この参照は、該当する要素へのリンクとしても機能します。
また、参照の構文は文献リストからの引用を行うciteにも使用できます。
このデフォルト形式では補足語と番号が必要なため、ラベルは 参照可能な要素 に付けなくてはなりません。
参照可能な要素としては、
headings、figures、equations、footnotes
などがあります。
定理(theorem)などのカスタム参照可能要素を作成したい場合は、カスタムkind
の図表として作成し、それに対応するshowルールを書くことで作成可能です。
将来的には、カスタム参照可能要素をもっと直接的に定義する方法が導入されるかもしれません。
例
#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")

Syntax
この機能には専用の記法も用意されています。
"normal"
の参照を作成するためには@
に続けてラベル名を入力します。
(たとえば= Introduction <intro>
というラベルを参照するには@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>

引数Parameters are the inputs to a function. They are specified in parentheses after the function name.
target
RequiredRequired parameters must be specified when calling the function.PositionalPositional parameters are specified in order, without names.
参照されるべき対象ラベル。
これは、ドキュメント内で定義されたラベルや、
参考文献リスト
の参照キーである場合があります。
supplement
デフォルト値: 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.

form
SettableSettable parameters can be customized for all following uses of the function with a set
rule.
set
rule.生成する参照の種類
使用可能な文字列値:
normal
ラベルに対して文字列での参照を生成します。
page
ラベルに対してページ番号での参照を生成します。
デフォルト値: "normal"
例を表示
#set page(numbering: "1")
Here <here> we are on
#ref(<here>, form: "page").
