Functional LaTeX for Scientists
LaTeX is probably among the most lightweight and extensible document creation tools available. Scientists, mathematicians, and engineers use it in professional work all the time, and in school no one tells you about it!

This site may be beneficial for you if:
  • You are interested in learning about LaTeX.
  • You don't know how to get started with LaTeX.
  • You can read English (more or less).
This site might not be beneficial for you if:
  • You know the basics of LaTeX already.
  • You don't even know/care what LaTeX is.
  • You cannot read English (more or less).
This project started out as a cross platform beginner's guide to LaTeX. Unfortunately, I only know the installers for Mac OS X, so practically it's a more complete guide for Mac OS X folks, but I still think it might be beneficial for Linux and Windows people as well.

If you are running Linux or Windows (or Mac OS X, for that matter), I wrote this doc so that you can learn the real fundamentals of LaTeX. It is my belief that once you know the basics, you can do anything with LaTeX and learn the technical details suitable to your purposes.

So this series of pages will be for the scientist or anyone who wants to learn functional LaTeX. In fact, that's all the LaTeX I know! If you have any suggestions or flat-out corrections, please feel free to write me at shane \*at*/ bu \*dot*/ edu.

There actually do exist some really great documents for LaTeX. There are also several good books on the subject, but I have found many of them to be really useful references and not guides. I see a void in LaTeX documentation that I am hoping to bridge with this website. LaTeX is such a wonderful tool that it shouldn't take a <insert overly esteemed professional here> to get it up and running.

What is LaTeX?
Typesetting. LaTeX is called a typesetting program, which doesn't seem to mean much to many people. So it's basically like taking your good ol' Microsoft Word but not having to deal with any formatting issues, including pagination, graphics, equation writing, and funny formatting.

The idea behind LaTeX is that you focus on the content of the document; LaTeX will handle the formatting, by and large.

If you are beginning in mathematics, chemistry, or really any technical discipline that has some very efficient, though rather unique formatting, chances are that LaTeX is appropriate for your uses.

Relief from formatting hell. In fact if you've ever used superscript, bold, footnotes, or any other formatting of a unique character in Word, you know how frustrating it can be to maintain that formatting amidst all of the other format changes you'd like to make to everything but those special cases.

In LaTeX, you can specify what gets formatted and what doesn't in such a way that it's pretty tough to screw things up.

The big picture. One of the nice things about LaTeX is that it relies on formats that are purely cross platform. The primary file format is a plain text document with the extension .tex. It takes a text file that you write (.tex file) and it processes it, reading your commands and then spitting out a document that looks great.

The beauty in using text files is that anyone can read them, anywhere. In fact, anyone can take a TeX distribution and compile your file in quite the same way as you would on your own machine. This is in contrast to Word documents, which even between two different computers can be a formatting nightmare.

.tex file - This is the standard LaTeX file extension for the plain text file in which you will type your entire document.
Pragmatic approach. But by and large, these .tex files are not "human readable," so we're going to focus here on creating cross-platform output files. For this we'll use the Portable Document Format (.pdf) that everyone in science is surely familiar with.

As far as I'm concerned, it is the standard document format. Formatting is not lost with pdfs, so you know that your client, professor, or audience is reading the document exactly how you wanted it to be read.

.pdf file - pdf stands for "portable document format," invented by Adobe Systems. It is "portable" because the entire document is contained within the file, including all text and pictures. The on-screen layout is identical to the print copy as well, so it is truly WYSIWYG. It is also a truly cross platform file format for documents, and largely the de facto standard in science journals.
Installation
Installation is so tough to talk about comprehensively or cross-platform-ily because there are dozens of different starting points, problems, and possible ways of going about it. In fact, there probably exist several best practice solutions to various installations.

-Chances are good that your Linux distro has some semblance of TeX installed somewhere.
-Install for Windows may or may not be straightforward. A quick search on Google turned up plenty of docs on this.
-For Mac OS X, Gerben Wierda's i-Installer used to be the way to go for a TeX install, but he is no longer maintaining it as of 1 Jan 2007. I will have to fall back on recommending a Fink install, though TUG has a nice doc about how to get a TeX install up and running, also.

