当中 texlode、TeXyoN 迟迟未公开,Texpile、rtex 用了一阵下来觉得仍然不稳定,而且也只有TeXyoN和rtex会提供VS Code插件。顺带一提,macOS 可以用 Texifier,但是我还是喜欢 VS Code。
因为上课要抄笔记实在无法忍受不稳定,我始终都要用回 let-def - TeXpresso,而且前几天 DominikPeters - TeXpresso VS Code Extension 终于更新,对接七月的 e8df770。
WSL 现在其实已经自带 WSLg,但是为了追求美观,我使用 GWSL,要自行 build,嫌麻烦可以直接买已经 build 好的 Microsoft Store 付费版。 官方文档
准备 Python 环境,安装 PyManager 以便和其他版本共存。
自行下载安装 Python 3.7 (python-3.7.9-amd64.exe)
坑:不可以直接用py install 3.7,因为这样不附带 tkinter。

(不选Add to PATH也行,因为已经有 PyManager 提供的py指令。)
测试 tkinter
py -3.7 -m tkinter

(看到这个界面即表示 tkinter 可用)
拉取GWSL-Source仓库(需时约 3 分钟)
git clone https://github.com/Opticos/GWSL-Source.git
cd GWSL-Source
安装virtualenv,创建(build_env)并进入
py -3.7 -m pip install virtualenv
py -3.7 -m virtualenv build_env
.\build_env\Scripts\activate
在(build_env)内安装 dependencies 并 build
pip install pygame pywin32 winshell Pillow imtools keyboard pyinstaller==3.5 pyxdg psutil
py build.py
成功的话会产生dist/GWSL_'version'/,复制到%AppData%/GWSL/bin/(反正 GWSL 资料目录就在%AppData%/GWSL/),在 cmd 运行
cd dist
for /d %i in (GWSL_*) do @if /i not "%~nxi"=="GWSL_service" xcopy "%i\*" "%AppData%\GWSL\bin\" /E /H /C /I /Q
打开%AppData%/GWSL/bin/GWSL.exe,成功的话就可以删除原来的GWSL-Source

安装 TeXpresso VS Code Extension
坑:因为 VS Code 用的是 non-interactive, non-login shell,要弄个 wrapper 加载 env
cd /opt/texpresso
touch texpresso-vscode.sh
chmod +x texpresso-vscode.sh
nano texpresso-vscode.sh
在 nano 里贴上(提示:Ctrl + S储存、Ctrl + X离开)
#!/bin/bash
export DISPLAY=$(ip route | grep default | awk '{print $3}'):0.0 #GWSL
/opt/texpresso/build/texpresso "$@"
在VS Code按Ctrl+Shift+P呼叫command palette,选Preferences: Open User Settings (JSON)

在settings.json里贴上
"texpresso.useWSL": true,
"texpresso.command": "/opt/texpresso/texpresso-vscode.sh",
"texpresso.packageProvider": "tectonic",
"texpresso.useChangeRangeMode": true,
"texpresso.streamFiles": true,
"texpresso.syncTeXForwardOnSelection": true,
然后储存
Recipes, Tools
"latex-workshop.latex.recipe.default": "lastUsed",
"latex-workshop.latex.recipes": [
{
"name": "latexmk (pdflatex)",
"tools": [
"pdflatexmk"
]
},
{
"name": "latexmk (xelatex)",
"tools": [
"xelatexmk"
]
},
{
"name": "latexmk (lualatex)",
"tools": [
"lualatexmk"
]
},
],
"latex-workshop.latex.tools": [
{
"name": "pdflatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"-auxdir=%OUTDIR%/.aux",
"%DOC%"
],
"env": {}
},
{
"name": "lualatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-lualatex",
"-outdir=%OUTDIR%",
"-auxdir=%OUTDIR%/.aux",
"%DOC%"
],
"env": {}
},
{
"name": "xelatexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-xelatex",
"-outdir=%OUTDIR%",
"-auxdir=%OUTDIR%/.aux",
"%DOC%"
],
"env": {}
},
],
PDF Viewer, SyncTeX
"latex-workshop.synctex.afterBuild.enabled": true,
"latex-workshop.synctex.indicator": "circle",
"latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
"latex-workshop.view.pdf.reload.transition": "none",
"latex-workshop.view.outline.sync.viewer": true,
SumatraPDF, SyncTeX
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.viewer.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.viewer.args": [
"-reuse-instance",
"-forward-search",
"%TEX%",
"%LINE%",
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "C:/Program Files/SumatraPDF/SumatraPDF.exe",
"latex-workshop.view.pdf.external.synctex.args": [
"-reuse-instance",
"-forward-search",
"%TEX%",
"%LINE%",
"%PDF%"
],
ChkTeX, Logging
"latex-workshop.message.badbox.show": "none",
"latex-workshop.message.latexlog.exclude": [
"too small"
],
"latex-workshop.linting.chktex.enabled": true,
"latex-workshop.linting.chktex.exec.args": [
"-wall",
"-n3", // ab_c -> {ab}_c
"-n6", // Italic correction
"-n9", // Half open/closed intevals
"-n17", // Number of ( needs to be equal to number of )
"-n21",
"-n22",
"-n25", // x^Tx -> x^T x
"-n30",
"-n36", // Requires space in front of (
"-n40", // Prohibits punctuation inside \(\), including factorial !
"-e16",
"-q",
"-n1"
],