% All comment lines start with %. There are no multi-line comments
% Every LaTeX command starts with a backslash (\)

% Preamble
% Document Class

% Packages
\usepackage{caption}     % Sets figure captions
\usepackage{float}       % Allows figures to float
\usepackage{hyperref}    % Allows hyperlinks

% Document Properties Definitions
\author{Author's name}

% Document

% Title
\newpage          % Creates a new page

% Tables of Content
\tableofcontents % Main table of content
\listoffigures   % List of figures
\listoftables    % List of tables

% Abstract: command is available in the document classes article and report.
 \LaTeX{} documentation written as \LaTeX! How novel and totally not
 my idea!

% Sections
Hello, my name is Colton and together we're going to explore \LaTeX!

\section{Another section}
This is the text for another section. I think it needs a subsection.

\subsection{This is a subsection} % Subsections are also intuitive.
I think we need another one.

Much better now.

\section*{This is an unnumbered section}
However not all sections have to be numbered!

\section{Some Text notes}
\LaTeX{} is generally pretty good about placing text where it should
go. If
a line \\ needs \\ to \\ break \\ you add \textbackslash\textbackslash{}
to the source code.

Separate paragraphs by empty lines.

You need to add a backslash after abbreviations (if not followed by a comma), because otherwise the spacing after the dot is too large:
E.g., i.e., etc.\ are are such abbreviations.

\begin{enumerate} % This creates an "enumerate" environment.
  % \item tells the enumerate to increment
  \item Salad.
  \item 27 watermelon.
  \item A single jackrabbit.
  % we can even override the item number by using []
  \item[how many?] Medium sized squirt guns.

  Not a list item, but still part of the enumerate.
\end{enumerate} % All environments must have an end.


Here's how you state all x that belong to X, $\forall x \in X$.
We can also enter math mode with \[a^2 + b^2 = c^2 \].

% Display math with the equation 'environment'
\begin{equation} % enters math-mode
    c^2 = a^2 + b^2.
    \label{eq:pythagoras} % for referencing
\end{equation} % all \begin statements must have an end statement

Eqn.~\ref{eq:pythagoras} is also known as the Pythagoras Theorem which is also
the subject of Sec.~\ref{subsec:pythagoras}. A lot of things can be labeled:
figures, equations, sections, etc.


% See,_Figures_and_Captions for more details

\begin{figure}[H] % H here denoted the placement option.
    \centering % centers the figure on the page
    % Inserts a figure scaled to 0.8 the width of the page.
    % Commented out for compilation purposes. Please use your imagination.
    \caption{Right triangle with sides $a$, $b$, $c$}


  \caption{Caption for the Table.}
  % The basic is simple: one letter for each column, to control alignment:
  % basic options are: c, l, r and p for centered, left, right and paragraph
  % optionnally, you can add a | for a vertical line
  % See for more details
  \begin{tabular}{c|cc}  % here it means "centered | vertical line, centered centered"
    Number &  Last Name & First Name \\ % Column rows are separated by &
    \hline % a horizontal line
    1 & Biggus & Dickus \\
    2 & Monty & Python

\section{Getting \LaTeX{} to not compile something (i.e.\ Source Code)}

% There are other packages that exist (i.e. minty, lstlisting, etc.)
% but verbatim is the bare-bones basic one.
  print("Hello World!")
  a%b; % look! We can use % signs in verbatim.
  random = 4; #decided by fair random dice roll,


  \item Write the document in plain text (the ``source code'').
  \item Compile source code to produce a pdf.
    The compilation step looks like this (in Linux): \\
      > pdflatex learn-latex.tex


There exists two main types of links: visible URL \\
\url{}, or
\href{}{shadowed by text}
% You can not add extra-spaces or special symbols into shadowing text since it
% will cause mistakes during the compilation

This package also produces list of thumbnails in the output pdf document and
active links in the table of contents.

\section{Writing in ASCII or other encodings}

It is easy to insert accents and basic Latin symbols, with backslash shortcuts
Like \,c, \'e, \`A, \ae and \oe etc.  % for ç, é, À, etc
% See for more

To write directly in UTF-8, when compiling with pdflatex, use
The selected font has to support the glyphs used for your document, you have to add


That's all for now!

% Bibliography
  \bibitem{latexwiki} The amazing \LaTeX{} wikibook: \emph{}
  \bibitem{latextutorial} An actual tutorial: \emph{}

% Ends the document

Document Classes

Usage: \documentclass[opt,opt]{class}.


book    % Default is two-sided.
report  % No \part divisions.
article % No \part or \chapter divisions.
letter  % Letter.
slides  % Large sans-serif font.

Common options

10pt/11pt/12pt       % Font size.
letterpaper/a4paper  % Paper size.
twocolumn            % Use two columns.
twoside              % Set margins for two-sided.
landscape            % Landscape orientation. Must use dvips -t landscape.
draft                % Double-space lines.


\usepackage{fullpage}  % uses 1 inch margins.
\usepackage{anysize}   % sets margins: \marginsize{l}{r}{t}{b}
\usepackage{multicol}  % uses n columns: \begin{multicols}{n}.
\usepackage{lscape}    % allows a page to be rendered in landscape mode
\usepackage{appendix}  % allows appendix section to be included
\usepackage{lettrine}  % supports various dropped capitals styles
\usepackage{hyperref}  % allows hyperlinks
\usepackage{url}       % inserts URL: \url{http://... }.
\usepackage{latexsym}  % uses \LaTeX\ symbol font.

\usepackage{graphicx}  % shows image: \includegraphics[width=x]{file}.
\usepackage{epstopdf}  % convert eps figures to pdf
\usepackage{caption}   % sets figure captions
\usepackage{subcaption}% captions for the subfigures
\usepackage{float}     % allows figures to float

\usepackage{amsmath}   % American Mathematical Society package (allows \eqref)
\usepackage{amssymb}   % American Mathematical Society extra symbols
\usepackage{amsthm}    % offers the theorem setup of the AMS document classes
\usepackage{cancel}    % allows showing canceled terms in equations

\usepackage{tabularx}  % an extension of tabular which has an additional column designator, X, which creates a paragraph-like column whose width automatically expands so that the declared width of the environment is filled
\usepackage{booktabs}  % enhances the quality of tables and provides extra commands
\usepackage{multirow}  % tables with cell occuping more than one row
\usepackage{threeparttable} % tables with footnotes
\usepackage{placeins}  % defines a \FloatBarrier command, beyond which floats may not pass


Usage: \maketitle

\author{text}          % Author of document.
\title{text}           % Title of document.
\date{text}            % Date.

Page Style

\pagestyle{empty}      % Both header and footer are cleared
\pagestyle{plain}      % Header is clear, but the footer contains the page number in the center.
\pagestyle{headings}   % Footer is blank, header displays information according to document class (e.g., section name) and page number top right.
\pagestyle{myheadings} % Page number is top right, and it is possible to control the rest of the header.

Tables of Content

\tableofcontents % Adds a table of content.
\listoffigures   % List of figures
\listoftables    % List of tables

Document Structure

\setcounter{secnumdepth}{x} % suppresses heading numbers of depth > x, where chapter has depth 0.

\section*{title}, % not numbers the section and it does not appear in the table of contents

Text Environments

\begin{comment}   \end{comment}   % Comment (not printed). Requires verbatim package.
\begin{quote}     \end{quote}     % Indented quotation block.
\begin{quotation} \end{quotation} % Like quote with indented paragraphs.
\begin{verse}     \end{verse}     % Quotation block for verse.
\begin{verbatim}  \end{verbatim}  % Verbatim environment.

\verb!text! % Text between the delimiting characters (in this case '!') is verbatim.

Text Properties

Font Face

Command Declaration Effect
\textrm{text} {\rmfamily text} Roman family
\textsf{text} {\sffamily text} Sans serif family
\texttt{text} {\ttfamily text} Typewriter family
\textmd{text} {\mdseries text} Medium series
\textbf{text} {\bfseries text} Bold series
\textup{text} {\upshape text} Upright shape
\textit{text} {\itshape text} Italic shape
\textsl{text} {\slshape text} Slanted shape
\textsc{text} {\scshape text} Small Caps shape
\emph{text} {\em text} Emphasized
\textnormal{text} {\normalfont text} Document font
\underline{text}   Underline

Font size

Usage {\command text }

\tiny         % tiny
\scriptsize   % scriptsize
\footnotesize % footnotesize
\small        % small
\normalsize   % normalsize
\large        % large
\Large        % Large
\LARGE        % LARGE
\huge         % huge
\Huge         % Huge


% Environment
\begin{center}     \end{center}
\begin{flushleft}  \end{flushleft}
\begin{flushright} \end{flushright}

% Declaration

Line Spacing

\linespread{x} % changes the line spacing by the multiplier x.


Symbol Latex
& \&
_ \_
\(\bullet\) \textbullet
$ \$
^ \^{}
| \textbar
\ \textbackslash
% \%
~ \~{}
# \#
S \S


Accent Latex
ò \`o
ó \'o
ô \^o
õ \~o
ō \=o
ȧ \.a
ö \"o
\c o
ă \u a
ǎ \v a
ő \H
ç \c c
\d a
ą \k a
œ \oe
æ \ae
å \aa
Å \A
ø \o
Ø \O
ł \l
Ł \L
¡ ~`
¿ ?`


Delimiter Latex
` | `  
` `` `
{} \{\}
[] []
() ()
< \textless
> \textgreater


Name Latex Example Usage
hyphen - X-ray In words
en-dash -- 1–5 Between numbers
em-dash --- Yes—or no? Punctuation


\begin{enumerate}     % Numbered list.
  \item text          % Adds an item.

\begin{itemize}       % Bulleted list.
  \item text          % Adds an item.

\begin{description}   % Description list.
  \item[x] text       % Uses x instead of normal bullet or number. Required for descriptions

Line and Page Breaks

\\         % Begin new line without new paragraph.
\\*        % Prohibit pagebreak after linebreak.
\kill      % Don't print current line.
\pagebreak % Starts new page.
\newpage   % Starts new page
\noindent  % Do not indent current line.


\today      % Prints todays date
~           % Space, disallow linebreak (W.J.~Clinton).
\@.         % Indicate that the . ends a sentence when following an uppercase letter.
\hspace{l}  % Horizontal space of length l (Ex: l = 20pt).
\vspace{l}  % Vertical space of length l.
\rule{w}{h} % Line of width w and height h.


\label{marker}   % Set a marker for cross-reference, often of the form \label{sec:item}.
\ref{marker}     % Give section/body number of marker.
\pageref{marker} % Give page number of marker.
\footnote{text}  % Print footnote at bottom of page.

Floating bodies

\begin{table}[place]     \end{table}    % Add numbered table.
\begin{figure}[place]    \end{figure}   % Add numbered figure.
\begin{equation}[place]  \end{equation} % Add numbered equation.
\caption{text}                          % Caption for the body.

The place is a list valid placements for the body. t=top, h=here, b=bottom, p=separate page, !=place even if ugly. Captions and label markers should be within the environment.

Tabular Environments

tabbing environment

\= % Set tab stop. 
\> % Go to tab stop.

Tab stops can be set on “invisible” lines with \\kill at the end of the line. Normally \\ is used to separate lines.

tabular environment

\begin{array}[pos]{cols}           \end{array}
\begin{tabular}[pos]{cols}         \end{tabular}
\begin{tabular*}{width}[pos]{cols} \end{tabular*}

Column specification:

l Left-justified column.
c Centered column.
r Right-justified column.
p{width} Same as \parbox[t]{width}.
@{decl} Insert decl instead of inter-column space.
| Inserts a vertical line between columns.


\hline Horizontal line between rows.
\cline{x-y} Horizontal line across columns x through y.
\multicolumn{n}{cols}{text} A cell that spans n columns, with cols column specification.

Math Mode

For inline math, use \(...\) or $...$. For displayed math, use \[...\] or \begin{equation} \end{equation}.

Math Element Latex
\(a^{x}\) a^{x}
\(a_{x}\) a_{x}
\(\frac{x}{y}\) \frac{x}{y}
\(\sum_{k=1}^n\) \sum_{k=1}^n
\(\sqrt[n]{x}\) \sqrt[n]{x}
\(\prod_{k=1}^n\) \prod_{k=1}^n


Math Symbol Latex
\(\leq\) \leq
\(\geq\) \geq
\(\neq\) \neq
\(\approx\) \approx
\(\times\) \times
\(\div\) \div
\(\pm\) \pm
\(\cdot\) \cdot
\(^{\circ}\) ^{\circ}
\(\circ\) \circ
\(\prime\) \prime
\(\cdots\) \cdots
\(\infty\) \infty
\(\neg\) \neg
\(\wedge\) \wedge
\(\vee\) \vee
\(\supset\) \supset
\(\forall\) \forall
\(\in\) \in
\(\rightarrow\) \rightarrow
\(\subset\) \subset
\(\exists\) \exists
\(\notin\) \notin
\(\Rightarrow\) \Rightarrow
\(\cup\) \cup
\(\cap\) \cap
\(\mid\) \mid
\(\Leftrightarrow\) \Leftrightarrow
\(\dot a\) \dot a
\(\hat a\) \hat a
\(\bar a\) \bar a
\(\tilde a\) \tilde a
\(\alpha\) \alpha
\(\beta\) \beta
\(\gamma\) \gamma
\(\delta\) \delta
\(\epsilon\) \epsilon
\(\zeta\) \zeta
\(\eta\) \eta
\(\varepsilon\) \varepsilon
\(\theta\) \theta
\(\iota\) \iota
\(\kappa\) \kappa
\(\vartheta\) \vartheta
\(\lambda\) \lambda
\(\mu\) \mu
\(\nu\) \nu
\(\xi\) \xi
\(\pi\) \pi
\(\rho\) \rho
\(\sigma\) \sigma
\(\tau\) \tau
\(\upsilon\) \upsilon
\(\phi\) \phi
\(\chi\) \chi
\(\psi\) \psi
\(\omega\) \omega
\(\Gamma\) \Gamma
\(\Delta\) \Delta
\(\Theta\) \Theta
\(\Lambda\) \Lambda
\(\Xi\) \Xi
\(\Pi\) \Pi
\(\Sigma\) \Sigma
\(\Upsilon\) \Upsilon
\(\Phi\) \Phi
\(\Psi\) \Psi
\(\Omega\) \Omega

Bibliography and Citations

When using BibTex, you need to run latex, bibtex, and latex twice more to resolve dependencies.

BibTex Citation Types

\cite{key}       % Full author list and year. (Watson and Crick 1953)
\citeA{key}      % Full author list. (Watson and Crick)
\citeN{key}      % Full author list and year. Watson and Crick (1953)
\shortcite{key}  % Abbreviated author list and year.
\shortciteA{key} % Abbreviated author list. 
\shortciteN{key} % Abbreviated author list and year.
\citeyear{key}   % Cite year only. (1953)

All the above have an NP variant without parentheses. Ex: \citeNP.

BibTex Entry Types

@article      % Journal or magazine article.
@book         % Book with publisher.
@booklet      % Book without publisher.
@conference   % Article in conference proceedings.
@inbook       % A part of a book and/or range of pages.
@incollection % A part of book with its own title.
@misc         % If nothing else fits.
@phdthesis    % PhD. thesis.
@proceedings  % Proceedings of a conference.
@techreport   % Tech report, usually numbered in series.
@unpublished  % Unpublished.


address      % Address of publisher. Not necessary for major publishers.
author       % Names of authors, of format ....
booktitle    % Title of book when part of it is cited.
chapter      % Chapter or section number.
edition      % Edition of a book.
editor       % Names of editors.
institution  % Sponsoring institution of tech. report.
journal      % Journal name.
key          % Used for cross ref. when no author.
month        % Month published. Use 3-letter abbreviation.
note         % Any additional information.
number       % Number of journal or magazine.
organization % Organization that sponsors a conference.
pages        % Page range (2,6,9--12).
publisher    % Publisher’s name.
school       % Name of school (for thesis).
series       % Name of series of books.
title        % Title of work.
type         % Type of tech. report, ex. “Research Note”.
volume       % Volume of a journal or book.
year         % Year of publication.

Not all fields need to be filled. See example below.

Common BibTex Style Files

abbrv    % Standard           
alpha    % Standard 
abstract % alpha with abstract
plain    % Standard           
unsrt    % Unsorted
apa      % APA

The LaTeX document should have the following two lines just before \end{document}, where bibfile.bib is the name of the file:



The  database goes in a file called file.bib, which is processed with bibtex file.

@String{N = {Na\-ture}}
  author  = {James Watson and Francis Crick},
  title   = {A structure for Deoxyribose Nucleic Acid},
  journal = N,
  volume  = {171},
  pages   = {737},
  year    = 1953


See Also

Back to top ↑