MacOs上Vscode + MacTex + skim实现latex编写

1.工具安装

  • 安装vscode
  • 在vs code上安装latex插件:latex workshop
    MacOs上Vscode + MacTex + skim实现latex编写_第1张图片
  • 在mac上安装 MacTex
    参考博文:https://blog.csdn.net/ChrisP_333/article/details/82943508
  • 安装skim

2.环境配置

2.1 实现vs code可以编译latex代码
在 vs code中 按如下步骤操作:
MacOs上Vscode + MacTex + skim实现latex编写_第2张图片
在搜索栏中搜索setting.json
MacOs上Vscode + MacTex + skim实现latex编写_第3张图片
添加如下设置:

"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预览还需以下的两条配置。
MacOs上Vscode + MacTex + skim实现latex编写_第4张图片

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相应代码处
MacOs上Vscode + MacTex + skim实现latex编写_第5张图片
MacOs上Vscode + MacTex + skim实现latex编写_第6张图片

然后就可以使用快捷键 command + ship + 鼠标左击就可以跳转到vscode 的相应的tex代码处。

你可能感兴趣的:(工具配置)