Numbered examples in LaTeX

For reasons that completely elude me, I still encounter linguists that do not use LaTeX for their writings. The reasons for using LaTeX over 'alternatives' are numerous, but one application for which LaTeX is a particularly natural tool is that of numbered examples. I compare three packages designed for this purpose: linguex, philex, and expex.

Linguex

Linguex is the classical package for this purpose and boasts a very simple syntax for the basic tasks:

\ex.
\a. \label{test} This is a sentence.
\bg. Dies ist ein deutscher Satz. \\
this is a German sentence \\
`This is a German sentence'

Sentence \ref{test} is interesting.

In order to get rid of the ugly hyphen in (1-a), you should put \renewcommand{\firstrefdash}{} in the preamble. As can be seen, glossing is particularly easy, for which the \exg. and \ag. commands are provided. Another nice feature is easy-input labelled bracketing by means of the \exi. command, which can also be combined with glosses:

\exi.
\a. [CP that [TP John$_i$ [vP $t_i$ likes Mary ]]]]
\bg. [CP dass [TP Peter$_i$ [vP $t_i$ Mari liebt ]]] \\
{} that {} Peter {} {} Mary loves \\
`that Peter loves Mary'

However, beyond these features, linguex is rather limited. The main problems are the following:

Conclusion: if you only need the very basic stuff, you can take advantage of linguex's simple syntax. Soon you will run into its limitations, though, and then it's time to look at one of the alternatives.

Philex

Philex is an extension of linguex mainly designed in order to solve the problems with cross-reference (the first two bullet points above).
\lb{test}{This is a sentence.}
\lbu{test2}{test}{$'$}{\gll Dies ist ein deutscher Satz \\
this is a German sentence\\
`This is a German sentence'}
Sentences \rf{test} and \rf{test2} are interesting.

As you can see, the syntax is rather different: \lb is the basic command, and \lbu ('update') is used to decorate earlier examples, creating (1'), (1+), (1*) or whatever. We also have to use cgloss4e.sty's \gll command for glosses. A disadvantage of this new \lb method is that it is obligatory to give each sentence a label (the first argument). However, since philex is just an extension of linguex – in particular they use the same counters – one can intersperse linguex and philex commands freely. So, using \lb for examples you wish to refer to, and \ex. for examples you don't want to refer to, is a reasonable workaround.

Philex also allows the user to do the alternative cross-references given in the second bullet point above. The \rf method used in the example, includes the parentheses, but \rn returns the bare example number, which is what you want. Philex has some more features related to alignment and spacing, for which I refer the reader to philex's manual.

The disadvantage of philex is that it is somewhat buggy. I encountered some issues with spacing and the alignment of judgment symbols that require some tweaking on the part of the user.

Conclusion: a nice extension of linguex that can be used in combination with it. There are some issues with it, though, and it does not solve the last three bullet points given above.

Expex

Expex is the package that by far has the richest feature set. The following example illustrates how it deals with all the five bullet points:

\ex<test>
\labels
\begin{tabular}[t]{cccccc}
\tl <x> & item 1 & \tl  <y>& item 2 & \tl & item 3 \\
\tl & item 4 & \tl & item 5 & \tl & item 6 
\end{tabular}
\xe
\pex~[exno=\getref{test}$'$,textoffset=!1.3em] 
\a \begingl
\gla \rightcomment{[German]}\ljudge{??/*}Dies ist ein deutscher Satz //
\glb this is a German sentence //
\glft `This is a German sentence'//
\endgl
\a Another sentence.
\xe
Sentence pair (\getfullref{test.x}\getref{test.y}) is interesting.

I used \lingset{everygla=,aboveglftskip=0pt} in the preamble to globally set some style preferences. As the reader may observe, expex deals with the problems, but at the cost of a more cumbersome syntax. The is especially apparent in the glosses (observe the special //, not \\). It also has a completely different reference system (although there is some backwards compatibility with LaTeX's \label\ref system). There are some other technical oddities that are sometimes well hidden in the manual:

Glancing through expex's manual and the expex-demo.tex file, one will quickly see it has many more advanced features: multilevel glosses, control over wrapped glosses, pstricks integration, glosses with panels, etc. Some of these are so cool that you should consider using them just because expex provides them.

Conclusion: there is a more cumbersome syntax, and some technical details you have to get acquainted with (I have listed some of them above), but the advanced feature set makes expex the clear winner.