1

I am trying to work with groff to generate a table where one cell spans multiple rows.

I tried

.TS BOXED LABEL "Table 1: Use Case 1"
allbox, tab(@);
l l
l ld
l ^ .
Use Case Identifier@UC1
Flow of events@T{1. System prompts for username and password
.br
2. User submits their username and password
T}
.TE

but I get the warning below, and the table renders incorrectly.

warning: file `report.mom', around line 55:
  table wider than line width

I was trying to generate a table like below, where the bottom left cell spans multiple rows.

example expected

I also tried one of the examples from the documentation, specifically the following one, and I get the same table wider than line width warning and the table does not render correctly. (The example below is the last example on the page I linked.)

.TS
box;
cb s s s
c | c | c s
ltiw(1i) | ltw(2i) | lp8 | lw(1.5i)p8.
Some Interesting Places
_
Name[[circle]]Description[[circle]]Practical Information
_
T{
American Museum of Natural History
T}[[circle]]T{
The collections fill 11.5 acres (Michelin) or 25 acres (MTA)
of exhibition halls on four floors. There is a full-sized replica
of a blue whale and the world's largest star sapphire (stolen in 1964).
T}[[circle]]Hours[[circle]]10-5, ex. Sun 11-5, Wed. to 9
\^[[circle]]\^[[circle]]Location[[circle]]T{
Central Park West & 79th St.
T}
\^[[circle]]\^[[circle]]Admission[[circle]]Donation: $1.00 asked
\^[[circle]]\^[[circle]]Subway[[circle]]AA to 81st St.
\^[[circle]]\^[[circle]]Telephone[[circle]]212-873-4225
_
Bronx Zoo[[circle]]T{
About a mile long and .6 mile wide, this is the largest zoo in America.
A lion eats 18 pounds
of meat a day while a sea lion eats 15 pounds of fish.
T}[[circle]]Hours[[circle]]T{
10-4:30 winter, to 5:00 summer
T}
\^[[circle]]\^[[circle]]Location[[circle]]T{
185th St. & Southern Blvd, the Bronx.
T}
\^[[circle]]\^[[circle]]Admission[[circle]]$1.00, but Tu,We,Th free
\^[[circle]]\^[[circle]]Subway[[circle]]2, 5 to East Tremont Ave.
\^[[circle]]\^[[circle]]Telephone[[circle]]212-933-1759
_
Brooklyn Museum[[circle]]T{
Five floors of galleries contain American and ancient art.
There are American period rooms and architectural ornaments saved
from wreckers, such as a classical figure from Pennsylvania Station.
T}[[circle]]Hours[[circle]]Wed-Sat, 10-5, Sun 12-5
\^[[circle]]\^[[circle]]Location[[circle]]T{
Eastern Parkway & Washington Ave., Brooklyn.
T}
\^[[circle]]\^[[circle]]Admission[[circle]]Free
\^[[circle]]\^[[circle]]Subway[[circle]]2,3 to Eastern Parkway.
\^[[circle]]\^[[circle]]Telephone[[circle]]718-638-5000
_
T{
New-York Historical Society
T}[[circle]]T{
All the original paintings for Audubon's
.I
Birds of America
.R
are here, as are exhibits of American decorative arts, New York history,
Hudson River school paintings, carriages, and glass paperweights.
T}[[circle]]Hours[[circle]]T{
Tues-Fri & Sun, 1-5; Sat 10-5
T}
\^[[circle]]\^[[circle]]Location[[circle]]T{
Central Park West & 77th St.
T}
\^[[circle]]\^[[circle]]Admission[[circle]]Free
\^[[circle]]\^[[circle]]Subway[[circle]]AA to 81st St.
\^[[circle]]\^[[circle]]Telephone[[circle]]212-873-3400
.TE
1

Based on your output required, the following will be the tbl code. Note you don't need the box option.

I assumed you needed a bold UC1 in the first row second column, so used a B in the column suffix.

.TS BOXED LABEL "Table 1: Use Case 1"
tab(@);
l lB, l l, l l, l l, l l
lT l, ^, ^, ^, ^.
_
Use Case Identifier@UC1
_
Title@Login
_
Participating actor(s)@Dental staff member or client
_
Precondition(s)@System is ready to receive requests
_
Parameters@Username, password
_
T{
Flow of events
T}@1. System prompts for username and password
^@2. User submits their username and password
^@3. System logs user in
^@4. User is redirected to homepage
_
.TE
2
  • I accepted this answer because it gave the cell borders that matches my sample screenshot, and also provided explanation for bolding. Do you happen to know how I can italicize the cells in my left column? – Shane Bishop Jan 21 at 17:01
  • 1
    For italicizing, you need to place an I after the column in the format section. – guest_7 Jan 21 at 17:29
1

The principal problem is that T{ must be at the end of a line, just like }T must be at the beginning of a line. With just this change of a newline character you get:

table1

You can help the typesetting by providing a width for a column using w(troff_width) (default scale is ens, the approximate width of the "n" character in the font). For example, using l lw(50) for the first format line gives:

enter image description here

Note that in the example from the documentation, for it to work you must replace the string [[circle]] by a tab character, as it mentions earlier on.

1
  • Thanks for pointing out that [[circle]] had to be replaced with a tab character! I missed that when I was reading the documentation. – Shane Bishop Jan 21 at 17:02
0

I also found a solution on my own (though this does not as closely match my sample screenshot as the other solutions):

.TS BOXED
box, tab(@);
l | l .
Use Case Identifier@UC1
_
Title@Login
_
Participating actor(s)@Dental staff member or client
_
Precondition(s)@System is ready to receive requests
_
Parameters@Username, password
_
Flow of events@1. System prompts for username and password
\^@2. User submits their username and password
\^@3. System logs user in
\^@4. User is redirected to homepage
.TE

This produces

sample render

The | in the l | l part tells tbl to place a vertical line between the two columns.

The _ tells tbl to place a horizontal line between the two rows.

The tab(@) tells tbl to treat the @ character as a delimiter between cells in a row.

The \^ tells tbl that the table entry immediately above spans downward over this row.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.