Here's a very brief guide to installation of LaTeX via Fink:
  1. Download and install Fink. Note that there is no Universal Binary - PowerPC users have a different installer file than Intel users.
  2. You might want to run the following commands, along with the Fink install (be patient as these may take awhile to run, and they require babysitting):
PROMPT$ sudo fink selfupdate
and
PROMPT$ sudo fink update-all
  1. Once these commands have finished, issue the following command:
PROMPT$ sudo fink install tetex
Note: that does say "tetex" with a "t" and NOT an "l." Don't worry, everything will be okay.
  1. Once that install has finished successfully, you have a working install of LaTeX! Congratulations. Now pdflatex can be issued from the command line successfully.
  2. There is one final step you must take if you want to use a frontend like TeXShop. Within TeXShop, you must change the path that TeXShop looks in for LaTeX.
Once the installer has finished, you've got the base stuff you need to run and compile LaTeX documents! Now you can either use the command line to work its magic, or you can use a frontend GUI such as TeXShop.

Let's get started
Jumping right in, this section assumes that you have a LaTeX distribution successfully installed. Please see Installation section above for some very limited details (some less limited details for Mac OS X).

Fire up your favorite text editor. For Mac OS X, you can use: Linux folks know what they like to use.
Aside from Notepad.exe, Windows folks might want to give a look at: (I do not have any experience with the Windows editors, but I hear these are among the better.)
A couple of things you need to know right now are that the backslash (\) and the percent sign (%) are really significant to LaTeX. The backslash tells LaTeX to follow a specific command. The percent sign tells LaTeX to ignore everything beyond it on that line (called commenting). For those who are already in a state of panic - but what happens when I need to type a backslash or percent sign??! - never fear. There's a command for each!
backslash (\) - a backslash tells LaTeX to read the next word as a command.

percent sign (%) for comments - a percent sign tells LaTeX to ignore everything following it on that line! It's called a comment.
There are two basic parts to every LaTeX document. The first is called the preamble, and we'll call the second part the body of the document. Preamble - specifies options before entering actual body of text.

Body - your actual text will go into the body of the document.
The Preamble
The preamble (also called the header) basically specifies three things:
  1. The kind of document
  2. Some of the unique global features of the document, and
  3. Any custom commands or features you want to add to make your life easier.
For the purposes of this document, we'll start from the simplest case, which is the kind of document. Every document has to have this specification, called a document class. An example of the command in action, therefore, is document class - a document class simply tells LaTeX some basic features of the document you intend to write. It's the first line of every LaTeX document. The command is \documentclass[options]{type}.

     \documentclass[12pt]{article}
    
The first line of your document will almost always look like this! So, you'll notice first that the backslash precedes the documentclass command, as it does for all commands. Remember, a pure backslash tells LaTeX to follow the command specified.
Ok, inside the brackets [ ] are options. Many different commands have options, such as graphics and captions. In this example, the only option we've specified is that the document should use a 12 point typeface. brackets [ ] - brackets denote options for the command. They are usually specified after the command name and before the particular command type (See example.)
Finally, the braces { } include the actual specification of what kind of document we're writing here, and more generally, the stuff contained in the curly braces are telling LaTeX how to use the command. 'article' is probably the most common document class, so that's what we'll use here. Remember, though, that a standard distribution of LaTeX comes with many documentclass specifications built in, and literally dozens more can be found online.

braces { } - braces tell LaTeX how to use the command. Some commands, such as \documentclass, require braces. Other commands, such as \maketitle (see next sections), do not require braces for anything.
The Actual Document
There's good reason why I'm calling this the body of the document, but it's also the document section, and it's denoted by LaTeX commands that begin and end the document.

     \documentclass[12pt]{article}

     \begin{document}

      Now, wasn't that easy?

     \end{document}
    
In this example, we see that the preamble simply consists of the \documentclass command, and the body is denoted by commands that tell LaTeX when the actual document begins and ends.

Everything between the \begin{document} and \end{document} commands are in the actual body of your text! When you compile the document, it will type out the text ("Now, wasn't that easy?").

