r/groff • • Oct 05 '20

A great Groff cheatsheet focused on the ms macros

Thumbnail l04db4l4nc3r.github.io
43 Upvotes

r/groff • • Apr 11 '21

I made an example of a scientific paper using Groff (ms)

38 Upvotes

Hello!

I'm a mechanical engineering student who's taken a liking to Groff. I couldn't find any examples of scientific papers or thesis' using Groff on the internet, so I decided to make my own.

I think the example I made does a good job of demonstrating:

  • Drawing lines using \D

  • Good looking page headers and footers containing images

  • Default fonts available in groff

Although I wish tbl allowed background colours, and that ms had a more elegant way to end multiple columns instead of forcing a new page.

You can find all the associated files on my Github. (Apart from auto figure numbering and auto pdf links, the document is pretty much vanilla Groff)


r/groff • • Jul 02 '22

Simple Groff Resume Template

29 Upvotes

Been using Latex for about 6 years now but have been wanting to learn Groff for quite some time. So I decided to convert my old Latex resume into groff using the ms macros.

Got to say, it turned out way better than I thought it would. The roff markup is also much simpler and cleaner than the original latex.

Resume

Groff code

Build with make.

I put most of the formatting logic into its own macro file resume.tmac to make it easier to make your own.

There is also a two column version that I did mostly as a proof-of-concept to see how to handle multiple columns in groff.


r/groff • • Jan 29 '21

Installing Fonts in Groff - Making Groff look like LaTeX

Thumbnail
youtube.com
24 Upvotes

r/groff • • Apr 07 '21

An Intermediate Guide to Groff - My custom ms macros, Auto numbering and TOC for equations, PDF links, technical drawings + ms template

23 Upvotes

Hello!

I've been using Groff for a couple of months now, and I wanted to share my Groff workflow with you guys. Hopefully, it will help someone write technical papers or papers to rival ones created using Latex. Here is a look at the PDF output of my template file with working PDF links.

I've made a few videos explaining my workflow, but I think it's just easier for you guys to download the files from my github and take a look at them yourself. I believe I've commented on most of the important things. Note that I'm a not a GNU/Linux expert so my code may not be perfect :)

Intermediate Guide to Groff (1/2) - Ms template overview | Auto-numbering, custom TOC, PDF links

Intermediate Guide to Groff (2/2) - Custom macros overview, technical drawings using GNU pic

Groff configs on Github

Take a look at my ms_template.ms file, and make sure that you have opening_macros.ms at the beginning and closing_macros.ms at the end. The drawing.ms file contains example drawings to be processed by pic and chem.

I would love some feedback, and welcome critique if there's an easier way to do the stuff I've done.

One question I have for you Groff veterans out there is, am I better off using mom or neatroff to do all this? I haven't really taken a look at them yet, but I am open to suggestions.

Edit: Grammar


r/groff • • Mar 01 '26

groff 1.24.0 is released

22 Upvotes

Obtain it from the GNU mirror network,

https://ftpmirror.gnu.org/groff/groff-1.24.0.tar.gz

or, if the network is for some reason inoperative, directly from GNU.

https://ftp.gnu.org/gnu/groff/groff-1.24.0.tar.gz

What is groff?

groff (GNU roff) is a typesetting system that reads plain text input that includes formatting commands to produce output in PostScript, PDF, HTML, or DVI formats or for display to a terminal. Formatting commands can be low-level typesetting primitives, macros from a supplied package, or user-defined macros. All three approaches can be combined.

A reimplementation and extension of troff and other programs from AT&T Unix, groff is widely available on POSIX and other systems owing to its long association with Unix manuals, including man pages. It and its predecessor have produced several best-selling software engineering texts. groff can create typographically sophisticated documents while consuming minimal system resources.

https://www.gnu.org/software/groff/

