Intro to LaTeX

Intro

LaTeX is great for writing math electronically. LaTeX is generally pronounced as "lay-teck" or "lah-teck"; I prefer "lay-teck". LaTeX is able to do lots of math things easily such as subscripts within subscripts, matrices, and switch between math notation and English text fairly easily. I will also write a LaTeX file so that you can follow along and edit the code to learn what the bits of code do.

Brief note: I am on Mac, so this guide will be specific to Mac users.

Installation

This link is likely where I downloaded my texshop. Texshop is what you'll use to write LaTeX in.

Stationery

Stationery are templates for LaTeX. As a beginner, it's best to start out with a good stationery so you can get to using LaTeX right away without fiddling with setup issues. For me, these files are located in:

    ~/Library/TeXShop/New/Version-4.31/Stationery
  

I have been using LaTeX for a while now; here is my light mode stationery.

Commenting

In LaTeX, comments are prefaced with '%', just like Python or R but with different symbols.

Macros

Macros are editable parts of LaTeX where you can save code and have it pasted into your document at a menu click. This is a really great way to learn LaTeX as you can save bits of code you think you will reuse and comment within it to help remind you of what the code is doing.

Typesetting

For Mac, you can use command + T to get LaTeX to output the document that you've been writing and see the results. It is a good idea to do this after writing for a bit to ensure that your code is working properly. You can do control + command + E to get LaTeX to highlight the line of code that is causing an error when it's trying to output your document.

Environments and packages

Environments are like the modes that LaTeX has. Things that are written between dollar signs ($) will be written in Math mode, where you can write equations. The default environment in LaTeX is the text environment. To write text within a math environment, you can use:

      \text{}
    

and just write the text you want within the squiggly brackets.

Example of math environment:

    $a = 0;\ \sum_{i = 0}^n n$
  

There are more environments, but these are the basic ones that are almost always present.

Tables

In the Text environment (Text mode), you can use:

    \begin{tabular}{| c | c |}
  \hline
  5 & 8\\
  \hline
  6 & 3\\
  \hline
  8 & 9\\
  \hline
\end{tabular}
  

This will create a 3x2 table. The \begin{tabular} and \end{tabular} code begins and ends the tabular environment, which is used to create the table. The {c | c} portion tells LaTeX how many columns you want, what their alignments should be, and if there should be lines between the columns or not. Specifically, here the 'c' tells LaTeX to align the elements to the center. The \hline part of the code creates a horizontal line for the table. The \\ introduces a newline. The ampersand & is used to align the elements between the rows so that they are in the same column.

Proofs

In the align environment, you can create proofs. The code within an align environment occurs in the math environment. You can use & to align parts of the equation similar to how it was used in tabular.

Packages

It's possible that you may not be able to do everything you want quickly with base LaTeX. Packages will allow you to do various things such as changing your LaTeX document colors, making elements stretch across multiple rows or columns, and even include pictures within your document.

Resources

List of LaTeX math symbols

This resource is great if you want to quickly find the code for a certain symbol in LaTeX.

Overleaf

Overleaf is great for learning about LaTeX basics such as figuring out what the various environments are.

Stack Exchange

Stack Exchange is great for finding answers to more niche questions that you have, such as "how can I make elements span across multiple rows/ columns?". (You can use the package 'multirow' for that by the way.)

Return to homepage