Classes are particularly useful for East Asian languages such as Chinese, Japanese, and Korean, where the number of needed characters is much larger than in European languages, and where large sets of characters share the same properties.
groff, a character class (or simply “class”) is a set of characters, grouped by some user aspect. The
classrequest defines such classes so that other requests can refer to all characters belonging to this set with a single class name. Currently, only the
cflagsrequest can handle character classes.
classrequest takes a class name followed by a list of entities. In its simplest form, the entities are characters or symbols:.class [prepunct] , : ; > }
Since class and glyph names share the same namespace, it is recommended to start and end the class name with
], respectively, to avoid collisions with normal
groffsymbols (and symbols defined by the user). In particular, the presence of
]in the symbol name intentionally prevents the usage of
\[...], thus you must use the
\Cescape to access a class with such a name.
You can also use a special character range notation, consisting of a start character or symbol, followed by ‘-’, and an end character or symbol. Internally,
gtroffconverts these two symbol names to Unicode values (according to the groff glyph gist) which then give the start and end value of the range. If that fails, the class definition is skipped.
Finally, classes can be nested, too.
Here is a more complex example:.class [prepunctx] \C'[prepunct]' \[u2013]-\[u2016]
The class ‘prepunctx’ now contains the contents of the class
prepunctas defined above (the set ‘, : ; > }’), and characters in the range between
If you want to add ‘-’ to a class, it must be the first character value in the argument list, otherwise it gets misinterpreted as a range.
Note that it is not possible to use class names within range definitions.
Typical use of the
classrequest is to control line-breaking and hyphenation rules as defined by the
cflagsrequest. For example, to inhibit line breaks before the characters belonging to the
prepunctxclass, you can write:.cflags 2 \C'[prepunctx]'
cflagsrequest in Using Symbols, for more details.