配置vs code用于Mac下latex的編寫。
首先要安裝好MacTex和VS Code,不多說。
下面的步驟是配置vscode編寫latex的中文支持。
打開vscode,安裝latex workshop插件。
然后,打開vscode的配置界面,需要修改下面兩項(xiàng)配置。
- 在latex-workshop.latex.tools配置中,增加xelatex項(xiàng),具體如下。這一項(xiàng)的作用是在工具集中定義xelatex項(xiàng),以便下一項(xiàng)配置能找到
- 在latex-workshop.latex.recipes配置中,將第一項(xiàng)的latexmk改為xelatex。這里定義的是編譯時(shí)調(diào)用的工具順序,默認(rèn)第一個(gè)為latexmk,因?yàn)槲覀円С种形?,所以替換為xelatex。
{
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%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 -> bibtex -> pdflatex*2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
]
}
在vscode中打開或創(chuàng)建一個(gè).tex文件,注意編碼一定要是utf8,輸入以下內(nèi)容。保存。會(huì)自動(dòng)編譯產(chǎn)生對應(yīng)的pdf。
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{STSong}
\begin{document}
hello 中文
\end{document}