The GNU roff program or groff is a typesetting program that takes marked up text files and produces structured output, most usefully in PostScript but also many other formats. It is related to the ancient Unix commands roff (run off), troff (typeset …), and nroff (new …). Because of stupid license issues groff is the only one left standing but it sometimes calls programs named after their inspirations for compatibility with such. Sticking with groff should suffice.

Seems like there is the core groff system and there are macros. This is like there is TeX and LaTeX. The most useful macros seem to be the ms set which stands for "Manuscript" macros. See man groff_ms.

There is another set of important macros, man which is for formatting man pages. Organizing man pages are probably groff’s main modern function. While you can use a modern tool to create man pages, they are classically specified in a roff type of syntax.

To see a language reference use man 7 groff.


It seems the correct extension (according to Vim) for groff formatted files is filename.roff. When working with a file named differently in Vim use :set syntax=groff.

To make an X window display of the thing use -TX75 or -TX100 like:

gunzip -c /usr/share/man/man1/ls.1.gz |groff -TX75 -man -

Might think about including a .warn in the document to cause warnings to be output. This could be handy in the case of mysterious problems.

If you just need some text file put into Postscript as is, you can use something like this:

(echo '.nf'; cat atextfile) | groff -ms  >

If someone has given you a groff formatted man page and you just need to see it like a man page, this works.

wget -qO- | groff -Tascii -man | less

Core groff Language

Some delightfully ancient (1972) documentation lives here.


Starts a command or macro if first character of the line.


Same as dot but does not produce a line break. Again, as start of line. Elsewhere it is apostrophe as expected.


You can use cm(c), inch(i), pica(P), point(p), Em(m), 100th of em(M), En(n).


There are operators like +, -, *, /, % and boolean logic, grouping, comparison operators, etc. All normal looking.

There is a conditional if, ie (if-else) and el, and a while command. Some testable conditions are N (true if not zero), !N (true if zero), ` s1’s2 ` (if string s1 == s2), e (even page now), o (odd page), F<font> (Font <font> exists), etc.


Dot with otherwise empty line. Does nothing.

.hw <words>

List of words with exceptional hyphenation.


Ignore text until .. encountered. Found in Copyrights, etc.


Enable kerning. Use .kern 0 to disable.

.length <reg> <string>

Set register to string length.


No output line adjusting.


No hyphenation mode.

.nm N [M [S [I]]]

Line number mode. Set number, multiple, spacing, indentation.

.pc [<c>]

Set page number character. Default is %.

.rj <n>

Right justify the next n lines.

.sp [<n]>

Skip one or n lines. Like a line break of sorts. Value of 0 is just inserts a line break. Also values of .5, etc, are ok.

.substring xx n1 n2

Maybe more like a "slice"?

.tl 'left'center'right'

Title definition.

.tr abcd...

Translate a to b and c to d etc.

.ul N

Underline (or italicize in some contexts) N lines.


There are various macros for use with groff which seem low level, but are a lot better than the real groff stuff. One common one is the macro -man which is useful for interpreting man pages.

Another very useful one is -ms which stands for "manuscript". This has a lot of very useful (essential!) things. If something you’re trying is not working and you think it should, make sure you’re not failing to load the corresponding macro package.

To convert a file with the -ms macro set use:

groff -ms file



Two columns starting here.


Back to one column at this point.


General multicolumn command.


Numbered Heading.


Simple/Standard? Heading (not numbered).


Ordinary paragraph starter.


Indented paragraph - comes with numbers if label supplied.


Right shift. Do the indenting yourself.


Release end. Resets a .RS back left again.


Next paragraph is indented (like blockquoting).


Start next several paragraphs indented.


End the indenting of paragraphs.


Italic. Can also be done by the word with .I word.


Roman. Resets italic back to normal.


Bold. Works like italic and resets with .R the same too.


Constant Width. Courier. Like <tt>.


Increase font from previous size until next major feature. Can be used multiple times and can cancel levels of .SM.


Decrease font from previous size until next major feature.


Normal font size as specified by the PS register.


Box. Don’t confuse with bold. .B2 stops boxed section.


Box a just a word.


Display (like <pre>) start. Also .DS C for center. Doesn’t rearrange words. Useful for code, tables, etc.


Display End.


Keep a block of text together, start.


Keep a block of text together, end.


Keep a block of text together, move the block through the text until it fits (all on the same page).


Begin new page.

.sp n

Insert n spaces.


Non-aligned right margins. (Left justify, not "full" justify.)


Break. Don’t know exactly how it works.


Force a date to be printed (at the bottom of the page).


Suppress printing of a date.


Include signature line (somewhere?). Not too helpful.

.EQ [n]

Equation formatting. Numbered with n.


End of equation? Or some other kind?


Start of table.


End of table.


Specify title.


Specify Author.


Start Abstract.


End Abstract.


Example?, fixed-width, like <tt>.


End Example.


There are named registers (like variables) that can be modified to achieve various effects. Use the .nr NAME VALUE syntax to change them.



Takes effect



Point Size

Next Paragraph



Vertical Spacing

Next Paragraph



Line Length

Next Paragraph



Length Title

Next Paragraph



Paragraph Padding

Next Paragraph



Paragraph Indent

Next Paragraph



Footnote Length

Next FS



Column Width

Next 2C



Intercolumn GTap

Next 2C



Page Offset

Next Page



Head Margin

Next Page



Foot Margin

Next Page



Left Head String


Center Head String


Right Head String


Left Foot String


Center Foot String


Right Foot String


Page Number


\*'e resume accented e (acute?)
\*:u umlaut over u