一、下载软件
下载MiKTex:Getting MiKTeX
安装完成有运行"Miktex console"进行配置(选择"以管理员身份运行")。
运行"vscode", 安装其扩展Latex Workshop.
对于Miktex, 需要对Latex Workshop配置其编译方案(recipe)。
先点左下角的小齿轮,点击设置。
再点击VS code右上角的图标:
就会出现json文件,修改如下:
{
// 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%"
]
}
],
"workbench.colorTheme": "Default Light+ Experimental",
"latex-workshop.latex.clean.enabled": true,
"latex-workshop.view.pdf.viewer": "external",
"latex-workshop.view.pdf.external.command": {
"command": "C:/Users/RM/AppData/Local/SumatraPDF/SumatraPDF.exe", //SumatraPDF.exe的实际路径
"args": [
"%PDF%"
]
}
}
测试test.tex
%!TEX program = xelatex
% 使用 ctexart 文类,UTF-8 编码
\documentclass[UTF8]{ctexart}
\title{文章标题}
\author{Siwind}
\date{\today}
\begin{document}
\maketitle
This is the context of the article.
这就是文章的所有内容。
\end{document}
预览:点击View LaTeX PDF中的View in VSCode tab。