Setup and Tutorial for Using LaTeX with TeXShop/BasicTeX

Introduction – WARNING: I DON’T USE MACS, SO I’M NOT SURE IF THIS’LL WORK. J

LaTeX works like this:

·  First, you use a text editor (we'll be using TeXShop) to create a LaTeX document foo.tex (note: "foo" is standing in for your file name).

·  Then, you run a LaTeX compiler (we'll be using BasicTeX) to turn the file foo.tex into three files: foo.aux, foo.log, and foo.dvi.

·  Finally, you need to use some kind of viewer/previewer (we'll be using Adobe Acrobat) to view or print the pretty formatted file foo.dvi.

You will do everything from TeXShop, which we will set up to control BasicTeX. This document will take you through the steps of downloading, installing, configuring, and working with BasicTeX and TeXShop. Be sure to follow ALL of the directions below, IN ORDER. Consider this the first test of your logical thinking abilities!

I recommend that you print out this document so that you can refer to it easily and check off steps as you do them. Don't be afraid to send me email or stop by my office if you get really stuck. (Double-check that you have Actually Followed The Directions before you do this!)

Downloading and installing BasicTeX

  1. Go to http://www.tug.org/mactex/morepackages.html and at the very bottom of the page, click to download "BasicTeX-2008.dmg".
  2. Save the file. Using a wireless connection on campus, this can take up to 30 minutes to download. A wired connection will be faster.
  3. When it has finished downloading, double-click the file (you can probably find it on your desktop) to open it. This should take you to a folder containing the file "BasicTeX-2008.pkg". Double-click this file to run the installer.
  4. Click "Continue" at the security warning.
  5. Click "Continue" until you agree to the license.
  6. Select "MacBook" drive and click "Continue" and then "Install".
  7. Type your WSU password if prompted.
  8. When the installation is finished (~5 minutes), click "Close".
  9. Eject the "BasiC Tex" volume and delete the "BasicTex.dmg" file from where you downloaded it to (probably your desktop).

Downloading and installing TeXShop

  1. Go to http://www.uoregon.edu/~koch/texshop/obtaining.html.
  2. Click on the link near the top that says "Latest TeXShop" to download the file "texshop.zip".
  3. Save this file to your desktop. This may take up to 5 minutes to download on a wireless connection on campus. A wired connection will be faster.
  4. When it has finished downloading, double-click the file (you can probably find it on your desktop) to uncompress it. This will create an icon called "TeXShop" in the same place. Double-clicking this will start the TeXShop program.

Creating a simple document using LaTeX

Now we're finally ready to write a document in LaTeX. The instructions below will take you through the process of creating a very simple document.

  1. Write: In the TeXShop program, type this:

\documentclass{article}

\begin{document}

Hello universe! $2^2 = \sqrt{16}$

\end{document}

  1. Save: Save this file as "universe.tex" to whatever directory you choose. Be sure the extension is "tex" and NOT "txt”.
  2. Compile: Click the “Typeset” button. If there are no compiling errors in your .tex file, then in the same directory where you saved universe.tex should be three new files: universe.aux, universe.log, and universe.pdf. These files will be updated every time you run latex on universe.tex. Take a moment now to go to your directory/folder and check.

POSSIBLE PROBLEM: If only the file universe.tex is there then it is possible that your system does not know where BasicTeX is installed. If this happens, contact the instructor for help.

  1. View: If there were no compiling errors in your .tex file, then two new windows should’ve automatically opened up. One a log file with a bunch of computer code-like text, and another with your very pretty document. If only the log file opened, then see the section below about handling compiling errors.
  2. Repeat: Now if you want to modify your file, go back and repeat the steps above: Write, Save, Compile, View.

Handling compiling errors

LaTeX is a very picky typesetting program, and a lot of tiny things can cause compiling errors. By following the instructions below you will introduce an error into your universe.tex file and then see how to deal with it.

  1. Change your universe.tex file so that it looks like this:

\documentclass{article}

\begin{document}

Howdy universe! $2^2 = \sqrt{16}$

The & is a special character.

\end{document}

  1. Save universe.tex and try to compile it (steps 2 and 3 above). The log window should appear, with typing in it, but it will "crash" before it is finished.
  2. Read the last few lines of information in the log window. It should look something like this:

! Misplaced alignment character &.

l.4 The &

is a special character.

  1. In LaTeX, the "&" character is used for tabbing (alignment) in certain environments, but it is not a legal character on its own; that is what the first line of the error message above is saying - that the character "&" is being used somewhere it shouldn't. The "l.4" at the beginning of the next line of the error message tells you that the error is on line 4 (it says "lowercase ell dot four" not "one dot four" at the beginning of the line). Notice also that the line breaks where the compiler thinks your error might be: at the "&" character.
  2. It's pretty clear that we need to get rid of or modify that "&", but for the sake of this exercise, let's say you don't understand the error message completely, but you do think that line 4 could be the culprit. One thing you can do is "comment out" the line in question, by inserting a "%" symbol at the start of the line. In LaTeX, the rest of the line following a "%" symbol is ignored by the compiler. Do this, and then compile again, and you should not get any errors.
  3. Of course, after the step above, you got rid of the error, but you also didn't get the document to say what you wanted; let's fix the error. In LaTeX, the character "&" can be produced by typing "\&". Un-comment line 4 (i.e. remove the "%" symbol) and put a backslash "\" in front of the ampersand. Recompile and everything should work.

Printing a finished LaTeX document

If you want to print right from the computer you are working on, it's easy; just click the "Print" icon on the viewer.

If you want to print from a computer that does NOT have LaTeX installed (or you want to send your file to someone who does not have LaTeX installed, but needs to see your beautiful typeset file), look in your working directory for your universe.pdf file (or foo.pdf file) that can be viewed and printed by anyone, on any computer, using Adobe Acrobat PDF Reader.