> ## 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 與[沙箱編譯](/zh-TW/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.