gtroff has if-then-else constructs like other languages, although
the formatting can be painful.
Evaluate the expression expr, and executes anything (the remainder of the line) if expr evaluates to a value greater than zero (true). anything is interpreted as though it was on a line by itself (except that leading spaces are swallowed). See Operators in Conditionals, for more info.
.nr xxx 1 .nr yyy 2 .if ((\n[xxx] == 1) & (\n[yyy] == 2)) true ⇒ true
Use the
ieandelrequests to write an if-then-else. The first request is the `if' part and the latter is the `else' part..ie n .ls 2 \" double-spacing in nroff .el .ls 1 \" single-spacing in troff
In many cases, an if (or if-else) construct needs to execute more than one request. This can be done using the
\{and\}escapes. The following example shows the possible ways to use these escapes (note the position of the opening and closing braces)..ie t \{\ . ds lq `` . ds rq '' .\} .el \ .\{\ . ds lq " . ds rq "\}
See Expressions.