DEV Community

Cover image for Let's use LaTeX!
Nicky Marino
Nicky Marino

Posted on • Edited on • Originally published at nickymarino.com

Let's use LaTeX!

This post was originally posted on my blog here.

LaTeX is a beautiful documentation system. It's similar to Markdown, but has many more features and is commonly used for academic papers and other publications that require a lot of equations. In this quick how to, we cover how to install LaTeX and use Visual Studio Code as an editor/previewer.

Installing LaTeX

I recommend downloading TeX Live for Windows/Linux, and MacTex for macOS.

Setting up our editor

If you haven't already, install Visual Studio Code and go through a tutorial. Then, we need to install our extension for LaTeX itself. Head over to LaTeX Workshop and click install.

Using LaTeX

Now that we have our editor setup, we can write our first project. All LaTeX documents have a (non-blank) file that ends with .tex, which is the "main" file that has all of the text of the document. Since LaTeX usually generates more files (such as .log, etc.) while building the document, it's recommended that every document you want to write has its own folder.

For starters, create a file named example.tex:

\documentclass{article}
    % General document formatting
    \usepackage[margin=0.7in]{geometry}
    \usepackage[parfill]{parskip}
    \usepackage[utf8]{inputenc}

\begin{document}
% Put your text here
This is starter text.
\end{document}
Enter fullscreen mode Exit fullscreen mode

Press Ctrl-Alt-B to build your project (or use the Command Palette), then Ctrl-Alt-T to view the pdf in a new tab. The end result should look like this:

picture

Conclusion

LaTeX and VSCode are a great combination that you can use to write beautiful reports and papers. Check out a tutorial or two to realize the full experience LaTeX has to offer.

Edit: Fanny recommends another great tutorial as well.
Edit 2: Fixed a tutorial link.

Top comments (19)

Collapse
 
fannyvieira profile image
Fanny

This tutorial can also help: github.com/LewisVo/Begin-Latex-in-...

Collapse
 
nickymarino profile image
Nicky Marino

Wow that's great! I'll add it.

Collapse
 
lucasreeh profile image
Lucas Reeh

If you do not use Latex often and need just to write one paper there are online tools available. I set it up on my machine because I write a lot, but I was trying out overleaf.com/ and it was a great experience because they have a lot of templates and git support. And no I do not get money to recommend them :D Just think it is a good place for beginners who have problems with the installation ;)

Collapse
 
nickymarino profile image
Nicky Marino

+1 Overleaf is great! I've recommended it to a few people as well.

Collapse
 
yssybyl profile image
Dr Janet Bastiman

I've loved LaTeX since I first saw it. I've been advocating Pweave for literal programming in my team and trying to get them to use it for automated diagrams too. I'm now delving into the depths of style files to create a PDF that appeases the marketing department for platform to customer automation. I've got a couple of posts already written on diagrams in LaTeX and using other True Type fonts which I'll cross post to here.

Spread the \LaTeX \heartshape :)

Collapse
 
oxfist profile image
Andrés

I strongly suggest using a specialized IDE such as TeXstudio, for me it was the best option (there are a lot!) and simply a delight to use during my college years.

Collapse
 
stealthmusic profile image
Jan Wedel • Edited

It’s probably very powerful, but it won’t replace markdown. I use markdown very often in Sublime with highlighting to just structure some thoughts without ever generating a document from it. Markdown is just some formalized way to structure a text file like humans would do. Latex clearly is not something a human would write.

Now look at you basic example, it’s completely unreadable as source.

For more complex technical documentation I would still probably use Asciidoc.

Then, there are scientific papers. Actually when I did my masters thesis, I wanted to use Latex but I knew I had to use a lot of formulas, pictures and tables. The way to add those to a latex document was overly complex at that time and unreadable in source. So I read a couple of articles about how to handle large documents in Word (yes, I said it) without crashing it. Then I spent some time to create a Layout, styles and add fonts etc to resemble a document that looks like something that Latex would produce. At the end, I was much faster with the formula editor, inline Tables and graphics.

So I don’t think I would ever write Latex as primary source. Some WYSIWYG editor that generates Latex that I could change If I want to.

Collapse
 
espoir profile image
Espoir Murhabazi

Thanks a lot , i've used latex for 2 years now for my research paper and all my universities homework, it is a good and awesome tool, my favorite editor is texstudio the other thing i like about latex it is his community, the tex.stackexchange has already answers to any problems you can have with that editor

Collapse
 
shreyasminocha profile image
Shreyas Minocha

I'm a fan of lyx, a WYSIWYM(What you see is what you mean) editor for latex.

Collapse
 
michie1 profile image
michie1

In my experience this is an application you want to use with Docker.

Collapse
 
marlysson profile image
Marlysson Silva • Edited

Why do use docker to this..?

Collapse
 
michie1 profile image
michie1

This is based on my experience a few years ago. I installed Latex from the default Ubuntu repo and it missed a package. Installing the missing package didn't work because it depended on a more recent version of Latex. I installed Latex with the official ISO, but there were some conflicts with the previous installation. I removed the previous installation but I forgot to remove some configuration settings. Possible it's just me, but it was not plugin and play.

Few months ago I needed Latex again and I tried one of the popular public available docker latex container. Besides waiting to download the container it only took me one minute to figure out what I wanted to do, did it and removed the container again.

Collapse
 
alex_escalante profile image
Alex Escalante

That's just how I use it nowadays. Look for the image in the Docker Hub!

Collapse
 
hoffmann profile image
Peter Hoffmann

I finally managed to write my reply to your article, thank you for the motivation

Collapse
 
heikodudzus profile image
Heiko Dudzus

I second that. Org-mode is great. I rarely use LaTeX, these days, but I use org-mode for many things, often exporting via LaTeX to PDF