[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Groff] RE: eqn matrix?
From: |
Ted Harding |
Subject: |
RE: [Groff] RE: eqn matrix? |
Date: |
Mon, 24 Sep 2007 11:49:16 +0100 (BST) |
A follow-up:
On 23-Sep-07 23:15:29, andlabs wrote:
>
> It seems as if the problem comes from my original file
> using tabs as whitespace instead of spaces, as it came
> in the email. That is weird, but it works now. Thanks.
This suggests that you were not the person who wrote the
original eqn code, so probably what I'm about to say may
be unnecessary for you! Nevertheless, I think it's worth
pointing out generally.
First of all, the original is not easy to read, partly
because of unnecessary use of "{...}". And it's more
typing than one needs to do.
Secondly, the repetitive use of "roman" within the eqn
code itself can be avoided by setting up some "eqn"
definitions beforehand. That also makes it easier to
read and type.
Thirdly, using an "eqn matrix" is often not the best
way to set up an array of equations. I know it is the
"classical" way, as described in the original "eqn"
manual, but in fact if you place your equations in
a table you get better control over the layout.
Below is
(A) Your original eqn code;
(B) The same, with excess "{...}" removed, and the
"roman" stuff pre-defined, laid out in a table
to be processed by "tbl".
(C) A refinement of (B), in which the use of "\&"
as the "unit-digit" marker in a tbl numeric
column ensures that the "=" signs will line up.
Explanation of some details follows at the end.
The layout resulting from (B) is similar to the
layout from your original (A). The layout from (C)
is in my judgement preferable to either (A) or (B).
In any case, you have the extra resources from tbl
to improve the presentation (e.g. if you want to
change the spacings between columns and/or rows,
or use lines as separators).
.\"(A)
.EQ
matrix{
ccol {
{ { roman cot ^ x } = { cos x } over { sin x } }
above { { arc roman cot ^ x } = { pi over 2 } - { arc tan x } }
above { { roman coth ^ x } = { cosh x } over { sinh x } }
}
ccol {
{ { roman sec ^ x } = 1 over { cos x } }
above { { arc roman sec ^ x } = arc cos x sup -1 }
above { { roman sech ^ x } = 1 over { cosh x } }
}
ccol {
{ { roman csc ^ x } = 1 over { sin x } }
above { { arc roman csc ^ x } = arc sin x sup -1 }
above { { roman csch ^ x } = 1 over { sinh x } }
}
}
.EN
.sp 2
.\"(B)
.EQ
define cot %{roman "cot"}%
define coth %{roman "coth"}%
define sec %{roman "sec"}%
define sech %{roman "sech"}%
define csc %{roman "csc"}%
define csch %{roman "csch"}%
.EN
.TS
centre tab(#) delim($$);
n n n.
$cot ^ x = {cos x} over {sin x}$#\
$sec ^ x = 1 over {cos x}$#\
$csc ^ x = 1 over {sin x}$
$arc cot ^ x = pi over 2 - arc tan x$#\
$arc sec ^ x = arc cos x sup -1$#\
$arc csc ^ x = arc sin x sup -1$
$coth ^ x = {cosh x} over {sinh x}$#\
$sech ^ x = 1 over { cosh x }$#\
$csch ^ x = 1 over { sinh x }$
.TE
.\">>> Much easier to read, isn't it?!
.\"(C)
.sp 2
.TS
centre tab(#) delim($$);
n n n.
$cot ^ x =""$\&$ {cos x} over {sin x}$#\
$sec ^ x =""$\&$ 1 over {cos x}$#\
$csc ^ x =""$\&$ 1 over {sin x}$
$arc cot ^ x =""$\&$ pi over 2 - arc tan x$#\
$arc sec ^ x =""$\&$ arc cos x sup -1$#\
$arc csc ^ x =""$\&$ arc sin x sup -1$
$coth ^ x =""$\&$ {cosh x} over {sinh x}$#\
$sech ^ x =""$\&$ 1 over { cosh x }$#\
$csch ^ x =""$\&$ 1 over { sinh x }$
.TE
The point of the
""$\&$
following the "=" signs is that
a) Having "=" between $...$ ensures that the Symbol
font with be used for "="
b) In setting $A = B$, eqn surrounds "=" with an
appropriate space on either side, PROVIDED both
A and B are present. $A =$ would follow "=" with
no spacing at all. Hence "" is inserted so that
there is a "B", even though as far as troff is
concerned this is simply empty; it's there so
that eqn can see it.
c) In a tbl numeric column, the final (unit) digit
of an integer, or the unit digit from a general
decimal as identified by the position of ".",
is always automatically lined up in the same
horizontal position.
However, for a table entry where neither of these
indications is present, some other indicator is
required if entries are to line up in desired
positions. Here, the desired position is the
right-hand end of the "=" sign.
The indicator recognised by tbl for this purpose
is \&, the "non-printing character" in troff.
But this has to be outside the eqn block $...$
(and in any case, eqn does not like it).
Hence, in an equation like
$csc ^ x =""$\&$ 1 over {sin x}$
the first part $csc ^ x =""$ is closed by $, then
the \& is inserted, and then the equation is
"re-opened" with another $.
Hoping this is useful!
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 24-Sep-07 Time: 11:49:12
------------------------------ XFMail ------------------------------