Using LaTeX

Introduction

This document constitutes an introduction to writing \( \LaTeX{} \) documents. By the end of this tutorial, you should have the tools to write simple LaTeX documents using a template. I will take you through the template and the creation of the document, explain both what the code does and some good practices I use to keep the source readable and easily modifiable.

Note: Everyone thinks they have the best style when it comes to writing LaTeX. I'm here to tell you that they're all wrong: my good practices and style are the best.

More seriously, everyone has their own style, and eventually you will have your own. I do think my guidelines are pretty good, but I do experiment with my style and I do change overtime. Do what feels right, but if you're my student and you want me to read your source code, I will insist that you avoid some bad practices.

In the rest of this page, we will write two versions of a simple LaTeX document. The former will be rather short, and should be enough to get you started on very simple documents that don't need anything fancy. The latter version will showcase some more of the power of LaTeX, and will be a bit longer.

The first time you read through, I suggest you skip the sections on expanding the preamble and the body of the document. While important, these sections are a bit more technical, and might be confusing at first. If you follow along the short route first, you should be prepared for the longer route on a second read through.

Last update: Wednesday, 18 January 2023.

Preamble

In this section, we will write the template for a \( \LaTeX{} \) document. Every document has two parts: the preamble, and the contents. The preamble is the part of the document at the start of the file which sets options and loads other files and settings for the document. The contents are the part of the document that will be turned into a human-readable PDF.

Short Preamble

The documentclass sets the type of output we expect, and can set some general options. We'll set the font to 12pt and use the amsart class.

\documentclass[12pt]{amsart}

The default page geometry is pretty bad, so we will load a package—i.e., a setup file—to adjust the margins.

\usepackage[margin=1in]{geometry}

Now we need to load some packages that will allow us to write nice looking mathematics.

\usepackage{amsthm, amssymb, mathtools}

Next we need to make the metadata of the document, which will also be used to construct a nice title page. Each command below defines exactly what you think it does for this document.

\title{\LaTeX{} Tutorial}
\author{Chris Eppolito}
\date{Created 2023-01-18}

Note that the curly braces define the "scope" of each of these. That's an important part of LaTeX, which will keep coming up.

Result

The result of putting these blocks together is below.

\documentclass[12pt]{amsart}
\usepackage[margin=1in]{geometry}
\usepackage{amsthm, amssymb, mathtools}
\title{\LaTeX{} Tutorial}
\author{Chris Eppolito}
\date{Created 2023-01-18}

We'll come back and add more stuff to the preamble, but this will suffice for now.

Longer Preamble

If this is your first time working with LaTeX, you should skip this section for now and read the section on content first. You can come back here after you've had a chance to see how we get a PDF out of our code.

The short preamble we made is enough to write very simple documents. However, often we want to do some not-so-simple things to make our documents look more professional. This section will construct a more complete preamble that will be more practical for writing nice documents.

Theorem Environments

Definitions, theorems, lemmas, etc., deserve special formatting to make them stand out for our reader. The best way to do this is to create environments for them. The code block below sets up some reasonably nice formatting for a variety of common environments.