Save the file in its own directory. For this example, we'll create a directory called latex_doc in our home folder. We'll call the file easypeasy.tex.

I'd recommend making a new directory for each document you want to write in LaTeX. The reasons will become apparent in a moment, but the long-and-the-short of it is that you will keep all of your files associated with a single document in this folder.

Compiling
Ok, ok. If you're like me, you're itching to do this to marvel at the joys of LaTeX. So let's get to it. Once again, I've got to assume that you have a working installation of LaTeX.

For the most general terms, I'll talk about running this stuff via the command line. In Windows, that might be through Cygwin, the Linux-like environment for Windows. In Linux, that's straight from your terminal or terminal emulator, and in Mac OS X, you can use the Terminal.app emulator program.

But as I mentioned before, plenty of excellent GUIs exist, and those might be preferable for some, though I won't cover them in detail here. (Remember that I'm differentiating between text editors and GUIs: everyone using LaTeX has to use a text editor in order to write a .tex file. Sometimes, text editors are found within a GUI that can also be used to compile the LaTeX document to make pdfs.) For Mac OS X, I like to use TeXShop.

At the command line, cd into the directory that your shiny new easypeasy.tex file is in, and (where PROMPT$ is your default prompt) type:

PROMPT$ pdflatex easypeasy.tex

and you'll get a crazy output like (please don't read this unless you really, really want to):

This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(./easypeasy.tex
LaTeX2e <2003/12/01>
Babel <v3.8d> and hyphenation patterns for american,
french, german, ngerman, bahasa, basque, bulgarian,
catalan, croatian, czech, danish, dutch, esperanto,
estonian, finnish, greek, icelandic, irish, italian,
latin, magyar, norsk, polish, portuges, romanian, r
ussian, serbian, slovak, slovene, spanish, swedish,
turkish, ukrainian, nohyphenation, loaded.
(/sw/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard La
TeX document class
(/sw/share/texmf-dist/tex/latex/base/size12.clo))
No file easypeasy.aux.
[1{/sw/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.
map}] (./easypeasy.aux) )</sw/share/texmf-dist/fonts
/type1/bluesky/cm/cmr12.pfb>
Output written on easypeasy.pdf (1 page, 5886 bytes).
Transcript written on easypeasy.log.


Ok, so the last two lines aren't really green, but I highlighted them so you can pay attention to them. All they say is that the easypeasy.pdf file was created, and they made a log file called easypeasy.log. Notice that all of the files will have the exact same root file name as the one you specified for your .tex file. Alright, so open up that easypeasy.pdf file, and marvel at your creation!

P.S. you can do this in Mac OS X with the following command:

PROMPT$ open easypeasy.pdf

Now, if you were to ls in this directory that we have been messing around in, you'll see that there are now at least four files with nearly identical names:
PROMPT$ ls
easypeasy.aux     easypeasy.pdf
easypeasy.log     easypeasy.tex
I only show you this right now to illustrate the point that it's a good idea to work inside a directory for each document file you intend to create. The added benefit becomes even more apparent when working with images, unique style files, etc., which all can reside in this directory together.

Real Documents
So clearly your documents are not a single line proclaiming one simple truth about, say, LaTeX, as we've gone through here. Instead they are probably well-organized, incredibly thoughtful, Pulitzer-worthy masterpieces, and as such, they probably require a good deal of formatting. Let's see what happens when we are dealing with larger bodies of text.

I'll give you some time to create a brilliant document. Go ahead.

