Getting Started with LaTeX

Have you ever taken a look at a scientific paper and thought “I wish my papers could look as neatly formatted as that.”? Well, they can! All you have to do is use \LaTeX. You may have heard of LaTeX before, perhaps you’ve even thought about trying it out. LaTeX is the typesetting software of choice for most scientific disciplines. It’s also a great tool to use anytime you want to produce a professional-looking document.

LaTeX is the preferred scientific typesetting environment for several reasons. One of these reasons is that it easy to consistently produces documents with the same formatting. Secondly, it is very easy to write mathematical equations in LaTeX. Math equations such as \Delta V = a \cdot t, are simply typed out, turning into a neat equation: \Delta V = a \cdot t. A third feature that makes LaTeX popular is that it provides effortless bibliography management, which is especially handy if you have to cite a lot of papers.

This guide is meant to serve as advice on how to begin using LaTeX. It also includes some helpful tips and tricks I’ve learned over the years. I will not go into much depth on many of the specific commands because there are many in-depth tutorials and explanations available online. In particular, ShareLaTeX has some very good video tutorials for beginners.

How to Start

To begin, you will need to get a LaTeX compiler. For this, you can either download a LaTeX package or use an online editor. Two of the most popular online LaTeX compilers are ShareLaTeX and Overleaf. These online compilers are a great place to try out LaTeX and offer an array of benefits. Firstly, all your work is saved online, so you can access your documents from any computer with internet access. Secondly, these websites allow you to collaborate in real-time with other authors, much like how Google Docs works.

If you are serious about using LaTeX, you may wish to download LaTeX for offline use. The LaTeX Project provides links to websites with full LaTeX distributions, which have all the various packages you will need. For Mac users, the MacTeX distribution is recommended, while Windows users will probably want proTeXt. Both distributions come with all the major packages, document templates, and an editing environment to easily create and view your documents. There are also many LaTeX distributions available for Linux, but I do not have enough experience with any of them to provide a recommendation.

When using a text editor like Microsoft Word, what you see is what you get. However, writing in LaTeX looks more like writing code. You’ll be inputting commands which will tell the compiler how to format your text. Once you compile your document, you’ll be able to view the finished pdf. While this may seem intimidating, it actually gives you a lot of power over how your document looks and can help make writing simpler in myriad ways.

In LaTeX, commands are usually denoted by a \ character, followed by the command name, such as \includegraphics. The command tells LaTeX what you want to do, but you must also specify some other parameters. These parameters go within curly braces, and state exactly what you want the command to do. For example, \includegraphics{picture.png} tells the \includegraphics command that you want to put in the picture file named “picture.png”. Some commands also have optional parameters. These go within square brackets, like so: \includegraphics[width=0.5\textwidth]{picture.png}. In this case, we’re saying “insert the image picture.png, and make it half the width of the text”. Other commands, like \hline don’t have any options associated with them, and can be used as-is.

An example of what editing a paper in LaTeX looks like (using the TeXStudio software in the proTeXt distribution).

The first part of your .tex file is called the preamble. The text you put here does not show up in your actual document but helps determine its formatting. The most common commands placed here are \usepackage{} commands. \usepackage{} tells LaTeX to load a package which is responsible for a particular part of the formatting. For example, the hyper package allows you to create hyperlinks. Another common package called geometry is used for setting up margins and paper sizes. After you have used LaTeX for a while, you gain familiarity with the packages you use most often.

When you start learning LaTeX, I recommend beginning your documents using a template. There are templates for many different kinds of documents, from books to theses, resumes to presentations, available from many sources online, like LaTeX Templates, Overleaf, ShareLaTeX, and others.. Many LaTeX distributions, like MacTeX and proTeXt also come with built-in templates. These templates have all the packages you need in the preamble, and all you have to do is edit the parts you wish to change. You can even create your own custom templates, like for lab reports, once you figure out which packages you like and normally use.

Some journals and science publishers actually provide LaTeX style documents in order to make sure all papers published in their journal have the same formatting. A good example of this is AASTeX. To use these special styles, all you have to do is download the provided .cls files. Then, you add the file to the folder which contains your .tex file. When you begin your document, use the command \documentclass{aastex61} (or whatever the name of the .cls file is). Most journals that provide a class file will also publish a guide which explains how to use it (like AASTeX does).

Once you’ve finished setting up the preamble, it’s time to start writing. At this point, you use the \begin{document} command. Anything placed between this line and the \end{document} line will be a part of your text. This is where all your text, figures, equations, and other commands go. While writing your document, you may need to cite sources. LaTeX uses BibTeX to manage references and bibliographies. There are many good BibTeX tutorials available online.

The best part about LaTeX is that it will do exactly what you tell it to do, nothing more. The downside to LaTeX is that it will do exactly what you tell it to do, nothing more. As long as you know how to format your commands, LaTeX is an extremely powerful and customizable tool. However, this also means that if you type your code incorrectly, you will get an error. Thankfully, there is a very large community of people who use LaTeX. When I have problems, I often turn to the TeX Stack Exchange. This website is a great repository of problems people have had while working with LaTeX, and usually I can find a solution to whatever problem I’m facing there.

When should you start?

At this point, you may be wondering when you should use LaTeX. The answer is: you can use it anytime you need to prepare a typed document. LaTeX easily produces professional-looking, high-quality documents that will be the envy of those still using Microsoft Word. I basically use LaTeX for everything, from simple reports to term papers to my personal resume.

So next time you need to type something, consider giving LaTeX a try. Learning it does not take very long, and it is a valuable skill to have.

About Peter Sinclair

I'm a graduate student at the University of New Mexico. My hobbies include reading, cooking, and playing board and video games. You can find me on Twitter @Phiteros and on my blog, themodernpolymath.com.

Discover more from astrobites

Subscribe to get the latest posts to your email.

Trackbacks/Pingbacks

  1. ¿Cómo empezar a escribir en LaTeX? | Astrobites en español - […] original: Getting Started with LaTeX por […]
  2. Empezar a programar | Astrobites en español - […] aquí). Si quieres saber más sobre cómo usar LaTex, puedes ver este tutorial, or referirte a este astrobite en…
  3. LaTeX Introduction - Study Astrophysics - […] Getting Started with LaTeX: https://astrobites.org/2018/01/20/getting-started-with-latex/ […]
  4. Tools for Reading Papers, Part 3 | astrobites - […] Have you ever seen an equation in a paper and thought, “I want to use this equation in picture…

Leave a Reply

Discover more from astrobites

Subscribe now to keep reading and get access to the full archive.

Continue reading