Post

Set up LaTeX Environment

Latex is a text formating language that is widely used in academia.

Windows: MikTeX

MikTeX is a modern implementation of TeX/LaTeX and related programs with good support for Windows.

MikTeX console is a GUI application that helps you to install and manage packages. We can set the pakcage source to be the nearest CTAN mirror(e.g. sustech).

MikTeX will automatically download and install packages when they are needed. It is recommended to install at user space as MikTeX will keep requiring admin permission to install packages if installed at system space.

There are multiple engines that can be used to compile LaTeX documents. xeLaTeX is a modern engine that supports Unicode and system fonts. It allows you to use any font installed on your system and supports Unicode perfectly.

latexmk is a script written in Perl that would call the LaTeX engine multiple times to compile the document. It would automatically detect the number of times the engine needs to be called to resolve all the references. Perl is not included in MikTeX, so we need to install it manually.

Unix: TeX Live

Official site

Ubuntu’s apt repository only contains the outdated version of TeX Live(2021). It is recommended to install TeX Live from the official site.

tug org provides a script that can install TeX Live from the official site.

CTAN(Comprehensive TeX Archive Network) is a collection of all things TeX and LaTeX. It is a good source to download packages.

Its recommended to assign a custom CTAN mirror to speed up the download process. SUSTECH is a recommended mirror for users in Shenzhen.

install command(need to install perl first):

1
perl ./install-tl --location https://mirrors.sustech.edu.cn/CTAN/systems/texlive/tlnet/

follow the instruction in interactive installtion process to set the installation directory.

WSL2

Possible problems of using TeX Live in WSL2:

  • lack of fonts: sudo apt-get install fonts-cmu

  • lack of font tools: sudo apt-get install texlive-font-utils

Latex Workshop

Latex Workshop is a VSCode extension that provides a rich editing experience for LaTeX, including syntax highlighting, code completion, and preview.

We can set the latex-workshop.latex.tools and latex-workshop.latex.recipes settings in VSCode to use latexmk to compile the document:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    "latex-workshop.latex.tools": [
        {
            "name": "xelatexmk",
            "command": "latexmk",
            "args": [
                "-pdf",
                "-xelatex",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-outdir=out",
                "%DOC%"
            ]
        }
    ],
    "latex-workshop.latex.recipes": [
        {
            "name": "xelatexmk",
            "tools": [
                "xelatexmk"
            ]
        }
    ],
    "latex-workshop.latex.outDir": "out"
This post is licensed under CC BY 4.0 by the author.