Alright. One of the nice features of LaTeX is that it treats line breaks between paragraphs quite nicely. When you're between the \begin{document} and \end{document} tags, you can just type like mad:
 
     \documentclass[12pt]{article}

     \begin{document}

      Here is a larger body of text. We have seen how easy
      LaTeX can be to use. It is actually not a matter of d
      ifficulty to learn, but I've found it hard to find a 
      good online reference to step me through each individ
      ual part without dealing with a lot of jargon and tec 
      hnical things to overcome. 

      % New paragraph
      LaTeX can even overcome your mistakes. So if you were
      to put        several spaces in a sentence by   accid
      ent, LaTeX would know that      this doesn't     make
      any     sense. It will come out looking just fine. Ad
      ditionally, if you really meant to put a bazillion sp
      aces between the words, you can do so by telling LaTe
      X to take everything within a section "verbatim." I'l
      l talk about "verbatim" in a later section (I hope.)

      % Another new paragraph, and hi, mom!
      By the way, reading the nonsense I have written here 
      has actually paid off for both of my readers: I have 
      stealthily introduced the comment operator percent. R
      emember, LaTeX will ignore everything on the same lin
      e after the percent sign. Not tired of the easter egg
      tips yet? Here's another one! As I am sure you have n
      oticed, I wrote out percent in the previous few lines
      . If I had actually put the percent sign there, then 
      LaTeX would have commented out everything following t
      hat on this line! So, the command for percent is ...
      \%! Notice that the backslash command indicator prece
      des the percent sign. Now LaTeX knows that you're not
      trying to comment but rather trying to type in percen
      t. Easy peasy.

      % New paragraph #3
      So one comment about these wonderful paragraphs. In o
      rder to take advantage of them, I have to skip an ent
      ire line, as I'm sure you've noticed. So just going t
      o the next line will NOT make a new paragraph in LaTe
      X.
      I'll teach you how to take advantage of this in one o
      f the future lessons. 

     \end{document}
    
Now, save your document, complete with paragraphs as we did before, and re-run the pdflatex command on this file. To some degree, you should get something that looks more or less like this. Notice that:
  1. Commented lines don't show up in the final output. (Recall that all text on a line past the % symbol indicated a comment.)
  2. Each whole empty line told LaTeX to create a new paragraph, which it has done.
  3. The entire page is justified, and all of the paragraphs are indented.
    The funky spaces are completely ignored.
  4. \% was rendered as simply %. (This is how to tell LaTeX to differentiate between the two.)
It's worth mentioning that it might not be a good idea to insult your boss, prof, funding organization, etc. in the comments, even if you know that the output will not show them. If you ever do have to give the source .tex file to them, they might not appreciate it!
The astute observers among you also noticed that the page margins are all crazy. This not a bug! The point of this is all about aesthetics, which biology people will be quick to point out follows a very pragmatic dogma (form follows function). Notice any (good) publisher's book, and you'll see that the page is often compacted with "uneven" margins on all sides.

But, chances are good that you or your professor wants something a bit more standard, so of course this is all highly customizable. It's actually a tad more complicated than I wish to get into here, but luckily there is a way to do standard one inch margins easily, and that's by using a package.

Packages - adding functionality to your document
In order to show you this, we have to talk about packages. As stated before, packages are pretty specific ways of adding features to a document. For instance, there are several packages for handling graphics, spacing, captions, comments, and, well, one inch margins. Packages are called in the preamble, before the document ever begins.

The command for using packages is, simply, \usepackage{packagename}, where you place the package name within the { }.
Packages - Allows LaTeX to look for elements particular to your document. It is necessary for handling graphics, some spacing issues, invoking verbatim commands, url insertion, captions, blocks of comments, and much more. The command is \usepackage{packagename}, where packagename is, well, the package name.
For our one inch page margins, we'll use a package called fullpage:

      
      \documentclass[12pt]{article}
 
      \usepackage{fullpage}
   
      \begin{document}
 
       Here is a larger body of text. We have seen how easy
       LaTeX can be to use. It is actually not a matter of d
       ifficulty to learn, but I've found it hard to find a 
       good online reference to step me through each individ
       ual part without dealing with a lot of jargon and tec 
       hnical things to overcome. 
 
       % New paragraph
       LaTeX can even overcome your mistakes. So if you were
       to put        several spaces in a sentence by   accid
       ent, LaTeX would know that      this doesn't     make
       any     sense. It will come out looking just fine. Ad
       ditionally, if you really meant to put a bazillion sp
       aces between the words, you can do so by telling LaTe
       X to take everything within a section "verbatim." I'l
       l talk about "verbatim" in a later section (I hope.)
 
       % Another new paragraph, and hi, mom!
       By the way, reading the nonsense I have written here 
       has actually paid off for both of my readers: I have 
       stealthily introduced the comment operator percent. R
       emember, LaTeX will ignore everything on the same lin
       e after the percent sign. Not tired of the easter egg
       tips yet? Here's another one! As I am sure you have n
       oticed, I wrote out percent in the previous few lines
       . If I had actually put the percent sign there, then 
       LaTeX would have commented out everything following t
       hat on this line! So, the command for percent is ...
       \%! Notice that the backslash command indicator prece
       des the percent sign. Now LaTeX knows that you're not
       trying to comment but rather trying to type in percen
       t. Easy peasy.
 
       % New paragraph #3
       So one comment about these wonderful paragraphs. In o
       rder to take advantage of them, I have to skip an ent
       ire line, as I'm sure you've noticed. So just going t
       o the next line will NOT make a new paragraph in LaTe
       X.
       I'll teach you how to take advantage of this in one o
       f the future lessons. 
 
      \end{document}
     
