2.1 实现vs code可以编译latex代码
在 vs code中 按如下步骤操作:
在搜索栏中搜索setting.json
添加如下设置:
"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.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
{
"name": "pdflatex",
"tools": [
"pdflatex"
]
},
{
"name": "latexmk",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
],
"files.associations": {
"*.tex": "latex"
},
//"latex-workshop.latex.clean.onFailBuild.enabled": true,
"latex-workshop.latex.autoClean.run": "onFailed",
"C_Cpp.updateChannel": "Insiders",
"window.zoomLevel": 1,
按照如下操作就可以进行编译以tex 结尾的latex代码
点击下面的view in vscode tab可以在代码的右边实现pdf预览。但是如果想要结合外部pdf预览还需以下的两条配置。
2.2 实现从vs code跳转到skim
第一条配置可以使得vscode从tex跳转到skim。
点击: view in external viewer 或者快捷键command + option + j
"latex-workshop.view.pdf.external.command": {
"command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"args": [
"0",
"%PDF%"
]
},
第二条配置可以使得从指定的tex代码处跳转到skim的pdf预览内容处,并且会在skim的pdf界面出现红色指示断点。
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.synctex": {
"command": "/Applications/Skim.app/Contents/SharedSupport/displayline",
"args": [
"-r",
"%LINE%",
"%PDF%",
"%TEX%"
]
},
2.3 实现从 skim中的pdf文件光标处跳转到vscode相应代码处
然后就可以使用快捷键 command + ship + 鼠标左击就可以跳转到vscode 的相应的tex代码处。