2

This question piggybacks off of the question/answer here, where one answer mentions how to create a phonological rule using the phonrule package.

MWE here:

\documentclass[a4paper,12pt,twoside,onecolumn]{memoir}

\usepackage{phonrule}

\begin{document}

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

\end{document}

Results in:

enter image description here

You can see that output and environments are centered. Is there any way to un-center them and/or left-align them? The centering that it does appears to be an intentional addition in v1.2.0 of phonrule. But there is nothing else in the documentation regarding alignment.

I need it to be the standard left-aligned version - that is, left-aligned output and left-aligned environment. Something like this (exact spacing is flexible):

enter image description here

Trying to throw in any type of alignment generally breaks the phonrule environment and it won't compile or it aligns the entire figure/example, rather than just the individual (output + environment) sections.

I have been using roughly the same as the other answer from the above question which utilizes \mbox. This is fine, but adding additional outputs and environments is either messy or requires a new command based on the differences. phonrule generally does all this in a much cleaner and more expandable way, which is why I'm looking into being able to modify the alignment.

3

Here's a complete reimplementation of phonrule:

\documentclass{article}

\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.
  }%
}

\begin{document}
\phon{x}{\oneof[l]{ \envr*{w}{z} \\
      \envl*{v}{\phonfeat{
      \textplus feature x \\
      \textminus feature y
}}}}

\phon{x}{\oneof[l]{
   \envr{w}{z} \\
   \envl{v}{\phonfeat{
   \textplus feature x \\
   \textminus feature y
}}}}

\phon{x}{\oneof{
   \envr{w}{z} \\
   \envl{v}{\phonfeat{
   \textplus feature x \\
   \textminus feature y
}}}}

\end{document}

The changes are:

  1. The \oneof command accepts an optional argument for the inner alignment, default c like in the original; it can be l or r.

  2. The commands \env, \envl, \envr and \envb have a *-form, which inserts an & after / instead of the default ~, so they can be used in the argument of \oneof in order to get the alignment you wish.

In the code above I used all three possibilities; the first example is what you're looking for, the second one just has left alignment, the final one is like the original.

enter image description here

  • Definitely overkill, but the options you created will help with flexibility or potentially changing preferences later. Thanks! – whatisit Dec 4 '16 at 0:04
1

Define a new command \oneofl by adding the line

\newcommand\oneofl[1]{\ensuremath{\left\{\begin{tabular}{l} #1 \end{tabular}\right.}}

to your preamble (i.e., between \documentclass and \begin{document}) and use it instead of \oneof. Then you get the following output by the code below.

enter image description here

\documentclass{article}
\usepackage{phonrule}
\newcommand\oneofl[1]{\ensuremath{\left\{\begin{tabular}{l} #1 \end{tabular}\right.}}
\begin{document}

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

\end{document}
  • This is actually quite nice, but I chose egreg's answer because it is more comprehensive and gives several additional options that I don't need but could be useful in the future. Wish I could accept both as answers for different reasons. – whatisit Dec 4 '16 at 0:11
  • By the way, the image you includes seems like the underscore before z and the left bracket are not perfectly aligned with each other... I was a bit curious why and if there's a way to tweak them to line up? – whatisit Dec 4 '16 at 0:18
  • @whatisit Thanks for the note. The aligned material was typeset in math mode instead of text mode; spacing is different in this case. I have corrected it. – gernot says Reinstate Monica Dec 4 '16 at 0:33
  • Gotcha, thanks for the explanation. I don't really use math mode so I wouldn't have thought of that. Perhaps you could edit your answer to include both, in case someone sees this in the future and prefers either or. – whatisit Dec 4 '16 at 22:58

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.