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

> 在 Overleaf Community Edition 部署中升級 TeX Live 或安裝套件。

<Danger>
  以下說明**僅**適用於 **Community Edition** 安裝。我們強烈建議 Ayakaleaf Pro 使用者啟用[沙箱編譯](/zh-TW/on-premises/configuration/overleaf-toolkit/sandboxed-compiles)，這不僅能讓使用者存取與 [overleaf.com](https://www.overleaf.com) 上幾乎相同的 TeX Live 映像檔，還能在各專案的編譯之間提供隔離，以強化安全性。
</Danger>

為了節省頻寬，Overleaf Community Edition 與 Ayakaleaf Pro 映像檔都只附帶最精簡的 [TeX Live](https://www.tug.org/texlive/) 安裝。你可以在 `sharelatex` 容器中使用 [tlmgr](https://www.tug.org/texlive/tlmgr.html) 指令安裝更多套件，或升級為完整的 TeX Live 安裝。

#### 進入 sharelatex 容器

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

```bash theme={null}
bin/shell
```

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

```bash theme={null}
root@309b192d4030:/#
```

在以下說明中，我們假設你已位於容器內。

#### 確認目前的 TeX Live 版本

TeX Live 每年大約在四月發布新版本。使用 `tlmgr` 的步驟會因你使用的是目前版本還是較舊版本而有所不同。你可以使用 `tlmgr --version` 檢查目前執行的 TeX Live 版本。例如，以下安裝執行的是 TeX Live 2021：

```bash theme={null}
# 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
```

<Info>
  TeX Live 的目前版本可在 [TeX Live 首頁](https://www.tug.org/texlive/)查詢。
</Info>

如果你執行的是較舊的 TeX Live 版本，有兩個選擇。新版的 Overleaf Docker 映像檔通常會在 TeX Live 發布後不久推出，你可以等待新映像檔推出後，使用 `bin/upgrade` 腳本升級你的部署；或者，如果你偏好保留較舊的 TeX Live 版本，則必須先讓 `tlmgr` 使用歷史版本的套件庫。相關說明請參閱[這裡](https://www.tug.org/texlive/acquire.html#past)。

#### 安裝套件

若要安裝完整的 TeX Live，請在 `sharelatex` 容器內執行以下指令：

```text theme={null}
tlmgr install scheme-full
```

你也可以手動安裝個別套件：

```bash theme={null}
tlmgr install tikzlings tikzmarmots tikzducks
```

<Warning>
  從 `3.3.0` 版開始，每次使用 `tlmgr install` 之後，都**必須**再次執行 `tlmgr path add`，才能將所有執行檔正確地以符號連結加入系統路徑。
</Warning>

還有許多其他指令可用。你可以透過以下指令了解更多：

```text theme={null}
tlmgr help
```

完成後，輸入 `exit` 或按下 Control-D 即可離開 shell。

#### 儲存你的變更

你剛才所做的變更修改了 `sharelatex` 容器，但這些變更是暫時性的——若 Docker Compose 重新建立容器（例如在更新設定時），這些變更就會遺失。

若要讓變更永久保存，請使用 `docker commit` 將變更儲存為新的 Docker 映像檔：

```bash theme={null}
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` 容器。

<Danger>
  每次[升級](https://github.com/overleaf/toolkit/blob/master/doc/upgrading.md)至新的 Overleaf 版本時，你都需要重複這些步驟。
</Danger>


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