groff: Request and Macro Arguments
5.5.1.1 Request and Macro Arguments
...................................
Arguments to requests and macros are processed much like the shell: The
Macro Arguments-Footnote-1::)
An argument to a macro that is intended to contain spaces can either
be enclosed in double quotes, or have the spaces "escaped" with
backslashes. This is _not_ true for requests.
Here are a few examples for a hypothetical macro 'uh':
.uh The Mouse Problem
.uh "The Mouse Problem"
.uh The\ Mouse\ Problem
The first line is the 'uh' macro being called with 3 arguments, 'The',
'Mouse', and 'Problem'. The latter two have the same effect of calling
Request and Macro Arguments-Footnote-2::)
A double quote that isn't preceded by a space doesn't start a macro
argument. If not closing a string, it is printed literally.
For example,
.xxx a" "b c" "de"fg"
has the arguments 'a"', 'b c', 'de', and 'fg"'. Don't rely on this
obscure behaviour!
There are two possibilities to get a double quote reliably.
* Enclose the whole argument with double quotes and use two
consecutive double quotes to represent a single one. This
traditional solution has the disadvantage that double quotes don't
survive argument expansion again if called in compatibility mode
(using the '-C' option of 'groff'):
.de xx
. tm xx: `\\$1' `\\$2' `\\$3'
.
. yy "\\$1" "\\$2" "\\$3"
..
.de yy
. tm yy: `\\$1' `\\$2' `\\$3'
..
.xx A "test with ""quotes""" .
=> xx: `A' `test with "quotes"' `.'
=> yy: `A' `test with ' `quotes""'
If not in compatibility mode, you get the expected result
xx: `A' `test with "quotes"' `.'
yy: `A' `test with "quotes"' `.'
since 'gtroff' preserves the input level.
* Use the double quote glyph '\(dq'. This works with and without
compatibility mode enabled since 'gtroff' doesn't convert '\(dq'
back to a double quote input character.
Note that this method won't work with Unix 'troff' in general since
the glyph 'dq' isn't defined normally.
Double quotes in the 'ds' request are handled differently. ⇒
Strings, for more details.