[comp.unix.questions] EQN and TBL

nrp1@rosemary.cs.reading.ac.uk (The HNT Corporation Chairman) (11/29/89)

Hello net.people,

Does anyone know how to combine eqn and tbl, so as to produce a table of
equations?  I've tried using delimiters, but they don't appear to work!

Any ideas will be welcome!

This message was sent by  ###   ###  n  ..          
the HNT Corporation.      ###   ###    /  )         
+----------------------+  ########-----+-+-----    "There's half a pound 
|    nrp1@rosemary@    |  #########     X           of Cadbury's Fruit &
|uk.ac.reading.cs.onion|  ###   ###    / \     .    Nut in there!"
+----------------------+  ###   ###  .'   `._.'     

jep@uxh.cso.uiuc.edu (John E. Prussing) (12/02/89)

  I have used eqn and tbl together successfully.
  You need to use delimiters in the construction of the
  table, and use the tbl preprocessor first, ala

  tbl filename | eqn | troff

 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--==-=-=
John E. Prussing                                Internet: jep@uxh.cso.uiuc.edu
Aeronautical & Astronautical Engineering        BITNET: jep@uiucuxh
University of Illinois at Urbana-Champaign      UUCP: uunet!uiucuxc!uiucuxh!jep

jimr@hp-lsd.COS.HP.COM (Jim Rogers) (12/06/89)

To make eqn work inside tbl you must use test blocks.
For instance, try the following example:

.TS
delim ($$) center;
l l.
1	T{
$x=2 pi int sin ( omega t)dt$
T}
2	T{
$a+b over 2c = 1$
T}
3	T{
$A ~=~ left [ pile { a above b above c } ~~ pile { x above y above z } right ]$
.TE

The second column on each line begins with "T{".  This begins a text block
in TBL.  Every "T{" must be the last set of characters on a line.
The text block ends with "T}".  Every "T}" must be the first set of
characters on a line.

Text blocks are very useful.  I have been known to put entire grap ouputs
in a column using text blocks.


Jim Rogers

Hewlett Packard Logic Systems Division
Colorado Springs, Colorado

jimr@hp-lsd.COS.HP.COM (Jim Rogers) (12/07/89)

Upon further study I find that text blocks, as useful as they are, are
**not** necessary for combining tbl and eqn.

The keys to this combination are explained in page 16 of the tbl 
technical discussion in the book "UNIX (R) System V Documentor's
Workbench User's Guide" printed by Prentice Hall.  This book is part of
the AT&T UNIX (R) System V series.

The most important issue in getting eqn and tbl to work together seems to
be the relative order in which they are invoked.  The book states that
eqn should **always** be invoked after tbl on files which have equations
inside tables.

	i.e   
		tbl foo.text | eqn | troff -mm

The example used in the book, which only works with the order shown above,
is:


.EQ
delim $$
.EN

.TS
doublebox;
c c
l l.
Name	Definition
.sp
.vs +2p
Gamma	$GAMMA (z) = int sub 0 sup inf t sup {z-1} e sup -t dt$
Sine	$sin (x) = 1 over 2i ( e sup ix - e sup -ix )$
Error	$roman erf (z) = 2 over sqrt pi int sub 0 sup z e sup {-t sup 2} dt$
Bessel	$J sub 0 (z) = 1 over pi int sub 0 sup pi cos (z sin theta )d theta $
Zeta	$ zeta (s) = sum from k=1 to inf k sup -s ~~( Re~s > 1)$
.vs -2p
.sp 2p
.TE



Sorry for the earlier misinformation.


Jim Rogers

lee@sq.sq.com (Liam R. E. Quin) (12/14/89)

In article <7370004@hp-lsd.COS.HP.COM> jimr@hp-lsd.COS.HP.COM (Jim Rogers) writes:
>Upon further study I find that text blocks, as useful as they are, are
>**not** necessary for combining tbl and eqn.

True.

You might also like to know that you can do

	.EQ
	delim @%
	.EN

instead of
	
	.EQ
	delim $$
	.EN

if you like.  This has two big advantages.  Firstly, you can define your
own macros without worrying that a $ in a macro will confuse eqn e.g.:
	.de B
	\fB\&\\$1\fP\c
	..
This is not so important, as you can use .so to read a file of macros if
you wany anyway.

The real big win is that if you accidentaly omit a delimiter, as in
	We can see that $a sup 2 is much closer to $pi$ than...
the rest of the document (up to a .EQ or .EN) gets inverted, so tht all of
the eqn text comes out normal, and eqn looks at all of the other text...
usually this causes syntax errors.

If instead I had written
	We can see that @a sup 2 is much closer to @pi% than...
then the effect would end at @pi$.

Finally, note that whilst @ is OK for a start delimiter, % occurs in
normal text, and is only ggod for the ending one.  And # does not work
at all, because tbl puts #-signs [pronounced `hash-signs' :-)] in its output.

Lee

[I was first shown the technique of using differing delimiters by David
 Epstein, in a paper written by Bill Thurston of Princeton]

-- 
Liam R. Quin, Unixsys (UK) Ltd [note: not an employee of "sq" - a visitor!]
lee@sq.com (Whilst visiting Canada from England, until Christmas)
 -- I think I'm going to come out at last...
 -- What?  Admit you're not a fundamentalist Jew?  They'll *crucify* you!  :-)