Further to my previous post, first here is a revision of the .PS and .PE macros in the 'ms' macro set which allow the use of ".PS T" so as to (effectively) suppress any effect on the printed page. It is assumed that no drawing is done during a call to ".PS T <....> .PE".
--8<-- cut here ------------------------------------- .de PS .nr Tacit 0 .ie \\n[.$]<3 \{\ .br .sp \\n[DD]u .ie \\n[.$]<2 ....@error bad arguments to PS (not preprocessed with pic?) .el \{\ . d...@need (u;\\$1)+1v . in +(u;\\n[.l]-\\n[.i]-\\$2/2>?0) . \} .HTML-IMAGE .\} .el \{\ .if '\\$3'T' \{\ .nr Tacit 1 . \} .\} .. .de PE .ie 1-\\n[Tacit] \{\ .HTML-IMAGE-END ....@reset .sp \\n[DD]u+.5m .\} .el \{\ .nr Tacit 0 .sp -1 .\} .. --8<-- cut here ------------------------------------- Then, if you do something like .LP Calulation by PIC .PS T h = 105.5 wc =h*0.36 wu = h*0.36*72000/25.4 command ".ds wstring " sprintf("%.7f",wu) command ".nr wnumber " wc/10 "c" .PE wstring: \*[wstring] .br wnumber: \n[wnumber] .br Calculation by PIC you should get the four lines of text without any extra spacing (i.e. the action of PIC is "invisible"). Regarding remarks by other concerning re-programming gtroff so that it does its arithmetic in reals rather than integers, I have to say that once -- a long time ago -- I looked into this. It seemed to me that the use of integer arithmetic was so deeply and extensively dispersed throughout troff that it would have meant, in effect, a complete re-write of nearly everything! So I have put up with the integer arithmetic for most of the "routine" internal calculations (such as scaling sizes or distances), but use PIC (in the sort of weay illustrated) when using real arithmetic really matters. Mostly, this is in connection with drawing graphs anyway, but on occasion I use it to calculate statistical tables for output (using PIC's "command" command) to be interpreted by TBL (provided you invoke them in the recommended order pic | tbl | eqn). Regarding heirloom troff, I have read through the user manual (Gunnar Ritter's revision and extension of the original Ossanna and kernighan manual) without finding a statement that heirloom troff does real arithmetic rather than integer (the main difference noted is that you can call for fractional point-sizes). There is of course the usual possibiloity to use fractional multiples of distance units, such a "1.25i" or "3.45c" etc. The only occurrence of the word "arithmetic" is in the section "1.4 Numerical expressions" where this issue is not mentioned, though all the arithmetic operators are discussed. Perhaps Gunnar could comment? Best wishes to all, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <ted.hard...@manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 15-Oct-09 Time: 22:07:20 ------------------------------ XFMail ------------------------------