# LATEX and BIBTEX by Example

A postscript version of this manual is available.

# Preface

This manual provides some introductory information about how to use LATEX and BIBTEX. It is assumed that the user of this manual has access to a LATEX compiler'' and knows how to create files with a text editor.

The manual has three main parts: An introduction, a discussion of major themes, and some supplementary concepts. The introduction provides an overview of LATEX, gives a list of other resources, and ends with a classical Hello World'' document.

Part III discusses a number of environments and concepts that I use on a regular basis. I unapologetically have omitted many details in favor of providing the big picture''.

The supplements discussed in part III gives hints on spell-checking LATEX documents and explains how LATEX is useful in handling large documents. It also discusses how to generate bibliographies using BIBTEX and a method for putting LATEX documents on the web.

Please feel free to contact me if you have errors to report or other questions. For additional resources you can refer to section 2 entitled Other Resources. For a short list of web pages and books.

# What and Why

LATEX is typesetting software that provides high quality output. It is especially well-suited for those who write technical articles and/or those who need to use mathematical notation in writing. As discussed in section 8, LATEX is also well suited for creating and handling large documents.

All LATEXdocuments are simple text files that contain commands and text. The commands tell LATEX how to render your writing. These facts have several consequences:

• LATEX is not WYSIWYG2
• LATEX documents must first be compiled''3 before they look pretty''
• LATEX is available on a variety of operating systems

A natural question at this point in the discussion would be Why would someone, in this modern era, use a non-WYSIWYG type-setting system? Especially one that requires you compile (and debug) your document before you can see what it is going to look like?'' If you happen to be one of my students the question is answer simply: Because I said you have to use it.'' For anyone else reading this document, let me outline some strengths of LATEX:

• LATEX is excellent for rendering mathematical notation and technical articles.
• You can define your own commands making a change of notation nearly instant (even if you have a large document).
• Numbering of sections, tables, figures (and references to such items) are updated automatically.
• LATEX provides excellent support for creating tables of contents and for creating bibliographies.
• If you are a programming nerd then you probably have already realized that you can generate LATEX documents from the control of a computer program.
• LATEX provides excellent support for handling large documents.
• There are programs available that will generate HTML documents from your LATEX source (with hyperlinks and so on).

# Other Resources

Anyone who is serious about wanting to use LATEX on a regular basis will find this document woefully inadequate. There are numerous books and websites that contain information beyond the scope of this short introduction.

## Books

There is no shortage of books on the topic and certainly you might want to consider browsing around an on-line store like amazon.com to see a variety of books. However, if you are going to have only one book on LATEX I would recommend without reservation the official User's Guide written by Lamport:
Lamport, Leslie, LATEX: A Document Preparation System, 2nd edition, Addison-Wesley, 1994.

After you have been using LATEX for several years and find yourself wanting to accomplish tasks that are not covered by the User's Guide, you may want to consider getting:

Goossens, Mittelbach, Samarin, The LATEX Companion, Addison-Wesley, 1994.

For true LATEX nerds, you may find that you would like to learn how to use the underlying TEX commands upon which LATEX is based. Although this book is not for the faint of heart, it is the canonical text on the subject (written by the creater of TEX):

Knuth, D., The TEXbook, Addison-Wesley, 1986.

## Web Sites

For every book on the topic of LATEX there are probably two or three web sites that have tutorials or references. As with the book list above I will exercise restraint and show only a few for you to consider.

There is a site a NASA that contains a fairly complete reference of LATEX commands. I might emphasis the word reference because the site does not contain a tutorial component.

The University of Cambridge Department of Engineering maintains a site that provides some useful information that is more complete and provides some nice examples. I would recommend looking at the site when this document has ceased to be helpful.

There is an interesting site maintained by Scott Peckham that contains a rather expansive list of tutorials, manuals and user's guides for a variety of topics. The LATEX portion of the site is at:

# Hello World

In the programming world it has become a sacred tradition that the first program you write when learning a new language is a simple program the prints the words Hello World!'' to the screen. In keeping with that time-honored tradition, we will write a simple LATEX document that will produce the same output. Without further ado, here it is:

Hello World'' Source

This is what the Hello World document would look like. The output of the document would be simply a page with the words Hello World'' and with a page number centered in the bottom margin.

