% in your .tex document, anytime you put a percentage sign, everything that follows it will not affect the % document in any way.  you can leave comments for yourself using percentage signs, and sometimes
% it is also a useful tool when you're debugging your document.

% the first line in every LaTeX document is \documentclass[x]{y}.  the first argument x is optional and is
% used to control the size of the text.  the second argument is necessary and dictates the style of your
% document.  besides article, other documentclass options include report (used for longer articles or
% theses), book, and beamer (used to create slideshows).
\documentclass[11pt]{article}


% everything between the \documentclass command and the \begin{document} command are macro
% settings.  there are many things you can do in this section, and i'll only highlight the ones i use most.


\oddsidemargin 0.0in %sets the left margin farther to the left than the standard article margin
\textwidth 6.5in %sets the width of the text on the page
\addtolength{\topmargin}{-1.0in} %moves the top margin up 1 inch
\addtolength{\textheight}{1.75in} %adds 1.75 inches to the total length of text allowed on a page


% the \usepackage command is used to call on non-standard packages.  you can list them inside a
% single \usepackage{...} or you can do each separately.  the first three i have, amsmath, amsthm, and
% amssymb include most math formatting you'll need, so i would include those every time.  the epsfig 
% and graphicx packages are used to include figures in your document.  the enumerate package
% is great for making lists of any sort.  there are many, many other packages you can use.
\usepackage{amsmath,amsthm,amssymb,epsfig,enumerate,graphicx}


% a really nice thing you can do in this macro section is to define your own commands that can be
% used in the actual document.  the format is \newcommand{cmd}[args]{def}, where cmd is the
% command you will use in the text, def is what you want substituted for cmd, and args is the
% number of arguments in the command.  below are some examples:

% these two i use when i'm writing assignments for the classes i teach.
\newcommand{\br}{\vskip 20pt \noindent}  % \br produces a vertical break of height 20pt and does not 
                                                                            % indent the next line

% a common thing to do is to create shortcuts for things you will use often
\newcommand{\rttw}{\sqrt{2}} % to put the square root of 2 in your document, you just type \rttw
\newcommand{\RR}{\mathbb{R}} % to put a blackboard bold R (for the real numbers), you just type \RR

% more complicated examples include
\newcommand{\f}[1]{\mathbb{#1}} % has one argument.  this command makes it possible to do any letter
                                                             % in blackboard bold by typing \f{R} or \f{C}, etc.
\newcommand{\diff}[2]{\frac{d #1}{d #2}} % this makes it faster to write derivatives.  if you
                                                                                           % type \diff{}{x} it will put d/dx.  if you
                                                                                           % type \diff{f}{x} it will put df/dx.
\newcommand{\Diff}[2]{\frac{D #1}{d #2}} % similar to other one, with capital D on top.

% to do theorems, propositions, lemmas, definitions, examples, remarks, etc, you can define how to 
% call those up in the document.  the 3 styles that i use are theorem, definition, and remark.  theorem
% style puts the header in bold and the text in italics.  definition style puts the header in bold and the
% text just regular.  remark style puts the header in italics and the text just regular.
% the default style is theorem style, so the following will be in the theorem style
\newtheorem{thm}{Theorem}[section] % so a theorem is started by typing \begin{thm}.  The title will come 
% up as Theorem and it will be numbered according to section.  to close it, you type \end{thm}
\newtheorem{cor}[thm]{Corollary} % \begin{cor} will start a Corollary.  the [thm] command makes it so
                                                             % that corollaries are numbered the same as theorems
\newtheorem{prop}[thm]{Proposition}
\newtheorem{lemma}[thm]{Lemma}
\newtheorem*{hopf}{Hopf-Rinow Theorem} % the * simply tells LaTeX to not number this theorem

\theoremstyle{definition} % the following will be in definition style
\newtheorem{defn}[thm]{Definition}

\theoremstyle{remark} % the following will be in remark style
\newtheorem{ex}[thm]{Example}
\newtheorem{remark}[thm]{Remark}


% you can put author and title in the macro section
\author{Aaron D. Wood}
\title{A Very Incomplete Introduction to \LaTeX}

% now we're ready to start the document.
\begin{document}

% does the title and author automatically.  includes the date in the article class
\maketitle

\begin{section}{Warning!}

This is only meant to provide an example of how to create a basic document in \LaTeX.  You will undoubtably need more than this as a resource.  There is a great resource called ``The Not So Short Guide to \LaTeX'' by Tobias Oetiker.  You can find it online quite easily and download it.

\end{section}



\begin{section}{Special Characters}

There are special characters that are used within the .tex file.  For example, the \& symbol is used in many environments to separate sections, the \% symbol is used to make comments in the .tex file, a \$ on each side of an expression puts that expression in math mode, the underscore is used for subscripts, braces \{,\} are used all over the place, and a $\backslash$ is also used in virtually everything.  Also, a double backslash $\backslash\backslash$ will put a line break.

If you want to have these characters appear in the actual document, you have to use a backslash to do so.  The special characters and the syntax for putting them in your document are given below.

\begin{tabular}{ll}
\&  & $\backslash$\& \\
\% & $\backslash$\% \\
\#  & $\backslash$\# \\
\$  & $\backslash$\$ \\
\_  & $\backslash$\_ \\
\{   & $\backslash$\{ \\
\}   & $\backslash$\} \\
$\backslash$ & $\backslash$backslash
\end{tabular}

\end{section}



\begin{section}{Environments}
In this section, we will highlight a few of the most useful environments in \LaTeX.


\begin{subsection}{Math Mode}
As mentioned, a dollar sign is used to typeset things in math mode.  Without dollar signs, you get things looking like this: x-1.  With dollar signs on either side, you get it to look like this: $x-1$.  If you want to have a mathematical expression centered and on a line of its own, put \$\$ on each side of the expression.  For example, 
$$\f{Q}=\left\{ \frac{m}{n} : m,n \in \f{Z}, n\neq0 \right\}$$
% putting \left before (, {, or [ will size it to fit the contents on the inside.  close it with \right followed by
% the same character.  also, \frac{numerator}{denominator} is how you typeset fractions.
In any math environment, spaces in your .tex file will be ignored.  If you need some extra horizontal space, you can use $\backslash$; $\backslash$: $\backslash$. $\backslash$, or $\backslash$hskip.
\end{subsection}


\begin{subsection}{Align Environment}
This is a math environment (everything is automatically in math mode) that allows you to align multiple lines.  Here are a couple of examples.
\begin{align}
\frac{dy}{dx}+\frac{2x}{x^2+1}y&=\frac{1}{(x^2+1)^2}\\
(x^2+1)\frac{dy}{dx}+2x\cdot y&=\frac{1}{x^2+1}\\
(x^2+1)y&=\int\frac{1}{x^2+1}dx\\
(x^2+1)y&=\tan^{-1}x+C\\
y&=\frac{\tan^{-1}x+C}{x^2+1}
\end{align}

\begin{align*}
d\omega
 =&d(|x|^{-n})\wedge\sum_{i=1}^n(-1)^{i-1}x_i\;dx_1\wedge\cdots\wedge\hat{dx_i}\wedge\cdots\wedge dx_n\\
       &\hskip20pt +|x|^{-n}\sum_{i=1}^n (-1)^{i-1}dx_i\wedge dx_1\wedge\cdots\wedge\hat{dx_i}\wedge\cdots\wedge dx_n\\
       =&-n|x|^{-n-2}\left(\sum_{j=1}^n x_jdx_j\right)\wedge
       \sum_{i=1}^n(-1)^{i-1}x_i\;dx_1\wedge\cdots\wedge\hat{dx_i}\wedge\cdots\wedge dx_n\\
       &\hskip20pt +n|x|^{-n}dx_1\wedge\cdots dx_n\\
     =&-n|x|^{-n-2}\sum_{i=1}^n(-1)^{i-1}x_i^2\;
       dx_i\wedge dx_1\wedge\cdots\wedge\hat{dx_i}\wedge\cdots\wedge dx_n\\
       &\hskip20pt +n|x|^{-n}dx_1\wedge\cdots dx_n\\
     =&(-n|x|^{-n-2}|x|^2+n|x|^{-n})dx_1\wedge\cdots\wedge dx_n\\
     =&0,
\end{align*}
\end{subsection}


\begin{subsection}{Tabular Environment}
The tabular environment organizes items into a table.  You can choose the number of rows and columns and, for every column, you can choose whether to center, left-justify, or right-justify the items in the column.  You also have the option of inserting vertical and/or horizontal lines in your table.  Here are some examples.
\br % this is the line break that was defined in the macro section
\begin{tabular}{ccc} % this table will have 3 columns, all centered.
1st column & 2nd column & 3rd column\\ %the & is used to separate the columns.
a & b & c\\
$x$ & $y$ & $z$  % if you want to do math mode in a table, each section of the table needs to be
\end{tabular}     % done separately
\begin{tabular}{c|c|c} % this table will have 3 centered columns, with vertical lines between them.
1st column& 2nd column & 3rd column\\  % the symbol you see between the c's is not an L.  it is a
\hline       % vertical line.  this can become confusing when you have left-justified columns.
a & b & c\\   % \hline puts a horizontal line above the row.
\hline 
$x$ & $y$ & $z$
\end{tabular}
\br
\begin{tabular}{|ccc|} % this table will have 3 centered columns with a vertical line on each side of table.
\hline 
1st column & 2nd column & 3rd column\\
a & b & c\\
$x$ & $y$ & $z$\\
\hline
\end{tabular}
\begin{tabular}{|c|l|r|} % this table will have 3 columns.  it's hard to see, but the symbols are as follows:
\hline
1st column & 2nd column & 3rd column\\  % { | c | L | r | }  so there will be vertical lines on each side of 
\hline
a & b & c\\    % every column, andthe left column will be centered, the middle column left-justified, the 
\hline
$x$ & $y$ & $z$\\   % right column right-justified
\hline
\end{tabular}
\end{subsection}


\begin{subsection}{Array Environment}
This environment can be used to typeset matrices.  It works practically the same as the tabular environment, but it is a math environment.  Here are a couple of examples.
$$\text{SL}(2,\f{R})=\left\{  \left(
\begin{array}{cc} % two columns
a&b\\
c&d
\end{array} \right)\in M_2(\f{R}): ad-bc=1\right\}$$

$$\left( 
\begin{array}{c|ccc}  % four columns with a vertical line between the first and second
a_{11} & a_{12} & \cdots & a_{1n}\\
\hline
0 & 1 & \cdots & 0\\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \cdots & 1
\end{array}
\right)$$
\end{subsection}


\begin{subsection}{Itemize and Enumerate Environments}
The itemize and enumerate environments are used to create lists.  The itemize environment should be used when the items in the list do not need to be ``numbered.''
\begin{itemize}
\item The default setting for itemize gives bullets.
\item[!] You can substitute another symbol at a specific stage by typing $\backslash$item[insert symbol].
\item[+] You can also substitute another symbol for the whole list.  This is done before the list begins with the command $\backslash$begin\{itemize\}[insert symbol].
\end{itemize}
The enumerate environment should be used when you want items of the list ordered.
\begin{enumerate}[1.]
\item You can choose what symbols you want to order your items.  After $\backslash$begin\{enumerate\}, you can put 1, a, i, or $\alpha$, in brackets.
\item For this list, [1.] was inserted.
\item You can have other symbols besides periods, e.g. [(i)] or [a:].
\end{enumerate}
\end{subsection}


\begin{subsection}{Cases Environment}
This environment is nice for defining piecewise functions, denoting simultaneous equations, etc.  You can align one spot, using \&.  For example,
$$|x|=\begin{cases}
x  & \text{ if } x\geq0\\
-x & \text{ if } x<0
\end{cases}$$
Another example:
$$\begin{cases}
x''+4x'-5=0\\
x(0)=0\\
x'(0)=6
\end{cases}$$
\end{subsection}


\newpage
\begin{subsection}{Figure Environment}
To include a figure, you can use the graphicx package or the epsfig package.  Included below is the same figure twice, one with each package.

\epsfig{figure=codewheel.pdf, height=3in}  % your figure needs to be in the same directory as the .tex
\includegraphics[height=3in]{codewheel.pdf}  % file that is accessing it.

Also, you can put these in a figure environment if you would like to include a caption.  This also gives you more control of where the figure appears in the document.

\begin{figure}[h!] % h means float here.  ! means to ignore where LaTeX thinks is a good spot to float it.
 \begin{center}
    \epsfig{figure=codewheel.pdf ,height=3in}
   \caption{Codewheel representation of the 3-bit reflected Gray code}
  \end{center}
\end{figure}

\end{subsection}

\end{section}


\newpage
\begin{section}{Theorem Styles}

This section will contain some (disconnected) examples of definitions, theorems, etc, pulled from various notes.

\begin{defn}
For an integer $n\geq0$, $\zeta\in\f{C}$ is called an \emph{$n^{th}$ root of unity} if $\zeta^n=1$.  If there is no integer $d$, $1\leq d<n$, such that $\zeta^d=1$, then $\zeta$ is called a \emph{primitive $n^{th}$ root of unity}.
\end{defn}

\begin{ex}
Let $f\in\f{Q}[x]$ be an irreducible polynomial of degree $5$ with exactly two non-real roots.  Let $\f{E}$ be the splitting field of $f$ over $\f{Q}$.  Let $\alpha\in\f{E}$ be a root of $f$.  Then $[\f{Q}(\alpha):\f{Q}]=5$, giving that $5$ divides $|G|$ where $G=\text{Gal}(\f{E}/\f{Q})$. Hence, if $G$ is viewed as a subgroup of $S_5$, then $G$ contains a $5$-cycle.  Let $\sigma:\f{C}\to\f{C}$ be given by $\sigma(z)=\bar{z}$.  Then $\sigma\in\text{Aut}(\f{C})$ and $\sigma|_\f{R}$ is the identity, giving that $\sigma\in\text{Gal}(\f{C}/\f{R})$.  Thus $\sigma\in G$.  Since $\sigma^2$ is the identity and $\sigma$ is not, then $G$ contains a transposition.  Therefore $G=S_5$ as $G$ contains both a transposition and a $5$-cycle.  Hence, $f$ is not solvable by radicals over $\f{Q}$ as $G=S_5$ is not solvable.
\end{ex}

\begin{prop}
Suppose a Riemannian manifold $M$ has an affine connection $\nabla$ compatible with $\left<,\right>$.  Let $V,W$ be vector fields along a $c:I\to M$.  Then
$$\diff{}{t}\left<V,W\right>=\left<\Diff{V}{t},W\right>+\left<V,\Diff{W}{t}\right>.$$
\end{prop}

\begin{proof}
Let $P_1(t),\dots,P_n(t)$ be an orthonormal frame of parallel vectors along $c$.  Such a frame exists as one can take the parallel transport of an orthonormal basis of $T_{c(t_0)}M$.  Then $V$ and $W$ can be written as
\begin{align*}
V&=\sum_{i=1}^n v_i(t) P_i(t),\\
W&=\sum_{j=1}^n w_j(t) P_j(t).
\end{align*}
Since $P_i$ is parallel along $c$, then $\Diff{P_i}{t}=0$ and hence
\begin{align*}
\Diff{V}{t}=\sum_{i=1}^n\diff{v_i}{t} P_i(t),\\
\Diff{W}{t}=\sum_{j=1}^n\diff{w_j}{t} P_j(t).
\end{align*}
Therefore,
\begin{align*}
\left<\Diff{V}{t},W\right>+\left<V,\Diff{W}{t}\right>
&=\sum_{i=1}^n\left(\diff{v_i}{t}w_i+v_i\diff{w_i}{t}\right)\\
&=\diff{}{t}\left(\sum_{i=1}^n v_i w_i\right)\\
&=\diff{}{t}\left<V,W\right>.
\end{align*}
\end{proof}

\newpage
\begin{thm}\label{bch} %the \label command makes it possible to refer to this theorem later on.
Let $\f{F}_q$ be a finite field and let $C$ be a BCH code with parameters $n,d$.  Then $d(C)\geq d$.
\end{thm}

\begin{proof}
Let $r$ be such that $q^r>n$, let $f$ be an irreducible polynomial in $\f{F}_q[x]$ with $\deg(f)=r$, and let $\alpha$ be any primitive element of the finite field $\f{F}=\f{F}_q[x] \big/ (f)$.  Define
$g(x)=\prod m_i(x)$
where the product is take over distinct terms and $m_i(x)$ is the product of terms of the form $x-\gamma$ where $\gamma$ is in the conjugacy class of $\alpha^i$.  Then
$$C=\Big\{f(x)g(x): f \in \f{F}_q[x], \deg(f)<n-\deg(g)\Big\}$$
is a BCH code with parameters $n,d$.  Since $C$ is a polynomial code, it is also a group code, and hence
$d(C)=\min\{\text{wt}(c):c\neq0, c\in C\}.$
For $c\in C$ nonzero, there exists $a\in\f{F}_q[x]$ such that $c(x)=a(x)g(x)$.  Therefore we have
\begin{enumerate}[(i)]
\item $c(\alpha^i)=0$ for $i=1,2,\dots,d-1$,
\item $\deg(c)<n\leq q^r-1 = \text{order}(\alpha)$.
\end{enumerate}
Since $c\neq0$, then the number of nonzero coefficients of $c$ is at least $d-1$, giving that $\text{wt}(c)\geq d$.
\end{proof}

To reference a previous theorem, definition, etc, label an item with $\backslash$label and refer to it using $\backslash$ref.  For Theorem \ref{bch}, we used the label \{bch\}, so to refer to it, we type $\backslash$ref\{bch\}.  You need to compile the document a couple of times to get the references to show up correctly.  Using $\backslash$ref and $\backslash$label is better than labeling things yourself, as \LaTeX will keep track of the numbering for you.

\begin{lemma}[Second Bianchi Identity]
${{R_i}^j}_{k\ell,m}+{{R_i}^j}_{\ell m,k}+{{R_i}^j}_{mk,\ell}=0$.
\end{lemma}

\begin{proof}
Recall the defining relation 
$d{\omega_i}^j -{\omega_i}^k{\omega_k}^j=-\frac{1}{2}{{R_i}^j}_{k\ell}\;\omega^k\wedge\omega^\ell$.
If we differentiate this relation, we obtain
$$-(d{\omega_i}k)\wedge{\omega_k}^j+{\omega_i}^k\wedge(d{\omega_k}^j)
=-\frac{1}{2}{{R_i}^j}_{k\ell}\Big((d\omega^k)\wedge\omega^\ell-\omega^k\wedge(d\omega^\ell)\Big).$$
Using the structure equations 
$$\begin{cases}
{\omega_i}^j+{\omega_j}^i&=0\\
\omega^j\wedge{\omega_j}^i&=d\omega^i
\end{cases}$$
The differentiated relation simplifies to
\begin{align*}
0&=\frac{1}{2}\Big[d{{R_i}^j}_{pq}+{{R_i}^k}_{pq}\;{\omega_k}^j-{{R_k}^j}_{pq}\;{\omega_i}^k
        -{{R_i}^j}_{kq}\;{\omega_p}^k-{{R_i}^j}_{p\ell}\;{\omega_q}^\ell\Big]\omega_p\wedge\omega^q\\
  &=\frac{1}{2}{{R_i}^j}_{pq,k}\;\omega^k\wedge\omega^p\wedge\omega^q\\
  &={{R_i}^j}_{pk,q}+{{R_i}^j}_{kq,p}+{{R_i}^j}_{qp,k}
\end{align*}
\end{proof}

\begin{hopf}
If $M$ is a connected Riemannian manifold, then the following are equivalent.
\begin{enumerate}[(a)]
\item For some $p\in M$, every geodesic through $p$ is defined for all $t$.
\item Closed and bounded subsets of $M$ are compact.
\item $M$ is complete as a metric space.
\item $M$ is geodesically complete.
\end{enumerate}
Moreover, each of (a) through (d) implies that for every $p,q\in M$, there exists a geodesic in $M$ connecting $p$ and $q$ of length $d(p.q)$.
\end{hopf}

\begin{proof}
The proof is left as an exercise.
\end{proof}


\end{section}




\end{document}
