From Dave's wiki
Jump to navigation Jump to search

LaTeX, created by L. B. Lamport, is one of a number of "dialects" of TeX, which are based on the version of TeX created by D. E. Knuth known as Plain TeX. It is well suited to the production of long articles and books, since it has facilities for the automatic numbering of chapters, sections, theorems, equations and cross-referencing.

See here ->

Typical input file

\documentclass[a4paper, 12pt]{article}

\documentclass ends with the names of one of the available styles (a.k.a. document style), which in this case is "article". Other available styles are report, book and letter. Between the \documentclass and document style, are options. Options are enclosed in [] and separated by commas. Available options include

11pt Specifies a size of type known as eleven-point and is 10% larger than the ten-point type
12pt Same as above but is 20% larger than the ten-point type
twocolumn Produces a two-column output
a4paper Ensures that the page is appropriately positioned on A4 sized paper

By default, a document is in ten-point type size and paper size is the American paper size.

The text of the document lies between \begin{document} and \end{document}. LaTeX will automatically indent all paragraphs with the exception of the first paragraph of a new section.

Pages are automatically numbered at the bottom of the page, unless you specify otherwise using the \pagestyle command. This command comes after the \documentclass and before the \begin{document} and the syntax is \pagestyle{option}, where option can be

plain The page number is at the foot of the page and is the default page style for article and report document styles
empty No page number
heading The page number is put at the top

So the input file


produces a document without page numbers with ten-point type sized font positioned on A4 sized paper.


LaTeX treats carriage returns, tab characters, a sequence of blank spaces as blank space.


Hyphens are obtained by -, en-dashes by -- and em-dashes by ---. Normally en-dashes are used to specify a range of numbers. em-dashes are used for punctuating.

Section headings

The commands \section, \subsection and \subsubsection produces section headings and are numbered automatically. The title of the section should be surrounded by curly braces

\section{Some heading}

Automatic numbering can be suppressed using the asterisk

\section*{Some heading}

Control sequences

\textit{word} italics
\emph{word} emphasis
\textbf{word} boldface
\textsl{word} slanted
\textsc{word} small caps
\textbf{\textdl{word}} boldface and slanted

Font size

Ranked from smallest to largest:


Special characters

The special characters { and } are used for grouping. Everything within the braces are treated as a single unit. The special character $ is used to set the boundary of mathematical expressions.

  1. $ % & _ { } need to be escaped. \ ^ and ~ are produced by \char92, \char94 and \char126 respectively.

Greek letters


and epsilon, zeta, eta, theta, iota, kappa, lambda, mu, nu, xi, o, pi, rho, sigma, tau, upsilon, phi, chi, psi and omega. For upper case Greek letters, capitalise the first character; for example



For numbered lists

Item 1
Item 2

Bullet points

Item 1
Item 2


\item[word 2]
Description 2


blah blah blah


Left justified tables


Right justified with vertical and horizontal lines



Head over to and download MacTeX.pkg from the closest mirror Then add this to your $PATH




I used MiKTeX for a while and eventually I just found that it was much easier to find help for TeX Live in Ubuntu. So IMHO, if you're using a Windows machine, install VirtualBox and Ubuntu and use TeX Live instead of MiKTeX.


sudo apt-get install texlive-latex-base
sudo apt-get install texlive-latex-recommended


latex test
dvips test

Installing packages

First search to see if the package is available as a Ubuntu package:

#use apt-file to search for packages
sudo apt-get install apt-file
sudo apt-file update
apt-file -x search '/textcomp.sty$'
#texlive-latex-base: /usr/share/texmf-texlive/tex/latex/base/textcomp.sty

Search for amsmath

apt-file -x search '/amsmath.sty$'
#texlive-latex-base: /usr/share/texmf-texlive/tex/latex/amsmath/amsmath.sty

For glossaries.sty

sudo apt-get install texlive-latex-extra

Installing fancytabs.sty

#where to put the sty file?
kpsewhich -var-value=TEXMFHOME
mkdir -p ~/texmf/tex/latex/commonstuff
cp fancytabs/fancytabs.sty ~/texmf/tex/latex/commonstuff
kpsewhich fancytabs.sty

Installing chemfig

cp chemfig/chemfig.sty ~/texmf/tex/latex/commonstuff/
kpsewhich chemfig.sty


BiBTeX style examples:


! LaTeX Error: Cannot determine size of graphic in 

Simply add natwidth and natheight


It seems the dimensions that were actually added don't matter.

More information

Notes taken from

My blog post on using LaTeX with WordPress

How to write a thesis in LaTeX

Inserting a pdf in LaTeX: