# VS Code下的$\LaTeX$環境設定 > [name=陳宥廷 Dextin][time=Sat, Mar 3, 2021] [color=#87CEFA] > ###### tags: `筆記` `LaTeX` ## ➤ TeX Live安裝 ### 前情提要 1. 筆者使用的電腦是win10作業系統 2. 已裝有VS Code 3. MikTex和TeX Live大同小異,擇一安裝即可 ### Step 1:下載 先到[TeX Live官網](https://www.tug.org/texlive/acquire-netinstall.html)下載安裝包(它的官網都是字,看得讓人眼花@@) 1. windows環境就下載install-tl-windows.exe 2. 其他就下載install-tl-unx.tar.gz ### Step 2:安裝 1. 使用管理員權限安裝,可以選擇安裝位置,點選**進階Advanced**選項 ![](https://i.imgur.com/mptmI8A.png =300x) 2. 點選**自訂Customize**選項,Disk space required是預估空間大小 ![](https://i.imgur.com/Ao5D0FE.png =550x) 3. 去掉不需要的語言,筆者使用中文、漢字和英文。TeXworks editor是Tex Live附的編輯器,可以取消勾選 ![](https://i.imgur.com/J2i3lq8.png =350x) 4. 回到前一畫面,如果有更動語言或模組,要確認**字體/巨集包**是否有勾選 ### Step 3:等待 經過慢常的等待(我大概跑2個多小時),終於載好了。 確認加入**環境參數PATH** 在cmd中測試 ``` tex -v latex -v xelatex -v pdflatex -v ``` ## ➤ VS Code環境設定 如果已經安裝好Tex Live,在VS Code的Extensions中安裝**LaTeX Workshop**,安裝後Ctrl+Shift+P開啟**setting.json** ``` json { // 編譯LaTeX的工具設定 "latex-workshop.latex.tools": [ { "name": "xelatex", "command": "xelatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "xelatex-with-shell-escape", "command": "xelatex", "args": [ "--shell-escape", "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "pdflatex-with-shell-escape", "command": "pdflatex", "args": [ "--shell-escape", "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOC%" ] }, { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "%DOC%" ] } //{ // "name": "bibtex", // "command": "bibtex", // "args": [ // "%DOCFILE%" // ] //}, //{ // "name": "makeindex", // "command": "makeindex", // "args": [ // "%DOCFILE%" // ] //} ], // 選擇LaTeX編譯工具的指令,以及工具的順序 "latex-workshop.latex.recipes": [ // 目前只使用xelatex和bibtex { "name": "xelatex", "tools": [ "xelatex" ] }, { "name": "xelatex with shell escape", "tools": [ "xelatex-with-shell-escape" ] }, { "name": "xelatex -> bibtex -> xelatex*2", "tools": [ "xelatex", "bibtex", "xelatex", "xelatex" ] }, { "name": "bibtex", "tools": [ "bibtex", ] } ], // 選擇pdf瀏覽器,可選browser/tab/external "latex-workshop.view.pdf.viewer": "tab", // 每次編譯前,刪除之前的output檔 "latex-workshop.latex.clean.enableed": true, "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" ], } ``` ## ➤ 中文設定 (研究中) ## ➤ 論文引用 http://tul.blog.ntu.edu.tw/archives/5764 ## ➤ 常見問題 以下是筆者所碰到的問題, ### 1. 找不到fmt檔 ``` I can't find the format file `xelatex.fmt'! ``` 字體沒安裝到,重新安裝 ### 2. 找不到sty檔 有些只支援TeX Live或MikTex的package https://www.ctan.org/ 丟到目標tex的資料夾 安裝方法研究中 ### 3. pdfLaTeX編譯問題 研究中,筆者只使用XeTeX和BibTexz。https://www.itread01.com/content/1546318083.html