/

交叉引用

在排版中,交叉引用是指向文档其他部分的引用,例如插图、表格、章节和公式。

在 Quarkdown 中,你可以使用 .ref {id} 函数来创建交叉引用,其中 id 是目标元素的引用 ID。该函数可以出现在目标元素之前或之后。

注意:当元素被编号,并且你已设置了受支持的文档语言时,交叉引用效果最佳。详见编号本地化

你通常使用 {#id} 语法来设置 ID。具体位置取决于元素类型,如下面的小节所述。

章节

示例 1

Once you install Quarkdown, check out .ref {getting-started} for a quick guide.

## Getting started {#getting-started}
Sections

提示:在 HTML 渲染中,标题的引用 ID 也会成为 HTML 的 id 属性,这使它们适合用于链接。

插图

示例 2

The Quarkdown logo is shown in .ref {logo}.

![Logo](icon.svg "The Quarkdown icon") {#logo}
Figures

表格

示例 3

As shown in .ref {data}, coffee is the most popular beverage.

| Person  | Beverage |
|---------|----------|
| Alice   | Tea      |
| Bob     | Coffee   |
| Charlie | Coffee   |
{#data}
Tables

示例 4

With a caption:

| Person  | Beverage |
|---------|----------|
| Alice   | Tea      |
| Bob     | Coffee   |
| Charlie | Coffee   |
"Beverage preferences" {#data}

公式

示例 5

Einstein's famous equation is shown in .ref {energy}.

$ E = mc^2 $ {#energy}
Equations

示例 6

For multi-line equations:

$$$ {#energy}
E = mc^2
$$$

提示:有关在 Quarkdown 中编写公式的更多信息,请参阅 TeX 公式

代码块(列表)

示例 7

See the main function in .ref {main}.

```kotlin {#main}
fun main() {
    println("Hello, World!")
}
```
Code blocks

示例 8

With a caption:

```kotlin "Hello World in Kotlin" {#main}
fun main() {
    println("Hello, World!")
}
```

自定义编号元素

.numbered 函数在编号中有详细说明。

示例 9

In Example .ref {my-example} you can see a custom numbered element.

.numbered {examples} ref:{my-example}
    number:
    **Example .number:** this is a custom numbered element.
Custom numbered elements