LaTeX/Linguistics

There are a number of LaTeX packages available for writing linguistics papers. Various packages have been created for enumerated examples, syntactic trees, OT tableaux, feature matrices, IPA fonts, and many other applications. Some packages such as the  package are effectively standard within the field, while others will vary by author preference.

Some recommended packages:
 * Glosses: or ;
 * IPA symbols: ;
 * OT Tableaux: ;
 * Syntactic trees: +  (for drawing arrows);
 * Alternatively, is very powerful but not as user friendly as ;
 * The package itself has a steep learning curve, but allows a lot of control; for simplest trees use the xymatrix feature and arrows;
 * has the same syntax as qtree, but uses PGF/TikZ, which allows more options for drawing arrows, etc.


 * Dependency trees and bubble parses:
 * The package provides a high-level, convenient interface to draw dependency graphs. It is based on PGF/TikZ but does not require prior knowledge of TikZ in order to be used productively.


 * Attribute-Value Matrices (AVMs):
 * John Frampton's expex:

Enumerated examples
There are several commonly used packages for creating the kinds of numbered examples that are used in linguistics publications.

The gb4e package
The package, last updated in 2010, is called with:

IMPORTANT: If you use gb4e package, let it be the last \usepackage call in the document's preamble. Otherwise you may get exceeded parameter stack size error.

Examples for this package are placed within the  environment, and each example is introduced with the  command.

Multiple examples can be included within the environment, and each will have its own number.

To create nested lists of examples, the  enviroment is used.

For notating acceptability judgments, the command can take an optional argument. When including a judgment marker, the corresponding sentence must be surrounded by braces.

Referencing examples in text works as it does in normal LaTeX documents. See the labeling and cross-referencing section for more details.

Further details can be found in the full documentation available here.

The ling-macros package
The package created by Emma Pease and last updated in 2016, is an alternate method for example numbering. This package uses two main commands, and. The former is used for singleton examples, while the latter command is used for nested examples.

Multiply nested examples make use of the normal LaTeX list environments.

Full documentation can be found here.

Syntactic trees
Often, linguists will have to illustrate the syntactic structure of a sentence. One device for doing this is through syntactic trees. Unfortunately, trees look very different in different grammar formalisms, and different LaTeX packages are suited for different formalisms.

Constituent trees
While there are several packages for drawing syntactic trees available for LaTeX, this article focuses on the qtree and xyling packages.

The qtree package
Drawing trees with is relatively straightforward. First, the package, last updated in 2006, has to be included in the document's preamble:

A new tree is started using the \Tree command, each (sub-)tree is indicated by brackets [ ]. The root of a (sub-)tree is always preceded by a ., leaf nodes are simply expressed by their labels. Note that the spaces before the closing brackets are mandatory.

By default, qtree centers syntactic trees on the page. This behaviour can be turned off by either specifying the behaviour when loading the package

or via the command

anywhere in the document. The effect of the latter can be undone by using the command

IMPORTANT: If you use gb4e package, let it be the last call in the document's preamble. Otherwise you may get exceeded parameter stack size error.

tikz-qtree
Using the same syntax as, , last updated in 2009, is another easy-to-use alternative for drawing syntactic trees.

For simple trees, is completely interchangable with. However, some of 's advanced features are implemented in a different way, or not at all. On the other hand, provides other features such as controlling the direction of the tree's growth (top to bottom, left to right etc.) or different styles for edges.

To use the package for drawing trees, put the following into the document's preamble:

The syntax of and result when drawing a simple tree is the same as for.

Note that, other than for, trees are not centered by default. To center them, put them into a centered environment:

For setting the style of trees, provides the  command. For example, to make a tree grow from left to right instead of from top to bottom, use the following code:

The above code changes the default orientation for all trees that are defined after commands. To only change the direction of a single tree, it has to be put into a environment:

Dependency Trees
Dependency trees can take multiple visual forms. Commonly, they quite resemble phrase structure trees. Alternatively, they can be captured by brackets drawn above running text.

Two-dimensional Dependency Trees
These can be either achieved using the fairly universal drawing package or the package, last updated in 2006:

TikZ has the advantage that it allows for generating PDF directly from the LaTeX source, without need for any detour of compiling to DVI using latex, and then converting to PDF probably via PS using tools such as dvips and ps2pdf.

An alternative to is the package, which is in turn based on the package.

Dependency Trees as Brackets above Text
One way to typeset dependency brackets above running text is using the package. It gives you fairly good control of how the brackets are typeset, but requires compiling the LaTeX code to DVI (and perhaps converting to PDF using the tools dvips and ps2pdf later).

Dependency Trees using the tikz-dependency package
The package, last updated in 2012, provides high level commands to design and style dependency graphs. To draw a graph, you only need to create a environment, write the text of the sentence within the  environment and use  commands to draw the edges. Global and local optional parameters can be used to style and fine tune the looks of the graph, as shown in the following example:

For more details see the TikZ-dependency documentation

Glosses
Below is how to make glossed examples with different packages.

With gb4e
To create a glossed example with, last updated in 2010, use the normal  environment. But after the tag, introduce the example and its gloss using  and the translation after it with  tag.

Vertically aligned glosses are separated by spaces, so if it's necessary to include a space in part the gloss, simply enclose the connected parts inside braces.

With ling-macros
The  package, last updated in 2016, uses the  command to introduce glossed examples inside the  and  commands. This command takes four arguments and builds off the normal tabular environment. Its first argument specifies the number of columns in the gloss. The second and third arguments give the text and its gloss respectively, and items within each column are divided by the usual & tabular separator. The fourth argument is the translation.

IPA characters
The package, last updated in 2004, was the standard  package for International Phonetic Alphabet symbols before the widespread adoption of Unicode. Now, however, IPA symbols in Unicode can be used directly in in combination with  and, greatly improving readability.

There are two methods for getting IPA symbols into a document. The first way is to use the environment.

This method is useful for long stretches of text that need to be in IPA. Alternatively, there is the command that will format the text in its argument into IPA. This command is similar to other font typesetting commands.

Basic symbols
The IPA format works by translating ASCII characters into corresponding IPA symbols. Lower case letters are rendered as usual,

however capital letters are rendered differently.

Punctuation marks that are normally used in are also rendered faithfully in the  environment.

Numerals and <tt>@</tt> also have variants in the environment.

In addition, there are a number of special macros for representing symbols that don't have other associations, some of which are listed here. For a complete list see the official Manual.

The macro preceding a capital letter produces a small caps version of the letter.

The macro produces retroflex symbols.

The macro produces implosive symbols and the bilabial click.

XeLaTeX
The modern way of inputting IPA symbols in a document is to use as the compiler and insert the symbols directly, using a character map or an IPA keyboard.

Phonological rules
Typesetting phonological rules can be done with the help of the package, last updated in 2017.

Following is an example of what you can achieve with the package: