vscode的编辑器非常强大,推荐使用,这里记录一下自己的配置过程。
所使用的软件:VSCode + Latex Workshop + MiKTeX + SumatraPDF
1. VS Code 安装:https://code.visualstudio.com/
安装过程比较简单,这里不赘述
2. MiKTex安装:??Getting MiKTeX
同样,废话不多说,下载安装即可
3. 在VS Code中安装 Latex Workshop插件(假设对vscode已稍微熟悉,知道怎么下载安装插件)
4.快捷键 control + shift + p,打开搜索配置,搜索:settings
设置以下代码:
{
"latex-workshop.latex.recipes": [{
"name": "xelatex",
"tools": [
"xelatex"
]
}, {
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.latex.tools": [{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%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.autoClean.run": "onBuilt",
"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"
],
"editor.fontSize": 20,
"latex-workshop.showContextMenu":true, //右键菜单
"jupyter.askForKernelRestart": false,
"editor.fontFamily": "Fira Code Light, Operator Mono",
"terminal.integrated.fontFamily": "monospace",
"editor.renderWhitespace": "all",
"files.autoSave": "onFocusChange",
}
5. SumatraPDF: 软件下载安装??Sumatra PDF reader download page
6. 配置SumatraPDF,同时配置双向定位:
// "latex-workshop.view.pdf.viewer": "tab", // 内置pdf阅读器
"latex-workshop.view.pdf.viewer": "external", // 外部pdf阅读器
"latex-workshop.view.pdf.external.viewer.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
"latex-workshop.view.pdf.external.viewer.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"D:/softwares/Microsoft VS Code/Code.exe\" \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"code \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
"%PDF%",],
注意对应修改:vs code软件位置和SumatraPDF.exe软件为位置
7. 显示编译结果:
?反向搜索:?双击 PDF 中的任意一处即可跳转到 VSCode 中所对应的内容的源代码处,同时,最好不要清理 ?gz 后缀的临时文件,否则就不能进行正向和反向搜索。
1)在 LaTeX 文件中,按?Ctrl + Alt + J ?跳转到对应的 PDF 文件位置。
? ?(2)在 PDF 文件中,按下?Ctrl + ← ?同时鼠标单机,跳转到对应的 LaTeX 文件位置。
但双向搜索一般会有以下问题:
通过VScode唤醒的SumatraPDF,双击PDF文件反向搜索失效(也没有任何报错提示);
单独打开SumatraPDF,双击PDF文件会跳转到cli.js文件上,如下图:
?可参考这里解决:VScode+Latex+SumatraPDF反向搜索失败解决办法(Version 1.63) - 知乎
附完整配置:
{
"latex-workshop.latex.recipes": [{
"name": "xelatex",
"tools": [
"xelatex"
]
}, {
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"latex-workshop.latex.tools": [{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%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", // 内置pdf阅读器
"latex-workshop.view.pdf.viewer": "external", // 外部pdf阅读器
"latex-workshop.view.pdf.external.viewer.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
"latex-workshop.view.pdf.external.viewer.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"\"D:/softwares/Microsoft VS Code/Code.exe\" \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
"%PDF%"
],
"latex-workshop.view.pdf.external.synctex.command": "C:\\Program Files\\SumatraPDF\\SumatraPDF.exe", //注意修改路径
"latex-workshop.view.pdf.external.synctex.args": [
"-forward-search",
"%TEX%",
"%LINE%",
"-reuse-instance",
"-inverse-search",
"code \"D:/softwares/Microsoft VS Code/resources/app/out/cli.js\" -gr \"%f\":\"%l\"",
"%PDF%",],
"latex-workshop.latex.autoClean.run": "onBuilt",
"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"
],
"editor.fontSize": 20,
"latex-workshop.showContextMenu":true, //右键菜单
"jupyter.askForKernelRestart": false,
"editor.fontFamily": "Fira Code Light, Operator Mono",
"terminal.integrated.fontFamily": "monospace",
"editor.renderWhitespace": "all",
"files.autoSave": "onFocusChange",
}
|