The source for this example is available at helloworld.tex.
% helloworld.tex
% This is the Hello World program.
\documentclass{article}
\begin{document}
Hello World            % the actual text to be output
\end{document}

There are several noteworthy observations to be made from this simple example.
• The backslashes are used to denote a command. The commands themselves do not necessarily produce output, but they are commands that may change how other text is output.
• Every latex document begins with \documentclass{article} except that the style article'' can be any one of several other options.4
• The actual stuff you want to appear is sandwiched in between the \begin{document} and \end{document} commands. Sometimes there are various commands that apply to the entire document that are sandwiched between the documentclass command and the \begin{document} command. Incidently, you can create your own commands. There is a small example of that in section 9, but other than that you'll have to go elsewhere to find out more information on commands.
• Everything that follows a % on a given line is not included in the output. These we call comments and they are used to annotate or explain the text, but are ignored when the document is being compiled. Smart-alecks and programmers often want to know how one can cause the percent sign to be printed instead of it marking the beginning of a comment. The answer is this: \%

There remains one rather important topic related to this Hello World'' document: How does one go from saving that text in a file to producing the nicely formatted output?

Compiling Hello World''

The details of compiling are necessarily installation-specific. These instructions apply to those who who are using a RedHat-based Linux distribution.

LATEX assumes that your source file has a name that ends with .tex. For this example, lets assume that we've saved those commands in a file named helloworld.tex. Further, let us assume that the operating system prompt is this: prompt. To compile, view, and print the document you would enter the following commands5:

prompt> latex helloworld
This is TeX, Version 3.14159 (Web2C 7.2)
(helloworld.tex
LaTeX2e <1998/06/01>
Babel <v3.6j> and hyphenation patterns for american,
french, german, italian, nohyphenation, loaded.
(/usr/share/texmf/tex/latex/base/article.cls
Document Class: article 1998/05/05 v1.3y Standard LaTeX
document class (/usr/share/texmf/tex/latex/base/size10.clo))
No file helloworld.aux.
[1] (helloworld.aux) )
Output written on helloworld.dvi (1 page, 232 bytes).
Transcript written on helloworld.log.
prompt> xdvi helloworld
prompt> lpr helloworld.dvi


Notice that typing latex helloworld6 generated quite a bit of output to the screen. If there had been errors in the document, those would have been flagged with several option of how to proceed listed. In case you are wondering, yes, that is all I intend to say about dealing with errors.

In addition to producing quite a bit of output to the screen, this first command also caused several files to be created. The file of interest to us right now is one called helloworld.dvi. This is a device independent file'' that contains the nicely formatted output. The command xdvi helloworld runs a program that allows you to view the contents of helloworld.dvi. Once you have (presumably) finished viewing the file and are pleased with the output you can print the document with the final command listed: lpr helloworld.dvi. Notice that you print the .dvi file and not the .tex file.

# Basic Typesetting Stuff

Typesetting has some major differences from word processing. One difference is that with typesetting you are expected to understand some rather subtle but important conventions of typewritten text. Many of those details are either handled for you by a typical word processor, or they are ignored (to the detriment of the output) by the word processor. Some of these subtle conventions are mentioned in section 4.1. Of course, we all like to have different fonts and sizes of text, some of the common styles are given in section 4.2.

therefore more responsiblity) over how the most difficult concept is le

## Picky Details

You may have never noticed that in most books, the opening quotation marks () and the closing quotation marks ('') are different. What that means to you is that when you open and close quotation marks you have to use different keys (see example below).

Also, a hyphen that separates words, a hyphen that separates numbers, and a hyphen appearing in mid-sentence are all of different sizes. Again, you will have to make sure these are entered differently.

Not everything in LATEX requires extra attention. For example, LATEX automatically handles inter-word spacing and line breaks. Words following a period are given extra space, for example. This brings up an important topic. If you want to add extra spaces between words, you cannot simply put extra spaces in your source file.7 As far as LATEX is concerned one space is the same as a hundred spaces. Incidently, to start a new paragraph, you will have to have one (or more) blank line(s) in your source document.

The example below illustrates these and other concepts:

The source for this example is available at subtleties.tex.

Typesetting Subtleties

