Instructor: Dheeran E. Wiggins
Email: dheeran2@illinois.edu
This tutorial was originally developed for students enrolled in Math 405: Teacher's Course, as taught by Dr. April Hoffmeister.
The essentials of creating a mathematics document, especially for teaching or note-taking purposes, in \(\LaTeX\) are described below.
First, visit Overleaf and log in. If you are affiliated with a university, then you can log in with your university credentials using the SSO option.
Then, click the "New project" button and select the "Blank project" option. You should then be prompted to name your project.
After naming, your project should have two panels. The left side is where you will write your \(\LaTeX\) code and the right side is where you can see how your document currently looks. At this point your code panel should look like the following:
\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\title{Your Title}
\author{Your Name}
\date{Month Year}
\begin{document}
\maketitle
\section{Introduction}
\end{document}
Everything above the \begin{document} command is your preamble. Then, \maketitle displays the document information you entered, after which you can begin adding content to the body. Using the percent symbol allows you to write % Comments, i.e., notes to yourself or collaborators in the code that are not visible in the compiled document.
You have countless options when it comes to formatting your documents. For formatting brief lecture notes, quizzes, problem sets, and such, I like using the amsart document class by the American Mathematical Society. This will give you access to the standard math packages and theorem styling without too much work.
To use amsart, you can replace
\documentclass{article}
with \documentclass[oneside]{amsart}
I recommend passing the [oneside] option, as above, since the pages of most documents you will make are likely not intended to be flipped like the pages of a book.
Now, the margins that come with amsart are a bit ridiculous for things like exams, so I would include the geometry package and pass the [letterpaper] option so your documents print as intended. Your preamble should look something like this now:
\documentclass[oneside]{amsart}
\usepackage{graphicx} % Required for inserting images
\usepackage[letterpaper]{geometry}
\title{Your Title}
\author{Your Name}
\date{Month Year}
\address{University of Illinois Urbana-Champaign, Illinois, 61801}
\email{NetId@illinois.edu}
Note that I have added the options to include your affiliation or address and your email. You can remove these by just deleting the relevant lines.
Finally, you can pick your fonts for text and math. Some classic choices, besides the default Computer Modern, are Times and Palatino. Just include either
\usepackage[T1]{fontenc}
\usepackage{newtxtext, newtxmath}
or
\usepackage[T1]{fontenc}
\usepackage{newpxtext, newpxmath}
beneath the other packages in your preamble to load Times or Palatino, respectively.
For a thorough list of your options, see the \(\LaTeX\) Font Catalogue.
Creating multiple sections in your document is easy. Just write
\section{Title of Section}
each time you want to begin a new one. Everything following such a section declaration will be contained in that section. Similarly, subsections are added by writing
\subsection{Title of Subsection}
To include a table of contents, you can add the simple
\tableofcontents
command, usually after \maketitle at the beginning of your body.
When taking notes, creating notes for others, or preparing a problem set or exam, it is helpful to have Theorem or Question environments ready. Include the code
\newtheorem{theorem}{Theorem}[section]
\newtheorem{question}{Question}
in your preamble, underneath your included packages. First, this creates a new theorem environment called Theorem, which will be numbered based on the section it is found in, and is used by writing
\begin{theorem}[Name of Theorem]
The content of the theorem.
\end{theorem}
If you type this in the \(n\)th section of the document and it is your \(m\)th theorem in that section, the output will look like
Theorem \({n.m}\) (Name of Theorem). The content of the theorem.
On the other hand, we have also created a theorem environment called Question. This will just be numbered by counting up from 1, which is usually what an exam would look like. Use this by writing
\begin{question}[Name of Question]
The content of the question
\end{question}
If this is the \(p\)th question in your document, then the output will look like
Question \({p}\) (Name of Question). The content of the question.
You can add other theorem environments, such as Lemma or Proposition, analogously by adding the following:
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
which creates a Lemma and a Proposition environment that are indexed by the same counter as Theorem. Use these as before:
\begin{lemma}[Name of Lemma]
The content of the lemma.
\end{lemma}Lemma \({n.m+1}\) (Name of Lemma). The content of the lemma.
\begin{proposition}[Name of Proposition]
The content of the proposition.
\end{proposition}Proposition \({n.m+2}\) (Name of Proposition). The content of the proposition.
Note that some classic environments that you may want, like Definition, probably ought to have upright text rather than italicized, and some, like Remark, usually have their heading italicized and their content upright. To implement this, you can insert the following code:
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}Using the analogous commands as for Theorem and Question, these will compile as follows:
Definition \({n.m+3}\) (Name of Definition). The content of the definition.
Remark \({n.m+4}\) (Name of Remark). The content of the remark.
Besides adding more packages and tweaking your fonts, your preamble should be set now. Here is an example of what your code panel could look like after all the above changes:
\documentclass[oneside]{amsart}
\usepackage{graphicx} % Required for inserting images
\usepackage[letterpaper]{geometry}
\usepackage[T1]{fontenc}
\usepackage{newpxtext, newpxmath}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{question}{Question}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\title{Your Title}
\author{Your Name}
\date{Month Year}
\address{University of Illinois Urbana-Champaign, Illinois, 61801}
\email{NetId@illinois.edu}
\begin{document}
\maketitle
\section{Introduction}
\end{document}
Surely, at some point while writing a math document, someone will have proven or solved something. Given a theorem, you can add a proof using the following format:
\begin{theorem}[Name of Theorem]
The content of the theorem.
\end{theorem}
\begin{proof}
The content of the proof.
\end{proof}Now, if you want to instead call the response a solution, you can add [Solution] directly after \begin{proof}. More generally, you can put any text in the brackets:
\begin{theorem}[Name of Theorem]
The content of the theorem.
\end{theorem}
\begin{proof}[Anything]
The content of the proof.
\end{proof}
Now, remember that one of your tasks is to prepare a quiz. Usually, for mathematics exams, ample workspace should be included for a student to write their solution to a question, assuming no separate answer sheet was provided. For this, I use a silly technique, but it works. The command \vspace{8cm} creates eight centimeters of vertical space where you insert it. So, one question and solution on an exam could be typeset as follows:
\begin{question}[Name of Question]
The content of the question.
\end{question}
\begin{proof}[Solution]
\phantom{a} \\
\vspace{8cm} \\
\phantom{a}
\end{proof}Here, the command \phantom{a} creates an invisible "a" and the command \\ moves us to the next line. I encourage playing around with these commands to see how it affects the output. Namely, try inputting different different centimeter lengths, since shorter intended solutions will likely need less than eight, whereas longer ones may need more.
Multiple choice questions and questions with multiple parts both require lists. There are a few ways to typeset lists, but I will describe a straightforward method that uses itemize. Generally, itemize allows you to make a list and put any compilable character as the bullet for that entry. An Arabic numerated list with periods would look like
\begin{itemize}
\item[1.] List entry one
\item[2.] List entry two
\item[3.] List entry three
\end{itemize}Similarly, a lowercase Roman numerated list with parentheses could look like
\begin{itemize}
\item[(i)] List entry one
\item[(ii)] List entry two
\item[(iii)] List entry three
\end{itemize}
Removing the brackets, leaving \item before each entry, will return a usual bulleted list. So, a question with multiple choices could be coded as follows.
\begin{question}[Question Name] Introduction to question. Here are the options:
\begin{itemize}
\item[(i)] The first option
\item[(ii)] The second option
\item[(iii)] The third option
\end{itemize}
Conclusion of question.
\end{question}
Being able to typeset mathematical characters efficiently is often the primary motivation for using \(\LaTeX\) while preparing course materials. The easiest way to insert math in your document is to do it in-line, surrounding whatever math you wish to write in $...$. For example, this sentence with the polynomial \(f(x) = 5x^3 + 2x + 1\) would be coded as
For example, this sentence with
the polynomial $f(x) = 5x^3 + 2x + 1$ would be coded as However, in-line math is often difficult to read, especially when it involves a longer expression, in which case you should use block equations. To do so, surround your math with \[...\]. For example, this sentence with the Taylor series of sine \[\sin(x)= \sum_{n=0}^{\infty} \frac{(-1)^n x^{2n+1}}{(2n+1)!}\] would be coded as
For example, this sentence with the Taylor series of sine
\[
\sin(x) = \sum_{n=0}^{\infty} \frac{(-1)^n x^{2n+1}}{(2n+1)!}
\]
would be coded asSometimes you will want block equation numbers, to reference later. In this case, you will write something along the lines of
\begin{equation}\label{Gaussian}
\int_{-\infty}^{\infty} e^{-x^2} dx = \sqrt{\pi}
\end{equation} and reference it as Equation \eqref{Gaussian}. Now, in these examples you can see the candid syntax of \(\LaTeX\) math commands. For a standard operator, like sine, cosine, or the natural logarithm, just write \sin(x), \cos(x), or \ln(x), respectively.
If you try an operator, like \Range(T) and it does not compile, then just write \operatorname{Range}(T) instead. This creates the correct spacing needed for operators, as opposed to inserting regular text in the math. Fractions are done by writing
\frac{numerator}{denominator}In math mode, i.e., between $...$ or \[...\], blackboard bold (\(\mathbb{R}, \mathbb{C}, \mathbb{P}\)) is given by \mathbb{...}, calligraphic (\(\mathcal{C}, \mathcal{R}, \mathcal{G}\)) by \mathcal{...}, Fraktur (\(\mathfrak{F}, \mathfrak{g}, \mathfrak{h}\)) by \mathfrak{...}, bold by \mathbf{...}, and sans-serif by \mathsf{...}.
There are many more characters that you will have to write--far more than I can cover here. The standard tool for finding out a \(\LaTeX\) command is Dextify, which gives the code for the character you draw. This brief list by Overleaf may be helpful.
More often that not, however, it is easiest to guess the command by writing your desired symbol's usual name after a backslash.
There is a standard bit of notation used across tasks in \(\LaTeX\) that is easily demonstrated by thinking about aligned equations and matrices. The mantra is that & is used for horizontal alignment and \\ is to make new rows. We recently saw the latter when adding vertical space for solutions.
Sometimes you will need to carry out a multi-line computation of the form \[ \begin{aligned} \int \frac{\mathrm{l}\mathrm{n}(x)}{x^2}dx &= - \frac{\ln(x)}{x} - \int - \frac{1}{x^2} dx \\ &= - \frac{\ln(x)}{x} - \frac{1}{x} + C \\ &= - \frac{\ln(x) + 1}{x} + C. \end{aligned} \] The code for this is
\begin{align*}
\int \frac{\ln(x)}{x^2}dx &= - \frac{\ln(x)}{x} - \int - \frac{1}{x^2} dx \\
&= - \frac{\ln(x)}{x} - \frac{1}{x} + C \\
&= - \frac{\ln(x) + 1}{x} + C.
\end{align*}
Observe that in the code, the ampersand & tells us where alignment should happen (at the \(=\) sign), whereas the \\ takes us to the next row. The asterisk after align leaves off equation labels. To include them, just remove it.
Similarly, when you wish to typeset a matrix of the form \[ M = \begin{pmatrix} a & b & c \\ d & e & f \end{pmatrix}, \] you can use multiple alignment ampersands to write
\[
M = \begin{pmatrix} a & b & c \\
d & e & f
\begin{pmatrix}
\]
Here, the p in pmatrix stands for parentheses. Replacing it with a b gives you matrices with square brackets, and using no letter at all, \begin{matrix}, will just display a floating array of numbers.
Adjusting characteristics outside of math mode is somewhat straightforward. For bolds, use \textbf{...}, for italics, use \emph{...}, and for small caps, use \textsc{...}. More information on text formatting and so forth can be found at this Overleaf guide.
Inserting various figures, especially graphics or images, will likely be vital for at least one of your documents. People often complain about this process, but the following method is reasonably foolproof. Begin by adding your graphic file, say graphic.jpg, by clicking "File tree" on the left of the code panel, clicking "Upload," and then selecting it from your computer.
Now, to insert a figure (usually) where you want it, use the code
\begin{figure}[htpb!]
...
\end{figure}To add your graphic into this figure, use the \includegraphics command:
\begin{figure}[htpb!]
\includegraphics[width=0.6\textwidth]{graphic.jpg}
\end{figure}The square brackets is where you control the sizing of your image in your document. Just mess around with the sizing until it looks decent.
If you would like to caption your figure, add
\caption{Your Caption}before \end{figure}.
My prefered way of generating math graphics, without having to hand draw, is through Mathcha, especially since it allows you to export most drawings, though not plots, as TikZ code (see the next section).
Plotting functions can be a bit tricky, and it is often easier to just graph the function elsewhere and upload an image. However, if you want your labels to respect global font changes in the document, then you may want to use TikZ.
First, add the following to your preamble, with the other packages.
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}Now, you will create a tikzpicture as a figure:
\begin{figure}[htpb!]
\begin{tikzpicture}
...
\end{tikzpicture}
\end{figure}
Inside the tikzpicture is where you will do your plotting, which will involve setting the axis characteristics, the labels, and describing the functions you want to plot. For example, see the code below for a plot of \(x^2\) and a basic sine.
\begin{figure}[htpb!]
\begin{tikzpicture}
\begin{axis}[
xmin=-2, xmax=6,
ymin=-2, ymax=2,
axis lines=middle,
xlabel={$x$},
ylabel={$y$}
]
\addplot[domain=-3:6, samples=100, color=blue, thick] {x^2};
\addplot[domain=-3:6, samples=100, color=red, thick] {sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{figure}
The xmin and xmax set the \(x\)-dimensions of the axes, and likewise for \(y\). The axis lines option can be switched from middle to left, and so forth. Then, labels are added.
Finally, two plots are added, one blue and one red. The domain can be set for each function as an interval, with the domain \([x,y] \subset \mathbb{R}\) corresponding to domain=x:y. Then, the function itself is listed in curly brackets. Note that for sine, deg is added to the argument, converting from radians into degrees, which sin natively takes as input.
See here for a method of plotting by first working in Geogebra.