##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.
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:
\usepackage
On Linux, I use Texmaker
####\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 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}
\begin{comment}
, \item
)[]
(e.g. \item[Badgers] are fierce
){}
(e.g. \textsl{lean} on me!
){}
and a blank or a special spacing command.\section*{Summary)
where the default numbers a list item, but * removes the numbering)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
A document is split into the preamble, the packages, the top matter, the abstract, the sections, and then any special pages.
\documentclass
) and our global settings. This is required.\usepackage{color}
). This is optional (if you want to use packages).\begin{document}
. This is optional.\begin{abstract}
with \end{abstract}
. This is optional.\part
(-1), \chapter
(0), \section
(1), \subsection
(2), \subsubsection
(3), \paragraph
(4), \subparagraph
(5). This is different depending on document class.####Preamble
Setup our document class for the entire paper (i.e. whether its an article, book, slides, etc.)
\documentclass[]{}
where parameter can be:
article
- for short reports, documentation (recommended)proc
- class for proceedingsminimal
- mainly for debugging (sets only page size and font)report
- for longer reports containing several chaptersbook
- for real booksslides
- for slides using big sans serif letters\begin{document}
and \end{document}
####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:
\usepackage[]{}
where some common packages are:
ifthen
allows if… then do… otherwise do…comment
allows commenting multi-lineslipsum
creates lipsum textmdwlist
(from the mdwtools package) creates more compact lists (controls spacing)hyperref
to customize how hyperlinks look####Top Matter
Setting up title, author, date.
\title[]{}
\author[]{}
\date[]{}
####Document
Meat of the report.
\begin{document}
\end{document}
####Abstract
Quick abstract/summary of what report covers.
\begin{abstract}
\end{abstract}
Here’s a few useful commands:
####Text Size
{}
(e.g. `{:
\tiny
\scriptsize
\footnotesize
small
normalsize
\large
\Large
\LARGE
\huge
\Huge
####Text Style
\textmd
- medium text (i.e. not quite bold, \textmd{Sample Text}
)\textbf
- bold text (e.g. \textbf{Sample Text}
)\textit
- italicized text (e.g. \textit{Sample Text}
)\underline
- underline text (e.g. \underline{Sample Text}
)\textsc
- small caps (e.g. \textsc{Sample Text}
)textrm
- serif (roman) using \textrm{Sample Text}
textsf
- sans serif using {textsf{Sample Text}
####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}
\centerline{}
- centers the object\noindent
- LaTeX treats all new text as a paragraph and indents by default; this specifies do not indent\hspace
can add horizontal spacing (e.g. Horizontal \hspace{1cm} spaces
)\hfill
- creates even spacing (horizontally) between whatever you put in it\vspace
can add veritcal spacing (e.g. Vertical \vspace{1mm} space
)\vfill
- creates even spacing (vertically) between whatever you put in it\smallskip
\smallskip
, \medskip
\bigskip
- make a small or big line skip####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}