You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.7 KiB

Introduction

This repository will help you to start working with Visual Studio Code and LaTeX.

Step 1: Install a LaTeX distribution

A LaTeX distribution is mandatory, depending on your system, you can install a complete or lite version. I recommend to install the full version. However there are several options like:

  • Texlive
  • MacTeX
  • MikTeX

Step 2: Install Visual Studio

Of course you will need Visual Studio Code (VSCode) as the main IDE for latex projects.

Step 3: Install and configure LaTeX Workshop extension

You need to install the Latex Workshop extension form James-Yu. This extension requires some extra configuration to properly work.

Thus, open the Command Palette by pressing Shift + Ctrl + P (Windows) or Shift + Cmd + P (macOS). Then type Open User Settings JSON and open the first item.

User setting JSON file example

Now copy and paste the following two snippets into your json file (inside the brackets {} of your file):

# "Your previous configuration" , 

"latex-workshop.latex.tools": [
 {
  "name": "latexmk",
  "command": "latexmk",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "-pdf",
   "-outdir=%OUTDIR%",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "xelatex",
  "command": "xelatex",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "pdflatex",
  "command": "pdflatex",
  "args": [
   "-synctex=1",
   "-interaction=nonstopmode",
   "-file-line-error",
   "%DOC%"
  ],
  "env": {}
 },
 {
  "name": "bibtex",
  "command": "bibtex",
  "args": [
   "%DOCFILE%"
  ],
  "env": {}
 }
],

Considers that most probably you already have a previous configuration inputs. Take care that these previous inputs (# your previous configuration) end with a comma after each entry.

Also copy and paste the next snippet:

"latex-workshop.latex.recipes": [
 {
  "name": "pdfLaTeX",
  "tools": [
   "pdflatex"
  ]
 },
 {
  "name": "latexmk 🔃",
  "tools": [
   "latexmk"
  ]
 },
 {
  "name": "xelatex",
  "tools": [
   "xelatex"
  ]
 },
 {
  "name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
  "tools": [
   "pdflatex",
   "bibtex",
   "pdflatex",
   "pdflatex"
  ]
 },
 {
 "name": "xelatex ➞ bibtex ➞ xelatex`×2",
 "tools": [
   "xelatex",
   "bibtex",
   "xelatex",
   "xelatex"
  ]
 }
],

Step 4. Write & Compile

Now you may open a tex file or create a new one. If you want to compile the file, press Ctrl + Alt + B (Windows) or option + Cmd + B (macOS). Moreover, you may choose another recipes from the sidebar. There is a button in the right top corner to preview PDF file.