LaTeX resources

Compiled by Ian Kirby (Site, Twitter)

These are some useful linguistics-related LaTeX resources that I've gathered or written over the years. It's basically the result of googling around for particular typesetting problems that come up, and of course asking my colleagues for help with particular issues.



Contents:


1. Macros

The code samples below include required packages the macro, then a code sample in below ellipsis. For each relevant macro and packages, they are bolded. That is...

            
\usepackage{times} % <------ this goes in the preamble

...
       % <------ this is where the body begins.
Here is a code sample.
The times package changes the font to Times New Roman.
            
        


Double brackets

 


\usepackage{stmaryrd} %Required for double brackets <\llbracket, \rrbracket)

\newcommand{\lf}[1]{$\llbracket$#1$\rrbracket$}

...

    instead of typing $\llbracket$X$\rrbracket$

    you type \lf{X}
            

which will produce....

double-brackets.png

If you would like space between the element in the brackets, change the macro to \newcommand{\lf}[1]{$\llbracket$ #1 $\rrbracket$} (i.e. add a space in the macro)




Back to top



Angled tuple brackets (e.g. for semantic types)

This one is particularly useful. Credit to Dora Mihoc.

\newcommand{\op}[2]{\ensuremath{\langle #1,#2\rangle}}

...

    instead of typing $\langle a, b\rangle$

    you type \op{a}{b}


which will produce ...

types-1.png

This is nice because LaTeX linters don't (as far as I know) highlight the scope of $\langle$, $\rangle$. Some really nice things about this are how straightforward it is to embed it


\newcommand{\op}[2]{\ensuremath{\langle #1,#2\rangle}}
\usepackage{linguex}

\ex.
    \a.\op{\op{e}{t}}{\op{\op{e}{t}}{t}}
    \b.\op{et}{\op{et}{t}}
    \b.\op{\op{e}{t}}{e}
    \b.\op{\op{s}{t}}{\op{\op{s}{t}}{t}}


types.png




Back to top



2. Essential packages




Back to top



3. Solutions to common pitfalls

Glosses (Linguex)

Referencing: change (1-a) to (1a):


\renewcommand{\firstrefdash}{}
\usepackage{linguex}
...

    \ex.
    \a.\label{x}This is a sentence.
    \b.\label{y}This is another sentence.
    \b.\label{z}This is yet another sentence.

Now let's refer to them:\\
Sentence \ref{y} is below \ref{x}.\\
Sentence \ref{z} is below \ref{y}.\\
Isn't that neat?

figures-dash.png


Right-justifying a piece of text after a three-line Linguex gloss (e.g. language name)

The linguex package can be pretty finicky with spacing. Sometimes, if you are comparing similar patterns in different languages, it's clearest to put the name of the language in the right margin that follows the example.


right-justify.png

A useful macro for this is included in the codebox below (credit to Brian Buccola for this macro). The macro goes after translation of the gloss.


\newcommand{\rcommentg}[1]{\hfill\raisebox{1.9\baselineskip}[0pt][0pt]{#1}}
\usepackage{linguex}
...

\ex.
\ag.Rechts -schutz -versicher -ung -s -gesellschaft -en\\
legal -protection -insure -\textsc{nmlz} -\textit{s} -society -\textsc{pl}\\
`insurance policies which provide legation protections'\rcommentg{(German)}
\bg.kolmi -vaihe -kilo -watti -tunti -mitta -ri\\
three -phase -kilo -watt -hour -meter -\textsc{nom}\\
`electricity meter'\rcommentg{(Finnish)}
\bg.al -fr{\ae}{\eth}i -or{\eth}a -b{\ae}k -ur -nar\\
all -study -word -book -\textsc{nom/acc.pl} -\textsc{def}\\
`the encyclopedias'\rcommentg{(Icelandic)}
\bg.z\`{\i} d\`{o}ng gu\'{\i} yu\'{a}n j\'{\i}\\
self move cabinet money machine\\
`ATM (automated teller machine)' \rcommentg{(Mandarin)}





Back to top



Special characters, diacritics

The letter i with accents macron, caron, tilde, breve



i-problem.png

This is caused by using the dotted-i as the base character (i.e. you are typing \={i}, etc. The solution to this is to use the dotless-i: ı, which you can get through the command \i




Instead of \={i}, \~{i}, \u{i}, \v{i}

you have to type \={\i}, \~{\i}, \u{\i}, \v{\i}




Back to top