\documentclass[11pt]{amsart}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% The % is the comment character.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% We start with the preamble, which sets up a lot of things;
% jump down to \begin{document} to see where the body text starts
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here are packages for fonts, symbols, and graphics
\usepackage{amsfonts}
% \usepackage[english]{babel}
\usepackage{amssymb, latexsym, amsthm, amsmath, verbatim}
\usepackage{graphicx}
% the following package typesets URLS and produces clickable links in your pdf-- useful for web-based bibliography items
\usepackage{hyperref}
% by default, margins are rather big; use the following package to save paper
% BUT: use standard margins for submitting homework, papers, etc.
%\usepackage{fullpage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here are useful environments for theorems, etc.. Use them by typing, e.g.
% \begin{thm} Statement of theorem \end{thm}
% Often followed at some point by \begin{proof} Proof \end{proof}
\theoremstyle{theorem}
\newtheorem{thm}{Theorem}[section]
\newtheorem{lem}[thm]{\textbf Lemma}
\newtheorem{cor}[thm]{Corollary}
\newtheorem{prop}[thm]{\textbf Proposition}
\newtheorem{crit}[thm]{Criterium}
\newtheorem{alg}[thm]{Algorithm}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Here are more theorem-like environments, but with a different style.
% Use them the same way as above-- see what it looks like
\theoremstyle{definition}
\newtheorem{defn}[thm]{Definition}
\newtheorem{conj}[thm]{Conjecture}
\newtheorem{exmp}[thm]{\textbf{Examples}}
\newtheorem{exe}[thm]{\textbf{Example}}
\newtheorem{prob}[thm]{Problem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% More theorem-like environments with yet another style.
% Try...
\theoremstyle{remark}
\newtheorem{rem}[thm]{\textbf{Remark}}
\newtheorem{note}[thm]{Note}
\newtheorem{claim}[thm]{Claim}
\renewcommand{\theclaim}{}
\newtheorem{summ}{Summary}
\renewcommand{\thesumm}{}
\newtheorem{case}{Case}
\newtheorem{ack}{ACKNOWLEDGEMENTS}
\renewcommand{\theack}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To change how your numbered equations etc. are labeled
% (here: numbered as (x.y), where x is section number, y is equation number)
\numberwithin{equation}{section}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Some macros for frequently used commands, and several ways to define them
\newcommand{\R}{\mathbb{R}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\ba}{\backslash}
\DeclareMathOperator{\rank}{rank}
\DeclareMathOperator{\dimension}{dim}
%% This is a partial derivative
\newcommand{\der}[2]{\frac{\partial #1}{\partial #2}}
%% This is an inner product
\newcommand{\ip}[2]{\left<#1,#2\right>}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% To make a title, author, etc.
\title{A Crash Course in \LaTeX}
\author{Liz Beazley}
\date{September 7, 2012; Some changes by David Lippel 2015-01-22}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Now for the actual document
\begin{document}
\maketitle
\LaTeX\ is free and a wonderful tool for all of your math typesetting needs! This document is designed to get you going using \LaTeX, but the best way to learn \TeX\ is the same as the best way to learn math in general: by just doing it! Your skills will improve over time with practice and experience, but diving in head-first is definitely the way to start. So let's get started!
\section{Getting \LaTeX}
To download \LaTeX\ onto your computer, visit the LaTeX page under the ``Student Resources" tab on the Haverford Math Department homepage:
\url{http://www.haverford.edu/mathematics/resources/LaTeX.php}
\section{General Commands}
\TeX\ code is supposed to be intuitive to math-minded users. To underline, use \underline{as desired}. Likewise, for overlines you can use $\overline{\text{this}}$. It is important to know how to put
items
in ``math mode''. (Note here that you have to type an open double quote as two singles.) A single dollar sign will give you inline math mode, such
as
$a+3=r$ while \verb+\[...\]+ produces a display math mode: \[ \lim\limits_{k \rightarrow \infty} \sum_{i=1}^{k} \left( \frac{1}{2}\right)^i = 1. \] All math commands need to be typed in a math environment.
As you see in the \texttt{.tex} file, it doesn't matter to \TeX\ where you place line breaks
and so forth in the file---everything is automatically spaced and formatted. For example,
\[ (A \cap B)^{C} = A^C \cup B^C \text{~This is where you put normal text
in math mode} \]
The initial tilde in the \texttt{\textbackslash text} command is for a non-breaking space and can be used
outside of math mode as well. Here is another example of using the \texttt{\textbackslash text} command to include text inside math mode: \[ \{ a \in \Z \mid a = 2k\ \text{for some $k \in \Z$} \}.\] If you want larger symbols, there are commands for each of these.\footnote{To find more commands, use
\href{http://mirror.ctan.org/info/symbols/comprehensive/symbols-letter.pdf}{The Comprehensive LaTeX Symbol List} or \href{http://detexify.kirelabs.org/classify.html}{DeTeXify}; note that in the pdf output, these resources are clickable links.} For example, to make larger union and intersection symbols, you can write
\[ \forall ~I,~~ \bigcap_{\alpha \in I} A_{\alpha} = \bigcup_{\alpha \in I}
B_{\alpha} .\] Obviously, TeX clearly doesn't care if the math is correct, so it's your job to make sure you aren't \TeX ing nonsense! \TeX\ is
only a markup language to allow users to present things in a clear and
attractive fashion.
\begin{center}
We can center things or even make them \textbf{bold} or \emph{italic}.\footnote{Note that the italics in the previous sentence are produced by using the command \texttt{\textbackslash emph} for \emph{emphasis}. That command ensures that the correct sort of emphasis is applied, based on the surrounding context. What happens when you use the \texttt{\textbackslash emph} command inside a theorem?}
\end{center}
\
\subsection{Additional commands}
For an exhaustive list of commands, you can visit \newline
\url{http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-letter.pdf} \newline
which contains 110+ pages of symbols.
%There is a list of commonly used \TeX symbols located on Moodle.
There is also an interactive symbol command finder called De\TeX ify, which you can access at the bottom of the \LaTeX\ page under ``Student Resources" on the department website.
\subsubsection{Just to show}
Other convenient things you can do:
\begin{align}
\nonumber (x-5)(x+5)(x-1) &= (x^2-25)(x-1) \\
&= x^3-x^2-25x+25 \label{eqn:prod1} \\
&= 21 \text{~for which value(s) of $x$?} \label{eqn:prod2}
\end{align}
Or, you can produce aligned text without numbering any of the equations:
\begin{align*}
\prod_{k=2}^{n} 1.034829k+\pi k &= \text{something} \\
25 &= \frac{50}{2} \\
&= \sqrt{625}
\end{align*}
Using the shortcut macros we defined in the preamble, we can easily type \[ \der{f(x)}{x^2} \hspace{.2in} \text{and} \hspace{15pt}
\ip{(3,2,-1)}{(0,1,1)} = 1. \] To get curly brackets, we must write $\{$ and
$\}$, while our common blackboard
notation can be written $\R$ (since it is a macro) or more generally
$\mathbb{C}$. We can write a set difference (backslash) as $\mathbb{C} \setminus \R$.
Since we labelled our equations earlier, we can refer back to Equations
\ref{eqn:prod1} and \ref{eqn:prod2}.
\subsection{More random stuff}
Here are some matrices:
\[ A_k^{-1} = \begin{pmatrix}
0 & 0 & 1 \\
1 & 0 & 0 \\
\end{pmatrix} \]
\[ I = \begin{bmatrix}
1 & 0 & \dots & 0 \\
0 & 1 & \dots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dots & 1
\end{bmatrix}
\]
\vspace{10pt}
Here are some random commands you might want to learn early for analysis and algebra, which we enumerate as you might your homework problems:
\begin{enumerate}
\item There is a map $\phi: GL_n(\R) \rightarrow \R^{\times}$ which takes $A \leadsto \det(A)$ and $\rank B = 2$
\vskip 5pt
\item $\liminf\limits_{n \rightarrow \infty} b_n = $
\begin{math}\begin{cases}
\sqrt{ \varepsilon^2+3} & \text{if}\ x \cong 2/3 \\
f^{-1}(y_j) & x \equiv [0,1) \\
\emptyset & \text{otherwise}.
\end{cases}\end{math}
\vskip 5pt
\item $\ker \varphi = \left\{ \sigma \in S_n \mid \sigma(1\ 2\ 3) \mapsto \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \right\} \sim X$
\vskip 5pt
\item $x \leq y \iff \sup \{ a_n \} \notin \Q$, and so $\vert a-b \vert = \frac{\epsilon}{2}$
\end{enumerate}
If you want to force a page break, the \texttt{\textbackslash pagebreak} command will vertically stretch everything to fill the previous page, while $\ba$\texttt{newpage} will simply force a page break without additional formatting.
\vspace{.25in}
\hspace{100pt}
Note that here we created an abbreviation for the backslash command, which we got tired of typing---look up in the ``preamble" of the source code.
\begin{comment}
Here is something more sophisticated . . . A figure saved as a pdf can be included if you place the figure file in the same folder with the \TeX \ document. If you download the file \TeXfigure.pdf from Moodle into the same folder on your computer as this file, then deleting the comment commands here will produce a figure!
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=1.05in]{TeXfigure.pdf}
\caption{\label{zfig} A math figure.}
\end{center}
\end{figure}
\noindent You can create figures for inclusion in \TeX \ files using xfig, where they will be exported as postscript files, but you can also include any pdf files you created by your favorite program.
\end{comment}
\section{Compiling Files}
If you are using a GUI such as TeXShop or TeXnic Center, there will be a button that compiles your document for you automatically. You can go to the preferences to change how you would like your documents to compile and what viewer you set as the default to see your output. To compile this file at a command line in either Linux or on a Mac, and to view and print the compiled version in a new window in the background, type: \texttt{pdflatex file.tex}.
\begin{rem}
Note that if you have references or
labels
you must run latex on your file \emph{twice} for all citations to show up
correctly.
\end{rem}
\subsection{Error Messages}
If you have even one thing mistyped or are missing one essential line of code, the entire document will refuse to compile. An error message box will pop up with an explanation of the complaint and the line number on which this error occurs. A GUI interface will also have a ``Go to Error" button, which will take you directly to the line on which the error is located. If there are multiple errors, this process will need to be repeated as many times as there are errors.
To avoid the headache of trying to decode multiple error messages, \begin{LARGE} I recommend \end{LARGE}\begin{Huge} compiling often\end{Huge}, after each new bit of mathematical input. That way, it will be simple to isolate the new text that is causing a problem.
\section{Conclusion}
I hope that you enjoy using \LaTeX \ for all of your future math typesetting! Your documents will appear professional and polished---even if the math isn't!! As you get started and throughout the semester, please feel free to ask me any \TeX\ questions that arise. Some beginning tutorials and help pages are saved on Moodle for quick reference, but you will also find an overwhelming supply of both general and specific \TeX\ help online with a quick google search.
By the end of the semester, yours will be the smug satisfaction of being fluent in a language reserved for math geeks! Welcome to the circle!
\end{document}