LaTeX

From Joint Lab Wiki
Jump to navigation Jump to search

This page is a brief overview of LaTeX, with specific information relevant to linguists.

Introduction[edit | edit source]

LaTeX is a powerful document preparation system and markup language which is designed with technical and scientific texts in mind, and is widely used in publishing. It's capable of typesetting complicated mathematical expressions, creating intricate tables, and performing complex typographical formatting, in addition to more commonly-available features such as citation management and indexing. Because it's an extensible system there are a wide variety of packages available for it that perform all sorts of functions use to linguists. For example, there are packages which facilitate the use of IPA characters, the alignment of interlinear gloss text, and the creation of syntax trees. Additionally, its use of templates to determine document formatting means it's very easy to change the formatting of an entire document (e.g. to conform to journal standards).

LaTeX files are written in plaintext with tags and some code (similar to HTML or Markdown), and are then compiled using a LaTeX distribution to create a PDF file (or some other format). For example, this:

\begin{enumerate}
    \item Item A
    \item Item B
    \item Item C
\end{enumerate}

Will produce a numbered list something like this:

  1. Item A
  2. Item B
  3. Item C

Why Use It?[edit | edit source]

  • It looks good.
  • Near complete freedom in the formatting of your document.
  • Preset styles/templates (e.g. for journals) make conforming to or switching standards simple.
  • Low-level formatting such as paragraph spacing, indentation, list formatting, page numbering, margins, headings are handled completely automatically (though this can be overridden). Note that this is handled completely differently from how a program like Word does it. Whereas Word tries (and often fails) to guess your intent, you must be explicit about the type of formatting you want in LaTeX, but once you do, you don't have to worry about it at all.
  • Automatically include text or images from other files (useful if you frequently recreate plots or modify scripts).
  • A powerful "math mode" for the typesetting of equations.
  • A useful citation manager.
  • LaTeX markup can be a bit scary at first, but most things are simple and the small learning curve comes with a big payoff in ease of use and automation.

Caveats[edit | edit source]

  • Because documents are compiled, mistakes in the markup can lead to compilation errors. These are usually easy to fix, but can occasionally be extremely frustrating.
  • Tables require a lot of formatting, and large ones can take a long time to get properly formatted. However, if you use R, the stargazer package can be used to automatically create a LaTeX-formatted version of any dataframe or statistical model.
  • LaTeX uses a "float" system for placing graphics and other objects. The goal of this is to find the optimal place for any given float, however this often results in plots being pages away from where you expect them to be. This can be remedied in a number of ways, but remains a hassle.

Installation[edit | edit source]

Windows[edit | edit source]

MiKTeX - A Windows implementation of LaTeX

TeXnicCenter - A LaTeX IDE that makes it easier to format, compile, etc.

Guide

To set things up, install MiKTeX, then TeXnicCenter, which should find the the necessary installations and configure things automatically. All you should need to do otherwise is set the output profile to LaTeX => PDF (unless you prefer another format).

OSX[edit | edit source]

MacTeX - An OSX implementation of LaTeX

Texmaker - A LaTeX IDE for OSX and other platforms (mercifully free of ridiculous capitalization).

Guide

Editing Online[edit | edit source]

You can avoid issues with downloading LaTeX and having to store auxiliary files by editing documents at Overleaf. "Premium" features of the service are available for UW users. You can store documents, share with collaborators, and compile LaTeX pdfs all online. This service is merged with the old ShareLaTeX website.

LaTeX for Linguists[edit | edit source]

  • The TIPA package can be used to produce IPA symbols (guide and key).
  • Several packages are available for the creation of syntax trees (guide).
  • The gb4e package can be used to align interlinear gloss text (guide).

See the LaTeX Wikibook section on linguistics for more details and examples.

Tips[edit | edit source]

  • Jim Fox at the UW maintains a LaTeX style file for UW-formatted theses and dissertations.
  • To get APA-style citations, include the following code in your .tex file:
    \usepackage[natbibapa]{apacite}
    \bibliographystyle{apacite}
  • Some packages for LaTeX require a special compilation schema. If your code isn't compiling, try a different path (e.g. latex -> dvips -> ps2pdf instead of PdfLaTeX).

Examples[edit | edit source]

The following zip file contains the .tex, .bib, and resulting .pdf from John Riebold's dissertation. File:Riebold dissertation.zip Note that this will not compile, due to it expecting a number of other files (graphics, code, etc.), but can still be useful as an example of how to format particular things.

Simple example from John Riebold's LaTeX presentation, Spring 2015. File:Latex example.zip

Resources[edit | edit source]

LaTeX Wikibook
An excellent reference manual for typesetting in LaTeX.

The LaTeX for Linguists Homepage
A page maintained by Doug Arnold featuring lots of tips and tricks for linguists.

UW CompLing Wiki page on LaTeX