天天看点

latex 1图加标题_使用VsCode编译latex心得

latex 1图加标题_使用VsCode编译latex心得

本人最早接触latex是刘海洋老师的《latex入门》,大家可自行搜索相关资源查阅,可以作为参考书,不建议从头到尾的翻阅学习。

学习窍门

  • 在配置好相关软件之后,应当立即编译一个模板,保证能通过。相关的模板如IEEE等学术报告,刚开始建议先从英文编译,成功后可以试着中文编译。
  • 在成功编译之后,尝试着写文章,大概实现标题、字体设置、表格、图片插入几个常见功能就好,千万不要深扎进去,没有任何价值。我们用latex是为了减少排版的工作量,并非成为latex专家,很多功能是用不到的。我们只需抓住一个原则: 拿来主义 ,需要什么功能,就搜索该功能的语法即可。

配置环境

  1. 下载vscode,miktex和SumatraPDF,没有特别的要求,直接安装即可;
  2. miktex安装后,需要注意两个地方
    1. 应当选择"以管理员身份运行",在overview设置。
latex 1图加标题_使用VsCode编译latex心得

2.选择update,点击check for update

latex 1图加标题_使用VsCode编译latex心得

3. vscode安装后,需要进行环境配置

    1. 安装插件:必要插件有latex workshop,扩展插件有beautify,code spell checker, latex language support, markdown preview enhanced 和one dark pro,具体的作用自行搜索查询。
latex 1图加标题_使用VsCode编译latex心得

2. 编写设置环境代码:点击设置-偏好,编辑setting.json文件,将以下代码复制进去。

{
  "markdown-pdf.displayHeaderFooter": false,
  "[python]": {},
  "files.associations": {
      "*.rmd": "markdown"
  },
  "files.autoSave": "onFocusChange",

  // Latex workshop 
  "latex-workshop.latex.recipes": [
    {
      "name": "texify",  //放在最前面为默认编译方案, 适用于MikTex
      "tools": [
        "texify"
      ]
    },
  {
        "name": "xelatex",
        "tools": [
            "xelatex"
        ]
    },
    {
        "name": "xe->bib->xe->xe",
        "tools": [
            "xelatex",
            "bibtex",
            "xelatex",
            "xelatex"
        ]
    }
  ],
  "latex-workshop.latex.tools": [
    {
      "name": "texify",
      "command": "texify",
      "args": [
        "--synctex",
        "--pdf",
        "--tex-option="-interaction=nonstopmode"",
        "--tex-option="-file-line-error"",
        "%DOC%.tex"
      ]
    },
  {
        // 编译工具和命令
        "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.external.command": {
    "command": "C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe",  //SumatraPDF.exe的实际路径
    "args": [
        "%PDF%"
    ]
  },
  "latex-workshop.view.pdf.external.synctex": {
    "command": "C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe",
    "args": [
        "-forward-search",
        "%TEX%",
        "%LINE%",
        "%PDF%"
    ]
  },
  "latex-workshop.showContextMenu": true,
  "editor.wordWrap": "on", // 自动换行
  "latex-workshop.view.pdf.viewer": "tab", //tab是软件内打开,推荐external是用pdf打开(进入第三步)

}
           

3. 配置SumatraPDF,需要设置反向搜索和正向搜索。

    1. 在setting.json里添加相关配置,上面的代码已经加入,但是需要注意软件的安装位置。
    2. 打开SumatraPDF-设置-选项 -“设置反向搜索命令行”,加入以下代码,即完成反向搜索。同样的,需要注意软件的安装位置。

      "C:Program FilesMicrosoft VS CodeCode.exe" -g "%f:%l"

      以上是我电脑code.exe安装路径。
    3. 如果存在找不到 SumatraPDF-设置-选项 -“设置反向搜索命令行”,则需要在高级选项(打开是txt格式)里面把EnableTeXEnhancements改为True就能看到了。

相关软件下载:链接:https://pan.baidu.com/s/16RuFV8F2bhDKhZAHy4sNtQ

提取码:971p

提供一些有用的网址

表格生成器https://www.tablesgenerator.com/

数学符号https://blog.csdn.net/Ying_Xu/article/details/51240291

伪代码https://blog.csdn.net/golden1314521/article/details/40923377

模板分享网站https://www.latexstudio.net/

继续阅读