fullpage - For 1" page margins, specify the fullpage package in the preamble, as shown below. Fullpage is nice because you don't have to re-specify it in the body of the document, as you do with most other packages.
Compile the document as previously, by saving the file and then running the pdflatex command on it.

Your output should be similar to the output here. The margins are now much more standardized (the bottom of the output is cut off). The paragraphs are rendered in exactly the same way as before, justified, and now they conform to the new margins.
One more example with packages ...
In the case with the fullpage package, you just write it in the preamble and all is right with the world (and your margins). However, most packages are invoked at the top but must be called from the body of the document (between the \begin{document} and \end{document} commands).
Possibly the easiest example of this is using the setspace command, which allows you do to all the fun things like control your line spacing.

Another (smaller) aside ...
\begin{soapbox}

If you have read this far and weren't already convinced that LaTeX would be useful to you or - dare I say - better than Microsoft Word, then perhaps this can help the case. Consider your last wonderful writing project, in which you had all the text doublespaced in the main body except for those inset long quotes that have to be singlespaced.

Now, in a rush you realized that your pages are flowing over by about an entire page, and in a rushed effort to truncate the length of your doc, you select all -> 1.5 space. Now you have the wonderful task of trudging back through and finding all of your inset quotes and making sure they're nice and single spaced so that your reviewers won't have a fit and triage your paper into hopeless oblivion, causing you to go mad and try to steal lab equipment that didn't belong to you in the first place (sorry, personal moment here).

Now instead of going through all that mess, LaTeX has a nice system in which the command is invoked and you can selectively change the components that need changing. Thus you can keep the nice formatting of your inset quote and just change the parts that you wanted to change.

\end{soapbox}

And moving right along ...
So there are two parts to the setspace command. The first is to invoke the package in the preamble. The second is to call the package from the body to actually do something interesting:
setspace - setspace allows you to invoke line spacing properties freely throughout your document. LaTeX is funny sometimes - in this case, when you call a global function like, \doublespacing you simply will change everything in your doc from that point forward.

      \documentclass[12pt]{article}
      
      \usepackage{fullpage,setspace}

      \begin{document}
    
       \doublespacing % Everything down is double spaced ...

       Here is a larger body of text. We have seen how easy
       LaTeX can be to use. It is actually not a matter of d
       ifficulty to learn, but I've found it hard to find a
       good online reference to step me through each individ
       ual part without dealing with a lot of jargon and tec
       hnical things to overcome.

       % New paragraph
       LaTeX can even overcome your mistakes. So if you were
       to put        several spaces in a sentence by   accid
       ent, LaTeX would know that      this doesn't     make
       any     sense. It will come out looking just fine. Ad
       ditionally, if you really meant to put a bazillion sp
       aces between the words, you can do so by telling LaTe
       X to take everything within a section "verbatim." I'l
       l talk about "verbatim" in a later section (I hope.)

       % Another new paragraph, and hi, mom!
       By the way, reading the nonsense I have written here
       has actually paid off for both of my readers: I have
       stealthily introduced the comment operator percent. R
       emember, LaTeX will ignore everything on the same lin
       e after the percent sign. Not tired of the easter egg
       tips yet? Here's another one! As I am sure you have n
       oticed, I wrote out percent in the previous few lines
       . If I had actually put the percent sign there, then
       LaTeX would have commented out everything following t
       hat on this line! So, the command for percent is ...
       \%! Notice that the backslash command indicator prece
       des the percent sign. Now LaTeX knows that you're not
       trying to comment but rather trying to type in percen
       t. Easy peasy.
  
       \singlespacing % until another command squashes it!

       % New paragraph #3
       So one comment about these wonderful paragraphs. In o
       rder to take advantage of them, I have to skip an ent
       ire line, as I'm sure you've noticed. So just going t
       o the next line will NOT make a new paragraph in LaTe
       X.
       I'll teach you how to take advantage of this in one o
       f the future lessons.

    
