Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm having the following problem. I'm using a tabular environment to create a phrase structure rule (linguistics stuff, don't care about it) and I need parentheses for those parts in the rule which are optional. This is a demo code of what I'm using:

\documentclass{article}

\newcommand{\symb}[2]{%
\begin{tabular}[t]{c}
\normalsize{#1}\\
\footnotesize{#2}
\end{tabular}}
% Optional rule support
\newcommand{\opt}[1]{\ensuremath{\left(#1\right)}}
% Macros
\newcommand{\ra}{\ensuremath{\rightarrow}}
\newcommand{\ua}{\ensuremath{\uparrow}}
\newcommand{\da}{\ensuremath{\downarrow}}
\newcommand{\blank}{\ensuremath{\quad}}

\begin{document}
    \symb{IP}{}\blank
    \symb{\ra}{}\blank
    \opt{
        \begin{tabular}[t]{c}
            \normalsize{TopicP}\\
            \footnotesize{{\sc (\ua topic) = \da}}\\
            \footnotesize{{\sc (\ua topic) = (\ua TopicPath)}}
        \end{tabular}
    }\blank
    \opt{\symb{IP}{\ua = \da}}
\end{document}

I know the code isn't the most elegant thing you'll ever see. It's because I've had to modify a somewhat well-known macro used for LFG phrase structure rules... which sadly doesn't support more than one annotation. Thus, I'm using the tabular in order to have more than one annotation under the phrasal category (NP, IP, whatever).

Thanks!

share|improve this question
add comment

3 Answers 3

Delete the optional [t] positioning argument from the tabulars; to keep the alignment of IP -> with the first line of the you can use another three row tabular, having \symb{IP}{}\blank\symb{\ra}{}\blank in the first row and two other empty rows:

\documentclass{article}

\newcommand{\symb}[2]{%
\begin{tabular}{c}
\normalsize #1\\
\footnotesize #2
\end{tabular}}
% Optional rule support
\newcommand{\opt}[1]{\ensuremath{\left(#1\right)}}
% Macros
\newcommand{\ra}{\ensuremath{\rightarrow}}
\newcommand{\ua}{\ensuremath{\uparrow}}
\newcommand{\da}{\ensuremath{\downarrow}}
\newcommand{\blank}{\quad}

\begin{document}
    \begin{tabular}{@{}c@{}}
    \symb{IP}{}\blank
    \symb{\ra}{}\blank \\ \\
    \end{tabular}%
    \opt{
        \begin{tabular}{c}
            \normalsize{TopicP} \\
            \footnotesize \scshape (\ua topic) = \da\\
            \footnotesize \scshape (\ua topic) = (\ua TopicPath)
        \end{tabular}
    }\blank
    \opt{\symb{IP}{\ua = \da}}

\end{document}

enter image description here

I also changed the obsolete \sc to \scshape and suppressed some superfluous braces (\fontnotesize, \normalsize and \schape don't take arguments). Also, as egreg mentions in his comment, since \quad is not a math mode command, \newcommand{\blank}{\quad} is a more correct definition.

share|improve this answer
    
Also \quad is not a math mode command, so \newcommand{\blank}{\quad} is "more correct"; \footnotesize and \normalsize don't take arguments. –  egreg Nov 21 '12 at 0:31
    
@egreg you're right about \blank; (about the font declarations too, but I had already made the changes and the comment). –  Gonzalo Medina Nov 21 '12 at 0:56
    
@egreg Ah, now I see that I had missed some font declarations still with braces; I've fixed them too now. Thnaks. –  Gonzalo Medina Nov 21 '12 at 0:59
add comment

Remove the position specifier [t] in \begin{tabular}{c} everywhere:

\documentclass{article}

\newcommand{\symb}[2]{%
\begin{tabular}{c}
\normalsize{#1}\\
\footnotesize{#2}
\end{tabular}}
% Optional rule support
\newcommand{\opt}[1]{\ensuremath{\left(#1\right)}}
% Macros
\newcommand{\ra}{\ensuremath{\rightarrow}}
\newcommand{\ua}{\ensuremath{\uparrow}}
\newcommand{\da}{\ensuremath{\downarrow}}
\newcommand{\blank}{\ensuremath{\quad}}

\begin{document}
    \symb{IP}{}\blank
    \symb{\ra}{}\blank
    \opt{
        \begin{tabular}{c}
            \normalsize{TopicP}\\
            \footnotesize{{\sc (\ua topic) = \da}}\\
            \footnotesize{{\sc (\ua topic) = (\ua TopicPath)}}
        \end{tabular}
    }\blank
    \opt{\symb{IP}{\ua = \da}}
\end{document}

enter image description here

The specifier [t] will align the tabular at the top, [c] at the center and [b] at the bottom as noted by cyberSingularity.

share|improve this answer
    
Hm... but that doesn't make the tabular to be aligned to the top of the "IP ->" –  nvteighen Nov 21 '12 at 0:16
    
And similarly in the definition of \symb for the "IP". It might be worth explaining why the issue is caused and what [t] and [c] (default) do. –  cyberSingularity Nov 21 '12 at 0:16
    
@cyberSingularity: Thanks I missed that. –  Harish Kumar Nov 21 '12 at 0:25
add comment

If you want top aligned tables with delimiters you can use delarray

enter image description here

\documentclass{article}

\usepackage{delarray}

\newcommand{\symbx}[4]{%
\begin{tabular}[t]#1{c}#2
\normalsize{#3}\\
\footnotesize{#4}
\end{tabular}}
\newcommand\symb{\symbx{}{}}
\newcommand\bsymb{\symbx()}
% Optional rule support
\newcommand{\opt}[1]{\ensuremath{\left(#1\right)}}
% Macros
\newcommand{\ra}{\ensuremath{\rightarrow}}
\newcommand{\ua}{\ensuremath{\uparrow}}
\newcommand{\da}{\ensuremath{\downarrow}}
\newcommand{\blank}{\ensuremath{\quad}}

\begin{document}
    \symb{IP}{}\blank
    \symb{\ra}{}\blank
        \begin{tabular}[t]({c})
            \normalsize{TopicP}\\
            \footnotesize{{\sc (\ua topic) = \da}}\\
            \footnotesize{{\sc (\ua topic) = (\ua TopicPath)}}
        \end{tabular}
    \blank
    \bsymb{IP}{\ua = \da}
\end{document}
share|improve this answer
    
Note I only addressed the question of alignment, @egreg's comments re font command usage all apply:-) –  David Carlisle Nov 21 '12 at 0:35
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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