> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-pro.ayaka.space/on-premises/zh-tw/wei-hu/extending-tex-live.md).

# 擴充 TeX Live

可以使用新的 Dockerfile 擴充現有的 TeX Live 映像，並設定應用程式使用新的映像。

我們在此提供一些安裝新套件或字型的指引，但自訂映像的設定不在我們的支援條款範圍內。

TeX Live 映像更新的頻率不高。我們建議在升級 Server Pro 時重建自訂映像。

{% hint style="danger" %}
以下章節適用於 Server Pro 和 [Sandboxed Compiles](broken://pages/62029113e67494d78d16303f3fbf09dcd5cd61f1) 僅限。
{% endhint %}

### 安裝與更新新套件

你可以使用 `tlmgr` 等指令，例如 `tlmgr install` 以及 `tlmgr update` 來管理 Tex Live 套件，如以下範例所示：

```dockerfile
FROM ghcr.io/ayaka-notes/texlive-full:2023.1

RUN tlmgr update --force ebproof
```

### 使用 `tlmgr` 在較舊的 TeX Live 映像中

預設情況下 `tlmgr` 會從最新的 TeX Live 發行版下載資源。當修補較舊的 TeX Live 映像時，下載來源需要切換到對應的封存版本。請參閱 <https://www.tug.org/historic/> 中的封存鏡像清單。

```dockerfile
FROM ghcr.io/ayaka-notes/texlive-full:2022.1

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

RUN tlmgr update --force ebproof
```

### 安裝新字型

在 Tex Live 發行版中安裝新字型有不同的流程，而安裝自訂字型可能需要幾個步驟。查看 [安裝 TeX 字型的說明](https://tug.org/fonts/fontinstall.html) 在官方 Tex Live 文件中，可能是個不錯的起點。

以下 `Dockerfile` 顯示了在既有的 Tex Live 2022 映像上安裝 TrueType 字型的範例：

```dockerfile
FROM ghcr.io/ayaka-notes/texlive-full:2022.1

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

# 重新建置字型資訊快取
RUN fc-cache
```

### 設定 Server Pro 使用新的映像

使用名稱 `ghcr.io/ayaka-notes/texlive-full` 以及自訂標籤來建置新映像，如下所示：

```bash
docker build -t ghcr.io/ayaka-notes/texlive-full:2023.1-custom
```

現在我們可以將 Server Pro 設定為使用新的 `2023.1-custom` 映像，並更新 `TEX_LIVE_DOCKER_IMAGE` 以及 `ALL_TEX_LIVE_DOCKER_IMAGES` 環境變數：

{% code overflow="wrap" %}

```
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"
```

{% endcode %}

在上例中，新專案預設會使用新的 `2023.1-custom` 映像，而 `2023.1` 在需要時仍然可用。


---

# 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://overleaf-pro.ayaka.space/on-premises/zh-tw/wei-hu/extending-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.
