> 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-tw/an-zhuang/upgrading-tex-live.md).

# 升級 TeX Live

{% hint style="danger" %}
以下指示 **僅** 適用於 **Community Edition** 安裝。我們強烈建議我們的 Ayakaleaf Pro 使用者啟用 [沙箱化編譯](/on-premises/zh-tw/she-ding/overleaf-toolkit/sandboxed-compiles.md) ，因為這可讓使用者存取幾乎相同的 TeX Live 映像，這些映像用於 [overleaf.com](/on-premises/zh-tw/she-ding/overleaf-toolkit.md) ，同時也在專案編譯之間提供隔離，以提升安全性。
{% endhint %}

為了節省頻寬，Overleaf Community Edition 與 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` 的步驟，會因你使用的是目前版本或舊版本而有所不同。你可以使用 `tlmgr --version`來檢查你正在執行的 TeX Live 版本。例如，這個安裝執行的是 TeX Live 2021：

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

{% 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-tw/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.
