Latex Lab
Goals
The goal of this lab is to introduce you to LaTex. You will learn:
- Some of the features available in LaTex
- How to compile a LaTex document
- Some basic methods in LaTex such as: creating a table, creating paper sections, writing an equation, creating bulleted and numbered lists, emphasizing words, and working with a bibliography
Available features and why you want to use LaTex
LaTex is a program for typesetting text. Some reasons to use it are:
- It makes beautiful documents, over which you have almost infinite control. I use it to write articles, your homeworks, slideshow presentations, and surveys.
- It is particularly good for typesetting math. Unlike Word, you can do it quickly and it doesn't cause your computer to crash.
- It has some programming capabilities.
- It has a great bibliography package, which eliminates the need to type up and format your references.
- You can create html files from it (this is how I do your homework)
- You can easily convert elements of a paper into other mediums
- It is free
Check if your computer has a pdf viewer. If not, download a viewer.
Here are some files that I have created using latex. Start by looking at the PDF. Then look at the latex file and see if you can figure out how things were done.
Creating your own document
You can create latex files using any text editor. I use Vim. TeXnic center is a Windows GUI that has some point and click capabilities.
- Open TeXnic Center at the Start -- All Programs (or on the desktop).
- Open a new file.
- Paste this basic template into your new file.
You will want to look at this great resource, to help you on the next section. There are, of course, numerous other LaTex resources online. When in doubt, google.
- Add some text between begin{document} and \end{document}. Here is the Gettysburg Address.
\begin{document} Four score and seven years ago our fathers brought forth on this continent a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now we are engaged in a great civil war, testing whether that nation, or any nation, so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this. But, in a larger sense, we can not dedicate—we can not consecrate—we can not hallow—this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us—that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion—that we here highly resolve that these dead shall not have died in vain—that this nation, under God, shall have a new birth of freedom—and that government of the people, by the people, for the people, shall not perish from the earth. \end{document}
- Next you will need to build (compile) your document. You can create several types of output. Lets start with DVI. Check that it says LaTex ====> DVI on the top of Texnic Center. If so, Click on Build -- Current File -- Build and View. You will see the document compiling below. This is where you will find any errors. View your document (it will open in Yap).
- Try making a word bold or italicized
\textbf{aword}
\textit{aword}
- Change your document to double-spaced
\renewcommand{\baselinestretch}{2}
- Make an itemized list
\begin{itemize}
\item this is the first item in a itemized list
\item The second
\end{itemize}
- Change your itemized list to an enumerated list by changing itemize to enumerate
- Can you create an outline?
- Lets create a shortcut for itemizing. At the top of the document, do the following
\newcommand{\bi}{\begin{itemize}}
Now you can write
\bi
everywhere you would have written
\begin{itemize}
- Make some other shortcuts
Lets add some other features that you might need in a document.
- Add anticipated section headings for your document
\section{Section name here}
- Add a subsection or two.
\subsection{name here}
- Add a title to your document, author info, etc (See the example article)
- Add a footnote
- Add an equation
- How about a table? There is a very simple example in the slides .tex example.
- Compile your document
Adding a bibliography
- Open a new file in TexNic. Paste the following three bibliographic entries.
@article{LeKamaSchubert2004,
author = {Le Kama, Alain Ayong and Schubert, Katheline},
year = {2004},
title = {Growth, Environment and Uncertain Future Preferences},
journal = {Environmental and Resource Economics},
volume = {28},
number = {1},
pages = {31--53}
}
Above is an example bibliography entry. The first line identifies that this reference is for a
an article (as opposed to a book, etc). You will want to create an identification system that
you use for referring to citations that will be easy to remember. I use LastnameYear for one
author, LastnameLastnameYear for two authors, and LastnameEtAlYear for more than 2 authors.
Here is an example book:
@book{Bartholomew,
author = {Bartholomew, D.J. and Knott, M.},
year = {1999},
title = {Latent Class Models and Factor Analysis},
edition = {Second},
address = {New York},
publisher = {Oxford University Press Inc.}
}
Here is an example file off of the internet:
@misc{USCensus2000,
author = {{US Census Bureau}},
year = {2006},
title = {{Current Population Survey, Annual Social and Economic Supplement}},
note = {\url{http://www.census.gov/hhes/www/poverty/poverty.html}.
Last accessed May 14, 2007}
}
- Save your bibliography with the ending .bib.
So now you've assembled a bibliography. How do you use it? Look in the example latex paper for
some examples. Basically, anytime you want to reference a paper in your document, do the following:
\cite{LeKamaSchubert2004}
- You need to tell the latex file the name of your bibliography document and the bibliography style that you want to use. Put this at the end of your latex document, right before \end{document}. You will need to provide a stylename (try plain) and the name of your .bib file
\bibliographystyle{stylename}
\bibliography{filename}
- Build the bibliography and then the latex document. You may need to compile for latex more than once. It will automatically create your bibliography for you.
- Experiment with some of the styles listed here. You can also create customized styles. Search for \gnu{bibtex} on the web for more info.
- It wouldn't be much fun if you had to type in all these bibliography entries (I used to have to!). Go to Google-Scholar and find a cite. In Scholar preferences, click the bibtex box. Copy the cite into your bibliography. Note that Google scholar will have identifiers but they are fairly cryptic, so you may want to use your own.
Installation
There is lots of documentation on the web on how to do this. See my installation page for links and a few notes.

