
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%% CCG stuff originally by B. Hoffman, modified by mjs
%frig \mathbf for combinators to sans:
\DeclareMathAlphabet{\mathbf}{OT1}{cmss}{bx}{n}

\newcommand{\bs}{\backslash}
\newcommand{\Tc}{{\mathbf T}}
\newcommand{\Bc}{{\mathbf B}}
\newcommand{\Sc}{{\mathbf S}}
\newcommand{\bu}{\%}%{\S}%{\letterspace to 0.82\naturalwidth{\%\%}}
\newcommand{\mathasterisk}{\raisebox{0pt}{*}}%an asterisk raised as in
                                             %textmode for mathmode

%frig \mathbf for combinators to sans:
\DeclareMathAlphabet{\mathbf}{OT1}{cmss}{bx}{n}

%somehow does #1 many c's
% CCG derivations
% arguments: #1 = no. of words, #2 = body
\newcommand{\deriv}[2]
{ %\arraycolsep=.25em
   \renewcommand{\arraystretch}{0.5}
  $\begin{array}[t]{@{}*{#1}{c@{~~}}}
     #2
   \end{array}$ }

% centered multicolumn, 
\newcommand{\mc}[2]
  {\multicolumn{#1}{c}{#2}}
%\newcommand{\less}{\\ \vspace{-.5ex}}
% Rules, argument #1 gives the number of columns to cover.
\newcommand{\uline}[1]
{\mc{#1}{\hrulefill} }
\newcommand{\fapply}[1]
{ \mc{#1}{\hrulefill_{>}} }
\newcommand{\bapply}[1]
{ \mc{#1}{\hrulefill_{<}} }
\newcommand{\fcomp}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{B}}}}
\newcommand{\fxcomp}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{B}_{\times}}}}
\newcommand{\fcomptwo}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{B}^2}}}
\newcommand{\fxcomptwo}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{B}_{\times}^2}}}
\newcommand{\fcompthree}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{B}^3}}}
\newcommand{\bcomp}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{B}}}}
\newcommand{\bxcomp}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{B}_{\times}}}}
\newcommand{\bcomptwo}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{B}^2}}}
\newcommand{\bxcomptwo}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{B}_{\times}^2}}}
\newcommand{\bcompthree}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{B}^3}}}
\newcommand{\bxcompthree}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{B}_{\times}^3}}}
\newcommand{\fsubst}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{S}}}}
\newcommand{\fxsubst}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{S}_{\times}}}}
\newcommand{\bxsubst}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{S}_{\times}}}}
\newcommand{\ftype}[1]
{ \mc{#1}{\hrulefill_{{>}\mathbf{T}}}}
\newcommand{\btype}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{T}}}}
\newcommand{\conj}[1]
{ \mc{#1}{\hrulefill_{{<}\Phi{>}}}}
\newcommand{\boundary}[1]
{ \mc{#1}{\hrulefill_{{<}\mathbf{\%}}}}
\newcommand{\asterisk}[1]
{ \mc{#1}{\hrulefill_{\mathbf{*}}}}
\newcommand{\comb}[2] % an arbitrary combinator
{ \mc{#1}{\hrulefill_{#2}}}
\newcommand{\dcomp}[2] % an arbitrary dcomposition
{ \mc{#1}{\dotfill_{#2}}}
\newcommand{\unfreeze}[1]
{\mc{#1}{\hrulefill_{\mathbf{@}}}  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% stuff to allow stuff besides brackets in citation labels
%\makeatletter
%\newcommand{\citedelimiters}[2]{    %change opening and closing brackets
%\def\@cite##1##2{#1{##1\if@tempswa , ##2\fi}#2}
%\def\@biblabel##1{#1##1#2\hfill}
%}
%\makeatother

%\citedelimiters{}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%% Examples
%%Notice that the example envirnment shrinks tabcolsep

%%%\newcounter{example}
\newlength{\labellength}
\newlength{\textlength}

%tried to change this to give less of a space at the beginning so
 %works better for two-column acl format - SC

%%%\newenvironment{example}
%%%{\begin{list}{}{\setlength{\itemindent}{0em}\settowidth{\labelwidth}{(\theexample)}\setlength{\labelsep}{0.5em}\settowidth{\leftmargin}{(\theexample)\makebox[0.5em]{}}\setlength{\topsep}{5pt}\setlength{\partopsep}{0ex}}
%%%\refstepcounter{example}\setlength{\tabcolsep}{1pt}}{\end{list}}

\newcommand{\startx} %cg example
 {\begin{example}\rm\settowidth{\labellength}{(\theexample)\makebox[0.5em]{}}\setlength{\textlength}{\textwidth}\addtolength{\textlength}{-\labellength}
  \item[(\theexample)]\begin{minipage}[t]{\textlength}}

\newcommand{\startxl}[1] %labelled cg example
 {\begin{example}\rm\settowidth{\labellength}{(\theexample)\makebox[0.5em]{}}\setlength{\textlength}{\textwidth}\addtolength{\textlength}{-\labellength}
  \label{#1}
  \item[(\theexample)]\begin{minipage}[t]{\textlength}}

\newcommand{\startpx} %paragraph example
 {\begin{example}\rm\settowidth{\labellength}{(\theexample)\makebox[0.5em]{}}\setlength{\textlength}{\textwidth}\addtolength{\textlength}{-\labellength}
  \item[(\theexample)]\begin{minipage}[t]{\textlength}}%{3.5in}}

\newcommand{\startpxl}[1] %labelled paragraph example
 {\begin{example}\rm\settowidth{\labellength}{(\theexample)\makebox[0.5em]{}}\setlength{\textlength}{\textwidth}\addtolength{\textlength}{-\labellength}
  \label{#1}
  \item[(\theexample)]\begin{minipage}[t]{\textlength}}

\newcommand{\stopx} %end all numbered example
 {\end{minipage}
  \end{example}}

%\newcommand{\startfnx}[1] %cg example IN A FOOTNOTE--OBSOLETE BUGGY
% {\par\noindent #1\makebox[.5em]{}
%  \setlength{\tabcolsep}{1pt}\settowidth{\labellength}{#1\makebox[0.5em]{}}\setlength{\textlength}{\textwidth}\addtolength{\textlength}{-\labellength}
%  \begin{minipage}[t]{\textlength}}
%
%\newcommand{\stopfnx} %end example in footnote
% {\end{minipage}\\}
%

\newcounter{fnexample}
\newenvironment{fnexample} 
{\begin{list}{}{\setlength{\itemindent}{0em}\settowidth{\labelwidth}{(\roman{fnexample})}\setlength{\labelsep}{0.5em}\settowidth{\leftmargin}{(\roman{fnexample})\makebox[0.5em]{}}\setlength{\topsep}{0pt}\setlength{\partopsep}{0ex}}
\refstepcounter{fnexample}\setlength{\tabcolsep}{1pt}}{\end{list}}

\newcommand{\startfnx} %cg example IN A FOOTNOTE DOES NOT TAKE ARG #1
 {\begin{fnexample}\rm\settowidth{\labellength}{(\roman{fnexample})\makebox[0.5em]{}}\setlength{\textlength}{\textwidth}\addtolength{\textlength}{-\labellength}
 \item[(\roman{fnexample})]\begin{minipage}[t]{\textlength}}

\newcommand{\stopfnx} %end example in footnote/endnote
 {\end{minipage}
  \end{fnexample}}

\newcommand{\lefta}[1]{\stackrel{\leftarrow}{#1}}
\newcommand{\righta}[1]{\stackrel{\rightarrow}{#1}}

\newcommand{\exref}[2][\mbox{}]{(\ref{#2}#1)}

% the body of an example made up of several unlabelled items
\newenvironment{exlist}{\begin{list}{}{\setlength{\itemsep}{0ex}\setlength{\parsep}{\parskip}\setlength{\leftmargin}{0in}\setlength{\itemindent}{0ex}\setlength{\labelsep}{0em}\setlength{\labelwidth}{0em}\setlength{\topsep}{0ex}\setlength{\partopsep}{0ex}}}{\end{list}}

\newcounter{lexlistcounter}
% the body of an example made up of several LABELLED items
\newenvironment{lexlist}{\begin{list}{\alph{lexlistcounter}.}{\usecounter{lexlistcounter}\setlength{\itemsep}{0ex}\setlength{\parsep}{\parskip}\settowidth{\leftmargin}{\thelexlistcounter .\makebox[0.5em]{}}\setlength{\labelsep}{0.5em}
\setlength{\itemindent}{0em}\setlength{\topsep}{0ex}\setlength{\partopsep}{0ex}\setlength{\labelwidth}{1em}
}}{\end{list}}

\newcounter{nexlistcounter}
% the body of an example made up of several LEFT-JUSTIFIED ROMAN NUMBERED items
\newenvironment{nexlist}[1]{\begin{list}{\roman{nexlistcounter}.\hfill}{\usecounter{nexlistcounter}\setlength{\itemsep}{0ex}\setlength{\parsep}{\parskip}\settowidth{\labelwidth}{#1 .}\addtolength{\labelwidth}{0.25em}\setlength{\labelsep}{0.0em}
\setlength{\itemindent}{0em}\setlength{\topsep}{0ex}\setlength{\partopsep}{0ex}\setlength{\leftmargin}{\labelwidth}%\addtolength{\leftmargin}{0.5em}
}}{\end{list}}

%\newcounter{nexlistcounter}
%% the body of an example made up of several NUMBERED items
%\newenvironment{nexlist}{\begin{list}{\arabic{nexlistcounter}.}{\usecounter{nexlistcounter}\setlength{\itemsep}{0ex}\setlength{\parsep}{\parskip}\setlength{\leftmargin}{2em}\setlength{\labelsep}{1em}
%\setlength{\itemindent}{0em}\setlength{\topsep}{0ex}\setlength{\partopsep}{0ex}\setlength{\labelwidth}{2em}
%}}{\end{list}}

% for figures
% FIGURES
\newenvironment{myfigure}{\begin{figure}[t]}{\end{figure}}

\newcounter{myfigure}
\newcommand{\mycaption}[1]{\vskip
10pt\refstepcounter{myfigure}\begin{minipage}{\textwidth}{\bf
Figure \themyfigure \\} {\rm #1}\end{minipage}}

\newcommand{\ldb} % left double bracket math mode
{[ \makebox[.1em][r]{\raisebox{0ex}{$[$}}}

\newcommand{\rdb} % right double bracket math mode
{] \makebox[.1em][r]{\raisebox{0ex}{$]$}}}

% superscripts and subscripts *in text*
\newcommand{\textsup}[1]{\raisebox{.8ex}[0pt][0pt]{\scriptsize#1}}
\newcommand{\textsub}[1]{\raisebox{-.8ex}[0pt][0pt]{\scriptsize#1}}

% make an empty box the width of text #1
\newlength{\mystringwidth}
\newcommand{\makeboxtowidth}[1]{\settowidth{\mystringwidth}{#1}\makebox[\mystringwidth]{}}

\newcommand{\hangingpar}[4]{#1#3}%a dummy

%%%Stuff to hang a long example beneath things like *prefixes
\newlength{\funnylength}
\newlength{\hanginglength}
\newcommand{\myindent}[1]{\settowidth{\hanginglength}{#1}\makebox[\hanginglength]{}}%indents width of #1
\newcommand{\starindent}{\myindent{*}}%indents an asterisk worth
\newcommand{\hangmyindent}[2]{\setlength{\funnylength}{\linewidth}\settowidth{\hanginglength}{#1}\addtolength{\funnylength}{-\hanginglength}\parbox[t]{\funnylength}{#2}}%makes parbox right size
