hansen@pegasus.UUCP (Tony L. Hansen) (11/08/84)
I'm having problems with the following constructs (created by a filter that I have): \h'0-\w'Dequeuing'/2u+14n'Dequeuing or 'nr XX 0-\w'Dequeueing'/2u+14n \h'\n(XX'Dequeueing The idea is to move over a certain distance and then center a given string at that location. (Fill mode is turned off during this operation.) The \w'foo'/2u should return half the width of the string. Subtracting that from zero and adding 14n should place the middle of the string at 14n to the right of where we started. The ditroff output from the above example follows. As can be seen from the h4488c, the string is being written off in right field rather than towards the left of the paper where the string belongs. The font used doesn't seem to make any difference. Does anyone have any ideas what is going wrong with the above? I have tried writing it in a number of different ways, none of which seem to work. Is it something stupid on my part or something subtle? Please reply by mail and I'll summarize anything of interest that I find out. Tony Hansen pegasus!hansen x T imp x res 240 1 1 x init x font 1 R x font 2 I x font 3 B x font 4 T x font 5 L x font 6 LB x font 7 H x font 8 S V0 p1 s10 f1 H232 V40 h4488cD 27e17q19u21e17u21e17i11n21gn40 0 x trailer V2640 x stop
edmoy@ucbopal.CC.Berkeley.ARPA (11/09/84)
>I'm having problems with the following constructs (created by a filter that I >have): > >\h'0-\w'Dequeuing'/2u+14n'Dequeuing > > or > >'nr XX 0-\w'Dequeueing'/2u+14n >\h'\n(XX'Dequeueing The default units for \h are em's, while the output of \w is units. So use: \h'0-\w'Dequeuing'u/2u+14n'Dequeuing or 'nr XX 0-\w'Dequeueing'/2u+14n \h'\n(XXu'Dequeueing Ed Moy Computing Services University of California, Berkeley
hansen@pegasus.UUCP (11/14/84)
Thank you to everyone who responded to my question on troff. My question had
to do with using the width of a string within a \h construct to do
horizontal movement, as in:
\h'0-\w'foo'/2u+14n'
The trouble boils down to the fact that the \w construct returns a number,
scaled in units, for the width. The fact that scaling has already occurred
is not returned. Then \h takes that number and scales it AGAIN with the
default scaling of an em. The solution is to add a 'u' after the \w to
indicate to troff that the number is already scaled, as in:
\h'0-\w'foo'u/2u+14n'
^
|
As one person put it,
< The key here is that troff is incredibly stupid about units.
< It is safest to always put a units specifier on everything.
Thanks again. I hope that this short note will save someone else grief at
some time in the future.
Tony Hansen
pegasus!hansen