groff
[Top][All Lists]
Advanced

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

Re: An example of a multiplication table: some unresolved questions


From: Thomas Dupond
Subject: Re: An example of a multiplication table: some unresolved questions
Date: Tue, 30 May 2023 10:09:45 +0200

Dear Oliver,

Le 2023-05-30 à 09:17, Oliver Corff a écrit :
Dear Thomas,

thank you very much indeed.

Beyond your critical correction of using a genuine tab (0x09) character
instead of \t, it was \c which does the trick.

Furthermore, my setting of tab stops had been flawed.

Using .nf is also important but I think it is not clear from the manual (either info or groff(7)) that this is needed, if only for getting rid of the 'cant break line' errors.

I now use

.ta T 6m

which works as desired. Yet I still run into a now definitely minor problem.

Given the general syntax .ta T 6mX where X is one of L C R,

I get the same output for any of L C R, the numbers are always adjusted
to the left.

1     2     3     4     5     6
2     4     6     8     10    12
3     6     9     12    15    18

instead of

1     2 3     4     5     6
2     4     6     8    10    12
3     6     9    12    15    18

I think I can tinker with prepending \~.

I think this achieves the desired result:

.nf
.ta 2mR T 2mR
.nr x 1
.nr y 1
.nr p 0
.while (\n[x] <= 12) \{\
.while (\n[y] <= 12) \{\
.nr p \n[x]*\n[y]
.nr y +1
        \n[p]   \c
.\}
.br
.nr x +1
.nr y 1
.\}

As you can see I added a tab character before and after \n[p] to achieve this. The previous example did not work because I did not remember that you should begin with a tab character.

For this kind of thing I tend to rely on the Unix Text Processing book more and more. A very similar example of what you are trying to achieve is described on page 66 (4. nroff and troff > Page Layout > Setting tabs). You can get this book here:

http://chuzzlewit.co.uk/utp_book-1.1.pdf

It is a build of the book (hosted on Deri James' website) from the UTP revival project.

https://github.com/larrykollar/Unix-Text-Processing/

Also there is no need to specify the steps x or y should take if auto incremented because we don't use that here. The step value is interesting if you use \n+[x] or \n+[y] somewhere in your code. There are more examples in section 5.6.3 of the info manual.

I produce the output as follows:

$ groff -Tascii table.roff | less

Thank you very much again, best regards,

You're welcome :D
Thomas



reply via email to

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