Latex setup

MacOS/Ubuntu + VS Code

Jacob Xie published on
2 min, 237 words

Categories: Post

Tags: Latex

MacOS

  1. MacTeX: choose smaller download, or by Homebrew:

    brew install mactex-no-gui
    

    or

    brew install basictex
    
  2. Update tlmgr and add to PATH:

    sudo tlmgr update --self
    sudo tlmgr path add
    
  3. Install tlmgr plugins, check ctan for more:

    sudo tlmgr install latexmk
    sudo tlmgr install ctex
    sudo tlmgr install collection-fontsrecommended
    

    note ctex supports Chinese words.

  4. Install latexindent:

    brew install latexindent
    

Ubuntu

  1. TexLive

    sudo apt-get install texlive-full
    

    or

    cd /tmp # working directory of your choice
    wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz # or curl instead of wget
    zcat install-tl-unx.tar.gz | tar xf -
    cd install-tl-*
    perl ./install-tl --no-interaction # as root or with writable destination
    # Finally, prepend /usr/local/texlive/YYYY/bin/PLATFORM to your PATH, e.g., /usr/local/texlive/2022/bin/x86_64-linux
    

Vs Code

  1. Install VS Code plugin: LaTex-Workshop.

  2. Add following configs into VS Code's settings.json:

    "latex-workshop.latex.outDir": "./out/",
    "latex-workshop.latex.recipes": [
       {
          "name": "xelatex",
          "tools": ["xelatex"]
       },
       {
          "name": "latexmk",
          "tools": ["latexmk"]
       }
    ],
    "latex-workshop.latex.tools": [
       {
          "name": "xelatex",
          "command": "xelatex",
          "args": [
             "-synctex=1",
             "-interaction=nonstopmode",
             "-file-line-error",
             "-output-directory=%OUTDIR%",
             "%DOC%"
          ]
       },
       {
          "name": "latexmk",
          "command": "latexmk",
          "args": [
             "-synctex=1",
             "-interaction=nonstopmode",
             "-file-line-error",
             "-pdf",
             "-outdir=%OUTDIR%",
             "%DOC%"
          ],
       }
    ]
    

    Note: we can choose a compiler to compile our files by LaTex Workshop: Build with recipe