LaTeX is a document preparation system, that is becoming the de-facto method in STEM fields, such as math, physics and computer science. It is being used heavily because it is extremely flexible and can create almost any document type you can think of, and will do so while doing semi-automatic formatting.
LaTeX is different than programs like Word, where what you see is what you get. That is, the output is no different from the location in which you are inputting content. Rather, you do not immediately see the output of your document. You interact with a text editor, and input plain text plus markup commands that apply formatting. You then compile your document into a PDF output. LaTeX will take care of formatting the document and putting images and tables into the appropriate locations.
There are many pros to LaTeX, including:
I cannot stress this enough - automatic formatting. When it comes time to work on your dissertation, you are going to want to use LaTeX to organize your chapters, bibliography, tables, and figures. LaTeX will automatically number your figures and tables for you, even if you move them aroudn in your document. It will also automatically format your bibliography for you. More on that later.
A version of the LaTeX template I used for my dissertation can be found here. Bite that many journals have LaTeX templates you can download from their website for easy formatting.
Of course, not every program is perfect. Here are some things to keep in mind when using LaTeX:
LaTeX documents are saved as .tex files, and are plain text. Luckily, there are many editors out there that make it easier to create documents, view them, and easily check syntax. Some even have panels for easy character/figure/table/equation insertion. Some are OS dependent, but it’s important to remember that .tex files can be transferred between operating systems without issue. Popular ones are TexShop (Mac only), TexMaker, TexWorks and TexStudio. There are also online editors, akin to Google Drive, such as ShareLaTeX and Overleaf.
For each document, there are a few basic steps to be taken: first, open your editor. Then type, save your document, compile it, and view it.
There are two basic sections to a LaTeX document: the preamble, and the body. The preamble includes global commands, page layout and other information. The body includes everything else, including your content. In your editor, try typing this, saving it on your computer in a stable folder, and pressing ‘Build and View’ or ‘Compile’:
\documentclass{article}
\begin{document}
Hello world!
\end{document}
Congratulations! You just made your first LaTeX document!
If you open the folder you saved your document in, you will notice that there are a lot of auxiliary files created. These all have to do with the compilation of the document. Therefore it’s good practice have a separate folder for each document you are creating. That helps with document management, and you can create a subfolder just for your figures.
There are a number of symbols that are used for formatting and creating commands in LaTeX. If you need to use one of these symbols in your text, you need to tell LaTeX specifically that you are using that symbol, rather than making a new command. These symbols include:
Basic commands that include these symbols are:
The preamble of your document includes all global parameters you will use. It also includes the specification of packages that might be needed, which will help with formatting, inserting special objects and characters (e.g., long tables, subfigures, IPA symbols, special bibliography formats).
There are many types of document classes. The most common type is ‘article’. Other classes include book (chapters, sections, etc.), report (similar to the book class but for single-sided printing), letter, slides, and beamer. When you are using a particular document style template, it will tell you the document type to use. The document type goes in curly brackets after \documentclass{}. There are also a number of optional changes you can make from the default, such as:
The ordering of the optional arguments doesn’t matter. They are included in square brackets, before the class is specified, as such:
\documentclass[<option1>, <option2>]{article}
There are a number of items you can add after your document class to change page formatting, such as:
How would you create a document with the following specifications? Try it out, and add some text in the document!
\documentclass[12pt,times, oneside, twocolumn]{article}
Packages are a specific set of ready-to-use LaTeX commands that can make your document look nice and professional, with your custom needs. There are hundreds (or more!) of them. You include the packages in the preamble of your document, with the \usepackage{} command. You can specify many of them in one \usepackage{} using a comma to separate them. Many are preloaded into LaTeX, and others can be downloaded. Some helpful ones include tipa, graphicx, and subcaption.
For tipa, your preamble would include:
\usepackage{tipa}
Your body would call symbols from the tipa package using:
\textipa{...}
A handy chart of common IPA symbols and diacritics is found here. A full list of tipa symbols available is found here.
The rest of your document is the body. It includes all of your content. If you have a simple document, like a report or even a journal article, your document will include all of your content, images, and tables. If you are working on your dissertation, or another big document, it is likely you will have a ‘Dissertation’ document with a body, that includes calls to include individual chapters. Here are some parts of your document that are useful to know about. Note that everything body-related to your document goes between \begin{document} and \end{document}.
If you need a title page for your document, you can specify the information you will need in your title page, and then use the \maketitle command. This will automatically create a nicely-formatted title page. The UIUC thesis template will create a title page that conforms to the Graduate College’s requirements for title pages.
Note that in this example, the [titlepage] option creates a separate page for the title. The double backslashes indicate a new line.
\documentclass[titlepage]{article}
\begin{document}
\title{How to Start a Latex File – or whatever you want to call you paper}
\author{Your Name\\
University of Illinois at Urbana-Champaign\\
Urbana, IL}
\date{\today}
\maketitle
this is a test
\end{document}
Splitting up a document into shorter sections is good practice (think of any dissertations or journal articles you’ve read lately). You can split them up using these commands:
\section{Section title}
\subsection{Subsection title}
\subsubsection{Subsubsection title}
You can make them numbered or unnumbered. Including a * creates unnumbered sections (\section{…} vs. \section*{…}). You can also label them and reference them in later text. Note that this doesn’t work for unnumbered sections, though there are packages that can allow you to do this.
\section{…}{label: sec:mysection}
See Section~\ref{sec:mysection} for details
Most font families will allow you to use the following commands for font styling:
You can also mix styles.
To emphasize text use the command \emph{…}, which compensates for the style of the surrounding text.
##Lists You can do enumerated lists, bulleted lists, and description lists. You can also embed lists within one another.
Enumerated lists:
\begin{enumerate}
\item Number 1
\item Number 2
\end{enumerate}
Itemized lists
\begin{itemize}
\item Dog
\item Cat
\end{itemize}
Descriptions
\begin{description}
\item[1st option] Pizza
\item[2nd option] Pasta
\end{description}
Embedded lists
\begin{enumerate}
\item Merp
\begin{itemize}
\item Dog
\item Cat
\end{itemize}
\item Derp
\end{enumerate}
Figures are made in the figure environment:
\begin{figure}[placement]
...
\end{figure}
Placement possibilities include:
LaTeX will try to put your figure as close as possible to where you specify it. Note that if it isn’t in the place you want, if you add more text to your document, the location will change!
Note that the image you are importing has to be in the proper folder. The default is same folder as the .tex file (assuming you give only the file name). It is usually useful to specify a graphics folder where all figures are located in the preamble:
\usepackage{graphicx}
\graphicspath{ {Images/} } - relative directory (within same folder as .tex file)
\graphicspath{/Users/goldrch2/Desktop/Images/} – absolute directory
The full specification to include a figure is as such. Note that the types of figures allowed include jpg, png, eps, and pdf.
\begin{figure}[placement]
\includegraphics[parameters]{graphic}
\caption{include a caption}
\label{fig:myfigure}
\end{figure}
Figure parameters can include the following:
Tables are found in the table environment:
\begin{tabular}{specifications}
...
\end{tabular}
Specifications must include:
Number of columns and alignment are coded together. Each column is specified by an alignment:
Vertical Lines are specified as follows. If you do not want a line between columns, do not include anything between them.
With the following example, there are three columns. The first is left-aligned, the middle is right-aligned, and the last is centered. There is adouble line on left margin, a single line between first and middle column, no line between the middle and last column, and a single line on right margin.
\begin{tabular}{|| l | r c |}
...
\end{tabular}
Other parts of tables:
Placing a table into the table environment allows you to assign it a caption and a label.
\begin{table}
\begin{tabular}
...
\end{tabular}
\caption{This is a table!}
\label{tab:mytable}
\end{table}
Note that making tables in LaTeX by hand can be VERY annoying. Luckily there are a few tricks to help. First, if you are exporting data or a model output from R to include in a document, the texreg package in R will automatically convert this output into LaTeX table form. The stargazer package also is able to output LaTeX table code. In addition, if you have a table in an Excel or Word file, or you need to create a table from scratch, the website https://www.tablesgenerator.com/ can help, including with formatting.
There are two ways to include bibliographies in LaTeX. One way to do it is to include all citations in your document. This becomes very messy very quickly.
\begin{thebibliography}{1}
@article{chomsky1968sound,
title={The sound pattern of English.},
author={Chomsky, Noam and Halle, Morris},
year={1968}, publisher={ERIC} }
\end{thebibliography}
It’s easier to use a program such as BibDesk, which will do the work for you. Zotero or Jabref can also generate .bib files. A .bib file with bibliographic data should be saved in the same folder as the .tex file. With Bibdesk, you are given a database-like interface. You compile a bibliography file, which then converts to a .bbl. You tell LaTeX the name of your file using the \bibliography{…} command. (If you want your bibliography on a new page, use \newpage).
Many websites, including Google Scholar, will allow you to automatically generate a LaTeX-style citation (sometimes called a Bibdesk citation). This includes a reference key (for example, chomsky1968sound), all information about the reference, and its type (article in this case).
To make an APA-style bibliography, or another specific format, the following needs to go into a preamble:
\usepackage{natbib}
\bibliographystyle{apalike}
Note that specific journals or conference proceedings might have a bibliography style of their own.
To make a citation in your document, you can use the \cite{…} command. The natbib package also allows for \citep{…}, which puts your whole citation in parentheses, and \citet{…}, which only puts the year in parentheses.
While I won’t go into them now, there are many other things you can do with LaTeX, such as doing nice mathematical formatting, includin equations, and figure formatting (rotation, cropping, in-text positioning, etc.). When you run into an issue you can’t figure out, Google it! Stack Exchange has a specific subpage, TeX Exchange, specifically focused on how to use LaTeX for customized documents. Be sure to search for your issue before posting a question - most of the time, someone has already run into this issue, and it is faster to find the answer they received than to wait for a new answer to your question.