La  Te  X
1 Why La  Te  X
2 Features of La  Te  X
3 Installing La  Te  X
3.1 Share  La  Te  X
3.2 Installing on OS X
3.3 Installing on Windows
3.4 More Information


1 Why LaTeX

LaTeX is the markup language used in math, computer science, and many other scientific domains to typeset documents. Most papers, proposals, theses, and books in these disciplines are written in LaTeX. Knowing LaTeX is part and parcel of doing science.

Perhaps more importantly, science is all about dissemination, and math is all about clarity. A good scientific or technical idea is useful only if others know about it and understand it, so you need to publish your ideas for them to have impact. Even within a company or a work group, you need to let others know and understand your thoughts. They won’t unless you explain them clearly to them. The burden is on you to interest them and use their reading time wisely: they have many other things to do. LaTeX lets you do this cleanly and elegantly, especially for documents that are rich in mathematical content.

Clarity is not just for others, it is also for yourself. An idea is clear in your head only once you write it down clearly. Only then can you scrutinize every piece of it and make sure that you are not missing any link in your reasoning.

Writing things clearly requires many iterations: jot down your idea roughly, then organize your thoughts in a logical order, then simplify your reasoning, then streamline your text and notation. Iterating by hand, with paper and pencil, would require too much rewriting. Using LaTeX, on the other hand, lets you iterate by cutting, pasting, and editing, and the final product is immediately usable as a finished document.

My graduate students, research collaborators, and I think and communicate in LaTeX. When we write a paper for publication, we often iterate ten times or even more. The paper keeps getting better, and so does our understanding of what we write. Try it yourself, and you will soon discover that LaTeX is not just a writing tool, it is a thinking tool.

2 Features of LaTeX

A word processor like Microsoft Word lets you to specify all the details of what you want your document to look like. If you have a section title, for instance, it is up to you to specify how that title is to be typeset: what typeface to use, what size and style, whether to center the title or align it with the left margin, and possibly more.

In contrast, LaTeX is a language that lets you specify what a specific part of a document is. For instance, for a section title you write

\section{Features of LaTeX}

This lets the LaTeX compiler know that it needs to start a new section, and that the string Features of LaTeX is the section’s title. All the other decisions—numbering, positioning, typeface, and so forth—have been made in advance by people who are experts of typesetting. As you write, you need not concern yourself with these details, and you can focus your thinking on the substance of what you want to convey.

LaTeX is also highly customizable. For instance, it lets you redefine what the compiler is supposed to do when it encounters a \section command. You can then wear a typesetter’s hat and just think about form: What typeface to use, where to place a section title, and so forth. When you do this, you are oblivious of what a document is about, as you should be. In addition, if you change your mind about format you can just redefine the commands, without touching your document, and all your format changes show up consistently the next time you recompile it.

So LaTeX embodies an important distinction we will make in several other places in this course: That between an imperative specification (how to do something) and a declarative specification (what something is). A Microsoft Word file is by-and-large an imperative specification of a document. A LaTeX file is a declarative specification.

3 Installing LaTeX

You will write all homework for this course in LaTeX. For this you will need the LaTeX software package and an editor you can use to write LaTeX files. These have a .tex file extension. The package and the editor are separate pieces of software, although some environments provide both.

There are two ways to get access to the necessary tools. One is to use an online LaTeX editor and compiler called ShareLaTeX, the other is to install LaTeX and an adequate file editor on your computer. Both these options are available free of charge and are explained below.

Pick your option and implement it now. Do not wait until you absolutely need to use LaTeX (such as the first homework assignment), as you will have to think about other things then. The choice between them is yours. It may take you an hour or so to install everything on your computer (the LaTeX package is huge, more than 2GB), but you make a long-term investment by doing so: You can now write papers even when you have no Internet access, things happen faster, you have greater flexibility about auxiliary files like pictures you want to incorporate in your documents, and you have access to the guts of LaTeX if you want to see how it works.

I haven’t heard of problems with ShareLaTeX availability, but we will not accept lack of availability as an excuse for not handing in homework on time. If you are impatient, or you are up against a deadline (it is not recommended to be in this situation), or you want to save disk space, the online version is the way to go. Remember, however, that you are tying yourself to Internet availability and you need to assume that the ShareLaTeX service is available when you need it as well.

3.1 ShareLaTeX

To use the online option, go to in your favorite web browser. If this is your first time on the site, you will be asked to register with an email and a password. There is no charge for doing so, and there is no need to upgrade to the paid version.

Once you register, you will have access to a gallery of LaTeX sample files. For homework, you will use the .tex templates we give you, and upload those to ShareLaTeX. For now, however, pick one of the samples in the gallery to get a feel for how the interface works. Open the file with the Open in ShareLaTeX button.