Consider the following source file:
% subtleties.tex
\documentclass{article}
\begin{document}
I would like to say: Hello World''.  But,
before              I do, let me give a
once-in-a-lifetime pause and instruct you
to look in section~2 on pages 12--45 of your text book---
you will be very glad you did.

Back to the topic in question: H.\ H.\ Henry once
said, \LaTeX\ is my \#1 hero.'\,''
\end{document}


The output of this file would be as follows:
I would like to say: Hello World''. But, before I do, let me give a once-in-a-lifetime pause and instruct you to look in section 2 on pages 12-45 of your text book-- you will be very glad you did.

Back to the topic in question: H. H. Henry once said, LATEX is my #1 hero.'''

The tilde (~) is used to produce a non-breaking space. The backslashes after the initials keeps LATEX from putting extra spacing there. This example also shows how to generate the LATEX logo with the \LaTeX command8 The \, is used to produce a small amount of space so that the quotation marks are interpreted correctly. Also notice that LATEX decided where the line breaks should go.

## Typestyles

To accomplish emphasizing of text or change text sizes you can use these commands:
 Command Product Example {\bf text} bold-faced text text {\em text} emphasized9 text: text {\it text} italicized text text {\tt text} typewriter text text {\sc text} small caps text TEXT {\small text} smaller text text {\large text} larger text text

Of course, there are other sizes, styles, and fonts, but this is enough to give you the idea.

# Math and Such

I have been saying that LATEX is particularly good at rendering mathematical notation. In this section I will discuss math mode'' and provide an extensive example. The example will not be accompanied by the extensive commentary that came with the earlier examples. To figure out how you render your own mathematical notation you will need to analyze the example carefully and then use one of the references suggested in section 2.

Before you can start enter mathematical equations it is necessary for you to inform LATEX that you intend to do so. That is, you want to instruct LATEX to enter math mode''. There are two main ways to enter math mode:

