Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Change default paper size in groff applications UNIX
If you use groff for any sort of printing, you will discover that Mac OS X ships with the default paper size set to A4. If you use A4 paper,this hint does not apply to you. If you don't, then you need to change your paper size. The paper size is set in a file that is associated with the particular output device you use. Most of the time, you use the ps output device (for PostScript). The following bit of perl magic will edit every file named DESC in your /usr/share/groff/1.18.1/font directories and set the papersize from A4 to 'letter.' Run it from a Terminal command prompt (one line, shown as two; the backslash should allow copy/paste to work):
% sudo perl -pi -e 's/^papersize a4/papersize letter/' \
/usr/share/groff/1.18.1/font/*/DESC
If you edit the /usr -> share -> groff -> 1.18.1 -> font -> devps -> DESC file, you can change the font family to "H" or "P". That will make Helvetica or Palatino, respectively, your default font. I like Palatino.

But why use groff?
The best use I have for groff is printing man pages. If I want to print, for example, the ls man page, I can run this from a Terminal window:
% groff -man /usr/share/man/man1/ls.1 | ps2pdf - ls.pdf
Then I can open and read or print the ls.pdf file. This beats the heck out of printing plain text.

But how do I know what file to print?
Type man -d ls and on the last line of output, you'll see what file it would have displayed. Then supply that file name as an argument to groff as shown above, and you can get a pretty man page out of it.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[9,281 views]  

Change default paper size in groff applications | 7 comments | Create New Account
Click here to return to the 'Change default paper size in groff applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
No reason to specify the path to the man page
Authored by: mzs on Jul 26, '04 12:26:49PM
To get nice postscript output from man use the -t option. It is better to do it this way than piping through troff directly because there are lines in man files that specify to use other preprocessors such as tbl and eqn that you will not use unless you specify them in your pipeline as well. If you want a man page that turns-out not to be the first one and you use a Bourne-style shell, just do the appropriate MANPATH=... before your pipeline. Also, ps2pdf is not installed by default on MacOS X, but pstppdf appeared with 10.2 or so. So for example to get the man page as a pdf file for the man command itself, you could do:

man -t man | pstopdf -i -o man.pdf
Although there really is no reason for the pstopdf step as with 10.3 at least I can open postscript files in Preview.app.

I personally dislike the 'pretty-printing' of typeset man pages. I personally like to use something like this:


man man | col -bx >man.txt
The col command strips away the escapes used for underlines and bold characters.

[ Reply to This | # ]
Change default paper size in groff applications
Authored by: rhithyn on Jul 26, '04 01:05:25PM

I don't know that much about perl and all that, but I had to alter the s command line to make it work:

instead of: ... 's^papersize a4/... I had to change the caret to a slash: ... 's/papersize a4/..., otherwise I was getting a "Substitution pattern not terminated at -e line 1."



[ Reply to This | # ]
The ^ is a shell character
Authored by: paco on Jul 26, '04 02:37:59PM

That's weird. I've tried in both bash and tcsh to duplicate this, and I can't.

Generally speaking, you have to use single quotes around that perl expression (i.e. '^papersize' ). If you don't, then your shell might interpret the '^' character and give you the error message that you got. If you copy and paste that command (including the single quotes), I'd be very surprised if you got an error.

In practice, you're right. The caret is actually unnecessary since "papersize" only appears once in the file and the pattern will work fine without the caret. I was just being extra cautious with the pattern.



[ Reply to This | # ]
Nope, it's definitely missing
Authored by: pmccann on Jul 26, '04 09:58:02PM

Look again at that line: there's no initial slash for the regex that you're asking perl to execute. You can leave the caret if you like, but the initial slash has to be there.

Cheers,
Paul



[ Reply to This | # ]
Change default paper size in groff applications
Authored by: sjk on Jul 26, '04 09:19:37PM

The groff_font(5) man page has the gory details about groff device and font description files.



[ Reply to This | # ]
Change default paper size in groff applications
Authored by: kd4ttc on Oct 16, '05 03:43:55PM

For getting the path to the manpage for command "xxx" the command is

man -w xxx

man -d xxx prints debug info.



[ Reply to This | # ]
Check for the current groff version
Authored by: kd4ttc on Sep 07, '07 04:35:24PM

Currently (9/2007) the groff version is 1.19.1, so change 1.18.1 to 1.19.1 above to get things to work currently.

---
Steve Holland



[ Reply to This | # ]