在VsCode中使用Latex === ###### tags: `Terminal Problem` `LaTex` `VsCode` <!-- **WebPlotDigitizer** --> Date : 2022/11/02 --- date : 20220928 author : Siao,YU-FONG 作業系統 : Ubuntu 20.04 vscode latex 中文 --- * ### step1. vscode --> 左下Manage鍵 --> Command Palette... --> Open Settings(JSON) --> 在大括弧中加入以下命令: ```groovy "files.autoSave": "onFocusChange", "latex-workshop.view.pdf.viewer": "tab", "latex-workshop.view.pdf.hand": true, "latex-workshop.synctex.afterBuild.enabled": true, "latex-workshop.latex.tools": [ { "name": "xelatex", "command": "xelatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOCFILE%" ] }, { "name": "latexmk", "command": "latexmk", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "-pdf", "%DOCFILE%" ] }, { "name": "pdflatex", "command": "pdflatex", "args": [ "-synctex=1", "-interaction=nonstopmode", "-file-line-error", "%DOCFILE%" ] }, { "name": "bibtex", "command": "bibtex", "args": [ "%DOCFILE%" ] } ], "latex-workshop.latex.recipes": [ { "name": "XeLaTeX", "tools": [ "xelatex" ] }, { "name": "PDFLaTeX", "tools": [ "pdflatex" ] }, { "name": "latexmk", "tools": [ "latexmk" ] }, { "name": "BibTeX", "tools": [ "bibtex" ] }, { "name": "pdflatex -> bibtex -> pdflatex*2", "tools": [ "pdflatex", "bibtex", "pdflatex", "pdflatex" ] }, { "name": "xelatex -> bibtex -> xelatex*2", "tools": [ "xelatex", "bibtex", "xelatex", "xelatex" ] } ], "code-runner.runInTerminal": true, "workbench.colorTheme": "Default Dark+", "editor.cursorSmoothCaretAnimation": true, "editor.smoothScrolling": true, "powermode.shake.intensity": 0, "powermode.enabled": true, "powermode.combo.counterEnabled": "hide", "powermode.combo.timeout": 3, "powermode.combo.counterSize": 1, "todo-tree.general.tags": [ "BUG", "HACK", "FIXME", "TODO", "XXX", "[ ]", "[x]", "Siao" ], "todo-tree.highlights.useColourScheme": true, "todo-tree.general.enableFileWatcher": true, "tabnine.experimentalAutoImports": true, "todo-tree.highlights.backgroundColourScheme": [ "red", "orange", "yellow", "green", "blue", "indigo", "violet", "blue" ], "todo-tree.highlights.foregroundColourScheme": [ "white", "black", "black", "white", "white", "white", "black", "white" ] ``` --- * ### step2. 先去terminal查看目前下載安裝好的中文字形: ``` $ fc-list :lang=zh-cn ``` 從裡面挑一個 例: ``` usr/share/fonts/truetype/arphic/ukai.ttc: AR PL UKai CN:style=Book ``` Latex: ``` \setCJKmainfont[AutoFakeBold=6,AutoFakeSlant=.4]{ukai.ttc} ``` 即可。 --- * ### Latex 中文範例 ``` \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{fontspec} \usepackage{CJK} \usepackage{xeCJK} \setmainfont{Times New Roman} \setCJKmainfont[AutoFakeBold=6,AutoFakeSlant=.4]{ukai.ttc} %cwTeXKai (楷書, Chinese traditional, Korean) %cwTeXMing (明體, Chinese traditional, Korean) %TW-Kai (全字庫正楷體, Chinese simplified and traditional) %TW-Sung (全字庫正宋體, Chinese simplified and traditional) %AutoFakeBold設定粗體字要多粗 %AutoFakeSlant設定斜體字要多斜,範圍-0.999到0.999,負值為往左斜 \begin{document} \section{Introduction} \LARGE 中文測試 English test \end{document} ```