Skip to Main Content
It looks like you're using Internet Explorer 11 or older. This website works best with modern browsers such as the latest versions of Chrome, Firefox, Safari, and Edge. If you continue with this browser, you may see unexpected results.
Michigan State University

LaTeX

A basic introduction to writing and managing citations in LaTex.

Starting a LaTeX Document

All LaTeX documents start with a preamble. If you open up a new document in Overleaf, it will auto-populate much of this information for you. The preamble allows you to define the type of document, author, date, language, and load in LaTex packages that you want to use in the document.

\documentclass[12pt, letter paper]{article}
\usepackage[utf8]{inputenc}

\title{Practice}
\author{Erika Weir}
\date{November 2019}

After we have included a preamble, we can go ahead and start the main text of our document. We can add things like a title, abstract, and table of contents.

\maketitle

\begin{abstract}
    This is an introduction to using LaTex. It will show how to format a paper, insert equations, figures, and tables. LaTex can also be used to create lab reports, CV's, bibliographies, and other documents.
\end{abstract}

\tableofcontents

We can then add sections that will automatically be added to the Table of Contents:

\section{Introduction}

We can also create lists:
\begin{itemize}
    \item llamas
    \item donkeys
    \item goats
\end{itemize}

And numbered lists:
\begin{enumerate}
    \item oranges
    \item bananas
    \item apples
\end{enumerate}

Equations

First, add this package to your preamble to complete this section:

\usepackage{amsmath}

One of the most useful features of LaTex is the ability to easily write mathematical equations. We can do this inline ($E=mc^2$) or in display mode:
\begin{equation}
    E=\frac{mc^2}{\surd(1-v^2/c^2)}
\end{equation}

You can also display equations without numbering.
\[E^2=p^2c^2+m^2c^4\]

You can reference the following list to lookup many mathematical symbols and operators:

Figures

Add the following packages to your preamble to add images and tables:

\usepackage{graphicx}

\usepackage[table,xcdraw]{xcolor}

To add images, you will need to first upload the images in Overleaf to your document:

Screenshot of the upload button in Overleaf

If you add your images in a folder, you must first add the file path.

\graphicspath{{images/}}

We can then add the image.

\includegraphics{hubble.jpg}

However, depending on the size of the image, it might not fully display on the page. We can edit the image to define the size.

\includegraphics[width=4cm]{hubble.jpg}

When writing academic papers, we may also want to label our figures so that we can refer back to them.

\begin{figure}[h]
    \centering
    \includegraphics[width=4cm]{aminoacids.jpg}
    \caption{an amino acid info-graphic}
    \label{fig:amino}
\end{figure}

More information on formatting images can be found here:

Tables

Formatting and stylistic changes to LaTex tables can be extremely complicated. The following web resource allows you to create a table and then creates the corresponding LaTeX code.

Cross References

LaTeX allows you to easily cross-reference anything that has been labeled in your document. This can include figures, tables, equations, or sections.

To create a label, use the label command: \label{marker}. LaTeX users also typically include a short (3 letter) descriptor for the type of object they are labeling. For example, the following label command is for an amino acids figure:

\label{fig:amino}

To refer back to any labeled object, we can use the reference command: \pageref{marker}. We can also use the page reference (\pageref{marker}) command to print the page number the object originally appears on. For example, the following LaTeX code references our original figure:

See Figure \ref{fig:amino} on page \pageref{fig:amino}.

Michigan State University