![]() |
Intro to Scientific ComputingPHYS 27/193Physics Department University of the Pacific |
While you have probably learned how to use Microsoft's Office Suite, including MS Word and Powerpoint, these tools are not very well suited to presentations which involve a significant mathematical exposition. Not only is it difficult to create equations, they look lame in MS Word.
That's why professional mathemeticians, physicists, chemists, computer
scientists, and others use Latex (pronounced "LAY' tek,
You can have a look at some other examples of Latex in action by visiting the "Preprint Archive" at Cornell University. Started by particle physicists in the late 1980s, this repository is where we send copies of our papers at the same time we send them off to the publisher. That way the paper, and more importantly its results, are available to everyone with internet access.
The archive is here: http://www.arxiv.org/
For some examples of Latex output, scroll down to my field: High
Energy Physics - Lattice which is where papers on large scale
simulations of particle theory go. (
As long as you are still visiting the archive, have a look around. The
new papers in "String Theory" usually appear on High Energy:
Theory while new experimental results show up in High
Energy: Phenomenology. There's an Astrophysics
branch that includes both new theoy and experimental results, as well
as a whole separate branch for Mathematics. Or, check out
Artificial Intelligence in the Computer Science
branch. If you are a scientist, start getting used to reading!
Won't it be cool to hand in your next lab report looking polished and
professional like one of these research papers?
One of the reasons that I have decided to switch to using Cygwin
is that latex comes completely installed if you choose it as
a package. That saves a lot of hassle installing it as a standalone
package.
You can verify that latex was correctly installed in your cygwin
installation by
This should display something like this:
If you see an error message, email me and we'll sort it out.
So, you first need a basic latex document.
I want to show you a unix "trick" (it's actually
just a standard unix command).
In the xterm window
That's because when the emacs application starts, it takes control
of the xterm's prompt--the xterm will wait until the emacs application
exits before responding to input.
Now, start emacs this way:
by adding an ampersand "&" after the command. This tells the xterm
to "start emacs in the background", detaching it from the current
xterm operation. Notice that emacs starts, but you now have your xterm
prompt back and can issue commands.
At your xterm prompt (the one that is now active because we
detached emacs with the "&" above), type:
This will create a file called
There are some cygwin PDF viewers that one could use to look at
this file, however I didn't have you install these (in the future I
may add one of these to the list. A good one is xpdf in the X11
category if you are interested). However, most everyone has Adobe's
free PDF viewer. If you DON'T have it, get it here:
here.
Now use the Shortcut to your home/ directory that should be on
your desktop (did you make one when I told you to?).
Double click on tiny.pdf and the viewer should open it up
so that you can see your new document.
Latex commands begin with a backslash: \, followed by
a keyword.
\documentclass
followed by arguments. We will usually use the article class, the
document begins
\documentclass{article}
Following this, we might add some further things to set up the
document (including packages, making definitions, for instance). These
are "setup" things, not part of the document text itself.
\begin{document}
Simple enough, right?
Finally, at the end we put
\end{document}
Let's make a file that is a bit more interesting.
You'll need the text below. You can also just download this file first.tex and save it in your latex/ directory,
Hint: Professionalism and Neatness can increase your grades!
LaTeX
Again, latex is pronounced: LAY' tek, (not lay . tecs like
the material). You can read why by googling latex. It was invented by
Donald Knuth in the 1980s.
|>latex -v
TeX (Web2C 7.4.5) 3.14159
kpathsea version 3.4.5
Copyright (C) 1997-2003 D.E. Knuth.
Kpathsea is copyright (C) 1997-2003 Free Software Foundation, Inc.
There is NO warranty. Redistribution of this software is
covered by the terms of both the TeX copyright and
the GNU General Public License.
For more information about these matters, see the files
named COPYING and the TeX source.
Primary author of TeX: D.E. Knuth.
Kpathsea written by Karl Berry and others.
Getting Started
Latex is a kind of programming language. What you actually do is write
a little program (using your text editor) which gets compiled
into a graphical format, usually PDF. The program that you are writing
is mostly composed of the text of your document, but in addition
contains key words to tell latex to make certain symbols, and
take certain lexigraphical actions (superscripting, or bolding, or
create a new section in your paper).
\documentclass{article}
\begin{document}
This is my first latex document.
Oh yeah,
\em{Physics is the Mother of all Sciences}
\end{document}
Navigate to your latex/ subdirectory and see if your
tiny.tex and tiny.pdf files are there.
It's tiny, but it's latex document.
Basic Latex Document Structure
Notice what you did above.
Let's look at the program part: The Latex Document.
Any other word in a latex document is considered text to be typeset.
A latex document must start with the keyword
but there are book and other classes.
\documentclass{article}
From here, everything either gets printed or actions
are taken on latex \keywords (like \em{} below).
\documentclass{article}
\begin{document}
\documentclass{article}
\begin{document}
This is my first latex document.
Oh yeah,
\em{Physics is the Mother of all Sciences}
A bit more interesting
If all went well above, try the file below.
First, a useful thing to remember is that most of us who know latex,
learned it by copying things out of other
files we were shown (or found).
So, you can do the same with these examples I'm giving you.
or copy and paste it into a file (called first.tex) using emacs.
% first.tex
% My first real Latex document
\documentclass[12pt]{article}
\begin{document}
\title{My First LaTeX Document}
\author{
Jane R. Feynman \\
Department of Physics\\
University of the Pacific \\
3601 Pacific Ave., Stockton, CA 95211
}
\maketitle
\begin{abstract}
In the abstract section you would put a brief (one paragraph)
description of your project or experiment, and the main results.
\end{abstract}
\section{Introduction}
% LaTeX comments begin with a percent sign, and are not printed.
In the Introduction you would put your introductory remarks. You will
introduce the project and give the reader some context for your study.
\subsection{Subsection: Math}
Including mathematics is easy.
$$
\int_{-a}^{\infty} f(x) dx= F(a)
$$
or you can do it like this for a numbered equation:
\begin{equation}
\oint_C \frac{dz}{z-z_0}=2\pi i
\end{equation}
\begin{equation}
\sum_{i=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}
\end{equation}
A numbered equation can be referred to or cited by giving it a label.
\begin{equation}\label{eq:pot}
V(r)={\hbar^2 \ell(\ell+1)\over 2mr^2}-{\hbar c \alpha\over r}
\end{equation}
Somewhere in your text you may wish to refer to this equation. You don't
need to know what Eq. number it is, just its label. Refer to it with
the command Eq.~(\ref{eq:pot}) and LaTeX automatically uses the correct
equation number, even if you go back and add more equations later. You
will need to run latex twice, once to compute the equation numbers.
\section{Tables}
Suppose that you want to create a table showing your data. The syntax
for a multicolumn table is found below.
\vspace{1cm}
\begin{tabular}{|c|c|c|c|}
\hline
Run 1 & Output & Run 2 & Output \\
\hline
1 & 37 & 1 & 28 \\
\hline
2 & 42 & 2 & 35 \\
\hline
3 & 73 & 3 & 19 \\
\hline
4 & 15 & 4 & 22 \\
\hline
\end{tabular}
\section{Conclusions}
In this section draw your conclusions and summarize your findings.
Certainly from this short and simple document, we can see that LaTeX
is tremendously powerful, easy, and FUN! There are many online
tutorials and help pages on LaTeX. Simply enter {\tt latex tutorial}
or {\tt introduction to latex} into Google and you will find lots of
help.
\end{document}
In this report, I will prove that Physics is the Mother of all Sciences.