由于在Windows中编译LaTeX的速度要远低于在LInux中编译速度,但我们可能经常需要在Windows系统上办公,因此有没有一种方法可以在Windows中用LaTeX写文章同时享受Linux的编译速度呢?
答案是:
sudo mount -o loop texlive2021.iso /mnt/
cd /mnt/
sudo ./install-tl
vim ~/.bashrc
source ~/.bashrc
#tex live 2021
export MANPATH=${MANPATH}:/usr/local/texlive/2021/texmf-dist/doc/man
export INFOPATH=${INFOPATH}:/usr/local/texlive/2021/texmf-dist/doc/info
export PATH=${PATH}:/usr/local/texlive/2021/bin/x86_64-linux
latex -version
,若显示版本信息即为安装成功。Host HMLab88 #自定义主机的名字
HostName 115.24.167.215 #主机的IP
Port 22 #若有端口号,在这里加
User xxx #主机用户的用户名
Ctrl+Shift+P
,输入json,打开配置文件。追加"latex-workshop.latex.recipes"和"latex-workshop.latex.tools"等即可,详细信息见附录。Ctrl+S
即可保存文件并进行编译问题:
在刚配置完环境后第一次执行编译时可能会报错:
Recipe terminated with fatal error: spawn latexmk ENOENT.
这是因为环境变量没有在VsCode中生效导致的。可以尝试以下操作:
F1
,输入Remote-SSH: Kill VS Code Server on Host…,再尝试重新编译。附录:
LaTeX配置信息:
// LaTeX配置
//自动换行
"[latex]": {
"editor.wordWrap": "on"
},
//默认应用上次使用的方法来编译
"latex-workshop.latex.recipe.default": "lastUsed",
//补全提示时显示 Unimath 符号
"latex-workshop.intellisense.unimathsymbols.enabled": true,
//从已引用的包中补全
"latex-workshop.intellisense.package.enabled": true,
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.recipes": [
{
"name": "pdfLaTeXmk",
"tools": [
"pdfLaTeXmk"
]
},
{
"name": "XeLaTeXmk",
"tools": [
"XeLaTeXmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
],
"latex-workshop.latex.tools": [
{
"name": "XeLaTeXmk",
"command": "latexmk",
"args": [
"-xelatex",
"-synctex=1",
"-shell-escape",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "pdfLaTeXmk",
"command": "latexmk",
"args": [
"-pdflatex",
"-synctex=1",
"-shell-escape",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}, {
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.clean.fileTypes": [
"*.aux",
"*.bbl",
"*.blg",
"*.idx",
"*.ind",
"*.lof",
"*.lot",
"*.out",
"*.toc",
"*.acn",
"*.acr",
"*.alg",
"*.glg",
"*.glo",
"*.gls",
"*.ist",
"*.fls",
"*.log",
"*.fdb_latexmk"
],