Mom -- Inline escapes

Next Prev Back to Table of Contents

## Inline escapes

Introduction to inline escapes
Index of inline escapes

## Introduction to inline escapes

Inline escapes, as described in the groff terms section of this manual, are typesetting commands that appear in text input lines, as opposed to macros and other control lines that must appear on lines by themselves.

Aside from altering type parameters within a line, inlines also tell groff about special characters -- em-dashes, bullets, figure/digit-width spaces, and so on. It is beyond the scope of this manual to provide a complete list of groff's inline functions and special characters. I recommend having a look at the canonical reference materials should you need more information than is contained herein.

In groff, the escape character is the backslash ( \ ). Groff interprets everything following the backslash as instructions, not literal text, until the escape sequence is complete. Should you need the actual backslash character as part of a line of text, simply enter it twice ( \\ ). Groff understands that this means "please print a backslash character." (You can also use \e to print a literal backslash.)

Groff has a number of ways of recognising what constitutes a complete escape sequence. This is both a boon and a curse; some escape sequences have no terminating delimiter and consequently become difficult to distinguish from real input text. Others require the use of an opening parenthesis with no corresponding closing parenthesis. Still others need to be enclosed in square brackets.

Mom recognises that certain escapes get used more often than others. For these, she has a consistent input style that takes the form \*[...], which makes them stand out well from the text of your documents. These escapes are the ones listed under Mom's personal inlines.

Despite mom's best intentions, there are still a number of typesetting functions that can only be accomplished with groff's native inline escapes. I've listed the ones that strike me as essential, but there are many others. If you want to know what they are, please read the canonical reference materials pertaining to groff.

HELPFUL BIT OF INFORMATION: Inline escapes can be used in document processing macros that take string arguments.

### Inlines index

- Mom's personal inlines
  - Changing fonts
  - Changing point size
  - Pairwise kerning
  - Horizontal movement
  - Vertical movement
  - Full measure rules
- Groff inline escapes
  - Font control \f
  - Inline horizontal motions \h
  - Inline vertical motions \v
  - String width function \w
  - Horizontal line drawing function \l
  - Special characters

## Mom's personal inlines

### Changing fonts

Mom provides five inlines to change fonts inline.

| \*[ROM] | Change font to roman
| \*[IT] | Change font to italic
| \*[BD] | Change font to bold
| \*[BDI] | Change font to bold italic
| \*[PREV] | Revert to previous font

See also font control with \f for other ways to change fonts inline.

NOTE: If you're using the document processing macros, inline font changes remain in effect only for the duration of the current macro.

### Changing point size

Mom's inline escape for changing point size, sadly, does not observe her normal inline syntax \*[whatever]. It's the only exception, and there's no way around it. The escape for changing point size looks like this:

    	\*S[size]

where "size" is the new size you want. For example, to change the point size inline to 12 points, you'd enter

    	\*S[12]

Notice that the new size does not require a unit of measure; points is assumed. However, a unit of measure may be appended to the size, if that's what you wish. Fractional sizes are, of course, allowed.

The size given to \*S may be expressed in plus or minus terms, which can be very useful. In the following example, the word "mom" will be output 2 points larger than the point size of the rest of the line.

    	While she isn't perfect, \*S[+2]mom\*S[-2] isn't half bad.

NOTE: If you're accustomed to groff's usual way of handling inline size requests (`\sN, \s±N, \s(NN, \s±(NN, \s[NNN], \s±[NNN]`), feel free to continue with your old habits. Mom doesn't care.

### Pairwise kerning

Pairwise kerning means moving specific letter pairs closer together or further apart (see Typesetting terms, kerning for more details).

Mom permits inline pairwise kerning through the use of the inline escapes