And, as you can see, we have called setspace in our \usepackage{} command, and we have used \doublespacing for double spacing and \singlespacing in order to single space.
Now you know how to use packages, so any functionality you want to learn later, just Google it, and you'll be able to implement it successfully.

One final note about packages
There is a distinction between standard LaTeX distributions and add-ons. Though a lot is included in a standard LaTeX distribution, there is always the possibility of invoking packages that are non-standard. Packages will add functionality to your document, and I recommend that you include them in the directory that your document is written in. (You can always put them in a subdirectory and use a relative path reference to it from your source file.)

Basically, because the emphasis is often on the cross-platform compatibility, there are times when you don't want to be adding a ton of extra style files, if someone is going to have to take a look at your source. In fact, some journals request specifically that you make your LaTeX source files as compatible as possible.

So let me just reiterate: packages can be grouped into two very broad categories:
  1. Ones that you simply call in the \usepackage{ } command that affect the document globally without another reference in the body (such as fullpage or
  2. Ones that you must call in the \usepackage{ } command that must be referred to later on in the document, when you need it, by commands that are specialized for that package. These are the more common types, and we have illustrated one here by using setspace.

Standard LaTeX distribution - a standard distribution contains standard document classes such as article, book, and report; and packages such as fullpage, graphicx, and url. This means that your document can be compiled on any system that has a relatively current LaTeX distribution.
Bold and italics (yes, a special section)
Alright, so you're probably thinking, geez, LaTeX is so overly complicated. You need a whole section for bold and italics?

Yes. So it sounds kind of cumbersome to have to write a command everytime something needs to be bold. But hopefully this tutorial can help you to consider the benefits.

In order to make some text bold, you will issue the \textbf{ } command (for "bold face") to LaTeX. This command tells LaTeX to only make the contents within the { } bold. Similarly, italics is invoked by the command \emph{ }, for emphasis.

Let's see this in action:
  
     \documentclass[12pt]{article}

     \begin{document}

      Now, \textbf{wasn't that easy?} \\

      And \emph{this is italics!}

     \end{document} 
    
So the output looks like this. Notice:
  1. The \textbf and the \emph commands are preceded with a \ in order to tell LaTeX that the next word is a command.
  2. The text between the braces is the only text affected by your command.
I snuck in a new command for you: the double backslash \\ is called a linebreak, and when placed at the end of the line, it tells LaTeX to skip the next line.

These commands are actually picked to illustrate a larger theme in LaTeX text decorations. Anything you want to do to a small amount of text has a similar command, such as underlining or small caps.

Linebreak - A double backslash \\ placed at the end of a line will force a skipped line before continuing.
Mathematics
By now you know the basic document structure, as well as how to use packages. Now onto the cool stuff. The mathematics capabilities are really what set LaTeX apart from programs such as Microsoft Word, which are still making use of Equation Editor to try and typeset equations. Not only is it a lousy solution, but it is difficult to use and basically inserts what amounts to an image within your Word document, which makes wrapping text around it the formatting nightmare we are so eager to avoid.

Probably if you have taken any mathematics or science courses in your life, some of the textbooks you used were typeset with LaTeX. LaTeX does some neat things that you've undoubtedly noticed in your leisure journal/textbook reading: it automatically numbers important equations. This means that, after you've written up your thesis with nice, numbered equations, and your advisor wants an equation to come before all of them, LaTeX will automatically renumber them and change all of your references for you. (This is also the great thing about reference management in LaTeX + BiBTeX.)

What I hope to show you here is how to call the mathematics environment when you need to typeset mathematics, either inline or in equations.

So what needs to be defined inside a mathematics environment? It's not only your standard equations, but it also includes any superscript or subscript, as well as all those pesky Greek letters you learned while taking physics. Do we really need to use ζ, seriously?

I should mention that, for a lot of the mathematics, you don't even need to call a package. However for some of the weirder mathematical language, like proving 1 + 1 = 2, you would want to call a package such as amsmath or amssymb, both of which are probably included in a standard LaTeX distribution.

Mathematics environment - Mathematics in LaTeX must be set off so that LaTeX understands that it is supposed typeset beautiful equations.
This can be done inline with the body of text, such that you read it like it is part of a sentence. It can also be done as an equation, which is set apart from the main body of text and automatically kept track of.
Inline mathematics
In order to render mathematics in the body of a paragraph, or perhaps just without a number, use $ $ as delimiters:

     \documentclass[12pt]{article} 

     \usepackage{fullpage}

     \begin{document}
      The greek letter $\zeta$ is a big pain to write 
      by hand, but it's easy (and prettier) in LaTeX!
     \end{document}

    
As you can see in the output of this example here, the Greek letter ζ has been rendered appropriately, with two properties of note:
  1. It has the $ $ delimiters that tell LaTeX that its contents are math-y.
  2. The LaTeX "command" for the Greek character ζ is \zeta
If either of these two elements are missing, the compile won't work. It's also worth noting that equations set off by the $ $ will not be automatically numbered. So here is another example of how the math mode works, using everyone's favorite - Euler's equation:

     \documentclass[12pt]{article} 

     \usepackage{fullpage}

     \begin{document}
      The greek letter $\zeta$ is a big pain to write 
      by hand, but it's easy (and prettier) in LaTeX!
     
      Here is Euler's beautiful and elegant and wonderful equation:
     
       
      \begin{equation}
       e^{i\pi} + 1 = 0
      \end{equation}
      

     \end{document}

    
Ok, so we just did a lot of stuff, so let's first look at the output. Here we can see that, in order to start equation mode, we've simply used the commands \begin{equation} and \end{equation}.

Notice some of the following features of this document:
  1. We didn't have to use the $ $ delimiters! This type of equation automatically gets its own number. You can also label it so that it can be referred to easily throughout your document.
  2. In order to do the superscript, simply use ^{ }, where the superscript is contained within the { }.
  3. The Greek lowercase letter π is rendered \pi. If it were a Π, then it would have been \Pi.
  4. Notice that there's no space between the i and the \pi. This is to ensure that when it renders, it looks like iπ.
  5. In the document's output, you'll also notice that the the number e is italicized.
    Some people will scoff or whatever, I think. (I've never been directly scoffed at for it, but word on the street). In order to get around this faux pas, there is a command for making text sit up straight in equation-modes: \mathrm{ }.
Mathematics conclusion
Here I've tried to equip you with some of the starting elements of mathematical modes in LaTeX. All of the complex math is better learned by checking out examples and then the corresponding code that generated it. It gets pretty hairy at times, but work with the simple stuff first and then move into the crazy "equations of everything." Some of the references listed here are great starting places for learning all you can about math modes!

Final notes
Hopefully this has been a useful introduction to LaTeX. I didn't to bog you down with details about various commands and throw a bunch of formatting tricks at you. In fact, I didn't even want you to pick up a lot of the basics such as graphics because I think that all of that stuff is easy to learn once you know the basic stuff.

Instead, I am hoping that you learned the basic structure of documents, as well as how to use basic features of LaTeX, so anything you may want to do in the future will be a pretty straightforward matter.

Play around with new commands that you may come across in your document. But getting started really is the most difficult part of LaTeX. Hopefully the resources outlined here are a great extension of this primer.

I'd like to thank Amy and Steve for reading through this doc.
This page is copyright ©2006 Shane Lee. Please utilize this page freely, but always \cite{} your sources.