Character Translations
======================
The control character (`.') and the no-break control character (`'')
can be changed with the `cc' and `c2' requests, respectively.
- Request: .cc [c]
Set the control character to C. With no argument the default
control character `.' is restored. The value of the control
character is associated with the current environment (Note:Environments).
- Request: .c2 [c]
Set the no-break control character to C. With no argument the
default control character `'' is restored. The value of the
no-break control character is associated with the current
environment (Note:Environments).
- Request: .eo
Disable the escape mechanism completely. After executing this
request, the backslash character `\' no longer starts an escape
sequence.
This request can be very helpful in writing macros since it is not
necessary then to double the escape character. Here an example:
.\" This is a simplified version of the
.\" .BR request from the man macro package
.eo
.de BR
. ds result \&
. while (\n[.$] >= 2) \{\
. as result \fB\$1\fR\$2
. shift 2
. \}
. if \n[.$] .as result \fB\$1
\*[result]
. ft R
..
.ec
- Request: .ec [c]
Set the escape character to C. With no argument the default
escape character `\' is restored. It can be also used to
re-enable the escape mechanism after an `eo' request.
Note that changing the escape character globally will likely break
macro packages since `gtroff' has no mechanism (like TeX) to
`intern' macros, i.e., to convert a macro definition into an
internal form which is independent of its representation. If a
macro is called, it is executed literally.
- Escape: \e
This escape sequence prints the current escape character (which is
the backslash character `\' by default).
A "translation" is a mapping of an input character to an output
character. The default mappings are given in the font definition files
for the specific output device (Note:Font Files); all mappings (both
with `tr' and in the font definition files) occur at output time, i.e.,
the input character gets assigned the metric information of the mapped
output character.
- Request: .tr abcd...
Translate character A to B, character C to D, etc. If there is an
odd number of arguments, the last one is translated to the space
character.
Some notes:
* Special characters (`\(XX', `\[XXX]', `\C'XXX'', `\'', `\`',
`\-', `\_'), characters defined with the `char' request, and
numbered characters (`\N'XXX'') can be translated also.
* The `\e' escape can be translated also.
* Characters can be mapped onto the `\%' and `\~' escapes (but
`\%' and `\~' can't be mapped onto another character).
* The following characters can't be translated: space (with one
exception, see below), backspace, newline, leader (and `\a'),
tab (and `\t').
* Translations are not considered for finding the soft hyphen
character set with the `shc' request.
* The character pair `C\&' (this is an arbitrary character C
followed by the zero width space character) maps this
character to nothing.
.tr a\&
foo bar
=> foo br
It is even possible to map the space character to nothing:
.tr aa \&
foo bar
=> foobar
As shown in the example, the space character can't be the
first character pair as an argument of `tr'. Additionally,
it is not possible to map the space character to any other
character; requests like `.tr aa x' undo `.tr aa \&' instead.
If justification is active, lines are justified in spite of
the `empty' space character (but there is no minimal
distance, i.e. the space character, between words).
* After an output character has been constructed (this happens
at the moment immediately before the character is appended to
an output character list, either by direct output, in a
macro, diversion, or string), it is no longer affected by
`tr'.
* Without an argument, the `tr' request is ignored.
- Request: .trnt abcd...
`trnt' is the same as the `tr' request except that the
translations do not apply to text that is transparently throughput
into a diversion with `\!'. Note:Diversions, for more
information.
For example,
.tr ab
.di x
\!.tm a
.di
.x
prints `b' to the standard error stream; if `trnt' is used instead
of `tr' it prints `a'.