[comp.text] Underlining in troff

morrell@hpsal2.HP.COM (Michael Morrell) (09/23/88)

Does anyone have a macro which does proper underlining in troff.  The one
supplied in the nroff/troff manual works provided the string to be underlined
does not cross a line.  For example, the following input failed miserably:

   .de us
   \\$1\l'|0\(ul'
   ..
   This is some text before the underlined stuff.
   This is some more text before the underlined stuff.
   .us "This is a very long line which will mess up the .us macro."

I got an underline of the appropriate length but it was all on the second line
with the last part of the "This is a very long line ..." sentence.

Any help would be greatly appreciated.  Thanks,

  Michael

P.S. The "u" macro supplied with the me macros is almost identical to the
above definition, and therefore, fails also.

kg@elan.UUCP (Ken Greer) (09/25/88)

From article <2610013@hpsal2.HP.COM>, by morrell@hpsal2.HP.COM (Michael Morrell):
> Does anyone have a macro which does proper underlining in troff.  The one
> supplied in the nroff/troff manual works provided the string to be underlined
> does not cross a line.

There is no general mechanism in troff, however one can do what you
want if you know the printer you're using.  Since I know you're an
Eroff and LaserJet user, Mike, here's how you do it in Eroff.
I've posted this for the sake of other Eroff users since this 
is a *very* common question we get!

For the LaserJet with Eroff...

|	.ds U+ \X'code="\e033&dD"'
|	.ds U- \X'code="\e033&d@"'

and just use \*(U+ when you want to start underlining and \*(U- to stop.
Works fine across line boundaries.  If you prefer macros...

|	.de us
|	\\*(U+\\$1\\*(U-
|	..
-- 
Ken Greer
Elan Computer Group, Inc.
{ames,hplabs,uunet}!elan!kg
415-322-2450

cosell@bbn.com (Bernie Cosell) (09/25/88)

In article <353@elan.UUCP> kg@elan.UUCP (Ken Greer) writes:
}From article <2610013@hpsal2.HP.COM>, by morrell@hpsal2.HP.COM (Michael Morrell):
}> Does anyone have a macro which does proper underlining in troff.  ...
}
}There is no general mechanism in troff, however one can do what you
}want if you know the printer you're using.  ...
}
}For the LaserJet with Eroff...
}
}|	.ds U+ \X'code="\e033&dD"'
}|	.ds U- \X'code="\e033&d@"'
}
}and just use \*(U+ when you want to start underlining and \*(U- to stop.
}Works fine across line boundaries.  If you prefer macros...
}
}|	.de us
}|	\\*(U+\\$1\\*(U-
}|	..

  But it doesn't work fine across *page* boundaries.  To get it really right,
  you have to have U+ set a global, and have the footnote, float and
  header/footer machinery push and pop U+/- mode appropriately.

   __
  /  )                              Bernie Cosell
 /--<  _  __  __   o _              BBN Sys & Tech, Cambridge, MA 02238
/___/_(<_/ (_/) )_(_(<_             cosell@bbn.com

pls@sorsac.UUCP (P. L. Sullivan) (09/26/88)

In article <2610013@hpsal2.HP.COM> morrell@hpsal2.HP.COM (Michael Morrell) writes:
>Does anyone have a macro which does proper underlining in troff.

In case you're using LaserJets (or anything else that has a similar built-in
underlining capability), the following technique may help.

We defined two special characters in the S font: ``\(US'' and ``\(UE'' to
start and end underlining.  The post-processor translates these into the
sequences ``\033&dD'' and ``\033&d@'' for the LaserJet family.

The only real kludge with this technique is that we need to tell troff to
do these characters zero width; e.g.,

	The word \z\(USunderlined\z\(UE is underlined.

========================================================
Pat Sullivan {gatech|att|akgua}!sorsac!pls (404)573-7382

johnk@opel.UUCP (John Kennedy) (08/23/89)

- I'm using troff and a laser jet filter (actually, eroff).

- Is there a way I can get font #2 to produced underlined output
  instead of italicized, ala the way nroff substitutes underlines
  for italics?   It seems I once read about a reg you could set
  that would effect this globally, but I can't find it now.

Thanks in advance,


John

-- 
John Kennedy                     johnk@opel.UUCP
Second Source, Inc.
Annapolis, MD

jos@idca.tds.PHILIPS.nl (Jos Vos) (08/24/89)

In article <266@opel.UUCP> johnk@opel.UUCP (John Kennedy) writes:

>- Is there a way I can get font #2 to produced underlined output
>  instead of italicized, ala the way nroff substitutes underlines
>  for italics?   It seems I once read about a reg you could set
>  that would effect this globally, but I can't find it now.

I never did hear about such a hidden register. And I really think
it isn't possible. Only by letting your postprocessor generating
an underlined character for every character in some font.
But then you have to adapt your postprocessor (source).

-- 
-- ######   Jos Vos   ######   Internet   jos@idca.tds.philips.nl   ######
-- ######             ######   UUCP         ...!mcvax!philapd!jos   ######