4

I want to typeset AVMs. A colleague wrote the following code and it works quite well. However there is a little problem with the brackets. Some of them are not aligned properly. For example the second closing bracket is too low:

enter image description here

This is the code. \ms checks whether a type (set in italics) is provided as optional argument or not.

\documentclass{article}


\usepackage{array}

\setlength{\extrarowheight}{1pt}

\def\ms{\futurelet\msLook\msdecide}
\def\msdecide{\ifx\msLook[\let\next=\xxtms%
\else\let\next=\xxms\fi\next}
%
\def\xxtms[#1]#2{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
#2%
\multicolumn{2}{>{\normalfont\itshape}l}{#1}%
\end{tabular}%
\right]%
$%
}%
\vspace{1mm}%
}

\def\xxms#1{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}

\begin{document}

\ms[word]{
syntax-semantics & \ldots \ms[local]{ category  & \ms[category]{ head & \ms[noun]{ case & 1\\
                                                                                               }\\[6mm]
                                                                               subcat & Det[\textsc{case}~1] \\
                                                                             } \\[6mm]
                                          content & \ldots \ms[grammatik]{ inst & X \\
                                                                                    }\\
            }\\
}



\end{document}

Edit:

There seems to be a problem with cases like this:

\ms{
synsem$|$loc$|$cat \ms{ head & \ms[verb]{vform & fin
                                       }\\
                        subcat & \ldots\\
                      }
}

The output looks like this:

enter image description here

The problem is that there is too much space between the two right-most brackets.

4
  • 1
    Your colleague must have been studying Bechtolsheim's books. ;-)
    – egreg
    Feb 24, 2016 at 16:46
  • 1
    Of course the problem is due to @{\hspace{5pt}} which has nothing to do with the size of brackets. If you want to open a new question for this you're welcome. Changing questions so that they invalidate already given and working answers is against the site's guidelines.
    – egreg
    Mar 1, 2016 at 10:06
  • The solution is pushing the skip in the second column: \begin{tabular}{>{\upshape\scshape}l@{}>{\hspace*{5pt}\normalfont\itshape}l}
    – egreg
    Mar 1, 2016 at 10:09
  • Ehm, sorry. I thought about this, but then thought it is the same issue and somehow may be related to the solution ... Thanks! I will put it into a new question. Mar 1, 2016 at 11:32

1 Answer 1

5

You probably want to set \delimiterfactor=1000 and \delimitershortfall=0pt, so as to ensure the delimiters will always cover the array.

I changed the code for \ms in order to avoid code duplication; also it's not necessary (and wrong, now) to end the argument to \ms with \\.

\documentclass{article}

\usepackage{array}

\setlength{\extrarowheight}{1pt}

\makeatletter
\newcommand{\ms}[2][]{%
  \mbox{%
    \delimiterfactor=1000 \delimitershortfall=0pt
    \tabcolsep=0pt
    $\left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}
    #2%
    \if\relax\detokenize{#1}\relax\else
     \\ \multicolumn{2}{>{\normalfont\itshape}l}{#1}%
    \fi
    \end{tabular}%
    \right]$%
  }%
  \vspace{1mm}%
}

\begin{document}

\ms[word]{
  syntax-semantics & \ldots 
  \ms[local]{
    category &
    \ms[category]{
      head & \ms[noun]{ case & 1 }
      \\[6mm]
      subcat & Det \ms{ case & 1 }
    }
    \\[6mm]
    content & \ldots \ms[grammatik]{ inst & X }
  }
}

\end{document}

There's a problem with one row \ms objects (I left one just for showing it). The solution would be not using \ms in this case, but \textup[ and \textup] should be used for the brackets.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .