Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm making my first 'man' page and I'm using groff to do it. However, when I "compile" it and view it, it only takes up a certain amount of columns in my terminal. I've tried viewing other man pages just in case and they stretch with the width of my terminal. For a visual exmaple:

---------------------------------------
| stuff(1)             stuff(1)         |
|                                       |
| NAME                                  |
|       a tool to do stuff but          |
|       it isn't really working         |
|                                       |
| DESCRIPTION                           |
|       yadadyadyadyadyadyadydy         |
|       segfwefwefwefwe                 |
|                                       |
|       srgswrgwrg                      |
 ---------------------------------------

... and so on, hopefully you get the idea. Most man pages take the full width.

Right now, after writing my man page in a text file (using the groff/nroff "syntax"), I make it like this:

groff -Tascii -man ./path/to/man | more
share|improve this question
    
You should include the exact steps you're using to "compile" your man page. –  wfaulk Aug 10 '11 at 13:58
    
@wfaulk, My bad I thought I had added it –  MaxMackie Aug 10 '11 at 14:00
    
hm, btw, what about changing the heading of this question into a real question? For example: 'How to change the width of a man page using groff?' Or something like this ... –  maxschlepzig Aug 10 '11 at 18:26
    
It doesn't really address your actual question, but I think it's worth pointing out that you can get real *nix man pages without all the pain of the old toolchain using something like ronn. Also, I seem to recall hearing that the OpenBSD toolchain for man pages is different (I have no real basis for comparison, though). Here's man mdoc –  Hank Gay Aug 10 '11 at 19:27
add comment

2 Answers 2

up vote 6 down vote accepted

I checked what groff call is executed when I invoke man man (which uses the full width):

$ strace -o log -f -v -s 1024 -e trace=process man man

Looking for the groff call results in the following:

$ grep groff log | sed 's/\], \[.*//' 
28721 execve("/usr/bin/groff", ["groff", "-mtty-char", "-Tutf8", "-mandoc",
                                         "-rLL=171n", "-rLT=171n"

Now I resize my xterm:

$ strace -o log2 -f -v -s 1024 -e trace=process  man man
$ grep groff log2 | sed 's/\], \[.*//'
28852 execve("/usr/bin/groff", ["groff", "-mtty-char", "-Tutf8", "-mandoc",
                                         "-rLL=119n", "-rLT=119n"

Thus, I assume that the -rLL and -rLT arguments influence what terminal width is used by groff during compiling.

share|improve this answer
    
Interesting, I looked through groff's manpage and it doesnt mention anything about -rLL or -rLT. I checked troff just in case because I know groff calls it. Then I just tried adding the flags with 119n and it did work, however there is still some space and it doesn't seem to "stretch" and conform to the terminal size, more like a static setting. –  MaxMackie Aug 10 '11 at 14:53
    
Thanks for outlining what you did by the way, very interesting –  MaxMackie Aug 10 '11 at 14:53
    
@MaxMackie, yes, it is static - man just 'dynamically' determines the current terminal width and supplies it - i.e. in my first call my terminal was 171 columns wide and in the 2nd call it was 119 columns wide. –  maxschlepzig Aug 10 '11 at 15:02
    
Alright I think my understanding of what groff actually does is flawed then. My "source" file (plaintext with macros) is the man file? Or does groff create a new file for me? If I were to create a man page and install it on my system, could groff help me do this, or does it only handle the formatting? For example, could I groff -Tascii -man ./path > /man/file? –  MaxMackie Aug 10 '11 at 15:11
1  
@MaxMackie, the man pages installed on my system are troff markup files, e.g. gunzip -c /usr/share/man/man1/man.1.gz > man.1, file man.1 man.1: troff or preprocessor input text. Meaning that the groff command is called on-the-fly by the man command every time it is invoked. Perhaps there are systems which do some caching of the troff output (and perhaps only support 80 column output ...). –  maxschlepzig Aug 10 '11 at 18:21
show 2 more comments

I believe most current versions of man will DoTheRightThing™ if you specify your man page as an argument containing a slash:

man ./stuff.1

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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