UMaine COS 301: Programming Languages

LATEX Information

LATEX Resources  
Documentation: ShareLATEX
“Short” introduction to LATEX: “Not So Short Introduction…”
All things LATEX (software, docs): CTAN: Comprehensive TEX Archive Network
An online LATEX system; nice editor, previewer: ShareLATEX
A WYSIWYG editor that uses LATEX: LYX
Other LATEX editors and tools: Wikipedia entry

LATEX is a document preparation/formatting language and program. It has been called a “what you see is what you mean” rather than a “what you see is what you get” facility, since it helps you to format your writing conceptually as you write, while automatically (for the most part) producing output of the right format. (This is analogous to some extent to the distinction between XML [concerned with logical format] and HTML [concerned with presentation on-screen].)

LATEX produces very high-quality output–in fact, its output is comparable to professional typesetting. (Many publishers accept LATEX and use it directly to create their typeset output.) It is especially noteworthy for its easy inclusion of high-quality mathematics typesetting and for its extensive built-in (or available via BibTeX) bibliography and citation support.

Using LATEX is different from using a word processor, however! You write your document in plain text, marked up with LATEX commands. You can use any editor for your document, even a word processor. However, I recommend Emacs, which is not only one of the best programmers’ editor (really, a programming environment) around, but that also “understands” LATEX and so can help you as you write your document. (Emacs can even run the latex program for you and track the errors, if any, in your document.)

Once you have created a document, you run LATEX’s formatting program, latex, on it. There are different versions of latex, depending on the output file you want. The one you will likely want to use for this class is called pdflatex, which produces PDF from the LATEX source file.

A bibliography formatting program, BibTeX, is also part of the LATEX distribution. You will keep your bibliography data in a separate file, called a .bib file. (You can often find BibTex versions of bibliography entries for books and articles you need already created for you via Google Scholar or CiteSEERx.) Each bibliography entry has a key that you can use to refer to it in the document’s citations. After formatting your document, you will run BibTeX’s program, bibtex, to create a bibliography (.bbl) file. Running pdflatex again will add the bibliography to the output. Often, if cross-references have changed (or it is the first time you have run bibtex), you will run pdflatex one more time to clean them up. The sequence you will use, then will be:

Write your document Run pdflatex Run bibtex Run pdflatex twice more At that point, you’ll have a beautiful PDF version of your document.

Getting and installing LATEX

LATEX is available for Linux, MacOS, and Windows. This page has information on how to find and install a version that is right for you. (Note that if you are using MacOS and typically use the command line, you may prefer to install LATEX as a Unix-like program rather than an application via something like Homebrew.)

An example

As an example of creating a project paper in LATEX, here is a sample LATEX file, here is a sample BibTeX file, and here is the finished output in PDF.

Creating and editing LATEX

Do yourself a favor and use Emacs, even if you have to learn it. It’s about the best editor around for programmers and can do most anything, and it is exceptionally good for editing LATEX. Install the AUCTeX package and off you go.1 You can find Emacs, if it’s not already installed on your computer, via your OS’s package manager (e.g., Homebrew on MacOS) or directly from the GNU project here.

The Org Mode package for Emacs also plays nice with LATEX and it has the advantage of hiding some of the messiness of LATEX in your file, as well as its normal features of outlining, etc. Plus, an Org Mode file can be output in a lot of different forms, such as LATEX, PDF (via LATEX), HTML, man pages, ebooks, etc.

WYSIWYG LATEX and translators

Despite LATEX being a markup language, there are WYSIWYG programs that look like standard word processors, but generate LATEX. I encourage you to use plain LATEX markup. However, LYX is a pretty good word processor-like editor that uses LATEX, and into which you can insert raw LATEX code.

Again, however, I strongly encourage you to learn LATEX itself and to use it to mark up your paper in a plain text form. Learning LATEX may seem like a bit of a pain, but it will reward you many times over throughout your career.

If you are not using Emacs’ Org Mode and you want to produce HTML (or even an ebook) from your LATEX code, see latex2html, TeX4ht, or latexml + latexmlpost, or pandoc (an all-purpose format converter).

Footnotes:

1

In Emacs, bring up a list of available packages with M-x package-list, look for auctex, press space on that line, then click on the install button.