> ## 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

> 为受支持的编译环境扩展 TeX Live Docker 镜像，添加宏包和字体。

你可以通过新的 Dockerfile 扩展现有的 TeX Live 镜像，并配置应用程序使用新镜像。

这里我们提供一些安装新宏包或字体的指导，但自定义镜像的配置不在我们的支持范围之内。

TeX Live 镜像的更新频率较低。我们建议在升级 Server Pro 时重新构建自定义镜像。

<Danger>
  以下内容仅适用于 Server Pro 和[沙盒编译（Sandboxed Compiles）](/zh-CN/on-premises/configuration/overleaf-toolkit/sandboxed-compiles)。
</Danger>

### 安装和更新新宏包

你可以使用 `tlmgr install`、`tlmgr update` 等 `tlmgr` 命令管理 TeX Live 宏包，示例如下：

```dockerfile theme={null}
FROM ghcr.io/ayaka-notes/texlive-full:2023.1

RUN tlmgr update --force ebproof
```

### 在旧版 TeX Live 镜像中使用 `tlmgr`

默认情况下，`tlmgr` 会从最新的 TeX Live 版本下载资源。为旧版 TeX Live 镜像打补丁时，需要将下载源切换到相应的归档。归档镜像列表请参见 [https://www.tug.org/historic/](https://www.tug.org/historic/)。

```dockerfile theme={null}
FROM ghcr.io/ayaka-notes/texlive-full:2022.1

RUN tlmgr option repository <MIRROR>/systems/texlive/<YEAR>/tlnet-final
# e.g. RUN tlmgr option repository ftp://tug.org/historic/systems/texlive/2022/tlnet-final

RUN tlmgr update --force ebproof
```

### 安装新字体

在 TeX Live 发行版中安装新字体有多种方法，安装自定义字体可能需要多个步骤。查阅 TeX Live 官方文档中的[TeX 字体安装说明](https://tug.org/fonts/fontinstall.html)或许是一个不错的起点。

下面的 `Dockerfile` 展示了在现有 TeX Live 2022 镜像上安装 TrueType 字体的示例：

```dockerfile theme={null}
FROM ghcr.io/ayaka-notes/texlive-full:2022.1

COPY ./myfonts/*.ttf /usr/share/fonts/truetype/myfont/

# rebuild font information cache
RUN fc-cache
```

### 配置 Server Pro 使用新镜像

使用名称 `ghcr.io/ayaka-notes/texlive-full` 和自定义标签构建新镜像，例如：

```bash theme={null}
docker build -t ghcr.io/ayaka-notes/texlive-full:2023.1-custom
```

现在，我们可以通过更新 `TEX_LIVE_DOCKER_IMAGE` 和 `ALL_TEX_LIVE_DOCKER_IMAGES` 环境变量，配置 Server Pro 使用新的 `2023.1-custom` 镜像：

```text wrap theme={null}
TEX_LIVE_DOCKER_IMAGE: "ghcr.io/ayaka-notes/texlive-full:2023.1-custom"
ALL_TEX_LIVE_DOCKER_IMAGES: "ghcr.io/ayaka-notes/texlive-full:2023.1,ghcr.io/ayaka-notes/texlive-full:2023.1-custom"
```

在上面的示例中，新项目默认使用新的 `2023.1-custom` 镜像，而 `2023.1` 仍可在需要时使用。


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