[Top][All Lists]

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

RE: [Groff] Coloured equations?

From: Ted Harding
Subject: RE: [Groff] Coloured equations?
Date: Mon, 05 Feb 2007 11:25:59 -0000 (GMT)

On 05-Feb-07 Robert Marks wrote:
> I'd like to have all eqn terms appear in a single colour.
> gfont chooses the eqn font, but there appears no easy way to have all
> en terms appear in a specific colour.
> Any suggestions?

Do you want:

a) Each entire equation to appear in a given colour
   (e.g. blue equations in a black text)? I.e. not
   only the symbols x, y, ... for quantities but also
   the operators like "+", "-", "times", and brackets,
   integrals, summation signs and everyting else.


b) The equation basically in the same colour as the text
   (e.g. black) but the symbols for quantities, like "x",
   "y", alpha, etc. in a different colour (e.g. blue)?

Case (a) is relatively easy, but the way you've worded your
query suggests that you may want (b).

For case (a), one way to automate the colour change would
be to re-write the macros .EQ and .EN by adding the escape
sequences which, when .EQ is called, changes the output colour
to the one you want and, when .EN is called, changes it back
again. To do this, you need to look at the definitions of
these macros in whatever macro package you use.

But this would not work for in-line equations (created with
"$ ... $").

However, it's not a lot of work to leave .EQ and .EN alone,
and immediately precede .EQ with the colour switch to (e.g.)
blue, and immediately follow .EN with the switch back to
the original colour. This method also works for in-line
equations. For example:

  This is a displayed blue equation\m[blue]
  {x ~+~  y ~+~ z} over {X ~+~ Y ~+~ Z}
  \m[]And now an in-line blue equation
  in a black line.

However, in the case of a numbered equation, if you do it as
above then the equation number will also be in blue, as in

  This is a displayed blue equation\m[blue]
  .EQ (1)
  {x ~+~ y ~+~ z} over {X ~+~ Y ~+~ Z}
  \m[]And now an in-line blue equation
  \m[blue]$X ~+~ Y~+~ Z$\m[]
  in a black line.

and, if you don;t want that, then there are two work-rounds.

One is to wrap the equation number in a colour-switch:

  .EQ \m[](1)\m[blue]

and the other is to put the colour-switches inside the equation
description itself, within quotes, so that they are treated
as stuff to be passed to groff and not interpreted by eqn:

  This is a displayed blue equation
  .EQ (1)
  "\m[blue]"{x ~+~ y ~+~ z} over {X ~+~ Y ~+~ Z}"\m[]"
  And now an in-line blue equation
  \m[blue]$X ~+~ Y ~+~ Z$\m[]
  in a black line.

As to case (b), there's no way to incorporate colour into the
selection of a font, neither purely in equation composition
(".EW ... .EN" and "$ ... $") nor indeed in troff itself.
In any case, symbols for quantities are selected not only
from latin fonts ("x", "y," etc.) but may -- acccording to
what one uses in an equation -- from special fonts like the
Symbol font (e.g. for Greek letters etc.)

So if you want to do that in equations, then you are tied to
the "\m[...]" method within the equation. For example

.ds + \m[blue]
.ds - \m[]
This is a displayed blue equation
.EQ (1)
{"\*+"x"\*-" ~+~ "\*+"y"\*-" ~+~ "\*+"z"\*-"}
over {"\*+"X"\*-" ~+~ "\*+"Y"\*-" ~+~ "\*+"Z"\*-"}
And now an in-line blue equation
$"\*+"X"\*-" ~+~ "\*+"Y"\*-" ~+~ "\*+"Z"\*-"$
in a black line.

where the strings \*+ and \*- are defined to reduce the
amount of typing, and complexity, when entering the
colour changes. Granted, this is tedious and error-prone,
but it's the only kind of way I can think of to use
colours in an equation solely for the quantitative symbols.

Other may have better ideas!

Best wishes,

E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 05-Feb-07                                       Time: 11:25:45
------------------------------ XFMail ------------------------------

reply via email to

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