> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/latex/zh-cn/shen-du-wen-zhang/46-testing-display-and-link-template.md).

# 测试显示和链接模板

## 测试显示和链接模板

注意：测试仍在进行中，因此结果可能会“波动”

## 用于显示 LaTeX 文档部分或全部内容的 MediaWiki 模板

拟议模板 [Template:OpenLaTeXInOverleaf](https://github.com/ayaka-notes/overleaf-learn-wiki/tree/main/learn/Template:OpenLaTeXInOverleaf/README.md) 可让你显示行内 LaTeX 代码 *和*，基于 Alf 的工作，自动生成一个 `在 Overleaf 中打开` 从行内 LaTeX 代码生成链接——你只需编写代码 *一次*。它还允许你只显示 `正文` 你的 LaTeX 正文，省略整个导言区和 \end{document}，或者显示整个文档，但在这两种情况下，Overleaf 中都会打开一个完整的文档。

* 注意：由于 MediaWiki 解析的原因， **你需要使用 `{{!}}` 在你的 TeX 代码中来生成 | 字符**.

### 用于控制 LaTeX 代码行内显示（以及文档构建）的参数

* **`pre`**，用于设置 `导言区` 你的文档的前导部分。默认值为

```
\documentclass{article}
\begin{document}
```

* **`正文`** 这就是你的 LaTeX 文档的核心代码
* **`post`**，用于设置文档末尾。默认值为

```
\end{document}
```

* **`show`** ，用于控制你的 LaTeX 代码的显示：可以是 `正文` 正文部分或整个文档
  * `show=ALL` 显示整个 LaTeX 文档——使用你对 `正文`, `pre` 和 `post`的设置，或者使用 *默认值* 用于 `pre` 或 `post`.
  * `show=BODY` 仅显示你的 LaTeX 代码正文

在所有情况下，都会使用以下设置自动构建一个“在 Overleaf 中打开”链接： **`pre`**, **`正文`** 和 **`post`**

### 用于控制 Overleaf API 调用的参数（继承自 Alf 的工作）

* **`engine`** 设置用于该代码的编译器，可以是以下之一：
  * `pdflatex` （如果未选择引擎，则为默认值）
  * `xelatex`
  * `lualatex`
  * `latex_dvipdf`
* **`名称`** 设置 Overleaf 文档的标题
* **`文本`** 设置用于显示链接的文本

## 示例

以下部分列出该模板的一些示例用法。

### 定义 pre、post 并设置 show=ALL

```
{{OpenLaTeXInOverleaf|show=ALL|pre=
\documentclass{book}
\begin{document}
|body=

你好

亲爱的

\LaTeX

|post=
\end{document}%Here we end the document
|engine=lualatex|name=使用 LuaLaTeX 的测试|text=在 Overleaf 中打开一个 LuaLaTeX 示例
}}
```

上述代码会生成以下行内显示和“在 Overleaf 中打开”链接

```latex
\documentclass{book}
\begin{document}
你好

亲爱的

\LaTeX
\end{document}%Here we end the document
```

&#x20;[在 Overleaf 中打开一个 LuaLaTeX 示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Bbook%7D%0A%5Cbegin%7Bdocument%7D%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%5Cend%7Bdocument%7D%25Here+we+end+the+document)

### 定义 pre、post 并设置 show=BODY

```
{{OpenLaTeXInOverleaf|show=BODY|pre=
\documentclass{book}
\begin{document}
|body=

你好

亲爱的

\LaTeX

|post=
\end{document}%Here we end the document
|engine=lualatex|name=使用 LuaLaTeX 的测试|text=在 Overleaf 中打开一个 LuaLaTeX 示例
}}
```

上述代码会生成以下行内显示和“在 Overleaf 中打开”链接

```latex
你好

亲爱的

\LaTeX
```

&#x20;[在 Overleaf 中打开一个 LuaLaTeX 示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Bbook%7D%0A%5Cbegin%7Bdocument%7D%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%5Cend%7Bdocument%7D%25Here+we+end+the+document)

### 定义一个空的 pre、一个空的 post，但一个更完整的 body

```
{{OpenLaTeXInOverleaf|show=ALL|pre=|post=|body=

\documentclass{book}

\begin{document}

你好

亲爱的

\LaTeX

\end{document}
|engine=lualatex|name=使用 LuaLaTeX 的测试|text=在 Overleaf 中打开一个 LuaLaTeX 示例
}}
```

上述代码会生成以下行内显示和“在 Overleaf 中打开”链接

```latex
\documentclass{book}

\begin{document}

你好

亲爱的

\LaTeX

\end{document}
```

&#x20;[在 Overleaf 中打开一个 LuaLaTeX 示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Bbook%7D%0A%0A%0A%5Cbegin%7Bdocument%7D%0A%0A%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%0A%0A%5Cend%7Bdocument%7D)

### 对 pre 和 post 使用默认值，但为 body 提供代码

```
{{OpenLaTeXInOverleaf|show=ALL|body=
你好

亲爱的

\LaTeX
|engine=lualatex|name=使用 LuaLaTeX 的测试|text=在 Overleaf 中打开一个 LuaLaTeX 示例
}}
```

上述代码会生成以下行内显示和“在 Overleaf 中打开”链接

```latex
\documentclass{article}
\begin{document}

你好

亲爱的

\LaTeX

\end{document}
```

&#x20;[在 Overleaf 中打开一个 LuaLaTeX 示例](https://www.overleaf.com/docs?engine=lualatex\&snip_name=Test+using+LuaLaTeX\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0AHello+%0A%0Adear%0A%0A%5CLaTeX%0A%0A%5Cend%7Bdocument%7D)

## 测试：忽略这些链接

```latex
\documentclass{article}
\begin{document}

\LaTeX

\end{document}
```

&#x20;[在 Overleaf 中打开](https://www.overleaf.com/docs?engine=\&snip_name=\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%0A%5CLaTeX%0A%0A%5Cend%7Bdocument%7D)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/latex/zh-cn/shen-du-wen-zhang/46-testing-display-and-link-template.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
