1. 安装 texlive
sudo apt install texlive-lang-chinese texlive-xetex texlive
2. VScode 安装插件 Latex Workshop,并配置
编辑 VSCode settings.json
:
{
// Latex workshop
"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"%DOC%"
]
},
{
"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.latex.recipes": [
{
"name": "xelatex",
"tools": ["xelatex"]
},
{
"name": "latexmk",
"tools": ["latexmk"]
},
{
"name": "pdflatex -> bibtex -> pdflatex*2",
"tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex"]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"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"
]
}
3. 试用
\documentclass[UTF8]{ctexart}
\begin{document}
你好 world!
\end{document}

参考
- Ubuntu 安装包参考:
- VSCode配置参考:
PS
我用的操作系统是 macOS,使用 VirtualBox 创建 Ubuntu 虚拟机,通过 VSCode 连接到虚拟机进行编辑。个人认为在虚拟机中开发可以避免个人电脑中安装过多工具,而且虚拟机的文件可以存在移动硬盘里,即使更换电脑也可以继续使用,不用再配置tex环境。
网友评论