8

I'm trying to (more or less) replicate this phonological rewrite rule:

enter image description here

I'm using the package phonrule, and what I manage to accomplish is this:

\documentclass{article}
\usepackage{phonrule}
\begin{document}

\phonc
    {\phonfeat{$-$cnt\\ +hi}}
    {[$\alpha$grv]}
    {\oneof{%
        \phonfeat{$-$cnt\\ $\alpha$grv}\phold\\
        \phold\phonfeat{$-$cnt\\ $\alpha$vce}%
    }}

\end{document}

enter image description here

My main problem here is what appears after the "when" slash:

(1) The package only provides a left curly bracket - how can I add a right one as well?

(2) The two options within the curly brackets are not well aligned. I think comparing the two pictures themselves says it better than what I could do with words.

  • 1
    in redard to (2): According phonrule.sty \oneof internally uses a simple tabular environment. If you insert an ampersand (eg. like this: \phonfeat{$-$cnt\\ $\alpha$grv} & \phold) and add a second newline `\\ \` the result looks not perfect but a little bit better ... – lAtExFaN Apr 17 '17 at 12:24
4

You can look at the reimplementation of phonrule I did for Alignment in \oneof from the phonrule package

We can now define a variant of \oneof where the closing brace is added and the space between columns is removed.

\documentclass{article}

% BEGIN reimplementation of phonrule
\providecommand*{\textrightarrow}{\ensuremath{\rightarrow}}
\providecommand*{\textplus}{\ensuremath{+}}
\providecommand*{\textminus}{\ensuremath{-}}

\newcommand*{\phold}{\rule[-1.5pt]{1.5ex}{.5pt}}

\newcommand*{\phon}[2]{#1 \textrightarrow{} #2}
\newcommand*{\phonc}[3]{\phon{#1}{#2}~/~#3}
\newcommand*{\phonr}[3]{\phon{#1}{#2}~/~\phold#3}
\newcommand*{\phonl}[3]{\phon{#1}{#2}~/~#3\phold}
\newcommand*{\phonb}[4]{\phonl{#1}{#2}{#3}#4}

\makeatletter
\newcommand*{\env}{\@ifstar{\@env{&}}{\@env{~}}}
\newcommand*{\@env}[3]{#2~/#1#3}

\newcommand*{\envr}{\@ifstar{\@envr{&}}{\@envr{~}}}
\newcommand*{\@envr}[3]{\@env{#1}{#2}{\phold#3}}
\newcommand*{\envl}{\@ifstar{\@envl{&}}{\@envl{~}}}
\newcommand*{\@envl}[3]{\@env{#1}{#2}{#3\phold}}
\newcommand*{\envb}{\@ifstar{\@envb{&}}{\@envb{~}}}
\newcommand*{\@envb}[4]{\@env{#1}{#2}{#3\phold#4}}

% set environment for feature matrix with square brackets
\newcommand*{\phonfeat}[1]{%
  \ensuremath{%
    \left[\begin{tabular}{c}#1\end{tabular}\right]%
  }%
}
\newcommand*{\oneof}[2][c]{%
  \ensuremath{%
    \left\{
    \begin{tabular}{#1#1}#2\end{tabular}
    \right.
  }%
}
\makeatother
% END

\newcommand{\oneofvar}[2][c]{%
  \ensuremath{%
    \left\{
    \begin{tabular}{#1@{}#1}#2\end{tabular}
    \right\}
  }%
}

\begin{document}

\phonc
    {\phonfeat{$-$cnt\\ +hi}}
    {[$\alpha$grv]}
    {\oneofvar{%
        \phonfeat{$-$cnt\\ $\alpha$grv} & \hrulefill \\
        \hrulefill & \phonfeat{$-$cnt\\ $\alpha$vce}%
    }}

\end{document}

enter image description here

| improve this answer | |
  • How can I add the @{}c@{} bit (from Alan's answer) to the tabular definition of \oneof and \oneofvar to get the braces closer? – Sverre Apr 17 '17 at 15:02
  • @Sverre If you remove the @{} from the \oneofvar definition it is the same as mine. (And personally I wouldn't use \hrulefill here, since the environment line is way too long and high.) – Alan Munn Apr 17 '17 at 15:19
  • @AlanMunn Yes, but I was wondering how I can put the @{}c@{} bit into the definition of \oneofvar/\twoof (I renamed it \phonbraces), so that I don't need to repeat it every time I write a rule. – Sverre Apr 17 '17 at 15:22
  • 1
    @Sverre Just replace the [c] in the macro definition with @{}c@{}. – Alan Munn Apr 17 '17 at 15:25
6

Here's a version that looks ok. I added a \twoof command for the second brace and made a longer \phold command \Phold. Since the underlying commands are tabular you can pass any tabular specification to it so I removed the intercolumn space to make the alignment look a bit nicer.

\documentclass{article}
\usepackage{phonrule}
\usepackage{amsmath}
\newcommand*{\twoof}[2][c]{%
  \ensuremath{%
    \left\{
    \begin{tabular}{#1#1}#2\end{tabular}
    \right\}
  }%
}
\newcommand*{\Phold}{\rule[-4pt]{2.5em}{.5pt}}

\begin{document}

\phonc
    {\phonfeat{$-$cnt\\ +hi}}
    {[$\alpha$grv]}
    {\twoof[@{}c@{}]{%
        \phonfeat{$-$cnt\\ $\alpha$grv} & \Phold\\
        \Phold & \phonfeat{$-$cnt\\ $\alpha$vce}%
    }}

\end{document}

output of code

| improve this answer | |
  • I was hoping you would come to the rescue, Alan :) Now as a follow-up: could you please make a package for phonological rewrite rules? – Sverre Apr 17 '17 at 12:41
  • 1
    I'll add this to the list of "packages I've been asked to write in TeX.se comments". :) – Alan Munn Apr 17 '17 at 12:49
  • 1
    @Sverre And see, egreg has already rewritten the package! – Alan Munn Apr 17 '17 at 13:01
1

Using egreg's answer as the basis, and incorporating something from Alan's answer as well as adding a few bits of my own, I've decided on this (stripping away lines I don't need for this MWE):

\documentclass{article}

\providecommand*{\textrightarrow}{\ensuremath{\rightarrow}}

\makeatletter
\newcommand*{\phoncrossbar}{\leavevmode\leaders\hrule height .5pt\hfill\kern\z@}
\newcommand*{\phon}[2]{#1 \textrightarrow{} #2}
\newcommand*{\phonc}[3]{\phon{#1}{#2}~/~#3}
\newcommand*{\phonfeat}[1]{%
  \ensuremath{%
    \left[\begin{tabular}{@{}l@{}}#1\end{tabular}\right]%
  }%
}
\newcommand*{\phonbraces}[2][@{}c@{}]{% for curly braces on both sides
    \ensuremath{%
    \left\{
        \begin{tabular}{#1#1}#2\end{tabular}
    \right\}%
}}
\makeatother

\begin{document}

\phonc
    {\phonfeat{$-$cnt\\ +hi}}
    {[$\alpha$grv]}
    {\phonbraces{%
        \phonfeat{$-$cnt\\ $\alpha$grv} & \phoncrossbar\\
        \\
        \phoncrossbar & \phonfeat{$-$cnt\\ $\alpha$vce}%
    }}

\end{document}

enter image description here

What I've changed from egreg's answer is this:

(1) Created a version of \hrulefill called \phoncrossbar that has the same thickness (0.5pt) as rules used elsewhere here.

(2) Added @{}c@{} to the definition of \phonfeat and \phonbraces to remove extra white space in matrices and around braces (this is also how it normally looks in the literature).

(3) Left aligned the features in the feature matrix (which is the norm).

| improve this answer | |
  • This is an aesthetic choice, of course, but to my eye the bar is still too long and too high. – Alan Munn Apr 17 '17 at 16:01
  • @AlanMunn I had the same doubts, but I compared with SPE, and that's how they do it, actually. – Sverre Apr 17 '17 at 16:03
  • 2
    Well it wouldn't be the only thing about SPE that's ugly. :) – Alan Munn Apr 17 '17 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.