12 May 2021

Neatroff is a typesetting tool for creating documents. It is a modern rewrite of GNU's groff (which has it's roots in `troff` from 1973). So this software has a very rich history, yet there's not much resources on the internet (in comparison to latex). So why should you care? Because it is extremaly fast. And does not weight 2GB like latex.

Installing neatroff

If you're using unix (macos is unix) or linux you probably have already groff or troff installed. You can use them mostly the same as neatroff.

The easiest method of installing neatroff is by using the neatroff_make repository. Just clone it with git then run make and it will download all needed resources (fonts, tmacs). Then go to the `/demo` directory and you can now test things out.



If you're using NixOS you can easily download neatroff from my nur:

$ nix-shell -p

In that package you will find these binaries: eqn pdf pic post refer roff soin tbl

Using neatroff

Here's a basic file:

This is document title
Patryk Niedźwiedziński
This is an introductory paragraph describing what the document will be about.
As this document is created for demonstratory purposes it will be short and trivial.

Then run: `roff -ms | pdf > demo.pdf`

(For groff: groff -ms -Tpdf > demo.pdf)

Tool description

Basically there are 3 types of tools in neatroff: preprocessors, text processor (a.k.a. roff) and postprocessors.

All of them easily customizable pipeline:

cat $file | eqn | tbl | roff -ms | pdf


Those are programs that run on source document. They prepare neatroff document for rendering i.e. render equations (eqn) or tables (tbl)

Thanks to simplicity of neatroff design you can simply write your own preprocessor. For example this is a preprocessor for fixing em-dashes: `cat | sed 's/---/\(em/g' | roff`

Text processor

roff - it's the main tool in neatroff pipeline. It executes macros and produces postscript document.


Those are programs that run on output of roff, on postscript document. The most basic is pdf postprocessor for converting postscript to pdf.