% underline.tex   bert@mit.edu   Oct 13 1994
%
% TeX equivalent of underline.sty (see that for comments)

\catcode`@=11

\let\lineunder=\underline
\def\underline#1{\relax\ifmmode \lineunder{#1}\else\text@underline{#1}\fi}

% this separates the argument into words, etc.  Use the TeXbook, Luke.

\def\text@underline#1{{\expandafter\under@word\ignorespaces#1 }}
\def\under@word#1 {\underbar{#1}\futurelet\@tempa\under@cont}
\def\under@cont{\if\@tempa\egroup\else\under@space\under@word\fi}

% stuff for \underlinespaces: defines \under@space as whatever the spaces go to

\def\nounderspace{\let\under@space=\space}
\def\underspace{\def\under@space{\discretionary{}{}{\hbox{\underbar{ }}}%
\nobreak\hskip0pt minus1pt}}

\nounderspace  % initialize default

\catcode`@=12