In-Line Math Mode:
This mode is useful if you want to place a small formula or statement within some running text. You mark the beginning and ending of the math mode using a single dollar sign ($). Offset Math Mode: Entering this mode will cause the formulas you enter to be set apart from the rest of the text and centered. To mark the beginning and end of this mode use $ and $, respectively. Math Example Enough talk of modes. Here they are up-close and personal. As I said earlier, there won't be any commentary to go along with this example, so you will need to study it carefully to see what is going on. The source for this example is available at mathdemo.tex. % mathdemo.tex \documentclass{article} \begin{document} Putting a formula like$\log_2 2 = 1$inside text is as easy as$(5-3)$-$\frac{8}{4}$-3. Of course you can do more omplicated things like this excerpt from my dissertation: $\mbox{offset} = \overbrace{\left\lfloor \frac{\mbox{row \#}}{2} \right\rfloor}^{\mbox{which pair}} \bmod \overbrace{\left(\frac{k}{r}\right)}^{\mbox{pairs/round}}$ \noindent Given the offset, the communication dimension is calculated as follows: $\mbox{commDim} = (p + r \cdot \mbox{offset}) \bmod k$ \end{document}  The output produced by the code would be as follows: Putting a formula like inside text is as easy as --3. Of course you can do more omplicated things like this excerpt from my dissertation: Given the offset, the communication dimension is calculated as follows: # Environments and More One of the major frustrations to new users of LATEX is that the program seems to have a mind of its own when it comes to formatting your text. Unfortunately, the new user also has a mind of his/her own and the two parties don't always see eye-to-eye. Let me offer a bit of advice. LATEX was designed by professionals who have a pretty good idea as to how material should be presented. You will do yourself a favor to not buck the system'' and simply try to find out how you can best present your material within the provided framework. This will result in getting your documents out the door much more quickly and, over time, you will find that your documents share a common look and feel that will almost certainly make combining pieces of documents a very natural step. Furthermore, unless you have some training in the presentation of documents, your personal preferences would likely communicate the contents of your document less effectively. LATEX provides a number of enviornments'' that are designed for presenting different kinds of materials. You should make extensive use of these niceties and avoid blazing your own trails, at least until you have spent some time working within the system. ## Sections and Labels Often documents are divided into parts, sections, and subsections, that are numbered. LATEX provides some commands that you can use to mark the beginning of various sections and subsections. I would urge you to make liberal use of these commands for several reasons: • LATEX will handle the numbering (and renumbering) of these sections automatically • LATEX will handle making uniform headers for the various levels of sections (and subsections and subsubsections) • If you decide to make a table of contents you will be able to create it by adding a single line to your source file For an example document that uses sectioning commands, look at the syllabus example given section 10. -Forms Many of the commands in LATEX have what are called star-forms (-forms). A -form is an alternate version of a command that behaves only slightly different than the original. For example, the command \section{My Section} will do the following: • Create a large, bold-faced, header with the text My Section • Automatically number the section for you • Add a small amount of vertical space after the header The -form of the command, \section*{My Section}, will do the same as the original except that it will not number the section. After all, not everyone likes to have their document parts labeled with numbers! Labels Since sections can be numbered automatically, that generates some concern with regards to how you can refer to a section by number from some other place in the document. The solution is that instead of using an explicit number to reference a section, you use a special internal name that will be translated to a number when LATEX compiles you document. Although the section numbers may change many times as you work on drafts of the document, the internal name you assign to a section will be constant. There are two steps to get this to work: 1. When you define a section header, label it (i.e., give it a name) using the \label command. For example:  \section{My Introduction} \label{intro}  Incidently, the label does not have to appear immediately after the section title, though it would make sense to do so. 2. Anytime to want to refer to the section by number you can use the \ref command like this: ... and you may recall from my introduction in section~\ref{intro} that ...  It should be noted that labels can be used for sections, subsections, etc., as well as inside of enumerate environments and so on. One final word is that when using labels you may need to compiling your two times in order to get the correct labels. Because. ## Lists Some material is nicely represented using list formats. There are three main listing environments that are quite similar in usage, but are appropriate in slightly different contexts. itemize is used to be created bulleted (unnumbered) lists. enumerate is used to create numbered lists. description is used when each item in the list begins with a highlighted word or phrase (like this list). It should be noted that lists can be nested to several levels. It is possible to override the default numberings for enumerate environment to create a customized outline ...but guess what? That's right, we don't cover that here! List Examples Notice that the second list is numbered and has a nested list within it. Here is the source file. The source for this example is available at listdemo.tex. % listdemo.tex \documentclass{article} \begin{document} \begin{itemize} \item This little piggy went to market. \item This little piggy stayed home. \item This little piggy had roast beef. \item This little piggy had none. \item This little piggy went wee wee wee wee all the way home. \end{itemize} \begin{enumerate} \item This little piggy went to market. And he bought the following items: \begin{enumerate} \item Bob the Tomato \item Larry the Cucumber \item Junior Asparagus \end{enumerate} \item This little piggy stayed home. \item This little piggy had roast beef. \item This little piggy had none. \item This little piggy went wee wee wee wee all the way home. \end{enumerate} \begin{description} \item [opportunistic:] This little piggy went to market. \item [lazy:] This little piggy stayed home. \item [fat:] This little piggy had roast beef. \item [hungry:] This little piggy had none. \item [scared:] This little piggy went wee wee wee wee all the way home. \end{description} \end{document}  And the output produced goes something like this: • This little piggy went to market. • This little piggy stayed home. • This little piggy had roast beef. • This little piggy had none. • This little piggy went wee wee wee wee all the way home. 1. This little piggy went to market. And he bought the following items: 1. Bob the tomato 2. Larry the cucumber 3. Junior asparagus 2. This little piggy stayed home. 3. This little piggy had roast beef. 4. This little piggy had none. 5. This little piggy went wee wee wee wee all the way home. opportunistic: This little piggy went to market. lazy: This little piggy stayed home. fat: This little piggy had roast beef. hungry: This little piggy had none. scared: This little piggy went wee wee wee wee all the way home. ## Tables and Arrays A surprising variety of material is nicely rendered using tables. If you have not worked with HTML or some similar markup language you will likely have a tendency to underuse tables. If you need anything to be lined up in columns you will likely want to use the tabular or array environment.10 There are two main environments for creating tables'' in LATEX: tabular and array. The two environments are basically identical except that array is used in math mode and tabular is used in regular'' mode. To decide which one should be used, simply answer this question: Does the table contain mostly mathematical entries or mostly non-mathematical entries.'' Most of the discussion below applies to both environments, but I have lazily refered to only the tabular environment. Although LATEX makes putting borders around tables rather simple, I would urge you not to get too carried away. Many tables look attractive with no lines.11 tabular vs. table vs. tabbing These three environments have such similar names they can be a bit confusing to newcomers. Here is a brief summary of the three environments. tabular is used for presenting material in rows and columns (i.e., what most of us would call a table) table is a floating environment (see section 6.4 for more detail) that is used to house material that should not be split and that can be moved around. That is, the contents of the table environment may be a table (i.e., tabular) or it may be something entirely different. tabbing is used to line up several rows of information by setting tab marks (like a typewriter, if you're old enough to have used one). I find this environment to be of limited usefulness, though I have used it. Tables (and by that I mean entities created with the tabular environment) are defined by specifying the number and type of columns to be in the table. Then the table is filled in row by row with an ampersand (&) separating each column entry and a double backslash (\\) marking the end of the row. Vertical bars (|) in the column definition are used to create vertical lines, and the command \hline after a row entry is used to create horizontal lines. The types of columns are specified by a single letter and are as follows: l text in column is left justified c text in column is centered r text in column is right justified p text in column is a paragraph'' which can span several lines. When using this type of column you must specify the width of the column. For example, p{1.5in}, would create a paragraph-style column that is one and a half inches wide. Except for the paragraph'' columns, LATEX automatically adjusts the width of columns to accommodate the largest entry. Here are some examples: tabular and array Examples You may notice that there is quite a bit of mathematical notation in the first table. There also happens to be a good bit of text as well. It was kind of a toss up as to whether to make this tabular or array--I chose tabular. The source for this example is available at tabulardemo.tex. % tabulardemo.tex \documentclass{article} \newlength{\circwidth} \settowidth{\circwidth}{$\bigcirc$} \newcommand{\numcirc}[1]{ \makebox{\ensuremath{\bigcirc}} \hspace{-1.4\circwidth} \raisebox{-1pt}{#1} } \begin{document} \begin{tabular}{|llp{2.5in}|} \hline Topology & Size & Definition \\ \hline Ring &$n$nodes &$\{C^1(1,n) \mbox{ and its inverse} \}$\\ Complete Graph&$n$nodes &$\{C^i(1,n) \mid 1 \leq i \leq n-1 \}$\\ Hypercube &$k$-dimensional &$\{(2i-1\; 2i) \mid 1\leq i \leq k \}$\\ Star Graph &$n!$nodes &$\{(1\; i) \mid 2\leq i \leq n \}$\\ Torus &$d_1 \times d_2 \times \cdots \times d_k$&$\bigcup_{j=1}^{k} C^1(1+\sum_{i=1}^{j-1}
d_i,\sum_{i=1}^{j} d_i)$and their inverses \\ \hline \end{tabular} $j= \left\{ \begin{array}{ll} i+1\: (\bmod\ n) & \mbox{ when } p=q \in \mathcal{H} \\ i-1\: (\bmod\ n) & \mbox{ when } p=q \in \mathcal{H} \end{array} \right.$ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Table Generated By \RESEARCH\PHD\FULL-TEX.C on Jul 28 1996 % \centering\begin{tabular}{|c||cc|cc|} \hline \multicolumn{1}{|c||}{Row} & \multicolumn{4}{|c|}{Rotations} \\ \cline{2-5} \multicolumn{1}{|c||}{Labels} & 1 & 2 & 2 & 1 \\ \hline \hline$+$&$+$& \numcirc{2} & \numcirc{2} &$+$\\ \hline$-$&$-$& \numcirc{2} & \numcirc{2} &$-\$ \\ \hline
\end{tabular}

\end{document}


The last example illustrates a couple of things. First the \numcirc command is not a standard LATEX command. I had to define it myself using the \newcommand command. Secondly, the source for this table was (as suggested by the comment) actually generated by a computer program.12 Here is the output:

 Topology Size Definition Ring nodes Complete Graph nodes Hypercube -dimensional Star Graph nodes Torus and their inverses

 Row Rotations Labels 1 2 2 1 2 2 2 2

## Pictures and Floats

It is often confusing to figure out how different software handles the incorporation of graphical images. In LATEX there are several choices, but I will share with you only the method that I have come to know and love. It requires that you use the standard graphics package (which simply involves putting \usepackage{graphics} after the documentclass command and before the \begin{document} command).

Although various LATEX installations support a variety of graphical formats I would urge you, if at all possible, to render all of your diagrams in encapsulated postscript format. There are several advantages in doing so:

• encapsulated postscript is portable across platforms
• encapsulated postscript is saved as a text file (as is LATEX so it is easily saved and transfered)
• encapsulated postscript documents contain image size information in the header which means you don't have to find and tediously specify the size of every image you choose to include

Since you will obviously follow my suggestions, I will only demonstrate how to include an incapsulated postscript document.

Most figures and many tables are not designed to be split across pages. This can create ugly looking documents because it can cause there to large gaps in the text. LATEX provides two similar environments that help to alleviate this problem: table13 and figure. These two environments are collectively called floats'' because their contents may be moved around so as to make them fit with the text more nicely.

The main difference between the two environments is there default captioning. It should be noted that although I have included the picture below inside the figure environment, there is no rule that says the two must be used together. That is, I can have a floating picture that may be placed on a page different that where it appears in the LATEX (i.e., a floating figure) or I can have a figure that stays put.

Picture and Float Example

The source for this example is available at floatfig.tex. The source for the encapsulated postscript file is also available at 2^4cay.eps.
% floatfig.tex
\documentclass{article}
\usepackage{graphics}

\begin{document}
\begin{figure}[!ht]
\centering\includegraphics{2^4cay.eps}
\caption{A 4-Dimensional Hypercube Labelled as a
Cayley Graph}
\label{fig:2^4cay}
\end{figure}
\end{document}


On thing to notice about the output below is that LATEX automatically labeled the graphic as figure 1. If we had used the table environment it would have been listed as table 1.

One final note about using the floating environments. If you use these you will find there are other longer term advantages:

• the placement of your diagrams and tables will be such that there won't (if possible) be large open gaps
• the tables and figures will be numbered automatically (and can therefore be referenced using labels and references ...see section 6.1
• you can automatically generate a list of tables and a list of figures (using \listoftables and \listoffigures, respectively)

## Miscellaneous

This section simply mentions some environments and details that didn't seem to belong anywhere else. To center text there is an environment called center. Like the other enviroments, you use it you simply to the following:
\begin{center}
Stuff to be centered \\
goes here.
\end{center}


Notice the use of the double backslash (\\) to produce an end of line prematurely. That brings us to a related topic. How can one add additional spacing to a document when LATEX is so stubborn about handling the spacing itself? There are several commands that allow you to override LATEX's default actions:

\\ As just mentioned, this causes the current line to end immediately.
\vspace{size} This is used to introduce vertical spaces in your document. The size parameter will be something like 1.2in to specify how much space you want.
\hspace{size} You guessed it--this is used to introduce horizontal spaces in your document.
\pagebreak Causes the page to end prematurely.

So as not to be misleading: There are other methods of getting things put exactly where you want them, but there are some fairly simple and useful methods that should keep you happy for a little while.

If you are using a long quotation, there is a quotation enviornment that takes care of the margins for you. Simply put the long quotation between a begin-end pair and you've got it. For you math-types there are theorem-like environments that you will want to look into as well.

Footnotes

Not surprisingly, adding footnotes is quite easy in LATEX. It works like this:
  ... and what I am saying is always true\footnote{except for
the exceptions, obviously} and should never be doubted ...


LATEX will choose a unique symbol for your footnote and will place the footnote at the bottom of the page appropriately.

# Spell Checking

In theory you can use any stand-alone spell checker to spell-check your LATEX source documents for spelling errors. One annoying result of using a non-LATEX-aware spell-checker is that many of the commands will be flagged as spelling errors. There are two ways to deal with this problem:
1. ignore it (and spend extra time doing so)
2. add command names to your dictionary

There exists spell-checkers that know how to parse LATEX documents. On systems using Red Hat Linux, there is a program called ispell that does a decent job with LATEX documents. Simply type ispell myfile.tex and then follow the instructions.

# Handling Large Documents

Allow me to show you a template for what a large document can look like in LATEX. For this example, let's assume you are writing a research paper and each section is quite long. Your paper is going to have a title, an abstract, a table of contents, a list of tables, a list of figures, several large sections, and a list of references. Your document might look like this:
% big.tex

\documentclass{article}
\begin{document}

\title{Super-Big Research Topic  \\ My Life's Journey}
\author{Me\thanks{I would like to thank my dog for
his unfailing support in this endeavor}}
\maketitle

\begin{abstract}
What I demonstrate in this paper is \ldots
\end{abstract}

\tableofcontents
\listoftables
\listoffigures

\input{intro.tex}
\input{bigthought.tex}
\input{biggerthought.tex}
\input{trulyamazing.tex}
\input{conclusion.tex}

\bibliographystyle{plain}
\bibliography{allmyreferences}
\end{document}


Notice that your super-big research paper fits on one page! Well, of course, that's not true. The \input commands tell LATEX to paste the contents of the specified file at that point in the document. This allows you to split your document into several source files. Also, if you have a slow computer, you can have it include only one section at a time so that compiling will be faster as you write. Furthermore, many of use who have written long documents know the frustration of have one gigantic source file that is so large you can't find anything!

Some other things to note:

• a special way to create a title
• an abstract environment
• simple, one-word commands that automatically generate your table of contents, list of figures, and list of tables
• two simple commands to create your references page for you ...actually this takes a good bit of explaining, so I have relegated that topic to section 9

The source for this example is available at big.tex.

# Using BIBTEX

Let me begin this section, like I have done several others, by explaining to you why you want to go to the trouble to learn how to use BIBTEX.
• BIBTEX handles all of the formatting of the bibliography entries for you
• BIBTEX can be instructed to order the entries in your bibliography in any number of ways
• if you have a set of bibliography entries that you reference from a variety of papers, you only have to type the entries once and BIBTEX will see that any of the items you reference will be placed in the references page automatically
• a corollary to the previous item (that you only have to type the entries once) is that if you make a mistake on an entry then you only have to correct in one place and the correction will take effect everywhere (upon recompilation)

For starters you will create a file with a .bib extension that will contain your bibliography entries.14 The entries must be written in a very specific format as you will see. Here is a sample file named demo.bib:

% demo.bib
@ARTICLE(booth,
AUTHOR  = "Kellogg S. Booth",
TITLE   = "Lexicographically Least Circular Strings",
JOURNAL = "Information Processing Letters",
YEAR    = "1980",
VOLUME  = "10",
PAGES   = "240--242")

@BOOK(polya,
AUTHOR  = "George Polya",
TITLE   = "Notes on Introductory Combinatorics",
YEAR    = "1983",
PUBLISHER = "Birkhauser")

@INPROCEEDINGS(culler:etal,
AUTHOR    = "D. E. Culler and R. M. Karp and D. A.  Patterson
and A. Sahay and K. E. Schauser and E. Santos and
R. Subramonian and T. von~Eicken",
TITLE     = "{LogP}: Towards a Realistic Model of Parallel
Computation",
BOOKTITLE = "Proceedings of the 4th {ACM} {SIGPLAN} Symposium
on the Principles and Practice of Parallel
Programming",
PAGES     = "1--12",
YEAR      = "1993")

@TECHREPORT(nash:etal,
AUTHOR    = "J. M. Nash and P. M. Dew and M. E. Dyer and
J. R.  Davy",
TITLE     = "Parallel Algorithm Design on the {WPRAM}
Model",
INSTITUTION= "School of Computer Science, University of
Leeds",
NUMBER     = "94.24",
YEAR    = "1994")

@INCOLLECTION(bisseling:mccoll,
AUTHOR    = "R. H. Bisseling and W. F. McColl",
TITLE     = "Scientific Computing on Bulk Synchronous
Parallel Architectures",
BOOKTITLE = "Technology and Foundations: Information
Processing '94",
EDITOR    = "B. Pehrson and I. Simon",
PUBLISHER = "Elsevier Science Publishers",
PAGES     = "509--514",
YEAR      = "1994")


This file demonstrates several (but not all) of the different forms that BIBTEX knows about. For details about the various forms you'll need to view some of the resources I list in section 2. On thing to note is that after specifying what kind of entry (book, article, etc.) you can specify a name (i.e., a label) for the entry in question. As you will see below, anytime you want to refer to that work in your document you can simply issue the \cite command. By default, LATEX will only include in the bibliography, those entries that you explicitly cite.

The file bibdemo.tex shown below, demonstrates how the .bib file can be used for citing works and for automatically generating a bibliography.

% bibdemo.tex

\documentclass{article}
\begin{document}
This paper is about my wonder experiements.  But first,
I must mention the work of others, which is, of course,
far inferior to my own.  Booth\cite{booth} gives a nice
discussion of circular strings.  And Polya\cite{polya}
waxes eloquent about combinatorics.  Furthermore, Culler
and others\cite{culler:etal} have much to say as well.

That is all I will mention at this point.

\bibliographystyle{plain}
\bibliography{demo}
\end{document}


The final two commands specify how the bibliography entries should be ordered and what files should be checked for entries, respectively. Some standard available bibligraphy styles are:

plain
entries are sorted alphabetically and citations are numbered
unsrt
entries are entered in order of their citations (and citations are numbered)
alpha
entries are sorted alphabetically and use authorname and publication year (Ser95) for citations
abbrv
like plain except uses abbreviations

The source for these examples is available at demo.bib and bibdemo.tex.

Compiling BIBTEX Documents

Before you rush out and try to use BIBTEX on your own you should know that compiling these documents requires some extra steps. Suppose we have the file names used in the examples above (demo.bib for bibliography entries and bibdemo.tex for the LATEX source document). You would compile the document as follows15:
prompt> latex bibdemo
prompt> bibtex bibdemo
prompt> latex bibdemo
prompt> latex bibdemo


Your eyes are not deceiving you. To make sure that all labels are references are correct, you may have to run LATEX three times. Not to worry, however, because you only need the references to read correctly in the final version anyway!

Generating the BIBTEX Logo

As best as I can tell, there is not predefined command that generates the BIBTEX logo. One way to handle that is to create a command yourself. I did it like this:
\documentclass{article}
\newcommand{\BibTeX}{{\sc Bib}\TeX}
\begin{document}
...
\end{document}


The command, as you can see, used the small caps typestyle to produce the BIB portion of the logo and then it simply uses the already existing \TeX command to produce the rest. Now to refer to BIBTEX you simply enter \BibTeX in your source document.

# Publishing on the Web

There are several programs available that offer to convert LATEX source to HTML. The package I am familiar with is LATEX2HTML. It should be no surprise to you that this document was written in LATEX and has been made available on my web site by converting to HTML using LATEX2HTML.

LATEX2HTML is available at its official web site:

LATEX2HTML actually provides three major pieces of functionality:

• of course, it converts .tex documents to .html documents
• it attempts to be smart'' in the conversion so that your document won't necessarily be one giant web page (but rather split up with navigation icons directing the user from one piece to another)
• it also provides definitions for a variety of specialized LATEX commands that allow you to create hyperlinks thoughout your document when it is published to the web

Basic usage is very simple. Just type latex2html mydoc and it will create a directory named mydoc that contains the converted files. There are, of course, many ways to customize the behavior of the program through modifying configuration files and though the command-line options. Some of the command-line options I have found helpful are these:

 Option Parameter Description -t title'' gives the web page a title of title'' -up_url url'' specifies where to take the user (url'') when they click the up'' button -up_title title'' what to call the page found at url'' in the -up-url option -info #'' where # is 1 or 0 specifying the the info'' section16 should be included or omitted, respectively -split #'' where # is the level (section, subsection, etc. where splitting of the source should stop

For an extensive example of how to use a variety of the LATEX2HTML features as well as overall LATEX usage, compare the source for the Operating Systems course syllabus with the output generated by LATEX2HTML at my website. The URLs are:

and

It should be noted that the sample output was generated using the default settings. You can compare that with the Operating Systems course syllabus at my web site to see how a similar document can be rendered differently by using some of the command-line options. Incidently, if you want to compile ossyl.tex yourself you will also need to get

and

Good luck. And as always, have fun!

LATEX and BIBTEX by Example

This document was generated using the LaTeX2HTML translator Version 2008 (1.71)

Copyright © 1993, 1994, 1995, 1996, Nikos Drakos, Computer Based Learning Unit, University of Leeds. Copyright © 1997, 1998, 1999, Ross Moore, Mathematics Department, Macquarie University, Sydney.

The command line arguments were: latex2html -nonavigation -address 0 -t 'LaTeX and BIBTeX by Example' -up_url ../../ -up_title 'Terry Sergeant's Homepage' -split 1 -dir ../web/latexhelp latexhelp

The translation was initiated by Terry Sergeant on 2012-12-14