\newtheorem{theorem}{Theorem}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\theoremstyle{definition}
\newtheorem*{definition}{Definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem{problem}{Problem}

The \theoremstyle macro gives LaTeX some information on how we want the general formatting to look. The \newtheorem command defines the environment's name for the code, as well as how it's name will be printed in the PDF. While theorems are numbered by default, we can force them to be unnumbered by using \newtheorem* instead (so our definitions will be unnumbered). Go to the section on theorems in the content to see how to use this in practice.

References

The following code sets up the package cleveref, which will handle referencing other parts of the document for us.

\usepackage[capitalise,nameinlink]{cleveref}
\crefname{theorem}{Theorem}{Theorems}
\crefname{proposition}{Proposition}{Propositions}
\crefname{lemma}{Lemma}{Lemmas}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{example}{Example}{Examples}
\crefname{definition}{Definition}{Definitions}
\crefname{remark}{Remark}{Remarks}
\crefname{problem}{Problem}{Problems}

Each \crefname macro takes an environment name and associates it to singular and plural printed names. Go to the section on references in the content to see how we use this in practice.

Citations

This code below sets up the formatting and references we will make to other papers and books.

\usepackage[citestyle=alphabetic,style=alphabetic,maxbibnames=9]{biblatex}
\renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{doi}{}
\DeclareFieldFormat{isbn}{}
\DeclareFieldFormat{issn}{}
\DeclareFieldFormat{url}{}

The biblatex package sets a bibliography processor which is more friendly than the default. The rest of the code mostly suppresses printing of certain undesirable parts of bibliographic entries. Go to the section on citations in the content to see how we use this in practice.

Result

Putting it all together, our long-form preamble looks like this.

\documentclass[12pt]{amsart}
\usepackage[margin=1in]{geometry}

\usepackage{amsthm, amssymb, mathtools}
\newtheorem{theorem}{Theorem}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\theoremstyle{definition}
\newtheorem*{definition}{Definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem{problem}{Problem}

\usepackage[capitalise,nameinlink]{cleveref}
\crefname{theorem}{Theorem}{Theorems}
\crefname{proposition}{Proposition}{Propositions}
\crefname{lemma}{Lemma}{Lemmas}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{example}{Example}{Examples}
\crefname{definition}{Definition}{Definitions}
\crefname{remark}{Remark}{Remarks}
\crefname{problem}{Problem}{Problems}

\usepackage[citestyle=alphabetic,style=alphabetic,maxbibnames=9]{biblatex}
\renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{doi}{}
\DeclareFieldFormat{isbn}{}
\DeclareFieldFormat{issn}{}
\DeclareFieldFormat{url}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\LaTeX{} Tutorial}
\author{Chris Eppolito}
\date{Created 2023-01-18}

Because our preamble is a bit longer now, I've added a comment line to draw our eyes to stuff we need to change, namely the metadata portion of the preamble. I've also added some comments to remind us what each piece does. Finally, I've grouped parts of the preamble together to make it more readable, and thus more easily modified. While these additional modifications don't change the output, they do make the code more readable.

Content

Every document happens in the document environment. This lets LaTeX know that we intend what follows to be part of the output. To let LaTeX know we want to begin the document, we write , and to end the document we write .

Short Content

The first thing we'll do inside the document is to tell LaTeX to produce a title for us.

\maketitle

Now we can write the content of the document. For this document, we'll illustrate some common maths symbols and environments. In doing so, it will be natural to separate the document into multiple sections. To create a numbered section, we use .

\section{In-line and Display Mathematics}

Note that both \maketitle and \section are examples of macros in LaTeX. LaTeX is an example of a macro language, meaning that we control the output of our code via macros which tell the computer to perform a sequence of actions. This sequence of actions varies from macro-to-macro.

To write any in-line mathematics, we need to use a maths environment with these symbols: \( \).

The best equation ever discovered is Euler's Identity, \( e^{i \pi} + 1 = 0 \).

In the compiled file, the LaTeX macro \pi will be replaced by the symbol for \( \pi \). There are macros for the Greek letters that are not also Latin letters; this makes producing all of the Greek letters possible. Moreover, the caret ^ tells LaTeX that whatever appears next, i.e., everything in the curley braces { }, needs to be in superscript on the e. This trick of using the braces to give LaTeX information about the "scope" of a command is very common! We've already seen it above: the braces delimited the arguments of macros like \usepackage and \title.

Next I will add some context to the first sentence of our document.

This fundamental identity was discovered by Leonhard Euler.
He wrote about it in the book \textit{Introductio in analysin infinitorum}, which appeared in 1748.

Since then, many mathematicians have been inspired by this equation to find generalizations.
Euler already knew that this was not as general as it could be; indeed, this is a special case of the general formula \( e^{i \theta} = \cos(\theta) + i \sin(\theta) \).

There's a lot going on in this block of code! Primarily, I used a bunch of new macros: \textit, \theta, \cos, and \sin. The \textit command tells LaTeX that we want the text in the following scope to be italic; there are also commands \textbf for boldface and \textrm for roman, as well as several others. The \theta will produce a \( \theta \) in the output. The \cos and \sin macros produce the symbols \( \cos \) and \( \sin \) for the cosine and sine functions respectively.

Secondly, I broke the line after each sentence in this code. I do this because it makes it easier for me to read the code when I edit it. While this is not necessary, it helps me stay organized. It is also important to note that this practice of breaking lines at sentence endings does not affect the output; LaTeX ignores newlines, unless we break a line at least twice.

Often, we want to write important equations on their own line in a nicely displayed style. We can get this effect by enclosing our mathematical expression in the \[ \] tags.

One generalization from abstract algebra---from field theory in particular---is that the \( n^{\textrm{th}} \) roots of unity sum to 0 for all positive integers \( n \).
An \emph{\( n^{\textrm{th}} \) root of unity} is a solution to the equation \( x^n - 1 = 0 \).
Thus, the second roots of unity are \( 1 \) and \( -1 \), as these are precisely the solutions of \( x^2 - 1 = 0 \).
For general \( n \), there are exactly \( n \) roots of unity; moreover, these have the formula \( \mu_n^k = e^{2\pi i \frac{k}{n}} \) where \( 0 \leq k \leq n-1 \).
In particular, this generalization asserts that the following equation holds:
\[
  \sum_{k=0}^{n-1} \mu_n^k
  = \sum_{k=0}^{n-1} e^{2\pi i \frac{k}{n}}
  = 0
  .
\]

The last bit will now be printed on its own line, and it will be displayed in a pretty fashion. Note that we used _ to get a subscript. The macro is special; we usually reserve this macro for definitions and extra important terms; it stands for emphasis.

Result

The document portion of our LaTeX file now looks like this.

\begin{document}
\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{In-line and Display Mathematics}

The best equation ever discovered is Euler's Identity, \( e^{i \pi} + 1 = 0 \).
This fundamental identity was discovered by Leonhard Euler.
He wrote about it in the book \textit{Introductio in analysin infinitorum}, which appeared in 1748.

Since then, many mathematicians have been inspired by this equation to find generalizations.
Euler already knew that this was not as general as it could be; indeed, this is a special case of the general formula \( e^{i \theta} = \cos(\theta) + i \sin(\theta) \).

One generalization from abstract algebra---from field theory in particular---is that the \( n^{\textrm{th}} \) roots of unity sum to 0 for all positive integers \( n \).
An \emph{\( n^{\textrm{th}} \) root of unity} is a solution to the equation \( x^n - 1 = 0 \).
Thus, the second roots of unity are \( 1 \) and \( -1 \), as these are precisely the solutions of \( x^2 - 1 = 0 \).
For general \( n \), there are exactly \( n \) roots of unity; moreover, these have the formula \( \mu_n^k = e^{2\pi i \frac{k}{n}} \) where \( 0 \leq k \leq n-1 \).
In particular, this generalization asserts that the following equation holds:
\[
  \sum_{k=0}^{n-1} \mu_n^k
  = \sum_{k=0}^{n-1} e^{2\pi i \frac{k}{n}}
  = 0
  .
\]
\end{document}

Note that I've added a line with 80 %'s. This will not affect the output; the % symbol is the comment character for LaTeX. This means that if you want to write some comments to yourself in the file, you can make a new line and write . Here, I've used this long string of %'s to mark an important part in the source code, namely the spot where a new section begins.

More Content

This section explains how we use some of the more advanced features of LaTeX.

Theorems

Often, we want to visually distinguish the most important parts of our document. The most frequent case of this is with definitions, theorems, and proofs. Assuming we've added the right code to our preamble, we can do this with theorem environments.

\section{De Moivre's Formula}

An interesting theorem related to Euler's identity is De Moivre's Formula.
\begin{theorem}[De Moivre's Formula]
  For all real numbers \( \theta \) and all positive integers \( n \) we have
  \[
    (\cos(\theta) + i\sin(\theta))^n
    = \cos(n\theta) + i\sin(n\theta)
    .
  \]
\end{theorem}
In fact, this theorem has an easy proof using Euler's Identity.
\begin{proof}
  Let \( \theta \in \mathbb{R} \) and \( n \in \mathbb{Z} \) be arbitrary.
  Applying the generalization of Euler's identity and usual laws of exponents, we obtain the following.
  \begin{align*}
    (\cos(\theta) + i\sin(\theta))^n
    &= (e^{i\theta})^n \\
    &= e^{i (n\theta)} \\
    &= \cos(n\theta) + i\sin(n\theta)
      .
  \end{align*}
  Hence the original statement holds.
\end{proof}

Note that the proof we gave applies more generally.
Indeed, the same computation proves the following more general identity.
\begin{proposition}
  For all real numbers \( \theta, r \) we have
  \[
    (\cos(\theta) + i\sin(\theta))^r
    = \cos(r\theta) + i\sin(r\theta)
    .
  \]
\end{proposition}

Now the theorem and proposition will be printed in a nice style to set it apart from the rest of the text. The proof environment has a similar effect for the proof, and comes with a tombstone, i.e., a \( \square \), at the end in the output.

We also had an align* environment to make aligned, unnumbered equations in the proof. The syntax for this environment has \\ to indicate a line break, and & as the character to align on. In the PDF output of the block above, you should see all the equal signs aligned.

References

Often, we want to refer to things that occurred earlier in the document. We could just hard code the number in the text, but this presents an issue as we edit the document. What if we decide we need to add a numbered lemma before Theorem 1? We then have to go back and change all of the references we made in the document for each theorem, proposition, and lemma to match the new numbers. This can be a lot of work; worse, if we miss one, it will could make reading our document difficult.

Fortunately, LaTeX can automate references to numbered environments and equations. Let's see this by expanding our discussion of roots of unity.

\section{Geometry and Roots of Unity}

There is some interesting geometry concerning roots of unity.
\begin{theorem}
  \label{result:n-gon-roots}
  If \( n \geq 3 \), then in the complex plane, the \( n^{\text{th}} \) roots of unity form the vertices of a regular \( n \)-gon.
  Moreover, this \( n \)-gon is inscribed entirely in the unit circle in the complex plane.
\end{theorem}
In fact, \cref{result:n-gon-roots} is another simple consequence of previous results.
By combining Euler's Formula and De Moivre's Formula, we have
\begin{equation}
  \label{eqn:roots-de-moivre}
  \mu_n^k
  = (e^{i\tfrac{2\pi}{n}})^k
  = (\cos(\tfrac{2\pi}{n}) + i \sin(\tfrac{2\pi}{n}))^k
  = \cos(k \tfrac{2\pi}{n}) + i \sin(k \tfrac{2\pi}{n})
  .
\end{equation}
Moreover, by elementary trigonometry, we know
\begin{equation}
  \label{eqn:trig-unit-circle}
  \cos^2(\theta) + \sin^2(\theta)
  = 1
  .
\end{equation}
By combining \cref{eqn:roots-de-moivre,eqn:trig-unit-circle}, we obtain
\[
  |\mu_n^k|
  = \sqrt{\cos^2(k \tfrac{2\pi}{n}) + \sin^2(k \tfrac{2\pi}{n})}
  = \sqrt{1}
  = 1
  .
\]
This justifies the claim that the corners lay entirely on the unit circle.
The rest of \cref{result:n-gon-roots} can be justified by proving \( |\mu_n^{k+1} - \mu_n^k| = |\mu_n^2 - \mu_n| \) for all \( 0 \leq k \leq n-1 \).

The command \cref is short for "clever reference", and inserts information about what kind of environment we're working with. The same command did two jobs in this snippet. First, it referenced a theorem; later it took a reference to two separate equations and produces a nicely formatted result. While this is just a fraction of it's power, this is already exceptionally nice.

Note we used the equation environment for equations. This is more-or-less a numbered version of the \[\] environment.

Citations

Citations in a document take a bit more care. First, we need to get a resource and put it's information into a form LaTeX can work with, namely in a BibTeX file. How to find sources is beyond the scope of this tutorial, but the following is a perfectly good bibliographic index.

@misc{websiteWithAnOpinion,
  title={The greatest equations ever}, url={https://physicsworld.com/a/the-greatest-equations-ever/},
  journal={Physics World},
  author={Crease, Robert P},
  year={2018},
  month={Aug}
}

@book{bookOfNumbers,
  place={New York, NY},
  title={Book of numbers},
  publisher={Springer},
  author={Conway, John H.},
  year={2012}
}

@book{expensiveBook,
  place={Washington, DC, Virginia},
  title={How Euler did it},
  publisher={Mathematical Association of America},
  author={Sandifer, Charles Edward},
  year={2007}
}

It's important that this index is kept in a separate file; it also helps us remember what this file is for if we give it the extension .bib. For us, that file is called latex-example-references.bib. Now we'll work on adding the citations to our work.

First, we need to register this references file in LaTeX. This is done by adding the code below to our preamble after loading the biblatex package.

\addbibresource{latex-example-references.bib}

Next we use the citations in the text of the document.

\section{More Reading}

There are lots of places we could read more about Euler's identity and other classical formulas in mathematics.
Some readers might find the website \cite{websiteWithAnOpinion} interesting, where the author gives some of their favourite equations.
One of the better resources on Euler's accomplishments is \cite{expensiveBook}.
Finally, \cite{bookOfNumbers} is an excellent textbook for mathy folks.

The \cite command tells LaTeX that we want to cite something from our bibliography. The stuff inside is the keys we gave in the .bib file above. Finally, we need to tell LaTeX that we want a list of references to be printed at the end of the document.

\printbibliography

Letting LaTeX take care of the citations in this way takes a lot of work off our plate. In particular, LaTeX will do the following for us.

  1. Choose reference labels.
  2. Automatically update reference labels as we add new citations.
  3. Organize the references alphabetically by author's last name.

In particular, it does all of the boring stuff for us!

Result

Putting this all together, we have the following longer version of the text portion of our document.

\addbibresource{latex-example-references.bib}

\begin{document}
\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{In-line and Display Mathematics}

The best equation ever discovered is Euler's Identity, \( e^{i \pi} + 1 = 0 \).
This fundamental identity was discovered by Leonhard Euler.
He wrote about it in the book \textit{Introductio in analysin infinitorum}, which appeared in 1748.

Since then, many mathematicians have been inspired by this equation to find generalizations.
Euler already knew that this was not as general as it could be; indeed, this is a special case of the general formula \( e^{i \theta} = \cos(\theta) + i \sin(\theta) \).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{De Moivre's Formula}

An interesting theorem related to Euler's identity is De Moivre's Formula.
\begin{theorem}[De Moivre's Formula]
  For all real numbers \( \theta \) and all positive integers \( n \) we have
  \[
    (\cos(\theta) + i\sin(\theta))^n
    = \cos(n\theta) + i\sin(n\theta)
    .
  \]
\end{theorem}
In fact, this theorem has an easy proof using Euler's Identity.
\begin{proof}
  Let \( \theta \in \mathbb{R} \) and \( n \in \mathbb{Z} \) be arbitrary.
  Applying the generalization of Euler's identity and usual laws of exponents, we obtain the following.
  \begin{align*}
    (\cos(\theta) + i\sin(\theta))^n
    &= (e^{i\theta})^n \\
    &= e^{i (n\theta)} \\
    &= \cos(n\theta) + i\sin(n\theta)
      .
  \end{align*}
  Hence the original statement holds.
\end{proof}

Note that the proof we gave applies more generally.
Indeed, the same computation proves the following more general identity.
\begin{proposition}
  For all real numbers \( \theta, r \) we have
  \[
    (\cos(\theta) + i\sin(\theta))^r
    = \cos(r\theta) + i\sin(r\theta)
    .
  \]
\end{proposition}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
One generalization from abstract algebra---from field theory in particular---is that the \( n^{\textrm{th}} \) roots of unity sum to 0 for all positive integers \( n \).
An \emph{\( n^{\textrm{th}} \) root of unity} is a solution to the equation \( x^n - 1 = 0 \).
Thus, the second roots of unity are \( 1 \) and \( -1 \), as these are precisely the solutions of \( x^2 - 1 = 0 \).
For general \( n \), there are exactly \( n \) roots of unity; moreover, these have the formula \( \mu_n^k = e^{2\pi i \frac{k}{n}} \) where \( 0 \leq k \leq n-1 \).
In particular, this generalization asserts that the following equation holds:
\[
  \sum_{k=0}^{n-1} \mu_n^k
  = \sum_{k=0}^{n-1} e^{2\pi i \frac{k}{n}}
  = 0
  .
\]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Geometry and Roots of Unity}

There is some interesting geometry concerning roots of unity.
\begin{theorem}
  \label{result:n-gon-roots}
  If \( n \geq 3 \), then in the complex plane, the \( n^{\text{th}} \) roots of unity form the vertices of a regular \( n \)-gon.
  Moreover, this \( n \)-gon is inscribed entirely in the unit circle in the complex plane.
\end{theorem}
In fact, \cref{result:n-gon-roots} is another simple consequence of previous results.
By combining Euler's Formula and De Moivre's Formula, we have
\begin{equation}
  \label{eqn:roots-de-moivre}
  \mu_n^k
  = (e^{i\tfrac{2\pi}{n}})^k
  = (\cos(\tfrac{2\pi}{n}) + i \sin(\tfrac{2\pi}{n}))^k
  = \cos(k \tfrac{2\pi}{n}) + i \sin(k \tfrac{2\pi}{n})
  .
\end{equation}
Moreover, by elementary trigonometry, we know
\begin{equation}
  \label{eqn:trig-unit-circle}
  \cos^2(\theta) + \sin^2(\theta)
  = 1
  .
\end{equation}
By combining \cref{eqn:roots-de-moivre,eqn:trig-unit-circle}, we obtain
\[
  |\mu_n^k|
  = \sqrt{\cos^2(k \tfrac{2\pi}{n}) + \sin^2(k \tfrac{2\pi}{n})}
  = \sqrt{1}
  = 1
  .
\]
This justifies the claim that the corners lay entirely on the unit circle.
The rest of \cref{result:n-gon-roots} can be justified by proving \( |\mu_n^{k+1} - \mu_n^k| = |\mu_n^2 - \mu_n| \) for all \( 0 \leq k \leq n-1 \).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{More Reading}

There are lots of places we could read more about Euler's identity and other classical formulas in mathematics.
Some readers might find the website \cite{websiteWithAnOpinion} interesting, where the author gives some of their favourite equations.
One of the better resources on Euler's accomplishments is \cite{expensiveBook}.
Finally, \cite{bookOfNumbers} is an excellent textbook for mathy folks.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\printbibliography
\end{document}

Completed Documents

This section has the completed code, for reference. Because we made two versions of the document, we will have two versions of the template. The template file on this site contains the longer version, in case you want to download that.

Short Document

If you followed along to create the short version of the document, these are the results of our labour.

\documentclass[12pt]{amsart}
\usepackage[margin=1in]{geometry}
\usepackage{amsthm, amssymb, mathtools}
\title{\LaTeX{} Tutorial}
\author{Chris Eppolito}
\date{Created 2023-01-18}

\begin{document}
\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{In-line and Display Mathematics}

The best equation ever discovered is Euler's Identity, \( e^{i \pi} + 1 = 0 \).
This fundamental identity was discovered by Leonhard Euler.
He wrote about it in the book \textit{Introductio in analysin infinitorum}, which appeared in 1748.

Since then, many mathematicians have been inspired by this equation to find generalizations.
Euler already knew that this was not as general as it could be; indeed, this is a special case of the general formula \( e^{i \theta} = \cos(\theta) + i \sin(\theta) \).

One generalization from abstract algebra---from field theory in particular---is that the \( n^{\textrm{th}} \) roots of unity sum to 0 for all positive integers \( n \).
An \emph{\( n^{\textrm{th}} \) root of unity} is a solution to the equation \( x^n - 1 = 0 \).
Thus, the second roots of unity are \( 1 \) and \( -1 \), as these are precisely the solutions of \( x^2 - 1 = 0 \).
For general \( n \), there are exactly \( n \) roots of unity; moreover, these have the formula \( \mu_n^k = e^{2\pi i \frac{k}{n}} \) where \( 0 \leq k \leq n-1 \).
In particular, this generalization asserts that the following equation holds:
\[
  \sum_{k=0}^{n-1} \mu_n^k
  = \sum_{k=0}^{n-1} e^{2\pi i \frac{k}{n}}
  = 0
  .
\]
\end{document}

We've created our very first LaTeX document! If you're feeling adventurous, you can stop here and try to make your documents by trial-and-error; I don't recommend it if you're new to LaTeX. If you choose to do so, you can jump to the section on online resources and get to writing :) However, I suggest that you go back to read about how to make the more complicated but practical elements of LaTeX work for you.

Longer Document

The following bit of code completes our longer document, with all the bells-and-whistles.

\documentclass[12pt]{amsart}
\usepackage[margin=1in]{geometry}

\usepackage{amsthm, amssymb, mathtools}
\newtheorem{theorem}{Theorem}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\theoremstyle{definition}
\newtheorem*{definition}{Definition}
\newtheorem{example}[theorem]{Example}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\newtheorem{problem}{Problem}

\usepackage[capitalise,nameinlink]{cleveref}
\crefname{theorem}{Theorem}{Theorems}
\crefname{proposition}{Proposition}{Propositions}
\crefname{lemma}{Lemma}{Lemmas}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{example}{Example}{Examples}
\crefname{definition}{Definition}{Definitions}
\crefname{remark}{Remark}{Remarks}
\crefname{problem}{Problem}{Problems}

\usepackage[citestyle=alphabetic,style=alphabetic,maxbibnames=9]{biblatex}
\renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{doi}{}
\DeclareFieldFormat{isbn}{}
\DeclareFieldFormat{issn}{}
\DeclareFieldFormat{url}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\LaTeX{} Tutorial}
\author{Chris Eppolito}
\date{Created 2023-01-18}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\addbibresource{latex-example-references.bib}

\begin{document}
\maketitle

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{In-line and Display Mathematics}

The best equation ever discovered is Euler's Identity, \( e^{i \pi} + 1 = 0 \).
This fundamental identity was discovered by Leonhard Euler.
He wrote about it in the book \textit{Introductio in analysin infinitorum}, which appeared in 1748.

Since then, many mathematicians have been inspired by this equation to find generalizations.
Euler already knew that this was not as general as it could be; indeed, this is a special case of the general formula \( e^{i \theta} = \cos(\theta) + i \sin(\theta) \).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{De Moivre's Formula}

An interesting theorem related to Euler's identity is De Moivre's Formula.
\begin{theorem}[De Moivre's Formula]
  For all real numbers \( \theta \) and all positive integers \( n \) we have
  \[
    (\cos(\theta) + i\sin(\theta))^n
    = \cos(n\theta) + i\sin(n\theta)
    .
  \]
\end{theorem}
In fact, this theorem has an easy proof using Euler's Identity.
\begin{proof}
  Let \( \theta \in \mathbb{R} \) and \( n \in \mathbb{Z} \) be arbitrary.
  Applying the generalization of Euler's identity and usual laws of exponents, we obtain the following.
  \begin{align*}
    (\cos(\theta) + i\sin(\theta))^n
    &= (e^{i\theta})^n \\
    &= e^{i (n\theta)} \\
    &= \cos(n\theta) + i\sin(n\theta)
      .
  \end{align*}
  Hence the original statement holds.
\end{proof}

Note that the proof we gave applies more generally.
Indeed, the same computation proves the following more general identity.
\begin{proposition}
  For all real numbers \( \theta, r \) we have
  \[
    (\cos(\theta) + i\sin(\theta))^r
    = \cos(r\theta) + i\sin(r\theta)
    .
  \]
\end{proposition}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
One generalization from abstract algebra---from field theory in particular---is that the \( n^{\textrm{th}} \) roots of unity sum to 0 for all positive integers \( n \).
An \emph{\( n^{\textrm{th}} \) root of unity} is a solution to the equation \( x^n - 1 = 0 \).
Thus, the second roots of unity are \( 1 \) and \( -1 \), as these are precisely the solutions of \( x^2 - 1 = 0 \).
For general \( n \), there are exactly \( n \) roots of unity; moreover, these have the formula \( \mu_n^k = e^{2\pi i \frac{k}{n}} \) where \( 0 \leq k \leq n-1 \).
In particular, this generalization asserts that the following equation holds:
\[
  \sum_{k=0}^{n-1} \mu_n^k
  = \sum_{k=0}^{n-1} e^{2\pi i \frac{k}{n}}
  = 0
  .
\]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Geometry and Roots of Unity}

There is some interesting geometry concerning roots of unity.
\begin{theorem}
  \label{result:n-gon-roots}
  If \( n \geq 3 \), then in the complex plane, the \( n^{\text{th}} \) roots of unity form the vertices of a regular \( n \)-gon.
  Moreover, this \( n \)-gon is inscribed entirely in the unit circle in the complex plane.
\end{theorem}
In fact, \cref{result:n-gon-roots} is another simple consequence of previous results.
By combining Euler's Formula and De Moivre's Formula, we have
\begin{equation}
  \label{eqn:roots-de-moivre}
  \mu_n^k
  = (e^{i\tfrac{2\pi}{n}})^k
  = (\cos(\tfrac{2\pi}{n}) + i \sin(\tfrac{2\pi}{n}))^k
  = \cos(k \tfrac{2\pi}{n}) + i \sin(k \tfrac{2\pi}{n})
  .
\end{equation}
Moreover, by elementary trigonometry, we know
\begin{equation}
  \label{eqn:trig-unit-circle}
  \cos^2(\theta) + \sin^2(\theta)
  = 1
  .
\end{equation}
By combining \cref{eqn:roots-de-moivre,eqn:trig-unit-circle}, we obtain
\[
  |\mu_n^k|
  = \sqrt{\cos^2(k \tfrac{2\pi}{n}) + \sin^2(k \tfrac{2\pi}{n})}
  = \sqrt{1}
  = 1
  .
\]
This justifies the claim that the corners lay entirely on the unit circle.
The rest of \cref{result:n-gon-roots} can be justified by proving \( |\mu_n^{k+1} - \mu_n^k| = |\mu_n^2 - \mu_n| \) for all \( 0 \leq k \leq n-1 \).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{More Reading}

There are lots of places we could read more about Euler's identity and other classical formulas in mathematics.
Some readers might find the website \cite{websiteWithAnOpinion} interesting, where the author gives some of their favourite equations.
One of the better resources on Euler's accomplishments is \cite{expensiveBook}.
Finally, \cite{bookOfNumbers} is an excellent textbook for mathy folks.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\printbibliography
\end{document}

Online Resources

The following is a list of resources I found to be helpful when I was learning to use LaTeX.

Detexify
allows you to lookup symbols by hand-drawing them.