groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Groff] Odd problem escaping `.'


From: Keith MARSHALL
Subject: Re: [Groff] Odd problem escaping `.'
Date: Tue, 2 May 2006 15:03:23 +0100

Louis Gillaume wrote:
> I'm looking for a way to get my section numbers in the table of
> contents. This is with -ms.
>
> This is what I've been trying:
>
> .NH 1
> OVERVIEW
> .XS
> \n[H1]
> \.\n[H2]

You would need \&.\n[H1] here, if the intention is to pass the initial
dot through as text; (the \& is a non-spacing invisible character, which
serves to hide the dot, suppressing its recognition as a precursor for
a troff request).

> \.\n[H3]
> OVERVIEW
> .XE

> Why does it not produce:
>   1.0.0.0 OVERVIEW . . . . . .

Because \. isn't sufficient to hide the dot from the parser, which still
recognises this as a request precursor.  OTOH, when you use \\.\n[H3],
you do prevent such recognition, because you've now placed a visible
reverse solidus glyph before the initial dot.

If you do use \& to "escape" the dot, you still will not get the effect
you wanted, because you've introduced white space before each dot, (as
a result of the newlines before each).  Thus what you will get is:

  1 .0 .0 OVERVIEW . . . .

As Joerg has already pointed out, you could get around this by:

  .NH 1
  OVERVIEW
  .XS
  \n[H1].\n[H2].\[H3] OVERVIEW
  .XE

but this still isn't a good solution, for while .NH 1 does set the number
register H1, it does *not* set H2, H3, or above -- they will simply remain
set at whatever value they had after previous .NH 2, .NH 3, etc., which
probably isn't what you want.

A better solution, which Joerg also suggested, is to use:

  .NH 1
  OVERVIEW
  .XS
  \*[SN_DOT] OVERVIEW
  .XE

which will give you:

  1. OVERVIEW . . . .

or:

  .NH 1
  OVERVIEW
  .XS
  \*[SN_NO_DOT] OVERVIEW
  .XE

which will give you:

  1 OVERVIEW . . . .

if you prefer not to see the final dot after the section number; it
will still insert dots *between* subhead levels, as in

  1.1 SUBHEAD . . .

Note that Joerg actually suggested \*[SN]; by default this is the
same as \*[SN], (it's an alias), but using \*[SN_DOT] and \*[SN_NO_DOT]
is more explicit, (and you can change the \*[SN] behaviour, e.g. by

  .als SN SN_NO_DOT

if you prefer the latter behaviour).

HTH,
Keith.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]