Sharing some programming knowledge.

0%

LaTeX Workshop:Use LaTeX in Vscode

Install LaTeX

  1. Install LaTeX: sudo apt install texlive-full
  2. Install LaTeX compile engine: sudo apt install texlive-xetex
  3. Fonts support: sudo apt install texlive-fonts-extra
  4. (optional)Install GUI editor: sudo apt install texstudio

Configure settings in Vscode

  1. Install LaTeX Workshop extension
  2. Open command pallete:ctrl+shift+P, type settings.json to open settings
  3. Add the following code to settings.json:
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
"latex-workshop.latex.recipes": [    // the first recipe is the default compile tool
{
"name": "xelatex", // you can change this to your compile tool if different
"tools": ["xelatex"]
},
{ // the seconde recipe is the recipe chain compile
"name": "xelatex->bibtex->xelatex*2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
],
"latex-workshop.latex.tools":[
{ // compile tools and commands
"name":"xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOCFILE%"
]
}, {
"name":"bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
]
}
],
"latex-workshop.latex.clean.fileTypes": [ // (Optional)choose which kind of files to clean
"*.aux",
"*.log",
"*.synctex.gz"
],
"latex-workshop.latex.autoClean.run": "onBuilt", // (Optional)clean auxiliary files if you want a clean working directory
"latex-workshop.latex.autoBuild.run": "never", // (Optional)never auto build .tex file when the file is auto-saved
"latex-workshop.view.pdf.hand": true, // (Optional)set default to hand mode when open pdf viewer in vscode

Note: The difference between latex-workshop.latex.recipes and latex-workshop.latex.tools may be confusion. Actually, latex-workshop.latex.toolchains is responsible for these stuff, but now it is seperated to parts. In my opinion, you can think that latex-workshop.latex.recipes is responsible for logical control while latex-workshop.latex.tools is responsible for args control.

After this, it should be ok to run.