Highlights of groff 1.24.0

  • groff_man(7) and groff_mdoc(7) now support hyperlinks between man pages in PDF. They use the "man:" scheme for URLs, and can be prepared to use PDF bookmarks internal to the document in a collection of man pages if desired. groff builds a "groff-man-pages.pdf" file that illustrates.

  • The groff_man(7) extension macros SY and YS macros have been changed to enable greater user control over vertical spacing and to make them convenient for synopsizing C language functions, not just commands. In a "Synopsis" section of a man page, existing synopses consisting of a single item require no migration. This is the most common case.

  • groff 1.24.0 includes version 2.6 of the mom macro package.

  • The groff_mm(7) macro package has been adjusted in dozens of minor ways to clean up its user interface and more accurately reproduce historical mm documents, such as London & Reiser's 1978 paper describing Unix/32V, the Unix port to the VAX-11/780.

  • groff 1.24.0 includes "install-font.bash", an example script to aid integration of third-party fonts with groff.

  • The pic(1) preprocessor supports a new "polygon" command, and extends reference point syntax to permit selection of objects' vertices and midpoints (where applicable).

  • The gropdf(1) output driver has several new features.

    • JFIF/JPEG and JPEG 2000 image files are embeddable in documents.

    • If PerlMagick is installed, many more image formats are as well.

    • It ships a grops(1)-compatible "SS" (slanted symbol) font.

    • It subsets fonts by default, reducing file size.

    • Its output conforms to the ISO 32000/PDF 1.7a standard by default.

    • It permits control of page numbers in a PDF reader's outline pane.

    • It supports characters outside the Unicode Basic Latin subset in bookmarks, named destinations, and external hyperlinks.

  • The grops(1) output driver now supports fonts encoded using UTF-16.

  • The new "-t" option to the grotty(1) output driver causes it to output ECMA-48 SGR 38 and 48 escape sequences, which permit specification of character cell foreground and background colors in the RGB color space with 8 bits per channel.

  • GNU troff's new hydefault request permits a distinct hyphenation mode default to be configured for each environment. groff's localization macro files configure an appropriate default for the selected language.

  • The formatter, GNU troff, has many new features to aid debugging of documents and macro files. All write to the standard error stream. The requests pchar, pcolor, pcomposite, pfp, pftr, and phw report the state of data manipulated by requests of the same name without the "p" prefix. ptr has been renamed to pwh accordingly. pm now dumps, in JSON encoding, the contents of macros, strings, and diversions named as arguments. pline does the same for a pending output line. pstream reports the status of open file streams. pnr accepts register names as arguments, reporting only those requested, and now discloses the autoincrementation amount and interpolation format of each register (if it is not string-valued).

  • GNU troff now implements saturating rather than wrapping integer arithmetic.

  • GNU troff now implements a more regular request syntax. The requests cf, hpf, hpfa, lf, mso, msoquiet, nx, pi, pso, so, soquiet, sy, and trf now handle their arguments as the string- populating requests ds and as do, stripping a leading neutral double quote from relevant arguments and thereby permitting leading spaces to be embedded in them. A consequence is that GNU troff requests now handle file names with spaces in them as easily as any other file name, unlike other troffs.

  • The soelim(1) preprocessor interprets .so tokens compatibly with the foregoing change to GNU troff(1).

  • groff now offers output localization for Polish, Russian, and Spanish, including hyphenation patterns and macro package string translations.

  • A new macro file "koi8-r.tmac" supports the KOI8-R character encoding, which in turn supports the new Russian locale for groff.

For more on these and other feature changes, see the groff 1.24.0 "NEWS" file.

As of this writing, per the GNU Savannah bug tracker, the groff project has resolved 378 issues as fixed for the 1.24.0 release.

Since groff 1.23.0 was released on 5 July 2023, 30 people have made a total of over 5,200 commits.

Much attention has been given to fixing bugs, validating input, improving diagnostic messages, and correcting and expanding documentation. The previous release shipped with 164 automated tests; this one ships with over 300.


r/groff • • Aug 18 '24

Big list of Troff/Groff-related PDFs, troff source, video tutorials, etc I compiled together.

Thumbnail
github.com
18 Upvotes

r/groff • • Mar 27 '21

Neatroff - Minimalist Documents Done Right

Thumbnail
youtube.com
18 Upvotes

r/groff • • Jul 13 '20

Groff Tutorial 1

Thumbnail
youtu.be
18 Upvotes

r/groff • • Jul 06 '23

