[comp.text.tex] Request for a more intelligent underline{} macro.

grunwald@foobar.colorado.edu (Dirk Grunwald) (01/15/91)

Actually, some one mailed me the underline code. A little hacking
produces the following example. The original code was a little liberal
with spaces in the code, which produces an extra space after each word
in the underlined region. This version corrects that and gives a
single underlined space between words.

\documentstyle{article}

\def\underl#1 {\leavevmode\let\first=\relax\underli #1 }
\def\underli#1 {\ifx&#1\let\next=\relax\unskip
                \else\let\next=\underli\first\ulinebox{#1}\fi\let\first=\undersp\next}
\def\undersp{\penalty50\ulinebox{\space}\penalty50}
\def\ulinebox#1{\vtop{\hbox{\strut#1}\hrule}}%Taken from TexHax v.88, 52


\begin{document}
\underl now is the time for all now is the time for all good men to now is the time now is the nownownow now iw is fhgdkhfd dfygdfg fkudshf &
\end{document}

Damian.Cugley@prg.ox.ac.uk (Damian Cugley) (01/15/91)

From:		Dirk Grunwald <grunwald@foobar.colorado.edu>
Message-Id:	<1991Jan14.235759.5765@csn.org>

> Actually, some one mailed me the underline code. A little hacking
> produces the following example [deleted]. The original code was a
> little liberal with spaces in the code, which produces an extra space
> after each word in the underlined region.

> This version corrects that and gives a single underlined space between
> words.

But the "space" it gives is (a) rigid (defeating right-justification)
and (b) doesn't dissappear at the margin.  I think you could usefully
replace the \ulinebox{\space} with 
\leaders\somesortofunderlinedbox\hskip\spaceskiporsimilar.

Also, the line this code produces is too low -- it looks silly and makes
the lines taller.  Having the underscore cutting through the descenders
seems to look better to me.  Better still either use a special
pre-underlined font or DON'T USE UNDERLINING AT ALL (I can't think of a
good reason for it except in legal documents when pedantry requires it).

 //- Damian Cugley ----\  /--- Oxford University Computing Laboratory, -\ 
 ||  pdc@prg.ox.ac.uk  || \--- 11 Keble Rd, Oxford, UK  OX1 3QD --------/ 
 ||  pdc@uk.ac.ox.prg  ||                                               
  \--------------------//   "His feet are the wrong size for his shoes."