4

I'm trying to write a manpage by using the man macro package of Groff. Specifically, I would like to write some text like the following:

The daemon can be configured by means of a configuration file. The default location of such file is /etc/trolls.conf, and this is quite nice.

Desired text proprieties:

  • /etc/trolls.conf is rendered in Italic
  • It is followed by a comma which is not in Italic,
  • There is no space between /etc/trols.conf and the comma.

It is incredibly hard to get a text which satisfies such proprieties! For example, the following will result in an Italic comma:

.SH DESCRIPTION
The daemon can be configured by means of a configuration file. The default
location of such file is
.I /etc/trolls.conf,
and this is quite nice.

Result 1

On the other hand, this second attempt will put a space between /etc/trolls.conf and the roman comma:

.SH DESCRIPTION
The daemon can be configured by means of a configuration file. The default
location of such file is
.I /etc/trolls.conf
, and this is quite nice.

Result 2

Is there some way to get this to work?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Dacav
  • 13,590
  • 11
  • 60
  • 87
  • 1
    When writing man pages it is useful to read the man page for the man macros, [groff_man](http://man7.org/linux/man-pages/man7/groff_man.7.html) where you would also find out about the `\c` character at the end of a line to avoid the space, but your solution using the documented `.IR` macro is indeed the preferred one. Troff was created over 40 years ago, and its longevity says a lot for how well it was crafted. – meuh Aug 21 '18 at 08:46
  • 1
    @meuh Thanks for the advice. I noticed that the suggested manpage (`groff_man`) is not available on my operating system (Fedora). The package `groff-1.22.3-15.fc28.x86_64` provides the `groff_man` manpage, but it turned out to be [another variant](https://manpage.me/index.cgi?q=groff_man). – Dacav Aug 21 '18 at 14:39
  • I suppose that is not too surprising, as `\c` is "raw" troff, so I doubt that many people know about it, or any of the weird `\f(` type of inline commands, and perhaps that is just as well. I only know it because I used troff before GNU made it groff and the complexity exploded (judging from some of the other groff man pages). You can read about the original troff typesetting package [here](http://www.troff.org/). For when computers had 64kbytes of ram. – meuh Aug 21 '18 at 14:54
  • @meuh I owe you some respect! – Dacav Aug 21 '18 at 14:57

1 Answers1

2

This typesetting language is incredibly hard (well, it's also incredibly old), and eventually I solved this by looking at existing manpages!

The solution follows:

.SH DESCRIPTION
The daemon can be configured by means of a configuration file. The default
location of such file is
.IR /etc/trolls.conf ,
and this is quite nice.

The .IR macro will in fact alternate between Italic (I) and Roman (R), resulting in the correct rendering effect: good result

Dacav
  • 13,590
  • 11
  • 60
  • 87