在 WSL 中安装 LaTeX
安装 TeX Live
进入华为云镜像,下载 install-tl-unx.tar.gz 。
解压
在线安装
./install-tl -repository https://mirrors.huaweicloud.com/CTAN/systems/texlive/tlnet/添加到 Path
cd /usr/local/texlive/2020/bin/x86_64-linux ./tlmgr path add安装部分缺少的库
apt-get install build-essential运行
latexindent,根据提示cpan install对应库。更新包
tlmgr update --self --all
同步字体
安装
fontconfigapt install fontconfig创建
/etc/fonts/local.confvi /etc/fonts/local.conf写入
/etc/fonts/local.conf<?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <dir>/mnt/c/Windows/Fonts</dir> </fontconfig>刷新字体缓存
fc-cache -fv
使用
推荐 VSCode 配合 LaTeX Workshop 和 Remote - WSL 使用。
注: LaTeX Workshop 默认不支持 xelatex 编译。
可以向
settings.json中添加以下内容。{ "latex-workshop.latex.tools": [ { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-xelatex",//添加该行 "-pdf", "%DOC%" ] } ] }或者可以在文件头部表明编译器。
% !TEX program = xelatex
或者向
settings.json中添加以下内容。{ "latex-workshop.latex.tools": [ { "name": "xelatex", "command": "xelatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "%DOCFILE%" ] }, { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOCFILE%" ] }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ] } ], "latex-workshop.latex.recipes": [ { "name": "xelatex", "tools": [ "xelatex" ] }, { "name": "pdflatex", "tools": [ "pdflatex" ] }, { "name": "xe->bib->xe->xe", "tools": [ "xelatex", "bibtex", "xelatex", "xelatex" ] }, { "name": "pdf->bib->pdf->pdf", "tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ] } ] }