# Is there a package for formatting phonological rules in LaTeX?

The following is a phonological rule, taken from this Wikipedia page:

Is there a package or some other convenient way to format this in LaTeX?

These kinds of phonological rules are pretty easy to do with standard LaTeX such as mbox, the array environment, etc. Here's an example (warning to TeXperts, you may find this ugly!):

\begin{figure}[h]  \centering %#%\small
$\mbox{/h/ \rightarrow} \left\{ \begin{array}{l} \parbox{1.7in}{[h] \sim [\slashed{0}]{\Large /} \underline{~~~~}C_{\textsubscript{\textsc{son}}}} \\ \parbox{1in}{[\texthth] {\Large /} V\underline{~~~~}V} \\ \mbox{[h] ~ elsewhere} \end{array} \right.$
\caption{Allophonic variation of /h/}
\end{figure}


This gives:

I'm not sure what other phonological rules you're interested in displaying in LaTeX, but I can provide an example Optimality Theory tableau if that's helpful.

There's some useful information at the LaTeX for linguists page. That page is getting a bit outdated now but a general web search (eg 'latex linguistics phonology') will find lots more examples.

EDIT: since I've updated the package, \mbox is not necessary and I removed it from the example below.

I developed a package for typesetting phonological rules: phonrule.

An example:

\phon{x}{\oneof{
\envr{w}{z} \\
\envl{v}{\phonfeat{
+feature x \\
-feature y}}}}


The code to achieve the rule of the question:

\phonb{\phonfeat{+stop \\ +consonant \\ +alveolar}
}{[ɾ]}{\phonfeat{+vowel \\ +stressed}}{\phonfeat{+vowel \\ +stressed}}


with its output.

• I uploaded an update in CTAN, it will take a while for the new version to spread. In this version the \mbox is not necessary anymore, simplifying things a bit. I'll update the answer asap. Jul 4 '15 at 12:05
• It has long puzzled me why there wasn't a package on ctan that would do this for you. Now finally there is! Jul 14 '15 at 21:36

A late answer but perhaps it will help someone. Here's some code to generate a rule very similar to that of the example.

\documentclass[11pt]{article}
\usepackage{amsmath,amsthm,amssymb}

\usepackage{tipa}
\usepackage{soul}

\begin{document}

\begin{math}
\left[
\begin{array}{l}
+\mbox{stop} \\
+\mbox{consonant} \\
+\mbox{alveolar}
\end{array}
\right]
\longrightarrow
\end{math} % Ending math mode to use the IPA symbol below
[\textfishhookr] % Using tipa' package in the preamble
\begin{math} % Resume math mode
\left. \middle/
\left[
\begin{array}{l}
+\mbox{vowel} \\
+\mbox{stressed}
\end{array}
\right]
\right.
\end{math} % Ending math mode to have a good underscore below (using package soul')
\setul{.5cm}{.4pt}% Lower the space between the underline and the text
\ul{$\qquad$}
\begin{math}
\left[
\begin{array}{l}
+\mbox{vowel} \\
-\mbox{stressed}
\end{array}
\right]
\end{math}

\end{document}


And it should look like this:

You could make the above rule as follows:

\documentclass{article}\usepackage{tipa,amsmath}
\begin{document}
$\left[\begin{array}{l}+\text{stop}\\+\text{consonant}\\+\text{alveolar}\end{array}\right] \longrightarrow$ \textipa{[R]} /
$\left[\begin{array}{l}+\text{vowel}\\+\text{stressed}\end{array}\right]$ \rule[-10pt]{20pt}{1pt} $\left[\begin{array}{l}+\text{vowel}\\-\text{stressed}\end{array}\right]$
\end{document}


Generally, you could define a macro to automate some of the typing. A crude and simple one puts the following commands in the preamble:

\newcommand{\fSet}[2]{#1\text{#2}\\}
\newcommand{\featMatrix}[1]{$\left[\begin{array}{l}#1\end{array}\right]$}
\def\goesTo{$\longrightarrow$}
\def\Context{\rule[-10pt]{20pt}{1pt}}


Then you can produce the same rule more simply as:

\featMatrix{\fSet{+}{stop}\fSet{+}{consonant}\fSet{+}{alveolar}}
\goesTo
\textipa{[R]}
/
\featMatrix{\fSet{+}{vowel}\fSet{+}{stressed}}
\Context\
\featMatrix{\fSet{+}{vowel}\fSet{-}{stressed}}