RotateTables


How to rotate a table in groff (i.e. print it sideways without messing up the headers & footers).

 .nr ps-x-off (-\n[.p])
 .nr ps-y-off 0
 .
 .pl (\n[LL]u + \n[HM]u + \n[FM]u)
 .
 .TS H
 tab(;);
 |cw(2.5i)|cw(2.5i)|cw(2.5i)|.
 \X'ps: exec -90 rotate \n[ps-x-off] u \n[ps-y-off] u translate'
 .in 0
 .sp -1                  \" undo vertical effect of \X
 .TH
 Boring;data;here.
 Boring;data;here.
 (as many lines as needed)
 Boring;data;here.
 .TE

This example doesn't reset the rotation after the table ends! Is that an issue, or should there be a

 \X'ps: exec 90 rotate'
just before the .TE line?

It doesn't appear to need it. However, I was trying to place two rotated tables on one page and have not figured out the magic incantation to do that yet.


Another way to rotate tables is to keep them in a separate file, convert to EPS and include in the "main" document using PSPIC. Like this:

 groff -t -ms -P-l widetable.rt >tmp.ps
 eps2eps tmp.ps widetable.eps
 rm tmp.ps

To prevent page breaking before you're ready, subtract 2v from the line length. For example, if you're using USletter paper, you have 9i to work with after subtracting header and footer margins. Put .ll 9i-2v before the beginning of the table and use the expand global option.

If you have to put two tables side-by-side:

 .mk
 .PSPIC -L wide1.eps
 .rt
 .PSPIC -R wide2.eps

(LK)


Another option for rotating a table in EPS form is to use ps2eps with the --rotate=<direction> option. For example,

 groff -t widetable.tr | ps2eps --rotate=+ > rottable.eps

will rotate the table 90 degress clockwise. Then use PSPIC to insert rottable.eps into the main document.

The direction options are:

 + : clockwise 90 degress
 - : counterclockwise 90 degrees
 ^ : 180 degrees (inverted)

See man ps2eps for more options.

(rwf)


Back to: GroffTips


Edit RotateTables FrontPage PageList RecentChanges PageHistory