groff: Operators in Conditionals
5.20.1 Operators in Conditionals
--------------------------------
In 'if', 'ie', and 'while' requests, in addition to ordinary
Expressions, there are several more operators available:
'e'
'o'
True if the current page is even or odd numbered (respectively).
'n'
True if the document is being processed in nroff mode (i.e., the
'.nroff' command has been issued). Troff and Nroff Mode.
't'
True if the document is being processed in troff mode (i.e., the
'.troff' command has been issued). Troff and Nroff Mode.
'v'
Always false. This condition is for compatibility with other
'troff' versions only (identifying a '-Tversatec' device).
''XXX'YYY''
True if the output produced by XXX is equal to the output produced
by YYY. Other characters can be used in place of the single
quotes; the same set of delimiters as for the '\D' escape is used
(Escapes). 'gtroff' formats XXX and YYY in separate
environments; after the comparison the resulting data is discarded.
.ie "|"\fR|\fP" \
true
.el \
false
=> true
The resulting motions, glyph sizes, and fonts have to match,(1)
(Operators in Conditionals-Footnote-1) and not the
individual motion, size, and font requests. In the previous
example, '|' and '\fR|\fP' both result in a roman '|' glyph with
the same point size and at the same location on the page, so the
strings are equal. If '.ft I' had been added before the '.ie', the
result would be "false" because (the first) '|' produces an italic
'|' rather than a roman one.
To compare strings without processing, surround the data with '\?'.
.ie "\?|\?"\?\fR|\fP\?" \
true
.el \
false
=> false
Since data protected with '\?' is read in copy-in mode it is even
possible to use incomplete input without causing an error.
.ds a \[
.ds b \[
.ie '\?\*a\?'\?\*b\?' \
true
.el \
false
=> true
'r XXX'
True if there is a number register named XXX.
'd XXX'
True if there is a string, macro, diversion, or request named XXX.
'm XXX'
True if there is a color named XXX.
'c G'
Conditionals-Footnote-2::); G is either an ASCII character or a
special character ('\N'XXX'', '\(GG' or '\[GGG]'); the condition is
also true if G has been defined by the 'char' request.
'F FONT'
True if a font named FONT exists. FONT is handled as if it was
opened with the 'ft' request (this is, font translation and styles
are applied), without actually mounting it.
This test doesn't load the complete font but only its header to
verify its validity.
'S STYLE'
True if style STYLE has been registered. Font translation is
applied.
Note that these operators can't be combined with other operators like
':' or '&'; only a leading '!' (without whitespace between the
exclamation mark and the operator) can be used to negate the result.
.nr xxx 1
.ie !r xxx \
true
.el \
false
=> false
A whitespace after '!' always evaluates to zero (this bizarre
behaviour is due to compatibility with UNIX 'troff').
.nr xxx 1
.ie ! r xxx \
true
.el \
false
=> r xxx true
It is possible to omit the whitespace before the argument to the 'r',
'd', and 'c' operators.
Expressions.