Once you have chosen a file and opened it, familiarize yourself with the ShareLaTeX interface. At the very top left there is a menu icon that gives you some options. Initially, you want to leave those alone. Some of them also require a paid subscription.

Next to the menu icon there is an angled arrow pointing up. This takes you to the list of projects you are working on. Documents are organized into projects in ShareLaTeX. You can think of a project as a folder in which you have all the files that relate to a specific document. Every LaTeX document has at least one .tex file, say, hw1.tex for your first assignment. Larger documents are best organized into several .tex files, perhaps one per chapter or section, with one master file, say book.txt that includes the others with commands like \include{chapter1} (the \include command already knows to expect a .tex extension, so you need not provide that in the command).

Follow the up arrow to see the list of projects you are working on (for now this list may just have a single project). After that, go back down to the project you chose by clicking on its title.

At the same level as the up arrow and the project title, but on the far right of the window, you see three other icons. Please ignore these features of the paid subscription.

The rest of the window has three columns:
  • The list of files in the project. Many of these files are generated by the LaTeX compiler when you compile a document. Note in particular the “upload” icon (third icon) at the top of this column. This will let you upload your own .tex file.

  • An editor open on the main .tex file of the project. The name of the file currently open in this column is in red in the leftmost column of the window.

  • A view of the PDF file obtained by compiling the .tex file.

Try to make a small change to the .tex file in the middle column. Change the English text somewhere, not what is inside commands, and do so after the command \begin{document}, which always occurs in a document. Keep in mind that lines that start with a percent symbol are comments, and those do not show up in the final PDF. Then click on the large Recompile button at the top of the rightmost column, and verify that your change shows up in the document.

Make also a bad change and then recompile, to see what happens. For instance, all LaTeX commands start with a backslash character ‘\’. Add the string \bogus, which is not a recognized LaTeX command, somewhere in the English text after the command \begin{document}. Depending on the nature of the error you introduce, you will get some highlight information in the middle column, and LaTeX still limps ahead after ignoring the command. If the error is fatal, no PDF is produced, and you get some diagnostic information in the PDF column on the right. It takes some time to get used to this information, which is sometimes overly verbose, sometimes not very informative.

Once you have corrected the mistake(s), save the PDF file to your disk by clicking on the “download” icon (a down-arrow with a computer disk below it) next to the Recompile button.

You now know the basics of using ShareLaTeX.

3.2 Installing on OS X

On a Mac, go to and download the MacTeX.pkg installation package, then double click on it to install. The software will show up in a Tex folder in the Applications folder of your computer. Drag the application TeXShop from that folder onto your taskbar, so you have easy access to it in the future. You could also use TexWorks instead of TeXShop (in the same Tex folder) if you prefer a more minimalist interface. I recommend TexShop for this class.

Open the TeXShop application.

A window shows up with a blank page. Make sure that the menu to the right of the Typeset button at the top is set to LaTeX. To create an empty document, select LatexTemplate from the Templates menu at the top of the window. If you now click on Typeset, you will be asked to name and save the .tex file. After doing that, the LaTeX compiler generates the .pdf file corresponding to that .tex file (same base name), and TeXShop displays the result, which will look rather empty.

The renderer used to display the PDF file is TeXShop’s own. You can of course also open the same file by navigating to it in the Finder and opening it with your favorite PDF viewer (Preview by default if you double-click the file).

You have now made your first LaTeX document. Try to add some text and inject some errors, along the lines of the last few paragraphs of the section on ShareLaTeX above, and see what error messages you obtain.

3.3 Installing on Windows

On a Windows computer, go to and download the MiKTeX installer. Find the installer in the folder you downloaded it to, and double-click on it to run it.

You will then need to separately install a text editor that understands LaTeX. WinEDT is highly recommended. Click on the Download link on the WinEDT page to download and follow the installation instructions.

After installation, run WinEDT. The configuration wizard will run automatically. Click on the File Associations tab and under Current User click on Modify file type associations.... When you clik OK, all .tex files are associated to WinEDT as the default application that opens them when you double-click.

To create a simple .tex file, paste or copy the following into the main WinEDT window:



    \title{My first {\LaTeX} Document}

    \author{My Name}





    Hello, World!



Save the document as a file, say first.tex. There are various ways to turn this document into a PDF file. The preferred way for this course is to use the PDFLaTeX command you will find in WinEDT’s toolbar at the top right. WinEDT will call the default PDF viewer to display this file. Alternatively, you can double-click on the first.pdf file from Windows.

You have now made your first LaTeX document. Try to add some text and inject some errors, along the lines of the last few paragraphs of the section on ShareLaTeX above, and see what error messages you obtain.

3.4 More Information

If you like movie tutorials, download this zip file and watch the movies therein.

A quick LaTeX tutorial can be found at, and the quick start version on the same site is an even faster, one-page introduction.

The LaTeX Wikibook is an authoritative online reference to LaTeX.