> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 升级 TeX Live

> 在 Overleaf 社区版部署中升级 TeX Live 或安装宏包。

<Danger>
  以下说明**仅**适用于\*\*社区版（Community Edition）\*\*安装。我们强烈建议 Ayakaleaf Pro 用户启用[沙盒编译（Sandboxed Compiles）](/zh-CN/on-premises/configuration/overleaf-toolkit/sandboxed-compiles)，因为它能让用户使用与 [overleaf.com](https://www.overleaf.com) 几乎相同的 TeX Live 镜像，同时在各项目编译之间提供隔离，以增强安全性。
</Danger>

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

#### 进入 sharelatex 容器

要在 `sharelatex` 容器中启动 shell，请运行

```bash theme={null}
bin/shell
```

你将看到类似如下的提示符：

```bash theme={null}
root@309b192d4030:/#
```

在以下说明中，我们假定你已位于容器内。

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

TeX Live 每年大约在四月份发布。使用 `tlmgr` 的步骤取决于你使用的是当前版本还是旧版本。你可以使用 `tlmgr --version` 查看正在运行的 TeX Live 版本。例如，以下安装运行的是 TeX Live 2021：

```bash theme={null}
# tlmgr --version
tlmgr revision 59291 (2021-05-21 05:14:40 +0200)
tlmgr using installation: /usr/local/texlive/2021
TeX Live (https://tug.org/texlive) version 2021
```

<Info>
  TeX Live 的当前版本可在 [TeX Live 主页](https://www.tug.org/texlive/)上查看。
</Info>

如果你运行的是较旧的 TeX Live 版本，有两种选择。新版 Overleaf Docker 镜像通常会在 TeX Live 发布后不久推出，你可以等待新镜像并使用 `bin/upgrade` 脚本升级部署；或者，如果你希望保留旧版 TeX Live，则需要先让 `tlmgr` 使用历史仓库。相关说明请参见[这里](https://www.tug.org/texlive/acquire.html#past)。

#### 安装宏包

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

```text theme={null}
tlmgr install scheme-full
```

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

```bash theme={null}
tlmgr install tikzlings tikzmarmots tikzducks
```

<Warning>
  从 `3.3.0` 版本开始，每次使用 `tlmgr install` 后都**必须**再次运行 `tlmgr path add`，以便将所有二进制文件正确地符号链接到系统路径中。
</Warning>

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

```text theme={null}
tlmgr help
```

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

#### 保存更改

你刚才所做的更改修改了 `sharelatex` 容器，但这些更改是临时的——如果 Docker Compose 重新创建容器（例如在更新配置时），这些更改就会丢失。

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

```bash theme={null}
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` 容器。

<Danger>
  每次[升级](https://github.com/overleaf/toolkit/blob/master/doc/upgrading.md)到新的 Overleaf 版本时，你都需要重复这些步骤。
</Danger>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.