1

As output for a script, I produce inut for tbl. However, when a table seems to reach an end of page, the borders of a table go all over the place. As an example:

             │            │                │                 │
             │            │                │                 │
             │            │                │                 │
             │            │        ‐ 1 ‐   │                 │
             │            │                │                 │
             │            │                │                 │
             │            │                │                 │
       4.  The in3 intermediate data structure               │
             │            │                │                 │
       In3   is   an   intermediate   language.  The  goal  of  the
       intermediate language is to provide all the content  in  the
       right │order,  in  such  a  way  that the output‐filters can

(this is nroff-output). The column-borders conform to table at the bottom of the page.

This mainly seems to happen when a table is fully specified (i.e. for every row, a line is written in the header), for example:

.TS
allbox,center;
l l l
l l l
l l l
l l l
l l l
^ l l
l l l.

I must do this, because I do not know beforehand when two rows need a merged cell (^).

I tried to put in a conditional new page before every table, but that is less obvious than it looks, because a) nroff (text output) and groff (ps-output) do not seem to handle this the same way and b) it is difficult (due to possible multi-line cells) to predict how long a table will be.

I would like a solution that does not force me to begin a new page for every table.

Ljm Dullaart
  • 4,273
  • 2
  • 14
  • 31

1 Answers1

0

It may be sufficient just to fully specify the table by giving it an explicit table header, which needs to be repeated at the start of the next page after a page split. You may also need to use macros -mm or -ms, which are also doing end-of-page handling, and need to co-operate with tbl and the T# macro it creates for this purpose.

The format is

.TS H
options ;
format .
heading
.TH
data
data
.TE

The heading line above can be omitted, but you still need the .TH and the .TS H.

I made some tests with groff 1.22.3 and the following example, with a forced page length (.pl) of 14 lines worked well with -mm but not with -ms.

( echo .pl 14
  echo .TS H
  echo 'allbox,center;'
  for ((i=1;i<5;i++)); do echo 'l l l'; done
  echo '^ l l'
  for ((i=1;i<5;i++)); do echo 'l l l'; done
  echo 'l l l.'
  echo .TH
  for ((i=1;i<11;i++)); do echo -e 'a\tb\tc';done
  echo .TE
) >t
tbl t | nroff -mm

Here's part of the output, with the blank lines removed:

         - 1 -

     +--+---+---+
     |a | b | c |
     +--+---+---+
     |a | b | c |
     +--+---+---+

         - 2 -

     +--+---+---+
     |a | b | c |
     +--+---+---+

         - 3 -

     +--+---+---+
     |  | b | c |
     |a +---+---+
     |  | b | c |
     +--+---+---+
meuh
  • 11,500
  • 2
  • 29
  • 45
  • Tried it with an empty header and wit a dummy header (`abc`), but to no avail. Also tried putting `.DS` and `.DE` around the table, but that did not work either. Macro package used is a slightly modified `ms`. I did try, however, with `-mm` and with `-ms` also. Note that when you do not use headers, the the macro-package will complain that the table does not fit on the page. – Ljm Dullaart Aug 26 '18 at 15:51
  • It seems to work with my groff 1.22.3, see updated answer. – meuh Aug 26 '18 at 16:19
  • `mm` works indeed. don't know what I did wrong when testing that. Will try to make the modifications that were made to `ms` to `mm`. Thanks – Ljm Dullaart Aug 27 '18 at 19:28
  • 1
    Lots of debugging etc, but in the end, it was caused by a `.TS` too many in the script output. – Ljm Dullaart Aug 30 '18 at 16:01