Next: , Previous: , Up: GNU troff Reference   [Contents][Index]


5.7 Comments

One of the most common forms of escape sequence is the comment.67

Escape sequence: \"

Start a comment; read everything up to the next newline in copy mode (see Copy Mode) and discard it. \" is interpreted even in copy mode.

It can be tricky to keep the comments from interfering with the appearance of the output. If the escape sequence is to the right of some text or a request, that portion of the line is ignored, but GNU troff processes spaces preceding it normally. This affects requests that read the remainder of the control line as a single argument, including ds, as, tm, and char; their variants; as well as ab, device, length, output, pi, pso, rd, sy, write, and writec.

One possibly irritating idiosyncrasy is that tabs should not be used to vertically align comments in the source document. Tab characters are not treated as separators between a request name and its first argument, nor between arguments.

The formatter handles a \" comment on a line by itself as a blank line, because after eliminating the comment, that is all that remains.

apples bananas
\" cantaloupes
durians
    ⇒ apples bananas
    ⇒
    ⇒ durians

To compensate, it is common to combine the empty request with the comment escape sequence as ‘.\"’, causing the input line to be ignored.

Another commenting scheme sometimes seen is three consecutive neutral apostrophes (''') at the beginning of an input line. This works,68 but GNU troff emits a warning diagnostic (if enabled) about an undefined macro (namely ‘''’).

Escape sequence: \#

Start a whole-line comment; read everything up to and including the next newline in copy mode69 and discard it. GNU troff introduced this extension to avoid the problems described above. (\" is still widely seen, and remains useful for partial-line comments on control lines.) \# is interpreted even in copy mode.

.nr in-indonesia 1
apples bananas \" common favorites
\# cantaloupes
.ie \n[in-indonesia] durians \" Borneo, Sumatra
.el                  elderberries \" England, France
    ⇒ apples bananas durians

If we change the comment escape sequence from \" to \# on the line with the ie request, we get the following undesired output.

    ⇒ apples bananas durians .el elderberries
Request: .ig [end]

Ignore input until, in the current conditional block (if any),70 the macro end is called at the start of a control line, or the control line ‘..’ is encountered if end is not specified. ig is parsed as if it were a macro definition, but its contents are discarded, not stored.71

.ll 45n
hand\c
.de TX
fasting
..
.ig TX
This is part of a large block of input that has been
temporarily(?) commented out.
.TX
shake
    ⇒ handfasting shake

Observe the result if we remove the ig request and the call of its end macro.

    ⇒ handThis  is  part  of a large block of input
    ⇒ that has been temporarily(?)  commented  out.
    ⇒ shake

Next: , Previous: , Up: GNU troff Reference   [Contents][Index]