% tipaman.sty for TIPA Manual

\ifTUG
  \def\Sep{\\}
  \def\ipaitem#1#2#3#4#5#6#7{\leavevmode
    \def\@tipashortcut{\ifx\empty#5\empty\else\,(#5)\fi}%
    \setbox0\hbox to1.3em{\tipaencoding #1\hfil}%
    \setbox1\hbox{\copy0\texttt{#4\@tipashortcut}}%
    \ifdim\wd1>\hsize
      \hbox to\hsize{\box0\texttt{#4}\hfil}
      \hbox to\hsize{\hbox to1.3em{\hfil}\texttt{\@tipashortcut}\hfil#2}%
    \else
      \setbox1\hbox{\copy0\texttt{#4\@tipashortcut}\,#2}%
      \ifdim\wd1>\hsize
        \hbox to\hsize{\box0\texttt{#4\@tipashortcut}\hfil}
        \hbox to\hsize{\hfil#2}%
      \else
        \hbox to\hsize{\box0\texttt{#4\@tipashortcut}\hfil#2}%
      \fi
    \fi}
\else
  \def\Sep{}
  \newcount\charcount \charcount=0

  \def\patterni{\hbox to .8pt{%
    \hfil\vrule width .2pt height .1pt depth .1pt \hfil}}

  \def\patternii{\hbox to .8pt{%
    \hfil\vrule width .3pt height .15pt depth .15pt \hfil}}

  \def\charboxht{4.8ex} % height of normal charbox
  \def\charboxdp{2.4ex} % depth of normal charbox
  \def\charboxlen{3.4em}
  \def\charboxmargin{4pt}
  \def\charboxsep{.2em}
  \def\charboxtotalht{}

  {\setbox\z@\hbox{\Huge\tipaencoding l}\xdef\ascheight{\the\ht\z@}
   \setbox\z@\hbox{\Huge\tipaencoding x}\xdef\xheight{\the\ht\z@}
   \setbox\z@\hbox{\Huge\tipaencoding p}\xdef\descdepth{\the\dp\z@}}

  \def\@dottedline#1#2{%
    \dimen\z@\charboxht \advance\dimen\z@ by-#1\relax
    \vtop to\z@{\kern\the\dimen\z@
      \hbox to\charboxwd{\xleaders#2\hfil}\vss}}

  \def\ipaitem#1#2#3#4#5#6#7{{\leavevmode
    \setbox\z@\hbox{\tipaencoding\Huge #1}%
    \dimen\z@\ht\z@ \advance\dimen\z@ by\charboxmargin\relax
    \ifdim\dimen\z@>\charboxht \edef\charboxht{\the\dimen\z@}\fi
    \dimen\z@\dp\z@ \advance\dimen\z@ by\charboxmargin\relax
    \ifdim\dimen\z@>\charboxdp \edef\charboxdp{\the\dimen\z@}\fi
    \dimen\z@\charboxht \advance\dimen\z@ by\charboxdp\relax
    \edef\charboxtotalht{\the\dimen\z@}%
%
    \dimen\z@\charboxtotalht \advance\dimen\z@ by-1.2ex
    \raise\dimen\z@\hbox to\z@{\hss\global\advance\charcount by1
      \scriptsize\number\charcount\ }% serial number
    \raise .2ex\hbox to\z@{\hss\scriptsize\itshape #7\ }% char code
%
    \dimen\z@\wd\z@ \dimen\@ne\charboxmargin
    \advance\dimen\z@ by2\dimen\@ne
    \edef\charboxwd{\the\dimen\z@}\advance\dimen\z@ by\charboxsep\relax
    \ifdim\dimen\z@>\charboxlen \edef\charboxlen{\the\dimen\z@}\fi
%
    \hbox to\charboxlen{%
      \hbox to\charboxwd{\hsize\charboxwd
        \hss\vrule
        \vbox to\charboxtotalht{\offinterlineskip
          \hrule
          \@dottedline{\ascheight}{\patterni}
          \@dottedline{\xheight}{\patterni}
          \@dottedline{\z@}{\patternii}
          \@dottedline{-\descdepth}{\patterni}
          \dimen\z@\charboxht \advance\dimen\z@ by-\ht\z@
          \kern\dimen\z@
          \hbox to\hsize{\hfil\box\z@\hfil}
          \vss
          \hrule}%
        \vrule\hss}\hfill}%
%
    \dimen\z@\textwidth \advance\dimen\z@ by-\charboxlen
    \vbox to\charboxtotalht{%
      \vss
      \hbox to\dimen\z@{#2%
        \ifx\empty#3\empty\else, \usage#3\fi\hfill}%
%      \kern.05ex
      \hbox to\dimen\z@{ %
        \ifx\empty#5\empty
          {\itshape Input:} {\ttfamily #4}%
        \else
          {\itshape Input1:} {\ttfamily #4}, {\itshape Input2:}\ 
          {\ttfamily #5}%
        \fi
        \hfill}%
%      \kern.05ex
      \setbox\z@\hbox{\tipaencoding #1\ {\slshape #1\/}\ %
        {\bfseries #1}\ {\sffamily #1}}%
      \hbox to\dimen\z@{ %
        {\itshape Styles:} \unhbox\z@, {\itshape Sources: #6}\hfill}%
      \vss}%
   }}

  \def\usage{\@ifstar{\nonipausage}{\ipausage}}
  \def\nonipausage{Usage: }
  \def\ipausage{{\itshape IPA usage:} }
  \def\ipaall{IPA '49--'93}
  \def\ipaold{IPA '49, '79}
  \def\ipanew{IPA '89, '93}
  \def\psg#1{\PSG\ p.\#1}
\fi % end of \ifTUG

\def\tbs{{\ttfamily\char'134}}
\def\tbi{{\ttfamily\char'173}}
\def\tbii{{\ttfamily\char'175}}
\def\ttilde{{\ttfamily\char'176}}
\def\tcircum{{\ttfamily\char'136}}
\def\TT#1{\tbi #1\tbii}
\def\TD#1#2{\tbs #1\tbi #2\tbii}
\def\Td#1#2{\texttt{\TD{#1}{#2}}}
\def\Tt#1{\texttt{\tbs #1}}

\def\PSG{{\slshape PSG\/}}

\newcount\excnt
\def\@inout{i}
\def\yitem{\if i\@inout
 \item[{\itshape Input\/}:]\def\@inout{o}\else
 \par\nobreak\item[{\itshape Output\/}:]\def\@inout{i}\fi}

\ifTUG
  \newenvironment{tipaexample}{%
    \begin{list}{}{\excnt=1%
    \setlength\labelsep{.5em}%
    \setlength\labelwidth{4em}%
    \setlength\leftmargin{4.5em}%
    \setlength\parsep{0pt}}}%
    {\end{list}}
  \def\xitem{\if i\@inout
   \item[{\itshape Input\the\excnt\/}:]\def\@inout{o}\else
   \par\nobreak\item[{\itshape Output\the\excnt\/}:]\def\@inout{i}%
   \global\advance\excnt by1\fi}
\else
  \newenvironment{tipaexample}{%
    \begin{list}{}{\excnt=1%
    \setlength\labelsep{1em}%
    \setlength\labelwidth{5em}%
    \setlength\leftmargin{6.5em}%
    \setlength\parsep{0pt}}}%
    {\end{list}}
  \def\xitem{\if i\@inout
   \item[{\itshape Input \the\excnt\/}:]\def\@inout{o}\else
   \par\nobreak\item[{\itshape Output \the\excnt\/}:]\def\@inout{i}%
   \global\advance\excnt by1\fi}
\fi

\ifTUG
  \newenvironment{Quote}{\medskip}{\medskip}
\else
  \def\labelenumi{(\theenumi)}
  \newenvironment{Quote}{\begin{quote}}{\end{quote}}
\fi

\endinput
