Groff - ArchWiki

# Groff

From ArchWiki
Jump to navigation Jump to search

Related articles

- Man page

According to Wikipedia:

  Groff (GNU troff) is a typesetting system that reads plain text mixed with formatting commands and produces formatted output.

Output may be PostScript or PDF, html, or ASCII/UTF8 for display at the terminal. Formatting commands may be either low-level typesetting requests (“primitives”) or macros from a supplied set. Users may also write their own macros. All three may be combined. Using groff may be a solid alternative to TeX Live due to small size and native language.

## Installation

You may find groff package already installed on your system as it is a part of base-devel group in core repository. Otherwise install it with pacman as usual.

### Package documentation

Groff's detailed documentation and usage examples are available via info package:

     info groff

Manpages also contain general information, use:

     man groff

You can also access the documentation online at:

- https://www.gnu.org/software/groff/groff.html#documentation

## Usage

Groff is a powerful and yet lightweight easy to use system. You can see an example of document created in groff here.

This was made with -me macros, however, groff has several built-in macros as well.

You may be interested in using ms for not complicated tasks or mom to produce scientific papers. See:

     man 7 groff_ms
     man 7 groff_mom

See the following resources for feature information:

- The Groff and Friends HOWTO
- Creating Documents in Groff or LaTeX
- Mom macros examples

## Tips and tricks

### Adding support for cyrillic fonts

If you see inappropriate symbols when output documents with cyrillic fonts to ps or pdf, make following steps:

- Download type1 fonts with cyrillic support (for example from here Arial, Times, Courier, read README.html)
- Place your cyrillic type1 fonts into `/usr/share/fonts/gsfonts` -- this is default folder for ghostscript to find fonts
- Change ghostscript fontmap file to associate default fonts with cyrillic ones in `/usr/share/ghostscript/%YOUR_VERSION%/Resource/Init/Fontmap.GS`

     cd /usr/share/ghostscript/%YOUR_VERSION%/Resource/Init/
     cp Fontmap.GS Fontmap.GS.backup
     vim Fontmap.GS

- Use '%' to comment lines with default associations. Place below new aliases, as follows:

     %/Times-Roman /NimbusRoman-Regular ;
     /Times-Roman  /TimesNRCyrMT ;
     /TimesNRCyrMT (times8.pfb) ;

Where '(times8.pfb)' is a name of your copied type1 font.

- From now on you can prepend your default groff command with iconv prefix to print cyrillic symbols in ps files:

     iconv -f utf-8 -t koi8-r test.ms | groff -ms -Tps > test.ps && ps2pdf test.ps test.pdf

### Correctly display Polish diacritics

To display Polish diacritics:

     groff -Kutf8 -Tdvi -mec -ms test.ms > test.dvi
     dvipdfm -cz 9 test.dvi

## See also

- Groff parser and template engines for Rails
- Mom macros
- Mom macros full manual

Category:

- Applications