\documentclass{2800hw}

% This line is a comment. Comments start with the character % and continue until the end of the line
% LaTeX does not have multiline comments, so you have to comment each line individually

% This is a command telling LaTeX to load the package named "amsmath". LaTeX commands start with a backslash, and you pass in arguments in {}.
% The amsmath (American Mathematical Society) package is a collection of math symbols/environments. You may find it useful
\usepackage{amsmath}

% amssymb is another AMS package that include even more symbols
\usepackage{amssymb}

% verbatim is a package that has a "verbatim" environment, which will be used later
\usepackage{verbatim}

% you can define your own commands, using \newcommand. Notice that \newcommand takes some arguments in [ ], and other arguments in {}. The arguments in [] are optional.
% This \newcommand creates a new command (or macro) named "\foo" that takes one argument. Each time \foo{bar} is used in the text, it is replaced by the body "bar is cool". I.e. it replaces #1 with the argument to foo, and expands the rest of the text.
\newcommand{\foo}[1]{#1 is cool!}

% These are commands that set the name of the author, the HW # etc. These are part of the 2800hw class that Prof. Kozen created for the class 
\name{Mark Reitblatt}
\netid{mjr336}
\homework{1}

% Up until now, we've been in the "preamble". This is where you define new commands, include packages, etc. Now, to actual typeset text, we enter the body by issuing the \begin{document} command

\begin{document}

% This generates the title header, using the info we passed to \name{}, \netid{} and \homework{}
\maketitle

% By default, text in the body is typeset as plaintext. There are three things to note here:
%    1) Even though these three sentences are on different lines, LaTeX typesets them as a single paragraph. If you want to separate them, you need to either insert an empty line between them, or use an explicit new line command: \\
%    2) LaTeX automatically fixes extra whitespace according to English text conventions. I.e. the text "Hello    students" gets typeset the same as "Hello students"
%    3) You can issue commands in text mode such as \foo{}
Hello    this is a sentence.
This is another sentence.
\foo{\LaTeX}.

% If you want to use mathematical symbols or to typeset equations, you need to enter mathmode by wrapping the mathy stuff in $ ... $
This is a sentence that contains an equation $x=y \vee y=x$.

% You can type greek letters by entering mathmode and issuing \pi or \phi or \eta etc.
$\pi$

% To typeset a system of equations, you enter the align* environment. Environments are LaTeX's way of specially typesetting paragraphs of text. The align* environment typesets a series of lines as a table (or array) of text. Note that align* automatically enters you into mathmode.

\begin{align*}
% align* lets you align sections of different lines by entering the alignment character &
% Here, we are aligning the "=" on each line by placing & right before "=". This will typeset all of the "=" to line up.
x + y &= y + x\\
0(x + y) &= 0(y + x)\\
0 &= 0
\end{align*}

% To get a numbered sequence of entries, use the enumerate (or exercises) environment
% Each time you use the \item command, a new entry will be created and automatically numbered
\begin{enumerate}
\item Do some work
\item Do some more work
\end{enumerate}
%
% For non-numbered entries, use the itemize enviroment
\begin{itemize}
\item I'm in a list!
\end{itemize}

% You can nest enumerate and itemize:
\begin{enumerate}
  \item Go shopping
    \begin{itemize}
    \item Milk
    \item Eggs
    \end{itemize}
  \item Sleep
\end{enumerate}

% To typeset a table, use the tabular environment. Tabular takes as arguments the number and layout of each column. Here, we're saying to create 3 columns of center (c) text, with vertical lines (|) between them. We could also create columns of right aligned (r) or left aligned (l) text, or mix and match.

\begin{tabular}{|c|c|c|}
% This creates a horizontal line above the first row in the table
\hline
% Just like in align*, we use & to align the text (separate the columns)
p & q & p nor q\\
\hline
true & true & false\\
true & false & false\\
false & true & false\\
false & false & true\\
% If you want to insert a literal & symbol, you can escape it with \&:
false & false & \&\\
\hline
\end{tabular}

\section{Installation}
\subsection{Mac OS X}
\begin{itemize}
  \item TexShop
  \item MacTex
\end{itemize}

\subsection{Linux}
\begin{itemize}
  \item TexLive (check your repos)
\end{itemize}

\subsection{Windows}
\begin{itemize}
  \item MikTeX (No personal experience)
\end{itemize}

\subsection{Editors}

I recommend that you use a text editor with special support for \LaTeX. This includes Emacs, VIM (with appropriate packages installed), TexShop, Eclipse, Sublime, TeXworks. I personally have limited experience with these editors beyond Emacs/VIM, but other TAs may be able to help.
 
\section{Text vs Mathmode}

By default, everything you type is in text mode, like this sentence. To use math symbols such as $x^y$ (\verb_x^y_) and $\sum_0^n$ (\verb!\sum_0^n!), you need to enter them in math mode, by surrounding them with \verb&$&, like \verb#$x^y$#. You can also wrap environments (in a second!) with mathmode.

\section{Environments}

Environments are a way to specially typeset a paragraph. There are many different environments in \LaTeX, but you only need to know a couple for this class.

In general, typeset text \textsc{foo} in environment \textbf{bar}, you will wrap it with begin/end commands:

\begin{verbatim}
\begin{bar}
foo
\end{bar}
\end{verbatim}


\end{document}