Working with LaTeX on VSCode

Posted by 韩同学的笔记本 on March 21, 2020

Toolchain 安装

TexLive or MacTex

插件选择

LaTeX Workshop by James Yu

VSCode 配置

添加以下代码到 settings.json 。注意:%DOC% 代表绝对路径,%DOCFILE% 代表相对路径。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"latex-workshop.latex.autoBuild.interval": 2000,
"latex-workshop.latex.recipe.default": "lastUsed",
"latex-workshop.latex.tools": [
{
    "name": "latexmk",
    "command": "latexmk",
    "args": [
    "-synctex=1",
    "-interaction=nonstopmode",
    "-file-line-error",
    "-pdf",
    "%DOCFILE%"
    ]
},
{
    "name": "xelatex",
    "command": "xelatex",
    "args": [
    "-synctex=1",
    "-interaction=nonstopmode",
    "-file-line-error",
    "%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": "latexmk",
    "tools": [
    "latexmk"
    ]
},
{
    "name": "xelatex -> bibtex -> xelatex*2",
    "tools": [
    "xelatex",
    "bibtex",
    "xelatex",
    "xelatex"
    ]
}
],
"latex-workshop.view.pdf.viewer": "tab",
"latex-workshop.latex.clean.fileTypes": [
    "*.aux",
    "*.bbl",
    "*.bcf",
    "*.blg",
    "*.idx",
    "*.ind",
    "*.lof",
    "*.lot",
    "*.out",
    "*.toc",
    "*.acn",
    "*.acr",
    "*.alg",
    "*.glg",
    "*.glo",
    "*.gls",
    "*.ist",
    "*.fls",
    "*.log",
    "*.fdb_latexmk"
]

个人模板

附上个人模板。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
\documentclass[UTF8,fontset=adobe,a4paper]{ctexart}
% 如果没有 adobe 字体,上一行当中的 `fontset=adobe` 可以删掉
\usepackage[margin = 2cm, centering, includefoot]{geometry}
\usepackage[
backend = biber, style = caspervector, utf8,
giveninits = true, sortgiveninits = true
]{biblatex}
\usepackage{dsfont, color}
%\color{white}
%\pagecolor{black}
\usepackage{xeCJK}
\xeCJKsetup{CJKmath=true}
\usepackage{amsmath, amssymb, booktabs, diagbox, graphicx, float, threeparttable, iftex, fancyhdr, hyperref, enumitem, fancyvrb, hologo}
\xeCJKsetup{CJKmath=true}
\hypersetup{colorlinks = false}
%\hypersetup{colorlinks = true, allcolors = blue}
\pagestyle{fancy}\fancyhf{}\cfoot{\thepage}
\renewcommand{\headrulewidth}{0pt}
\setlist{nolistsep}
\setlength{\hfuzz}{3pt}
\ctexset{linestretch = {\maxdimen}}
\renewcommand{\bibfont}{\small}
\newcommand{\myemph}[1]{\emph{\textcolor{red}{sub1}}}
\RecustomVerbatimEnvironment{Verbatim}{Verbatim}%
{frame = single, tabsize = 4, formatcom = {\ifXeTeX\xeCJKVerbAddon\fi}}
\RecustomVerbatimCommand{\VerbatimInput}{VerbatimInput}{
fontsize = {\small}, baselinestretch = 1,
tabsize = 4, formatcom = {\ifXeTeX\xeCJKVerbAddon\fi}
}
\DeclareBibliographyCategory{cited}
\AtEveryCitekey{\addtocategory{cited}{\thefield{entrykey}}}
\addbibresource{main.bib}
%\setcounter{secnumdepth}{0}"
\title{\textbf{作业}}
\author{
MagHSK
}

\begin{document}
\maketitle


% Your content
% \input{content.tex}


\nocite{*}
\end{document}