[Top][All Lists]

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

RE: [Groff] tbl: contolling table width

From: Ted Harding
Subject: RE: [Groff] tbl: contolling table width
Date: Thu, 08 Jul 2010 22:44:00 +0100 (BST)

On 07-Jul-10 21:45:11, Anton Shepelev wrote:
> Werner Lemberg:
>> Then what about the `x' column specifier?
> Thanks. I was 'fixed' on the 'w' specifier.
> Ted Harding:
>> Meanwhile, looking for something "clever"...
> May I ask you if you have found it?
> Anton

Well, this is an approximation to "something clever", but it is
definitely "work in progress"!

First: groff code (NB View the result in PostScript and use 'groff -t):
The line below is the current line-length:
\D'l \n[.l]u 0'
|l2 | l2 | l2 | l |.
Row 1, Col 1 A A A\ER'H1 \n[.k]'#Row 1, Col 2#\
Row 1, Col 3\ER'H3 \n[.k]'#Row 1, Col 4
Row 2, Col 1#Row 2, Col 2#Row 2, Col 3 AA\ER'H3 \n[.k]'#\
Row 2, Col 4\h'2m'X
Row 3, Col 1#Row 3, Col 2 A\ER'H2 \n[.k]'#Row 3, Col 3#Row 3, Col 4
Row 4, Col 1#Row 4, Col 2#Row 4, Col 3#Row 4, Col 4 A A A\

Next: some comments (first view the output):

1 Note that \ER'H1 \n[.k]' (1st col), \ER'H2 \n[.k]' (2nd col)
  \ER'H3 \n[.k]', and the final (col 4)[*]
  occur at the end of the  table entry which is the longest
  in that column.

  [*] This is probably not necessary for the final column,
      but I am unsure whether ignoring it would survive
     all possible cases for col 4.

2 The "-8n" in the final "\h'...'" is as it is because I have
  set 2n column spacings: "|l2 | l2 | l2 | l |."
  Thus from the lefthand edge of the table there is 1n from the
  left-hand vertical rule until the entries start, then 2n from
  col 1 to col 2, then 2n from col 2 to col 3, then 2n from
  col 3 to col 4, then 1n at the righthand edge from the end
  of the longest entry to the right-hand rule, hence 8n in all.

  With default (3n) column spacing, it would be 3n each time
  instead of 2n, hence "-11n" in all with no other changes.

  Without the left-hand or right-hand rules, omit the 1n for each
  one which is not there.

  Rather than this kludgy "counting n's" method, there is probably
  a way to exploit the tbl-generated registers \n[3cl0] and \n[3cl3]
  (in a 4-column table), but I have not yet succeeded in getting
  this to work properly!

3 This code, as written, is somewhat dependent on the columns being
  left-justified. However, if a column is centred you can use the
  entry in that column which extends furthest to the right. If a
  column is right-justified, then you don't need to worry.

4 There is no obvious way to automate this for arbitrary tables!


E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861
Date: 08-Jul-10                                       Time: 22:43:53
------------------------------ XFMail ------------------------------

reply via email to

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