[comp.text] In troff, is "|" supposed to be slanted in Italic? +fix

lee@sq.sq.com (Liam R. E. Quin) (05/12/91)

(There's a short sed sript enclosed as a work-around for this problem...)

Chris Lewis (clewis@ferret.ocunix.on.ca) said:
>    1) eqn has a bug in that it is requesting "|" instead of \(br in this
>       context.  \(br is in the Symbol font in both CAT troff and probably
>       most ditroff's width tables.  \(br would make more sense in the
>       context of eqn requesting vertical lines.
>       It gets big square brackets right, why not this?
>       All eqn's seem to request "|" rather than \(br, but only certain
>       eqn's make the mistake in (2) that makes it noticable.
>       "|" is a character, NOT a line drawing "part".

I agree with Chris -- it is a bug that has arisen because of the way
in which left <thing> and righ <thing> are handled by eqn.  Note that
if you type | elsewhere in eqn input, it does come out in Roman.

>    3) I'm not sure whether I agree with Brian (that only alphanumerics
>       should be slanted in an Italic font), but eqn shouldn't insist
>       on it either.  If you go by Brian's insistance, then you lose a lot
>       of potentially useful glyphs.

Whilst I can't claim to be on first-name terms with Brian Kernighan :-), I
again agree to a large extent with Chris.  Actually I have seen some very
frustrated mathematicians when they first saw the italic < and > signs that
a very old versiqon of xroff used to generate...  and I've seen other troffs
do the same since.
The answer, I think, is that one should be able to access both sets of
symbols, but that the default ought to be to use the roman (unslanted) face.

Note that if one follows the C/A/T scheme of having | on a search font,
one then can't get at a Courier "|" sign, which Unix users often want, as in
	ls | rev | sort | cat > /dev/null

If you have the eqn source, it's easy to change the two (I think) lines that
use | instead of \(br.  If you don't have source, here is a fairly
straight-forward way to use sed to fix the eqn output.

	sed -e '/\\b'"'"'||*/s/\([^\\]\)|/\1\\(br/g' \
	    -e '/\\(br|/s/br|/br\\(br/g'
(with /bin/sh) will work.

For example

	#! /bin/sh
	: put this line first instead of the #! one on System V
	/usr/bin/eqn ${@+"$@"} |
	sed -e '/\\b'"'"'||*/s/\([^\\]\)|/\1\\(br/g' \
	    -e '/\\(br|/s/br|/br\\(br/g'

if placed before /usr/bin in one's $PATH, will do what's wanted.
The shell quoting gymnastics make sed see the string
	sed -e /\\b'||*/s/\([^\\]\)|/\1\\(br/g -e /\\(br|/s/br|/br\\(br/g
but it's necessary to use '...' to stop \ being interpreted by the shell,
and then we can't put a ' in the script, so we end the quotes, and put a
single quote inside double quotes ("'") on the end, then start single quotes
again, which results in '"'"' and looks rather pretty, in a way.
This turns eqn output such as
    .ds 11 \|\v'-3u'\b'|||'\v'3u'\*(11\|\v'-3u'\b'|||'\v'3u'
into
    .ds 11 \|\v'-3u'\b'\(br\(br\(br'\v'3u'\*(11\|\v'-3u'\b'\(br\(br\(br'\v'3u'
which by inspection is obviously correct. :-)


In case you're tempted to try turning | into
	roman "\(br"
in the eqn input, remember that DWB eqn has a file inclusion mechanism.
Also, the grammar treats
	left |
and
	left roman "\(br"
differently from each other in some versions of eqn.

But you could get that approach to work too if you wanted.
Still another way is
	.EQ
	define | % roman "\(br" %
	.EN
which will work on most (not all) versions of eqn out there, I think.

Lee

-- 
Liam Russell Quin, SoftQuad Inc., Toronto... 416 963 8337... lee@sq.com
	   `What one person finds valuable others do not even notice.
	    And they do not notice that they do not notice.'
-- Scott Kim, `Interdisciplinary Communication', in `The Art of [HCI] Design'