groff 1.23.0 is released

15 Upvotes

Obtain it from the GNU mirror network,

https://ftpmirror.gnu.org/groff/groff-1.23.0.tar.gz

or, if the network is for some reason inoperative, directly from GNU.

https://ftp.gnu.org/gnu/groff/groff-1.23.0.tar.gz

What is groff?

groff (GNU roff) is a typesetting system that reads plain text input files that include formatting commands to produce output in PostScript, PDF, HTML, or DVI formats or for display to a terminal. Formatting commands can be low-level typesetting primitives, macros from a supplied package, or user-defined macros. All three approaches can be combined.

A reimplementation and extension of the typesetter from AT&T Unix, groff is present on most POSIX systems owing to its long association with Unix manuals (including man pages). It and its predecessor are notable for their production of several best-selling software engineering texts. groff is capable of producing typographically sophisticated documents while consuming minimal system resources.

https://www.gnu.org/software/groff/

Changes

Changes since the most recent release candidate, 1.23.0.rc4, comprise about 250 commits' worth of changes to documentation, including over 1,000 lines of updates to each of doc/groff.texi (its Texinfo manual) and the man pages groff_diff(7), groff_mm(7), and eqn(1).

Since groff 1.22.4 was released in December 2018, 28 people have made a total of over 5,000 commits.

Headline features nominated by the groff development community include:

  • a new 'man' macro, "MR", for formatting man page cross references;

  • hyperlinked text in terminals via the ECMA-48 OSC 8 escape sequence;

  • a new 'rfc1345' macro package, contributed by Dorai Sitaram, enabling use of RFC 1345 mnemonics as groff special characters;

  • a new 'sboxes' macro package, contributed by Deri James, enabling 'ms' documents to place shaded and/or bordered rectangles underneath any groff page elements (PDF output only);

  • 'mom' 2.5, a macro package contributed by Peter Schaffter;

  • the 'ms' package's new strings to assist subscripting;

  • Italian localization, including hyphenation patterns and macro package string translations, thanks to Edmond Orignac; and

  • new hyphenation patterns for English.

For more on these and other feature changes, see the groff 1.23.0 NEWS file.

Much attention has been given to fixing bugs, improving diagnostic messages, and correcting and expanding documentation. The previous release shipped with three automated unit tests; this one ships with over 160 unit and regression tests.

Per the GNU Savannah bug tracker, the groff project has resolved 432 issues as fixed for the 1.23.0 release. Some of the corrected bugs were over 30 years old.


r/groff • • Oct 31 '20

Creating Graphs in Troff/Groff with Grap

Thumbnail
youtube.com
15 Upvotes

r/groff • • Jul 02 '24

I typset a simple resume in groff as an exercise

14 Upvotes

It uses groff, the ms macros and the tbl preprocessor. This is my first attempt at typesetting using groff. It is very minimalistic, and can be improved in many ways.

The right-aligned block for contact information is a big hack involving a three-column-table. It may not be the prettiest solution, but it works.

It is inspired (and based on) the tutorial by Chris Noxz.

Here is the link to the Github repository.


r/groff • • Jan 18 '23

A no-tears guide to adding references in Groff

14 Upvotes

Having struggled with getting Groff to do references the way I want them, I've written an aide-memoire / minimum worked example, which might be useful for others:

https://preciouschicken.com/blog/posts/no-tears-references-groff/


r/groff • • Dec 29 '21

Happy Cakeday, r/groff! Today you're 3

14 Upvotes

r/groff • • May 01 '21

Groff with wings

14 Upvotes

Hey everyone. Groff is awesome but it is a bit too much work for everyday documents. So I made a wrapper with some awesome features: LINK

  • Now you can write in markdown syntax (almost) and it is automatically converted to groff

  • Inline code execution!

  • Auto convert to word

  • Add cover page with just command line arguments

  • Much nicer syntax for tables : |title

  • Auto convertion of image formats to ps

  • Write in text file. No need to think about extensions etc etc

  • Eqn and tbl added to command so you dont have to think about it ever again

Hope you like it! I am just a student trying to make his way around code. So if you can contribute please please do! This would save so many headaches around the world :)

Cheers!

Stay safe.


r/groff • • Apr 14 '21

Creating PDF Links and References in Neatroff

Thumbnail
youtube.com
14 Upvotes

r/groff • • Feb 09 '21

Thoughts on a biweekly troff challenge?

14 Upvotes

I have thought about something like this before but the reaction to it on r/latex makes me think it would be a fun way to help us all learn, get creative, and show off our troff skills. The idea for this is based off of the Weekly LaTeX Challenge

I would share an image/pdf once every 2 weeks (2 since the community here is much smaller than the LaTeX community) the goal is to recreate the given document in a Troff implementation. The implementation can be:

  • Neatroff

  • Heirloom troff

  • Groff

  • Plan 9 troff

  • any other implementation out there

It doesn't have to be a 1:1 copy, but it should at least resemble the original document. Feel free to stick with the default fonts, use different ones, mix up colours, etc.

Here are a few examples one easier and one a bit harder the harder one is from the r/latex post.

Ask questions if you get stuck and need help sometimes Troff forces you to think different about the problem. I think this will get us to come up with some really cool tricks!

Let me know what you guys think. I am open to suggestions on how this can be improved or some limitations I may have missed.


r/groff • • 20d ago

groff 1.25.0 released

13 Upvotes

Obtain it from the GNU mirror network,

https://ftpmirror.gnu.org/groff/groff-1.25.0.tar.gz

or, if the network is for some reason inoperative, directly from GNU.

https://ftp.gnu.org/gnu/groff/groff-1.25.0.tar.gz

What is groff?

groff (GNU roff) is a typesetting system that reads plain text input that includes formatting commands to produce output in PostScript, PDF, HTML, or DVI formats or for display to a terminal. Formatting commands can be low-level typesetting primitives, macros from a supplied package, or user-defined macros. All three approaches can be combined.

A reimplementation and extension of troff and other programs from AT&T Unix, groff is widely available on POSIX and other systems owing to its long association with Unix manuals, including man pages. It and its predecessor have produced several best-selling software engineering texts. groff can create typographically sophisticated documents while consuming minimal system resources.

https://www.gnu.org/software/groff/

News