| \*[BU #] | Closes the space between letters (Back Units).
| \*[FU #] | Opens the space between letters (Forward Units).

"#" is the number of kern units by which to close or open the space between letters. Decimal fractions are allowed.

For example,

    	THE HUMAN COST OF COMMODIF\*[FU 1]YING FRESH W\*[BU 4]A\*[BU 5]TER

moves the letter Y in "COMMODIFYING" 1 kern unit away from the letter F, and the letter A in "WATER" 4 kern units closer to the letter W. Additionally, the letter T in "WATER" is moved 5 kern units closer to the letter A.

For backward compatibility, the forms

| \*[BU1]...\*[BU36] | Move back 1...36 kern units
| \*[FU1]...\*[FU36] | Move forward 1...36 kern units

also exist (i.e. with no space before the number of kern units desired, up to a limit of 36).

NOTE: Using BU or FU between characters pairs that are already automatically kerned disables the automatic kerning and uses the value you give to BU or FU instead.

### Horizontal inline movement

Sometimes, you may need to insert a specified amount amount of white space into an output line, or -- occasionally -- back up to a previous position on an output line in order to create special typographic effects.

Mom's inline escapes for these horizontal movements are

| \*[FWD #<unit>] | Move forward inline the specified number of units of measure; decimal fractions are allowed.
| \*[BCK #<unit>] | Move backward inline the specified number of units of measure; decimal fractions are allowed.

For example,

    	1.\*[FWD 12p]The Free Trade Play-Offs: WalMart 100, Mexico 0

puts 12 points of space between "1." and "The".

NOTE: For backward compatibility, the forms

| \*[BP.25]...\*[BP12.75] | Move back .25...12.75 points
| \*[FP.25]...\*[FP12.75] | Move forward .25...12.75 points

also exist (i.e. with no space before the digit and points being the unit of measure, hence no unit of measure required). Both accept quarter points, so it's possible to do, for example, \*[FP.5] or \*[BP1.25] up to a limit of 12.75 points.

### Vertical inline movement

If you need to move portions of type up or down on a line, mom provides the following inline escapes:

| \*[UP #<unit>] | Move up inline the specified number of units of measure
| \*[DOWN #<unit>] | Move down inline the specified number of units of measure

For example,

    	Tel: 905\*[UP 1p]-\*[DOWN 1p]4072

moves the hyphen in the telephone number up by 1 point, then moves back down by the same amount.

NOTE: For backward compatibility, the following are also available:

| \*[ALD.25]...\*[ALD12.75] | Advance lead .25...12.75 points (move downward)
| \*[RLD.25]...\*[RLD12.75] | Reverse lead .5...12.75 points (move upward)

Both \*[ALD] and \*[RLD] work in points, hence you musn't use a unit of measure.

### Full measure rules

I find I often need rules drawn to the full measure of the current line or tab length. The official way to do this is `\l'\n(.lu'`, which is annoying to type, and doesn't mean a whole heck of a lot if you're new to groff. The inline, \*[RULE], is a simple replacement for \l'\n(.lu'. Use it whenever you need a rule drawn to the full measure of the current line or tab length, for example:

    	.LL 6P
    	\*[RULE]

The above draws a rule the full measure of the 6-pica line length. Please note that \*[$RULE] should appear on a line by itself and that it draws the rule to the full measure, hence it cannot be used to fill the remainder of a partial line with a rule in this way:

    	Signature__________________________________________

If you wish to accomplish this effect, you have to use \*[RULE] in conjunction with the PAD macro and string tabs. (See the example provided with .PAD.

See groff's Horizontal line drawing function for more information on drawing horizontal rules.

## Groff inline escapes

### Font control with \f

Groff's basic mechanism for inline font control is the escape \f.

| \fR | Change font to roman
| \fI | Change font to italic
| \fB | Change font to bold
| \f(BI | Change font to bold italic
| \fP | Revert to previous font

A special instance of \f is \f[font], where "font" can be a complete legal family/font name combo. This is especially useful should you need to change both family and font inline. For example, if your prevailing family and font are Times Roman and you want a few words in Courier Bold Italic, you could do this:

    	.FAM T
    	.FT  R
    	The command \f[CBI]ls -l\fP gives a "long" directory listing.

The Unix command "ls -l" will appear in Courier Bold Italic in a line that is otherwise in Times Roman.

### Inline horizontal motions with \h

Whenever you need to move forward or backward on a line, use the inline \h'<distance>'. In order to avoid unpleasant surprises, always append a unit of measure to "distance".

    	\h'1.25i'

moves you 1.25 inches to the right (forwards) of the horizontal position on the current output line. \h'<distance>' is exactly equivalent to \*[FWD #<unit>].

    	\h'-1.25i'

moves you 1.25 inches to the left (backwards). \h'-<distance>' is exactly equivalent to \*[BCK #<unit>].

### Inline vertical motions with \v

If you need to raise or lower type on a line (say, for sub- or superscripts, or any other special effect), use \v'<distance>'. In order to avoid unpleasant surprises, always append a unit of measure to "distance".

    	\v'.6m'

moves you (approx.) 2/3 of an em downward on the current output line. \v'<distance>' is exactly equivalent to \*[DOWN #<unit>].

    	\v'-.6m'

moves you (approx.) 2/3 of an em upward. \v'<-distance>' is exactly equivalent to \*[UP #<unit>].

IMPORTANT: The vertical motion of \v affects ONLY type on the current output line. When groff breaks the output line, the effect of \v is cancelled; the baseline of the next output line is where it would be if you hadn't used \v.

TIP: When using \v for occasional effects on a line, don't forget to reverse it when you've done what you want to do. Otherwise, the remaining type will be set too high (if you used \v with the minus sign) or too low (if you used \v without the minus sign).

### String width function \w

In the context of mom, the string width inline \w'string' primarily serves to let you establish the horizontal measure of something (e.g. indents) based on the length of a bit of text. For example, if you want a left indent the length of the word "Examples:" plus a space, you can set it with the \w inline escape:

    	.IL "\w'Examples: '"

NOTE: Whenever you pass \w'string' to a macro that normally requires a unit of measure, do NOT add a unit of measure to the \w'string' argument.

Furthermore, if the string is composed of several words separated by spaces, you MUST surround the whole escape with double quotes, as in the example above.

### Horizontal line drawing function \l

The \l'distance' inline allows you to draw a horizontal rule of the specified distance. You must supply a unit of measure. Therefore, to set a 3-pica rule into a line of text, you'd do

    	A line of text with a superfluous \l'3P' 3-pica rule in it.

\l'3P' above not only draws the rule, but advances 3 picas horizontally as well, just as you'd expect.

For an easy way of drawing rules to the full measure of the current line or tab length, see Full measure rules.

The weight (thickness) of rules varies according to the point size in effect when you invoke \l, but you can't fix the weight with any real precision. A point size of 12 produces a tastefully moderate rule weight of between one-half and one point (depending on your printer), and is the point size used by mom for all macros and routines that create rules.

NOTE: There are, in addition to \l, a number of other line-drawing escapes, but frankly, using them for typographically precise drawing is a bit like hammering in a nail with a screwdriver -- doable, but not recommended.

Groff comes with a number of "preprocessors" designed to ease creating rules, boxes, splines, and so on (tbl, pic, and friends), but I tend not to use them. A firm believer in the "right tool for the job," I prefer a vector drawing program (in my case, tgif) when I need to combine type with graphic elements (say, a complex ruled form). Inserting the results into a document is easy enough with .PSPIC (consult the grops man page for information on this indispensible and easy-to-use macro).

### Special characters and symbols

Here follows a short list of commonly-used special characters available via inline escapes. If you're not sure of the meaning of some of these characters, consult the Definitions of Terms. For a more complete list, consult the section Special Character Names at the end of the Tutorial Examples in cstr54, available here.

        CHARACTER                   ESCAPE SEQUENCE
        ---------                   ---------------

        Comment line                \#
        Fixed-width space           \<space>  i.e. backslash followed by a space
        Unbreakable space           \~
        Digit-width (figure) space  \0
        Zero-width character        \&
        Discretionary hyphen        \%
        Backslash                   \\ or \e
        Plus/minus (arithmetic)     \(+-
        Subtract (arithmetic)       \(mi
        Multiply (arithmetic)       \(mu
        Divide (arithmetic)         \(di
        Em-dash                     \(em
        En-dash                     \(en
        Left double-quote           \(lq
        Right double-quote          \(rq
        Bullet                      \(bu
        Ballot box                  \(sq
        One-quarter                 \(14
        One-half                    \(12
        Three-quarters              \(34
        Degree sign                 \(de
        Dagger                      \(dg
        Foot mark                   \(fm
        Cent sign                   \(ct
        Registered trademark        \(rg
        Copyright                   \(co
        Section symbol              \(se

Next Prev Top Back to Table of Contents