DEV Community

Cover image for How to create and compile LaTeX documents on Visual Studio Code
Akila Maithripala for Mozilla Club of UCSC

Posted on

How to create and compile LaTeX documents on Visual Studio Code

We all know that when it comes to typesetting lengthy documents, LaTeX is the answer. You only need to focus on content, and LaTeX will do the formatting for you.

There are many online LaTeX compilers like Overleaf and offline editors like TexStudio but still, if you want to edit LaTeX documents on your favourite text editor (yes, it's everyone's favourite), this is how to do just that, on a Windows system.

1. Installing the TeX distribution (TeX Live)

TeX Live is a straightforward way to get up and running with the TeX document production. It includes all the major TeX-related programs and fonts including support for many languages around the world.

You can download TeX live installer here.
install-tl-windows.exe (ctan.org)

If the above link is not working go to this link and download install-tl-windows.exe
Installing TeX Live over the Internet - TeX Users Group (tug.org)


Tex-Live download page

Then "install" the program (not unpack) and wait for the packages to install.

Reboot after the installation is complete so it will reload the environment variables.

2. Setting up VS Code

To export LaTeX documents to PDFs, view PDFs, Intellisense and more features, we have to install an extension for VS Code.

You can install the extension from the link below.

LaTeX Workshop - Visual Studio Marketplace

LaTeX workshop

For additional features you can install LaTeX utilities, but it is no longer maintained by the developer.

LaTeX Utilities - Visual Studio Marketplace

All done! Now you have set up the environment for creating LaTeX documents.

Let's test our setup with a practice code.

Create and save file with a .tex extension on vscode. (eg: "mydocument.tex")

\documentclass[12pt]{article}

\usepackage{amsmath}

\usepackage{graphicx}

\usepackage{hyperref}

\usepackage[utf8]{inputenc}

\title{How to Set Up LaTeX on VSCode}

\author{Mozilla Club of UCSC}

\date{2020–12–10}

\begin{document}

\maketitle

\section{Introduction}

Here is the introduction of our text

\begin{itemize}

\item One

\item Two

\item Three

\end{itemize}

\end{document}
Enter fullscreen mode Exit fullscreen mode

After saving the file, click on the magnifying glass icon on the top right corner.

Compile PDF button

Now it should display the PDF view of your latex document on the right side of the VS Code window.

If it doesn't show up, click the TeX icon on the left horizontal menu, and click on "View LaTeX PDF" under the COMMANDS palette.

Commands palette in vscode

Compiled PDF document will now open with your default browser.

That's it! Now you can create and export LaTeX documents on your favourite text editor. If you have any problem regarding the whole process please drop a comment below.

Top comments (1)

Collapse
 
jebin1999 profile image
Jebin Larosh Jervis

what about Mac?