天天看點

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/

繼續閱讀