% \documentclass tells what type of document you are preparing.
% ''article'' is the most generic type and works for anything you'll be doing
\documentclass{article}
% \usepackage imports packages with new symbols
% There are LOTS of possible packages, but the ones below cover most everything
% you'll need for math and graphics.
\usepackage{amsmath,amsthm,amssymb,latexsym,graphicx}
% \newtheorem lets you name a few different kinds of theorem environments
% The first argument is what you want the command to be named.
% The second argument is the word that should actually appear in the document.
% The optional third argument tells them all to use the same numbering scheme.
% It will make more sense when you see it in use later in the document.
\newtheorem*{thm}{Theorem}
\newtheorem*{prop}{Proposition}
\newtheorem*{defn}{Definition}
\newtheorem*{lem}{Lemma}
\newtheorem*{cor}{Corollary}
\newtheorem*{conj}{Conjecture}
% Put your title, author, and date information BEFORE \begin{document},
% then call the \maketitle command immediately after \begin{document}
\title{\LaTeX \ Examples}
\author{Austin Mohr}
\date{\today} % You can specify a date, or just use \today to use today's date.
% \begin{document} and \end{document} mark the beginning and end of the
% part of the document you actually want to be typeset
\begin{document}
% \maketitle takes all the title, author, and date information and makes
% a nice looking header for the document
\maketitle
% Finally, we'll start typing the body of our document.
% The \section and \section* commands let you include section headings.
% The * means that LaTeX will not number the section, and this is a common practice for many commands.
\section{Two Theorems About Sums}
% This tells the compiler that I'm getting ready to type a theorem.
\begin{thm}
The sum of two even integers is an even integer.
\end{thm}
% This tells the compiler that I'm getting ready to type a proof.
% Notice anything mathematical is surrounded by dollar signs.
\begin{proof}
Let $m$ and $n$ be any two even integers, which means $m = 2j$ and $n = 2k$ for some integers $j$ and $k$.
Now,
% The align* environment lets you arrange long strings of equations.
% You don't use a $ anywhere in align* (it already expects math is coming).
% The & tells where the equations should be aligned (usually at the equals sign).
% The \\ is the LaTeX command for newline.
\begin{align*}
m + n &= 2j + 2k\\
&= 2(j + k).
\end{align*}
Since the integers are closed under addition, $j + k$ is an integer, and so we have written $m + n$ as
twice some integer. Therefore, $m + n$ is even, as desired.
\end{proof}
% Here's another example, but written a little more tersely using symbols.
\begin{thm}
The sum of any two rational numbers is rational.
\end{thm}
\begin{proof}
Let $r, s \in \mathbb{Q}$, which means $r = \frac{a}{b}$ and $s = \frac{c}{d}$, where $a,b,c,d \in \mathbb{Z}$ and $b, d \neq 0$.
Now,
\begin{align*}
r + s &= \frac{a}{b} + \frac{c}{d}\\
&= \frac{ad}{bd} + \frac{bc}{bd}\\
&= \frac{ad + bc}{bd}.
\end{align*}
By properties of integer addition and multiplication, we know $ad + bd, bd \in \mathbb{Z}$. We know also $bd \neq 0$, since $b, d \neq 0$. Therefore, $r + s$ is a rational number.
\end{proof}
\section{A Ramble About $e$}
% Not everything has to be inside a theorem or proof.
It is an indisputable fact that $e$ is a better number than $\pi$. Anyone who thinks otherwise is wrong.
Consider, for example,
\begin{align*}
\frac{d}{dx} (a^x) &= \lim_{h \rightarrow 0} \frac{a^{x+h} - a^x}{h}\\
&= a^x \lim_{h \rightarrow 0} \frac{a^h - 1}{h}.
\end{align*}
This limit exists for all $a > 0$, but is there a choice that makes the limit equal unity? If this were possible, we would have
% The $$ sign begins and ends ``displayed'' math mode.
% Notice the expression is centered on a new line.
% There are other aesthetic changes to make the content more readable.
$$
\lim_{h \rightarrow 0} \frac{a^h - 1}{h} = 1,
$$
which rearranges to
$$
a = \lim_{h \rightarrow 0} (1 + h)^\frac{1}{h}.
$$
This limit exists and is roughly equal to $2.71828$. The precise value of the limit is transcendental and is referred to by $e$ (probably for ``exponential'').
According to our analysis, $e^x$ is the only function (up to a constant factor) that is its own derivative. Based on that fact, the theory of Taylor series gives us another representation of $e^x$, namely
% I hope this example is enough to convince you that math looks better in LaTeX.
$$
e^x = \sum_{n = 0}^\infty \frac{x^n}{n!}.
$$
Take the formal derivative of the series and you'll see what I mean.
Finally, it is the only exponential function whose tangent line at the origin has unit slope.
% The easiest way to deal with images in LaTeX is to use a standard image editor and import the image.
% I find that .png gives pretty good quality, but other image types are supported.
% You must have the image in the same directory as your .tex file when you compile.
% The optional h argument in \begin{figure} tells LaTeX to place the figure ``here'' in the document. Without this, LaTeX has its own ideas about where it looks best.
% The optional \centering command centers the image horizontally.
% The optional scale argument in \includegraphics allows you to shrink or stretch the image.
\begin{figure}[h]
\centering
\includegraphics[scale=.5]{ex.png}
\caption{The graph of $e^x$ is truly exquisite.}
\end{figure}
% Here's the end of the document
\end{document}