> 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/on-premises/zh-cn/an-zhuang/upgrading-tex-live.md).

# 升级 TeX Live

{% hint style="danger" %}
以下说明 **仅** 适用于 **社区版** 安装。我们强烈建议我们的 Ayakaleaf Pro 用户启用 [沙盒化编译](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/sandboxed-compiles.md) 因为这使用户能够访问与 [overleaf.com](/on-premises/zh-cn/pei-zhi/overleaf-toolkit.md) 上使用的 TeX Live 镜像几乎相同的镜像，并为项目编译之间提供隔离，以增强安全性。
{% endhint %}

为节省带宽，Overleaf 社区版和 Ayakaleaf Pro 镜像都只附带最小安装的 [TeX Live](https://www.tug.org/texlive/)。你可以使用 [tlmgr](https://www.tug.org/texlive/tlmgr.html) 命令在 `sharelatex` 容器中安装更多包或升级为完整的 TeX Live 安装。

#### 进入 sharelatex 容器

要在 `sharelatex` 容器内启动一个 shell，请运行

```bash
bin/shell
```

你会看到一个类似这样的提示符：

```bash
root@309b192d4030:/#
```

在以下说明中，我们将假设你已在容器中。

#### 确定你当前的 TeX Live 版本

TeX Live 每年大约在四月发布一次。使用 `tlmgr` 的步骤会因你使用的是当前版本还是较旧版本而有所不同。你可以通过以下命令检查你正在运行的 TeX Live 版本： `tlmgr --version`。例如，这个安装运行的是 TeX Live 2021：

```bash
# tlmgr --version
tlmgr 修订版 59291 (2021-05-21 05:14:40 +0200)
tlmgr 使用的安装位置：/usr/local/texlive/2021
TeX Live (https://tug.org/texlive) 2021 版
```

{% hint style="info" %}
TeX Live 的当前版本可以在 [TeX Live 主页](https://www.tug.org/texlive/).
{% endhint %}

如果你运行的是较旧的 TeX Live 版本，你有两个选择。Overleaf Docker 镜像的新版本通常会在 TeX Live 发布后不久发布，你可以等待它发布，然后使用 `bin/upgrade` 脚本升级你的部署，或者，如果你更希望保留旧的 TeX Live 版本，你首先需要告诉 `tlmgr` 使用历史仓库。你可以在 [这里](https://www.tug.org/texlive/acquire.html#past).

#### 安装软件包

要安装完整的 TeX Live，请在 `sharelatex` 容器中运行此命令：

```
tlmgr install scheme-full
```

你也可以手动安装单个软件包：

```bash
tlmgr install tikzlings tikzmarmots tikzducks
```

{% hint style="warning" %}
从 `3.3.0` 版本起，运行 `tlmgr path add` 是 **必需的** 在每次使用 `tlmgr install`之后再次执行，以便将所有二进制文件正确地符号链接到系统路径中。
{% endhint %}

还有许多其他命令可用。通过以下命令了解更多：

```
tlmgr help
```

完成后，输入 `exit` 或按 Control-D 退出 shell。

#### 保存你的更改

你刚刚所做的更改已经修改了 `sharelatex` 容器，但它们是临时的——如果 Docker Compose 重新创建该容器，它们就会丢失，例如在更新配置时。

要使其持久化，请使用 `docker commit` 将更改保存为新的 docker 镜像：

```bash
cat config/version #5.2.1
docker commit sharelatex sharelatex/sharelatex:5.2.1-with-texlive-full
echo 5.2.1-with-texlive-full > config/version
```

提交更改后，相应地更新 `config/version` 。然后运行 `bin/up`，以重新创建 `sharelatex` 容器中安装更多包或升级为完整的 TeX Live 安装。

{% hint style="danger" %}
每次你 [升级](https://github.com/overleaf/toolkit/blob/master/doc/upgrading.md) 到新版本的 Overleaf 时，都需要重复这些步骤。
{% endhint %}


---

# 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/on-premises/zh-cn/an-zhuang/upgrading-tex-live.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.
