399 字
2 分钟
overleaf-wsl2

Entering the Docker Container#

First, you need to access the shell of your Docker container where ShareLaTeX is running. You can do this with the following command:

Terminal window
bin/shell

This command will drop you into the shell of the container, allowing you to execute further commands directly within the container environment.

Upgrading TeX Live to 2024#

To ensure compatibility with the latest TeX Live packages and features, you should update your TeX Live to the 2024 version using the following commands:

Terminal window
wget https://mirrors.bfsu.edu.cn/CTAN/systems/texlive/tlnet/update-tlmgr-latest.sh
chmod +x update-tlmgr-latest.sh
./update-tlmgr-latest.sh --update

These commands perform the following actions:

  1. Download the update script from a reliable CTAN mirror.
  2. Make the script executable to prepare it for running.
  3. Execute the script to update tlmgr and ensure it can handle the new 2024 packages.

Installing the Full TeX Live Scheme#

Once TeX Live is updated, you can install the complete TeX Live collection to have all available packages:

Terminal window
tlmgr --version
tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
tlmgr update --self --all
tlmgr install scheme-full
tlmgr install ctex
tlmgr path add

This sequence will:

  • Check the version of tlmgr to ensure it’s updated.
  • Set the repository to a specific CTAN mirror.
  • Install the scheme-full package, which includes all TeX Live packages.
  • Install the ctex package, crucial for handling Chinese text in LaTeX.
  • Add the necessary paths for the system to recognize the new TeX Live binaries.

Installing Fonts for Better Document Rendering#

To improve the rendering of documents, especially those requiring specific fonts, you can install Microsoft core fonts:

Terminal window
sed -i 's@//.*archive.ubuntu.com@//mirrors.tuna.tsinghua.edu.cn@g' /etc/apt/sources.list
sed -i 's/http:/https:/g' /etc/apt/sources.list
apt update
echo "yes" | apt install -y --reinstall ttf-mscorefonts-installer
apt install -y latex-cjk-all texlive-lang-chinese texlive-lang-english
# 更新字体缓存
fc-cache -fv

This will install fonts and refresh the font cache.

Saving the Updated Docker Image#

To preserve the changes made within the container, you need to commit the current state of the container to a new Docker image:

Terminal window
docker commit sharelatex sharelatex/sharelatex:with-texlive-full

This command creates a new Docker image based on the current state of sharelatex container.

Updating Docker Compose Configuration#

To use the new Docker image in your Docker compose setup, add the following lines to your /config/docker-compose.override.yml file:

---
version: "2.2"
services:
sharelatex:
image: sharelatex/sharelatex:with-texlive-full

This configuration will ensure that when you next run Docker Compose, it will use the newly created image with the updated TeX Live.

Restarting the Environment#

Finally, to apply all changes and updates, restart your Docker environment:

Terminal window
bin/stop && bin/docker-compose rm -f sharelatex && bin/up

This set of commands stops the running service, removes the existing container, and starts the service again with the new configuration and updates.

overleaf-wsl2
https://blog.alfakyun.icu/posts/overleaf-wsl2/
作者
Sakaizd
发布于
2024-04-17
许可协议
CC BY-NC-SA 4.0