LaTeX for Beginners
by Tom Schneider
The goal of this page is to provide a
very simple start for people to begin using
LaTeX
the powerful typesetting language.
If you find something on this page
confusing, please
email me.
Setting Up
Setting up LaTeX isn't too hard.
You can learn about it from
LaTeX Bibliography and other resources.
Here are several methods I've used:
-
Set it up using
the TEX Collection DVD from the
TeX User's Group
(TUG)
for a Mac.
-
A really easy way to get going:
install a RedHat Linux.
My Linux 7.1 had LaTeX already set up.
-
These days I'm using
Ubuntu Linux. It's not pre-installed but just
type 'latex' and it will lead you to installation!
To test my LaTeX installation
I typed in (or cut and paste) this small file:
\documentclass[12pt]{article}
\begin{document}
\large
a buncha
stuff
\begin{equation}
\sqrt{\pi}
\end{equation}
\end{document}
I called it test.tex. Then I did this:
latex test
xdvi test
The first line ran LaTeX and the second one poped up a viewer.
It worked fine.
On Ubuntu I also did:
latex test
dvips test
gv test.ps
ps2pdf test.ps
I found I needed to install gv - that took only a few seconds.
So I was able to get LaTeX running on Ubuntu in about 5 minutes,
mostly waiting for the download.
The last step made a PDF for me and double clicking on it
in the graphical window
opened it in evince.
Notes:
- A fully worked example is in
latex.test. You can see the result
in the test.png file, shown to the right.
It's not very fancy, but you can go to
The TeX showcase
if you want fancy!
- In general one may need to call LaTeX several times
to get cross references right.
- Actually, I put the two commands above into a file and used
it as a script, in preparation for automating the whole process using
atchange.
This makes LaTeX into a WYSIWYG
(what you see is what you want!).
- A more complex starting file and other paraphernalia is
in this directory.
It contains, among other things:
Some simple rules for typesetting in LaTeX:
- Get used to your text editor first. I like
vi and vim, other people like emacs.
The advantage of learning vim is that all unix operating
systems have it. It's also quite ergonomic.
Avoid using the arrow keys since they will not be available on all keyboards.
- In LaTeX,
paragraphs are separated by blank lines.
If you are using
the
vim
editor, you can hop between paragraphs with
"}" (move forward one paragraph)
and
"{" (move back one paragraph.
You can also move paragraphs around. If you are above one paragraph,
just d}p to switch it with the next paragraph!
- As in standard typing,
sentences are separated by two spaces.
If you are using
the
vi
editor, you can hop between sentences with
")" (move forward one sentence)
and
"(" (move back one sentence.
You can also move sentences around. If you are at the start of one sentence,
just d)p to switch it with the next sentence!
- \emph{Italics} gives italics
- \textbf{Bold face} gives bold face
- lines that begin with a percent (%) are
comment lines. They do not show up in the final text.
- \cite{Shannon1948}
automatically (!)
pulls in the citation for
Shannon's famous 1948 paper (assuming
you already have it in a database).
Further details are beyond the scope of this page,
but
you can use atchange to automate the generation
of the BiBTeX database.
- \command{argument} is the form of a command
with its argument.
- Mathematics inside a line is surrounded by the
$ symbol:
$\sqrt{\pi}$
gives the square root of pi.
Also
\begin{equation}
and
\end{equation}
surround larger equations, and these
automatically (!)
get numbered throughout the paper .
- Books
- TeXbook by Donald Ervin Knuth.
The original definition of TeX, upon which LaTeX was built.
(This is the raw language components.)
- LaTeX : A Documentation Preparation System User's
Guide and Reference Manual>
by Leslie Lamport, Duane Bibby.
The original definition of LaTeX, a macro system under TeX.
(This is the easier to use language, but the book is hard to read.)
- Guide to LATEX: Document Preparation for Beginners and
Advanced Users by Helmut Kopka, Patrick W. Daly.
VERY useful book.
- The Latex Companion
by Michel Goossens, et al.
This is a good book about packages to do everything imaginable in typesetting.
Advanced stuff
- LaTeX Bibliography and other resources
- We use two definitions:
- \newcommand{\todo}{\rule{0.5em}{1ex}}
Having made this definition one just says: \todo.
This just puts a black rectangle into the text. It is impossible
to miss these. They makr places where we still need to do something.
- \newcommand{\todobf}[1]{{\rule{0.5em}{1ex}\textbf{ #1}}}
Having made this definition one says: \todobf{some stuff}.
This will put the little black rectangle and "some stuff" in bold face.
It's useful for writing down what we need to do at this point.
- tools that make LaTex into a wysiwyg
- Changing the Font.
To change to the Times New Roman Font
using LaTeX2e, before your \begin{document}
put
\usepackage{pslatex}.
More on fonts.
- Making Figures.
To make figures
using LaTeX2e, before your \begin{document}
put
\usepackage{graphics}
\usepackage{wrapfig}
\usepackage{floatfig}
Then call the graphics directly like this:
\includegraphics*{fig/logowalker.ps}
or inside a figure:
\begin{figure}
\begin{center}
\scalebox
{0.9} % h_length
{
\includegraphics*{fig/logowalker.ps}
}
\end{center}
\caption{
The caption
}
\label{fig.logowalker}
\end{figure}
The wrapfig and floatfig packages are very cool - they let
you wrap figures around text. Between paragaphs:
\begin{floatingfigure}{7 cm}
\scalebox{0.6}{
\includegraphics*[140,270][450,640]{fig/t7-wt-ex.ps}
}
\caption{Sequence logos for T7 promoters.
Top: wild type promoters \cite{Schneider1986};
bottom: strong T7 promoters found by an
\emph{in vivo} genetic screen \cite{Schneider1989}.
}
\noindent \hrulefill
\label{fig.t7-wt-ex}
\end{floatingfigure}
Wrap figure looks like this:
\begin{wrapfigure}{r}{12cm}
\begin{center}
\rotatebox{-90}{
\scalebox
{0.57} % h_length
{
% Note: the "*" makes the graphic be clipped - this is needed!!
% Guide to Latex p. 168
\includegraphics*[50,110][540,695]{fig/baseflipcover.ps}
}
}
\end{center}
\caption{
Anomalous base in RepA binding sites.
Sequence logos for
12 repressors and activators were created.
The logos were
then aligned so that the proteins would all be on
the same face of the DNA.
Since proteins make most of their contacts
in major grooves, there are two highly conserved
regions that correspond to two major grooves of
DNA, shown on top.
In addition, the sequence logo for
bacteriophage P1 RepA protein binding sites
was overlayed on top of the other sequence logos.
An unusually conserved thymine (red T) in the middle of
the RepA sites,
dubbed ``Tom's T'' by Dhruba Chattoraj,
is visible which corresponds to the minor groove facing
towards RepA.
Such a large amount of sequence conservation
in the minor groove
($> 1$ bit) is not possible with B-form DNA,
so the base must be distorted.
This figure
was
the cover of \emph{Nucleic Acids Research}
Volume 29, Number 23,
December 1, 2001
\cite{Schneider.baseflip.2001}.
}
\label{fig.baseflipcover}
\end{wrapfigure}
}
More information may be found in:
Guide to LATEX: Document Preparation for Beginners and
Advanced Users by Helmut Kopka, Patrick W. Daly.
Essential!!
Schneider Lab
origin: 2000 February 16
updated: 2014 Nov 10