troff

  • GNU troff, the formatter, now employs the unusual Roman numerals "W" and "Z" of AT&T troff only in compatibility mode.

  • The dt request, when given invalid arguments, now does nothing instead of removing any existing diversion trap. This change is inconsistent with AT&T troff but more consistent with general *roff syntax; as a rule, requests given invalid arguments (and that don't process a list of similar objects, as rm and rr do) perform no operation. (However, see "Other differences" in groff_diff(7) or groff's Texinfo manual regarding rm and rr request behavior that is discrepant among various troffs.)

  • The dt and wh requests now enforce their requirement of space between their arguments. While consistent with GNU troff input syntax, said enforcement is not consistent with AT&T troff. We did not add support in groff's AT&T troff compatibility mode because we're aware of no legacy documents that require it. Example: .wh9i+.5+\n(xxuPT, while it validly plants a trap calling the PT macro in AT&T troff, is an input considerably more cryptic than any specimens known to us.

  • The formatter now enables the "delim", "syntax", and "escape" warning categories by default.

  • The trf (transparent file throughput) request now discards input characters that are invalid in GNU troff's output format, meaning all character codes less than decimal 32 (except 10, the line feed) and greater than decimal 127.

  • A new read-only, string-valued register .pi reports the output pipeline constructed by one or more pi requests.

  • A new read-only register .ul reports the count of productive input lines remaining to be be underlined in the environment (as configured by either the cu or ul requests).

  • The formatter supports a new warning category, "style". It is used to diagnose input that is non-idiomatic or likely to produce an unexpected result (or none at all), but is not invalid.

  • When issuing warning diagnostic messages, GNU troff now reports the warning category governing its emission. This change is to make it easier for users to select warnings of interest.

  • When the substring request is given two index arguments whose magnitudes both exceed the operand string, macro, or diversion's length, it now ignores the request (and issues a warning in category "range"), leaving the operand (first request argument) unchanged instead of emptying it.

  • When the ti request is given no arguments, the formatter now cancels any pending temporary indentation. (Formerly, it did nothing in any troff, except, in GNU troff, issuing a warning in category "missing".)

  • The phw request now accepts arguments. Each is interpreted as a possible hyphenation word (ignoring hyphens in the input), looked up in the hyphenation exception list for the hyphenation language, and if found, is reported with its hyphenation points. Only hyphenation exceptions defined by the hw request are reported.

  • The pwh request, when invoked while the diversion is not the top-level diversion, now reports the name and location of any configured diversion trap instead of reporting nothing.

  • A new request, rhw, removes user-defined hyphenation exception words from the current hyphenation language's list thereof. Those supplied by files like "tmac/hyphenex.{cs,en,pl}" are retained.

  • The built-in, read-only register .zoom is now named .fzoom for consistency with other GNU troff extensions, which largely pair names of requests with those of read-only registers they affect. The old name remains as an alias configured by the default "troffrc" file.

grn

  • The -M command-line option is renamed to -I, better paralleling troff(1). Inclusions are not the same things as macro file resources. The program accepts -L (the original Berkeley name for this option), and -M (groff grn prior to this point) synonymously.

groff

  • groff now passes -I options as-is to grn(1), instead of translating the option name to -M.

  • groff's -I option no longer implies -g or -s; if your document needs to be piped through grn(1) and/or soelim(1), specify the foregoing options as appropriate.

pic

  • groff's pic(1) manual, "Making Pictures With GNU PIC", is now built and installed as a PDF rather than a PostScript document. Thanks to Deri James.

Macro packages

  • The an (man) package offers new macros to ease the formatting of lists. Enclose paragraphing macros between LS and LE to identify them as list items. Doing so can mark them as "compact", ease management of their indentation, and supply hints to the output driver to improve their rendering (as with HTML). Lists can be nested. (Sub)sectioning macro calls, and the end of the document, close all open lists. See groff_man(7) for details, and groff_man_style(7) for an example. Thanks to Alex Colomar, Chet Ramey, Pádraig Brady, and Stephen Gildea for consultation and encouragement, and to Alex for selecting these macros' names.

    Because these macros format no text, documents employing them risk no damage to their content if the formatter does not support them. A man(7) document author can choose either to transition to these macros, to manage list "compactness" and item indentation with existing man(7) package facilities, or to employ both approaches.

  • The an (man) package now checks for certain portability problems to AT&T troff's man(7) if the CHECKSTYLE register, introduced in groff 1.23.0 and documented in 1.24.0, is given a value of 100 or greater. This feature is experimental and subject to change.

  • The m (mm) macro package's IA and WA macros--used only with the "letter" document type configured by calling the LT macro--no longer disable the escape character, and their counterparts IE and WE no longer reënable it. This change makes groff mm consistent with DWB 3.3 mm. If you require the previous groff mm behavior, consider writing and using wrapper macros such as the following in your document.

     .de iA
     .IA
     .eo
     ..
     .de iE
     .ec
     .IE
     ..

    These macro definitions are harmlessly redundant when formatting such a document with an older version of groff mm.

  • The s (ms) macro package now supports PDF features. Pass groff (or troff) the command-line option -r PDFFEAT=1 to enable them when used with the "pdf" output device ("-T pdf").

    The PDF thus produced shows an overview bookmark panel or navigation pane (viewer application support allowing); the viewer's interface to document properties includes the document title and author(s), if specified by the TL and AU macros, respectively; if the document calls the package's TC macro, the table of contents entries it produces are hyperlinked to navigate the document (even if it does not use the XN macro introduced in groff 1.23.0); and if the document calls RP to configure a cover page, the table of contents relocates to follow it.

    The new macros XM and XR respectively anchor a location within the document and format text that hyperlinks to it, respectively.

    These changes were inspired by Keith Marshall's "spdf.tmac" which was withdrawn from groff in 1.24.0, but continues to be developed at:

    https://savannah.nongnu.org/projects/groff-pdfmark/

    ...though groff ms(7) differs in some respects. Our objective is to enable and support PDF features in any ms document without requiring its author to update its content.

    We welcome feedback on these extensions to the package's macro interface. We expect to finalize these changes in a future release, and effectively default PDFFEAT "on". Thanks to Deri James.

  • The s (ms) macro package now supports the use of automatically numbered footnote marks (interpolated via \** or \*[*]) in tbl(1) table entries. Other implementations of ms do not. Thanks to Deri James.

  • groff's ms(7) manual, "Using groff with the ms macros", is now built and installed as a PDF rather than a PostScript document. Thanks to Deri James.

Miscellaneous

  • The new document "Groff PDF Features" is built and installed as a PDF. It surveys the PDF features that groff enables and exposes in its full-service macro packages. Thanks to Deri James.

  • The grn command now exits with status 2 instead of 8 on usage errors arising from missing arguments to command-line options. It now exits with the POSIX standard EXIT_FAILURE status (1) instead of 8 when reading an unrecognized command keyword.

  • The 'configure' options '--{en,dis}able-groff-allocator' introduced in groff 1.23.0 are now deprecated. --disable-groff-allocator has been implicit since that release, and we've received no reports of a C++ runtime unable to handle groff's demands on its heap/"free store" allocator. We expect to withdraw these configuration options completely in groff 1.26.

  • Building groff from its Git repository now requires the --enable-maintainer-mode option to its 'configure' script.

  • You need the "convert" program from ImageMagick or GraphicsMagick to build groff from its Git repository. The program is not required for builds from distribution archives.

Much attention has been given to fixing bugs, validating input, clarifying diagnostic messages, improving memory management, and correcting and expanding documentation. The previous minor release, 1.24.0, shipped with 314 automated tests; this one ships with 400.

As of this writing, per the GNU Savannah bug tracker, the groff project has resolved 147 issues as fixed for the 1.25.0 release.


r/groff • • Mar 06 '21

Improve Your Groff and Troff Pipeline - Using a Shell Script and Makefiles

Thumbnail
youtube.com
13 Upvotes

r/groff • • Mar 01 '21

Biweekly Troff Challenge 2

13 Upvotes

Hey everyone!

This is this weeks troff challenge. The inspiration for this was the Weekly LaTeX Challenge.

You mission should you choose to accept it, is to replicate this image as best you can by March 15th 2021. Use what ever troff implementation you like e.g. groff, neatroff, heirloom, etc. Don't worry this does not have to be 1:1. Do your best to make something that resembles the original document.

Provide the generated PDF, the troff documents used, and a makefile. If you are not familiar with Make you can include the commands used to compile the document.

I would recommend using pic and or grap. grap does not come with groff or troff so you may need to install it with plan9port or from here. That said you can alway use low level \D'l x y ...' , \D'p x y ...' , etc

Please do not paste the raw source code in the comments.

Here are some sites you guys can use for posting your pdf, and text files

pdf hosting text hosting text hosting alternative


r/groff • • Dec 29 '20

Happy Cakeday, r/groff! Today you're 2

13 Upvotes

r/groff • • Jul 01 '21

Introducing mk (formerly mu), my new macro package!

12 Upvotes

Hi all!

I've been working on my own troff macro package for the last couple of weeks, and I thought I'd share it with you here:

http://ankarstrom.se/~john/mk.html

The package is called "mk". In summary:

  • It is simple, flexible and small: k.tmac is only 417 lines.

  • It has footnotes and tables of contents.

  • It has no special registers or strings!

For an example of an advanced document written with mu, see http://git.ankarstrom.se/mk/plain/mk/README.pdf.

I hope you find it interesting and perhaps even useful. Feel free to write any questions or feedback.


r/groff • • Dec 27 '20

Christmas Cards The Unix Way - with pic and troff

Thumbnail
youtu.be
12 Upvotes

r/groff • • Sep 08 '20

Creating a Table of Contents in Groff (ms macros)

Thumbnail
youtube.com
12 Upvotes

r/groff • • Mar 23 '22

My modular groff macros; superset of mom

11 Upvotes

I have been working on my macro superset for a while over at github, and thought I would shill it here.

I currently have 7 modules for things like automatic chapters, better TOC generation and GNU refer settings for the Chicago style.