LaTeX Beginner's Guide
LaTeX Tutorials
There are a number of decent resources to learn the syntax and basics of LaTeX throughout the web:
 A Wikibook exists on the topic
 Companies like Overleaf and ShareLaTeX want you to learn LaTeX so you’ll use their tools
 Various sites on Google have LaTeX tutorials over a variety of topics (and of varying qualities)
 StackExchange has an entire subdomain just for TeX questions
The material here is intended to provide a specific introduction to the LaTeX commands and other information you’ll need when completing written assignments for this course. This is by no means a comprehensive introduction to LaTeX; make sure to ask questions if you have trouble or if something goes wrong.
The Basics
Here are a few basics you should know in preparing to work on your LaTeX documents.

LaTeX is a programming language in a fashion similar to C. In particular, LaTeX code must be compiled to produce a document. This is often done using
pdflatex
, a program which produces a PDF file from a LaTeX document. In this course, your repositories will come with appropriateMakefile
s.  Everything you want to be displayed in the LaTeX document should appear between the
\begin{document}
and\end{document}
commands. Other commands may appear outside of that space (e.g.\usepackage
to load libraries) but cannot try to draw anything. For the most part, you can just type text into the space between
\begin{document}
and\end{document}
and it will just show up there.
 For the most part, you can just type text into the space between

The
\input
command in LaTeX is the equivalent of C’s#include
: it is a glorified copyandpaste.  The content you write in LaTeX is largely in one of two modes: text mode or math mode. Text mode is the default.
 In text mode, whitespace matters. A blank line starts a new paragraph, while spaces between symbols are drawn as text spaces.
 In math mode, whitespace is irrelevant and math font is used. (Math font is similar to italics, but isn’t quite the same.)
 To enter math mode, you may simply type
$
or\(
. To exit math mode, you may type$
or\)
. You must match the enter command with the exit command; that is,\(
can only be used with\)
. The parenthesis versions are easier to debug;$
is easier to type.  Some symbols or commands only work in math mode. For instance,
\pi
appears as \(\pi\) in math mode but produces a compile error in text mode.
 LaTeX is a macro language: the “commands” are being translated to other code, which is then translated to other code, and so on. Eventually, all of this is translated to a series of TeX typesetting primitives. This means that there is not as much structure in LaTeX files as we might like and that the errors we get from LaTeX are often quite surprising.
Useful Symbols
The following is a list of symbols which are useful in this course.
 There are a few symbols specifically for this course’s assignments:
\zap
,\tri
,\sqr
, and\rng
. These produce the lightning bolt, triangle, and square from class as well as a ring/donut symbol. \leq
(\(\leq\)) and\geq
(\(\geq\))\forall
(\(\forall\)) and\exists
(\(\exists\))\Rightarrow
(\(\Rightarrow\))
If you’re having trouble finding the right command for a particular symbol, try using DeTeXify, a tool that allows you to draw the symbol and get suggestions for commands to use.
Useful Commands
 The
\emph
command emphasizes text. For instance,\emph{foo}
displays \(\textit{foo}\).  In math mode,
^
creates a superscript. For instance,n^{2}
is displayed as \(n^{2}\).  The command
\texttt
command displays text in “teletype” (fixedwidth) font. For instance,\texttt{thing}
displays \(\texttt{thing}\).
Useful Environments
Environments in LaTeX are opened by the \begin
command and closed by the \end
command. For instance,
\begin{center}
Text
\end{center}
puts the text inside of an environment that centers it on the page. The following environments are of particular note in this course:
mathpar
: The “math paragraph” environment is useful for presenting inference rules. (See below for instructions.) Your inference rules will look best if presented withinmathpar
.math
: Themath
environment works like$
…$
or\(
…\)
in that it processes all of the LaTeX it contains in math mode.
Inference Rules
In the homeworks in this course, the \ir
command creates inference rules. We write \ir[rulename]{premises}{conclusions}
to display a rule. To separate premises from each other, we use the command \\
. To write full proofs, we can nest the \ir
commands.
The \ir
commands must appear in math mode, preferably inside of a mathpar
environment.
For instance,
\ir[Rule 2]{
\ir[Rule 1]{
}{
x
}
\\
\ir[Rule 3]{
}{
y
}
}{
z
}
creates a proof of \(z\) by Rule 2, which relies on proofs of \(x\) and \(y\) given by the axioms Rule 1 and Rule 3.