groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Groff tip: super/subscripts in eqn


From: Ted Harding
Subject: [Groff] Groff tip: super/subscripts in eqn
Date: Fri, 20 Jul 2007 12:07:31 +0100 (BST)

Hi Folks,

As some of you are probably aware, the font size reduction
which occurs when eqn is setting superscripts and subscripts
is hard-wired. What is sent on to troff is the request

.ps (u;\n[.ps]*7+5/10>?5)

which takes the current point-size (in device units), and
scales it by 7/10 (rounding up), with a minimum point size
of 5.

Thus in 10-point, for instance, a first-order superscript
will be in 7-point, and a second-order will be in 5-point
(since 70% of 7 is 4.9 which is replaced by 5). Similarlay,

11pt -> 7.7pt -> 5.39pt.

Often (especially if using the Times family, which is a
somewhat lightly stroked font), the reduction by 70% may
be felt to be too drastic: even first-order super/subscripts
may be difficult to read, and second-order even more so.

For example:

.ps 11
.EQ
{roman e} sup {b ( theta ) t ( y ) ~+~ c ( theta )}
.EN

could be hard to read clearly. Therefore there can be a need
to modify the behaviour of eqn. But ".ps (u;\n[.ps]*7+5/10>?5)"
is hard-wired.

There are various ways to work round this. You could recompile
eqn to have a gentler reduction factor, or you could even
simply edit the eqn binary (vim can do this) to change the
contents of this ".ps" request (provided you stay within its
byte-space).

But the result of doing either is still hard-wired. Since you
may not always need to do this (and if your base point-size is
large there's probably no reason to), you need to be able to
choose whether or how you do it.

The following (if you are running a system which has 'sed'
installed, which Unix/Linux systems always do; and Windows
if you install the GNU utilities yourself), allows you to
change the behaviour in a flexible way.

Assume the troff source file is "eqn.stuff"

1. To change the point-size factor throughout a document,
   from a factor of 7/10 to a factor of 7/9:

eqn eqn.stuff | sed '
s/^.ps (u;\\n\[\.ps\]\*7+5\/10>?5)/.ps (u;\\n[.ps]*7+5\/9>?5)'

2. To replace the ".ps (u;\n[.ps]*7+5/10>?5)" by your own
   macro, say .PSeqn:

eqn eqn.stuff | sed '
s/^.ps (u;\\n\[\.ps\]\*7+5\/10>?5)/.PSeqn (u;\\n\[\.ps\]\*7+5\/10>?5)/

You can then write your own macro .PSeqn which, depending on ambient
conditions which it tests for, can either implement its argument
as it stands (i.e. no change), or set the point-size to something
else. So the whole thing is then under control in any circumstances.

The only real complication here is that it's not in general
a good idea to run 'eqn' before 'tbl' or 'pic': it's better to
run it last. So the usual shorthand

  groff -tpe eqn.stuff

might need to be replaced by an explicit pipeline like:

  tbl eqn.stuff | pic | eqn | sed '...' | troff ...

(together with any special options).

Hoping folks will find this useful. Comments welcome!
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Jul-07                                       Time: 12:07:27
------------------------------ XFMail ------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]