groff
[Top][All Lists]
Advanced

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

RE: [Groff] surprise, surprise


From: Ted Harding
Subject: RE: [Groff] surprise, surprise
Date: Sun, 26 Aug 2001 11:41:24 +0100 (BST)

On 25-Aug-01 Werner LEMBERG wrote:
> 
> Consider the following example:
> 
>   .de test
>   Hallo!
>   ..
>   \fB.test\fP
> 
> Surprisingly, this yields
> 
>   Hallo!
> 
> Even more surprising is the fact that it isn't bold...
> 
> Is this documented?  How does UNIX troff behave?

A documentation reference (if there is one anywhere, for
any version of troff) would be of interest.

In the revised "Troff User's Manual" which I am preparing
(now increasingly out-of-date under the flow of Werner's
upgrades to groff ... ) I wrote (for Section 2.1):

  The character whose name is \& is simply a logical object
  which occupies no space, and produces no visible result on
  printing. Its primary function is to provide a `dummy character'
  for special purposes: for instance, if it is desired that a
  printed line should begin with the characters .B, it could be
  input as \&.B where the \& serves to `hide' the initial dot
  (i.e. the dot is no longer the first character on the line)
  and prevents the .B being interpreted as a request for the Bold
  font (see below). Note that escape sequences such as \fB do
  not have the effect of `hiding' an initial dot: they are in
  effect transparent in this respect.

However, that (the bit about \fB etc. being transparent for
recognition of the start of a line) was based on experience
and not any any documentation that I can remember seeing.
(I do remember seeing documentation about the above use of \&,
though).

As to the fact that

  \fB.test\fP

does not produce bold text, I think the logic is that when
the line is parsed, ".test" does not evaluate immediately to
"Hallo!" but instead to a request name. The operation of
calling the macro (i.e. inserting the macro body into the
input stream) does not take place until the \n at the end
of the line is encountered. By this time, \fP has already
been encountered which has reset the current font to its
previous incarnation.

Hence as far as the font change is concerned \fB.test\fP is
equivalent to \fB\fP.

As evidence for this interpretation, consider the effect of
moving the trailing \fB down to the next input line:

  .de test
  Hallo!
  ..
  \fB.test
  \fP

You will (should ... ) find that it now prints in Bold.

It would of course be different if the macro had arguments.
For instance:

  .de test
  \\$*
  ..

  \fB.test Hallo!\fP

would again print "Hallo!" in Bold, because the macro
arguments carry their font with them when they are substituted
in the body of the macro.

Just my thoughts -- I don't know for absolutely sure about
any of this!

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 167 1972
Date: 26-Aug-01                                       Time: 11:41:24
------------------------------ XFMail ------------------------------

reply via email to

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