escapingmanpagegroff

Escaping dots in groff


According to info groff (section 5.11 Character Translations), \. should print just the dot. However, this is not what seems to happen. If I render this manpage

.TH x x x x
\.SH foo

I get foo rendered as a section heading, and .SH is not printed.

So, why does this happen, and how do I escape the dot (and the apostrophe) at the begginning of the line in groff?


Solution

  • To escape dot at the beginning of line write use \[char46] :

    \[char46]SH foo
    

    prints

    .SH foo
    

    This is an expected behavior but should be fixed in manual page. Here is a bug report.

    Below you can read the description of both \\ (shortened) and \. (from info pages).

    -- Escape: \\
    [...]
    
    `\\' is a `delayed' backslash; more precisely, it is the default
    escape character followed by a backslash, which no longer has
    special meaning due to the leading escape character. It is _not_
    an escape sequence in the usual sense! In any unknown escape
    sequence `\X' the escape character is ignored and X is printed.
    But if X is equal to the current escape character, no warning is
    emitted.
    
    As a consequence, only at top-level or in a diversion a backslash
    glyph is printed; in copy-in mode, it expands to a single
    backslash which then combines with the following character to an
    escape sequence.
    
    [...]
    
    -- Escape: \.
    Similar to `\\', the sequence `\.' isn't a real escape sequence.
    As before, a warning message is suppressed if the escape character
    is followed by a dot, and the dot itself is printed.