William Liu

TeX and LaTeX


##Table of Contents

##Summary

TeX (pronounced like ‘tech’) is a typesetting engine designed to handle typesetting text and mathematical formulas. LaTeX works with TeX and helps define the professional layout (think of it as the book designer) and is based on the TeX engine (think of this as the typesetter).

So what does LaTeX solve? LaTeX prevents formatting errors by forcing the author to declare the logical structure of the document, then LaTeX determines the most suitable layout. Behind the scenes, LaTeX ensures that things like font size, numbering of headings and sections, etc. are clear to the reader. This is different than a WYSIWYG system, where the author can generate any type of document with very little or inconsistent structure.

##LaTeX Setup

On a Mac, I have MacTeX installed. On a PC, I have MikTeX installed. The file must be plain ASCII text (default on Unix systems and make sure to specify on Windows). There should be a ‘Package Manager’ that allows you to install specific packages. General File formats include:

On Linux, I use Texmaker

##Basic Rules of LaTeX

####\usepackage

usepackage is a way to add different functionality to your LaTeX document. These are called with \usepackage{somepackage}. Packages can be found on the CTAN Comprehensive TeX Archive Network.

\usepackage{fancyhdr} % allows for header of each page after cover page
\usepackage{ifthen} % allows if then statements; if first page, etc.

####Comment with %

Comments apply by each line and start with %. For longer comments, you can use the \usepackage{comment} and ignore multiple lines.

% This is a regular one line comment %

\usepackage{comment}
\begin{comment}
  This is a multi-line comment using
  the comment package
\end{comment}

####Whitespace

Whitespace (e.g. space, tabs) are all treated as a ‘space’ (e.g. multiple spaces appear as one space)

This is multiple     whitespace.

####Empty lines

Empty Lines means a new paragraph. An empty line between two lines of text means the end of a paragraph. If there is no empty line, the text wraps around.

First Paragraph
Some text goes here  % First Paragraph Some text goes here

Second Paragraph % blank line creates a new paragraph


Third Paragraph % multiple blank lines still just a new paragraph

####Return Line

Return Line using \\

####Special Characters

Special Characters will not print and are any of the following reserved characters # $ % ^ & _ { } ~ \. To get these to print, use:

\# \$ \% \^{} \& \_ \{ \} \~{} \textbackslash

####LaTeX commands

LaTeX Commands are control sequences used to render specific logical structures like a section or math formula. The general format is: \command[optional parameter]{parameter}

####Input File Structure

Input File Structure is the logical structure that every LaTeX document has to follow.

\documentclass{...} % the kind of document you want to write (e.g. article)
\begin{document} % Start the body for the document
% ... Stuff here
\end{document} % End of the body for the document

##Overview of Sections

A document is split into the preamble, the packages, the top matter, the abstract, the sections, and then any special pages.

####Preamble

Setup our document class for the entire paper (i.e. whether its an article, book, slides, etc.)

####Packages

Define what additional packages we want to use (e.g. to set custom colors, create long comments, customize hyperlinks). For example, here’s a few:

####Top Matter

Setting up title, author, date.

####Document

Meat of the report.

####Abstract

Quick abstract/summary of what report covers.

##Common Commands

Here’s a few useful commands:

####Text Size

####Text Style

####Serif and Sans Serif

####Line Breaks

\section*{Line Breaks}
\begin{paragraph} Hello Paragraph  \\
This is how to break up lines \\
You just add these little lines here \\
And then your new line starts! \\
Amazing!
\end{paragraph}

####General Positioning

####Horizontal Positioning

####Vertical Positioning

####Justification

\begin{center} Center Me \end{center} % Center Text
\begin{flushleft} Place me to the left! \end{flushleft} # Justify Left
\begin{flushright} Place me to the right! \end{flushright}  % Justify Right

####Unodered Lists

\begin{itemize}
\item Part is a very large part of, say, a book
\item Chapter is a chapter of a book; not in article style
\item Section is a section of the document
\item Subsection is a section then broken into subsections
\item Subsubsection is pieces of a subsection
\item Paragraph contain some paragraphs
\item Subparagraph have even smaller pieces
\end{itemize}

####Ordered Lists

\begin{enumerate}
  \item This has sequential numbers
  \item Starting with 1
\end{enumerate}

####Nested Lists

\begin{enumerate}
    \item The labels consists of sequential numbers
    \begin{itemize}
        \item The individual entries are indicated with a black dot
        \item The text in the entries may be of any length
    \end{itemize}
\end{enumerate}