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

# 升級 TeX Live

為了節省頻寬，Overleaf Community Edition 和 Overleaf Pro 映像都只附帶最小安裝的 [TeX Live](https://www.tug.org/texlive/)。您可以使用 [tlmgr](https://www.tug.org/texlive/tlmgr.html) 指令安裝更多套件，或升級為完整的 TeX Live 安裝，該指令位於 `sharelatex` 容器內的 .log 檔案。

{% hint style="warning" %}
以下說明 **只** 適用於 Community Edition 安裝。我們強烈建議 Overleaf Pro 使用者啟用 [Sandboxed Compiles](broken://pages/62029113e67494d78d16303f3fbf09dcd5cd61f1) ，因為這可讓使用者存取與 [overleaf.com](/on-premises/zh-tw/she-ding/overleaf-toolkit.md) 上使用的相同 TeX Live 映像，並且提供專案編譯之間的隔離，以提升安全性。
{% endhint %}

#### 進入 sharelatex 容器

若要在 `sharelatex` 容器內啟動 shell，請執行

```bash
bin/shell
```

您會看到類似以下的提示字元：

```bash
root@309b192d4030:/#
```

在以下說明中，我們會假設您已在容器內。

#### 判定您目前的 TeX Live 版本

TeX Live 每年約在 4 月發行一次。使用 `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）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` 容器內的 .log 檔案。

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