Quick Introduction to Latex

Emily Carlin

April 5, 2006

1 Absolute Basics

To create a new file create your file as documentName.tex

To preview your file:

latex documentName
dvips -o documentName.ps documentName.dvi

Open Ghostview or another ps viewer open your .ps file.

To print:

latex documentName
dvips document.dvi | lpr or lpr documentName.ps if you

already have a .ps version.

Alternatively, you can use Scott’s latex.sh command, which gives you single-letter prompts for converting to PostScript or PDF, printing and the like.

latex.sh documentName

2 Special Latex Considerations

Latex treats all white space as one “space” therefore using whitespace to space out your work does not work. To deliniate a paragraph in L^{A}TEX simply leave a line of space between the paragraph and the previous one (e.g. pressing “return” twice).

Special characters: # $ % ˆ & { } \ To use these character put a backslash in front of them for example: \$. This does not work for the backslash itself as \\ is a linebreak. It also does not work for the ˆ , for this symbol you must type \^{}.

Comments: The % sign makes comments. Anything on a line after an % is ignored in the final document.

Enviroments: In the document enviroments take the form:

\begin{enviromentName}
...
\end{enviromentName}

3 Bare Bones Latex Document

Here is the minimum Latex document.

\documentclass{article}
\begin{document}
Insert your text here.
\end{document}

There are many options for the documentClass and there are special packages that can be added into the header of your document, but they will not be discussed here. One option that is useful if the font size option. L^{A}TEX prints 10pt fonts by default. To change this when you define your documentClass do the following

\documentClass[12pt]{article}.

4 Spacing

To align your document use the commands: “flushleft,” “flushright,” and “center.” For example:

\begin{flushleft}
I want this text to be aligned left.
\end{flushleft}

If you have a section of text with complicated spacing, such as a computer program use the verbatim enviroment. Do this by entering

\begin{verbatim} your code \end{verbatim}. Note that all

spacing must be done by pressing the “Space Bar” and not using the “Tab” key as L^{A}TEX does not recognize tabs. Here is an example of code written inside the “verbatim” enviroment.

while (arrivedHacker == 0) {
      if ((inBoat + arrivedHacker + arrivedSerf < 4) && (waitingHacker >= 2)) {
          waitingHacker = waitingHacker - 2;
          arrivedHacker = arrivedHacker + 2;
          waitingToBoardHacker.signal();
      } else {
          waitingToBoardHacker.wait();
      }
}

5 CS Considerations

For writing CS documents you will want to know how to make your code easily recognizable as code. The “verbatim” enviroment shows above is the best way to show large pieces of code. To show very short pieces of code use: \verb|your code here|. The pipes (||) define the beginning and end of the short verbatim enviroment. You can also use plus signs for the same purpose (this is especially useful if you code has a pipe in it).

You may also find that you want to display scientific notation or other mathematical operations. L^{A}TEX is particularly good at displaying mathematical functions and has a lot of options that will not be discussed here. To show scientific notation do the following $3 \cdot 10^{-6}$. This will display as 3 · 10^{−6} in your text.

Also, if you want to display mathematical operations use the tag \mbox{}. It will assure that the formula has the proper spacing. For example: 2+5=7 .

6 Writing Considerations

If you are using L^{A}TEX to write a paper you will probably want to know how to put in quotations. If it is a short quotation just use quotation marks, but if it is a long quote you should use the quote enviroment. Here is an example:

\begin{quote}
This is a sample quotation. It's not quite as long as it should be,
but it will have to do.
\end{quote}

It produces output that looks like this:

This is a sample quotation. It’s not quite as long as it should be, but it will have to do.

If you want to quote poetry use the enviroment “verse”.

\begin{verse}
Humpty dumpty sat on a wall.\\
Humpty dumpty had a great fall.\\
All the King's horses and all the King's men *added to make
the line longer to show just what will happen to a long line*\\
Couldn't put Humpty together again.
\end{verse}

This will look like this:

Humpty dumpty sat on a wall. Humpty dumpty had a great fall. All the King’s horses and all the King’s men *added to make the line longer to show just what will happen to a long line*

Couldn’t put Humpty together again.

You may also want to emphasize certain parts of you text, this can be done using the \emph{text to be emphasized} tag. For example: This text has been emphasized. Or you can make your text bold using

the \textbf{} tag.

L^{A}TEX makes footnotes incredibly easy. Just use the \footnote{} tag.

For example: \footnote{This is a footnote} does this ^{1}. L^{A}TEX

1This is a footnote

will automatically number and arrange your footnotes, so you never have to worry about renumbering them.

7 Other Considerations

At some point you may want to put an enumerated list in your document. This can be done in two ways, with itemized lists (numbered or bulleted) or descriptive lists. Here is an example of an itemized list:

1. This is a numbered item

• This is bulleted

- You can also customize how and item is bulleted

Here is the code that made that lovley list possible:

\begin{enumerate} %numbered
\item This is a numbered item
\begin{itemize} %bulleted
\item This is bulleted
\item[-] You can also customize how and item is bulleted
\end{itemize}
\end{enumerate}

Note that the bullets were lists within the overall numbered list, as they were an itemized list within the enumerated list. You can also have a definition list. For example:

Dog an often cute and fuzzy animal

Lists can be quite nice

Here is the code for the preceeding:

\begin{description}
\item[Dog] an often cute and fuzzy animal
\item[Lists] can be quite nice
\end{description}

Note that all of the different lists can be used within each other, so feel free to mix and match if you so desire.

8 Note

L^{A}TEX is a large and complicated program and this guide hasn’t even scratched the surface of its capabilities. For more information go to

www.latex-project.org or www.tug.org. Also there are online

manulas at

http://www.emerson.emory.edu/services/latex/latex_toc.html,
http://www.giss.nasa.gov/latex/ltx-2.html, and
http://www.scs.carleton.ca/~dehne/doc/latexMan/ and

many other locations online.