Back to Table of Contents Next: Inline escapes

Goodies

The macros in this section are a collection of useful (and sometimes nearly indispensable) routines to simplify typesetting.


Rename macros

Macro: ALIAS <new name> <old name>

The ALIAS macro may well be your best friend. With it, you can change the name of a macro to anything you like (provided the new name is not already being used by mom; see the list of reserved words).

Groff has always been a bit intimidating for new users because its standard macro packages use very terse macro names. Mom doesn’t like people to feel intimidated; she wants them to feel welcome. Consequently, she tries for easy-to-grasp, self-explanatory macro names. However, mom knows that people have their own ways of thinking, their own preferences, their own habits. Some of her macro names may not suit you; they might be too long, or aren’t what you automatically think of when you want to do a particular thing, or might conflict with habits you’ve developed over the years.

If you don’t like one of mom’s macro names, say, PAGEWIDTH, change it, like this:
.ALIAS PW PAGEWIDTH | | new--+ +--official name name The first argument to ALIAS is the new name you want for a macro. The second is the “official” name by which the macro is normally invoked. After ALIAS, either can be used.

Note that in ALIAS, you do NOT include the period (dot) that precedes the macro when it’s a control line.

Tip: A particularly good candidate for ALIAS is the macro, PT_SIZE. A more natural name for it would simply be PS, but PS conflicts with the eqn equation preprocessor and thus mom uses the longer form. However, if you’re not using eqn, you can happily rename PT_SIZE to PS:
.ALIAS PS PT_SIZE

Note: If you use ALIAS a lot, and always for the same things, consider creating an aliases file of the form
.ALIAS <new name> <old name> .ALIAS <new name> <old name> .ALIAS <new name> <old name> ...etc Put the file someplace convenient and source it (include it) at the beginning of your documents with the INCLUDE macro. Assuming that you’ve created an aliases file called mom-aliases in your home directory under a directory called Mom, you’d source it by placing
.INCLUDE /home/<username>/Mom/mom-aliases at the top of your documents.

If you share documents that make use of an alias file, remember that other people don’t have the file. Paste the whole thing at the top of your documents, please.

Experts: ALIAS is an alias of .als. You can use either, or mix 'n' match with impunity.

Hide input lines from output

Macro: SILENT toggle

Alias: COMMENT

Sometimes, you want to “hide” input lines from final output. This is most likely to be the case when setting up string tabs (see the quickie tutorial on string tabs for an example), but there are other places where you might want input lines to be invisible as well. Any place you don’t want input lines to appear in the output, use the SILENT macro.

SILENT is a toggle. Invoking it without an argument turns it on; any argument turns it off. E.g.,
.SILENT A line of text .SILENT OFF The line “A line of text” will not appear in the output copy.

SILENT is aliased as COMMENT. If you want to insert non-printing comments into your documents, you may prefer this.

Tip: SILENT does not automatically break an input line (see BR) when you’re in one of the fill modes (JUSTIFY or QUAD L | R | C | J). The same applies to tabs (typesetting or string) to which you’ve passed the J or QUAD argument. You must insert .BR yourself, or risk a portion of your text disappearing into a black hole.

Suspend/re-invoke traps

Macro: TRAP toggle

Traps are vertical positions on the output page at which you or mom have instructed groff to start doing something automatically. Commonly, this is near the bottom of the page, where behind-the-scenes processing is needed in order for one page to finish and another to start.

Sometimes, traps get sprung when you don’t want them. If this happens, surround just the offending macros and input lines with
.TRAP OFF ... .TRAP TRAP is a toggle, therefore any argument turns it off (ie suspends the trap), and no argument turns it (back) on.

Convert typewriter doublequotes to proper doublequotes

Macro: SMARTQUOTES [<off>] [ ,, | >> | << ]
or
Macro: SMARTQUOTES DA | DE | ES | FR | IT | NL | NO | PT | SV

If you invoke SMARTQUOTES without an argument, mom converts all instances of the inch-mark, ("), also called a doublequote, into the appropriate instances of true Anglo-American open-and close-doublequotes. (See Internationalization for how to get SMARTQUOTES to behave correctly for non-English quoting styles.)

Typographically, there is a difference between the inch-mark and quotation marks—a BIG difference. Sadly, typewriters and computer keyboards supply only one: the inch-mark. While using inches for doublequotes is, and always has been, acceptable in typewriter-style copy, it has never been, and, God willing, never will be acceptable in typeset copy. Failure to turn inches into quotes is the first thing a professional typesetter notices in documents prepared by amateurs. And you don’t want to look like an amateur, do you?

Internationalization

If you invoke SMARTQUOTES with one of the optional arguments (,, or >> or <<) you can use " (ie the inch-mark/doublequotes key) as “cheap” open-and close-quotes when inputting text in a language other than English, and have mom convert them, on output, into the chosen open-and close-quote style.

,, opens quotes with “lowered doublequotes” and closes them with “raised doublequotes”, as in this ascii approximation:
,,Hilfe !`` >> opens quotes with guillemets pointing to the right, and closes them with guillemets pointing to the left, as in this ascii approximation:
>>Zurück !<< << opens quotes with guillemets pointing to the left, and closes them with guillemets pointing to the right, as in this ascii approximation:
<<Mais monsieur! Je ne suis pas ce genre de fille!>> Please note: the above arguments to SMARTQUOTES are literal ASCII characters. ,, is two commas; << is two less-than signs; >> is two greater-than signs.

Alternatively, you can pass SMARTQUOTES the two-letter, ISO 639 abbreviation for the language you’re writing in, and mom will output the correct quotes.
.SMARTQUOTES DA = Danish >>text<< .SMARTQUOTES DE = German ,,text`` .SMARTQUOTES ES = Spanish ``text´´ .SMARTQUOTES FR = French << text >> .SMARTQUOTES IT = Italian << text >> .SMARTQUOTES NL = Dutch ´´text´´ .SMARTQUOTES NO = Norwegian <<text>> .SMARTQUOTES PT = Portuguese <<text>> .SMARTQUOTES SV = Swedish >>text>>

Turn SMARTQUOTES off by passing it any argument not in the argument list (e.g. OFF, QUIT, X, etc.)

If you’re using the document processing macros with PRINTSTYLE TYPESET, SMARTQUOTES is on by default (in the Anglo-American style); with PRINTSTYLE TYPEWRITE, it’s off by default (and should probably stay that way).

Finally, if you’re fussy about the kerning of quote marks in relation to the text they surround, or have special quoting needs, you have to enter quote marks by hand using groff’s native inline escapes for special characters (see man groff-char for a complete list of special characters). Entering quote marks this way allows you to use mom’s inline kerning escapes to fine-tune the look of quotes.

Note: SMARTQUOTES does not work on single quotes, which most people input with the apostrophe (found at the right-hand end of the “home row” on a QWERTY keyboard). Groff will interpret all instances of the apostrophe as an apostrophe, making the symbol useless as an open-single-quote. For open single quotes, input the backtick character typically found under the tilde on most keyboards. Here’s an example of correct input copy with single quotes:
"But she said, `I don’t want to!'"

Additional note: Whether or not you have SMARTQUOTES turned on, get into the habit of entering the foot-and inch-marks, when you need them, with the inline escapes \*[FOOT] and \*[INCH], instead of ' and ".

Convert to upper case

Macro: CAPS toggle

CAPS converts all lower case letters to upper case. Primarily, it’s a support macro used by the document processing macros, but you may find it helpful on occasion. CAPS is a toggle, therefore no argument turns it on, any argument (OFF, QUIT, X, etc.) turns it off.
.CAPS All work and no play makes Jack a dull boy. .CAPS OFF produces, on output
ALL WORK AND NO PLAY MAKES JACK A DULL BOY. If you wish to capitalise a section of type inline, use the inline escapes, \*[UC]...\*[LC] like this:
All work \*[UC]and\*[LC] no play makes Jack a dull boy. The above produces, on output
All work AND no play makes Jack a dull boy.

User-defined strings

Macro: STRING <name> <what you want in the string>

You may find sometimes that you have to type out portions of text repeatedly. If you’d like not to wear out your fingers, you can define a string that, whenever you call it by name, outputs whatever you put into it.

For example, say you’re creating a document that repeatedly uses the phrase “the Montreal/Windsor corridor”. Instead of typing all that out every time, you could define a string, like this:
.STRING mw the Montreal/Windsor corridor Once a string is defined, you can call it any time with the inline escape \*[<stringname>]. Using the example string above
The schedule for trains along \*[mw]: produces, on output
The schedule for trains along the Montreal/Windsor corridor:

Note: Be very careful not to put any spaces at the ends of strings you’re defining, unless you want them. Everything after the name argument you pass to STRING goes into the string, including trailing spaces. It’s a good idea to get into the habit of using groff’s native commenting mechanism, \", immediately following any string definition in order to avoid spaces you can’t see, like this
.STRING mw the Montreal/Windsor corridor\"

Experts: STRING is an alias for ds. You can use either, or mix 'n' match with impunity.

Change the escape character

Macro: ESC_CHAR <new character> | <anything>

Groff’s and mom’s default escape character is the backslash. Sometimes, you may want to include a literal backslash in your document. There are two ways to accomplish this. One is simply to double the backslash character (\\), which is convenient if you don’t have a lot of backslashes to input. If you need to input a whole batch of backslashes (say, when including code snippets in your document), you can use ESC_CHAR to make the change permanent (until you decide to restore the escape character to its default, the backslash).

ESC_CHAR with a single character argument changes the escape character to whatever the argument is. ESC_CHAR with no argument restores the escape character to the backslash.

Experts: ESC_CHAR is an alias of .ec. Mix 'n' match the two with impunity.

Get cap-height, x-height and descender depth of a font

Macro: SIZESPECS

Whenever you need to get the cap-height, x-height or descender depth of type at the current point size, invoke .SIZESPECS, which takes no argument. The dimensions are stored in the string registers \*[$CAP_HEIGHT], \*[$X_HEIGHT] and \*[$DESCENDER], respectively, in machine units to which the unit of measure, u, is already appended.

Thus, if you wanted to advance 2 inches from your current position on the page plus the cap-height of the current point size of type
.PT_SIZE <n> .SIZESPECS .ALD 2i+\*[$CAP_HEIGHT] would do the trick.

Single underscore

Macro: UNDERSCORE [ <distance below baseline> ] "<string>"

• Optional argument requires a unit of measure

By default, UNDERSCORE places an underscore 2 points beneath the required string argument. The string must be enclosed in double-quotes, like this:
.UNDERSCORE "Unmonitored monopolies breed high prices and poor products."  If you wish to change the distance of the rule from the baseline, use the optional argument <distance below baseline> (with a unit of measure).
.UNDERSCORE 3p "Unmonitored monopolies breed high prices and poor products."  The above places upper edge of the underscore 3 points below the baseline.

Note: UNDERSCORE does not work across line breaks in output copy, which is to say that you can’t underscore a multi-line passage simply by putting the text of the whole thing in the string you pass to UNDERSCORE. If you need to underscore several lines of type, use UNDERLINE.

Controlling the weight of underscores

The weight (thickness) of underscores may be controlled with the macro, UNDERSCORE_WEIGHT. Thus, if you want underscores with a weight of 1-1/2 points, you’d invoke:
.UNDERSCORE_WEIGHT 1.5 prior to invoking .UNDERSCORE. Every subsequent instance of .UNDERSCORE will use this weight.

Mom’s default underscore weight is 1/2 point.

Note: UNDERSCORE_WEIGHT also sets the weight of double underscores.

Colorizing underscored text

If you want underscored text to be in a different colour from the text around it, use the COLOR macro, rather than the inline escape for changing color. In other words, assuming your prevailing text color is black and you want underscored text in red
.COLOR red .UNDERSCORE "text to underscore" .COLOR black rather than
.UNDERSCORE "\*[red]text to underscore\*[black]" The latter will render the text in red, and the underscore in black. You can use this to create truly rainbow effects if you want, e.g. text in red, underscore in blue, and prevailing type in black:
.UNDERSCORE "\*[red]text to underscore\*[blue]" .COLOR black

Double underscore

Macro: UNDERSCORE2 [ <distance below baseline> [ <distance between rules> ] ] "<string>"

• Optional arguments require a unit of measure

By default, UNDERSCORE2 places a double underscore 2 points beneath the required string argument. The string must be enclosed in double-quotes, like this:
.UNDERSCORE2 "Unmonitored monopolies breed high prices and poor products." The default distance between the two rules is 2 points, measured from the bottom edge of the upper rule to the top edge of the lower one.

If you wish to change the distance of the double underscore from the baseline, use the optional argument <distance below baseline> (with a unit of measure), e.g.,
.UNDERSCORE2 3p "Unmonitored monopolies breed high prices and poor products." which places the upper edge of the first rule of the double underscore 3 points below the baseline.

If you wish to change the distance between the two rules as well, use the second optional argument <distance between rules> (with a unit of measure). Be aware that you must give a value for the first optional argument if you want to use the second. The distance between the two rules is measured from the bottom edge of the upper rule to the top edge of the lower one.

The weight (thickness) of double underscores may be controlled with the macro UNDERSCORE_WEIGHT (q.v).

Underline

Macro: UNDERLINE toggle

The distinction between underscoring and underlining is that underscoring is suitable for occasional effects (a word here, a word there), whereas underlining underlines whole passages of type. Furthermore, you cannot colorize underlining, and there’s a special macro, UNDERLINE_SPECS, to control the weight and distance from the baseline of the underline. Lastly, files that use UNDERLINE must be processed with
pdfmom -Tps filename.mom | ps2pdf - filename.pdf since groff's native pdf driver does not recognize UNDERLINE.

UNDERLINE is a toggle macro, therefore you invoke it by itself (ie with no argument) to initiate underlining, and with any argument (OFF, QUIT, X, etc) to turn it off.

Note: Underlining may also be turned on and off inline with the escapes \*[UL]...\*[ULX].

Additional note: In document processing, neither .UNDERLINE nor \*[UL] persist past the current document element tag. For example, if you turn underlining on in a paragraph (.PP), your next paragraph will not be underlined.

UNDERLINE_SPECS

The weight of underlining and the distance from the baseline is set with
.UNDERLINE_SPECS <weight> <distance> The <weight> argument can be expressed in any unit of measure you like, but points is the most usual. Mom’s default is 1/2 point (.5p). The same holds for the <distance> argument; mom’s default is 1-1/4 points (1.25p).

INLINE ESCAPE FOR UNDERLINING

The macro pair, .UNDERLINE / .UNDERLINE OFF, and the inline escapes, \*[UL] / \*[ULX], are functionally identical, hence, in fill modes
Which should I heed? .UNDERLINE Just do it .UNDERLINE OFF or .UNDERLINE just say no? .UNDERLINE OFF produces the same result as
Which should I heed? \*[UL]Just do it\*[ULX] or \*[UL]just say no?\*[ULX] In either case, this is a misuse of UNDERLINE. UNDERSCORE is preferable.

Insert equalized whitespace into lines

Macro: PAD "<string with pad markers inserted>" [ NOBREAK ]

With PAD, you can insert proportional amounts of whitespace into a line. The optional NOBREAK argument tells mom not to advance on the page after the PAD macro has been invoked.

PAD calculates the difference between the length of text on the line and the distance remaining to its end, then inserts the difference (as whitespace) at the place(s) you specify.

Take, for example, the following relatively common typesetting situation, found at the bottom of legal agreements:
Date Signature |

The person signing the agreement is supposed to fill in the date as well as a signature. Space needs to be left for both, but the exact amount is neither known, nor important. All that matters is that there be a little space after Date, and rather more space after Signature. (In the above, | represents the end of the line at the prevailing line length.)

The pad marker (see below) is # (the pound or number sign on your keyboard) and can be used multiple times in a line. With that in mind, here’s how you’d input the Date/Signature line (assuming a length of 30 picas):
.LL 30P .PAD "Date#Signature###"

When the line is output, the space remaining on the line, after "Date" and "Signature" have been taken into account, is split into four (because there are four # signs). One quarter of the space is inserted between Date and Signature, the remainder is inserted after Signature.

Example of PAD usage

One rarely wants merely to insert space in a line; one usually wants to fill it with something, hence PAD is particularly useful in conjunction with string tabs. The following uses the Date/Signature example, above, but adds rules into the whitespace through the use of string tabs and mom’s inline escape \*[RULE].
.LL 30P .PAD "Date \*[ST1]#\*[ST1X] Signature \*[ST2]###\*[ST2X]" NOBREAK .ST 1 J .ST 2 J .TAB 1 \*[RULE] .TN \*[RULE] .TQ

Here’s what the example does:

  1. Pads the Date/Signature line with a shorter space for Date (#) and a longer space for Signature (###), encloses the padded space with string tabs markers, and outputs the line without advancing on the page.
  2. Sets the quad for the two string tabs (in this instance, justified).
  3. Calls the first string tab and draws a rule to its full length.
  4. Calls the second tab with TN (which moves to tab 2 and stays on the same baseline) then draws a rule to the full length of string tab 2.

Often, when setting up string tabs this way, you don’t want the padded line to print immediately. To accomplish this, use SILENT. See the quickie tutorial on string tabs for an example.

Note: Because the pound sign (#) is used as the pad marker, you can’t use it as a literal part of the pad string. If you need the sign to appear in the text of a padded line, change the pad marker with PAD_MARKER. Also, be aware that # as a pad marker only applies within the PAD macro; at all other times it prints literally, just as you’d expect.

Another important consideration when using PAD is that because the string must be enclosed in double-quotes, you can’t use the double-quote (") as part of the string. The way to circumvent this is to use the groff inline escapes \(lq and \(rq (leftquote and rightquote respectively) whenever double-quotes are required in the string passed to PAD.

Change/set the marker used with PAD

Macro: PAD_MARKER "<character to use as the pad marker>

If you need to change mom’s default pad marker (#), either because you want a literal # in the padded line, or simply because you want to use another character instead, use PAD_MARKER, whose argument is the new pad marker character you want.
.PAD_MARKER @ changes the pad marker to @.

Once you’ve changed the pad marker, the new marker remains in effect for every instance of PAD until you change it again (say, back to the pound sign).

Inline escape to add leaders to a line

Inline: \*[LEADER]

Whenever you want to fill a line or tab with leaders, use the inline escape \*[LEADER]. The remainder of the line or tab will be filled with the leader character. Mom’s default leader character is a period (dot), but you can change it to any character you like with LEADER_CHARACTER.

Note: \*[LEADER] fills lines or tabs right to their end. You cannot insert leaders into a line or tab and have text following the leader on the same line or in the same tab. Should you wish to achieve such an effect typographically, create tabs for each element of the line and fill them appropriately with the text and leaders you need. String tabs are perfect for this. An example follows.
.LL 30P .PAD "Date\*[ST1]#\*[ST1X] Signature\*[ST2]###\*[ST2X]" NOBREAK .EL .ST 1 J .ST 2 J .TAB 1 \*[LEADER] .TN \*[LEADER] .TQ

The PAD line sets the words Date and Signature, and marks string tabs around the pad space inserted in the line. The string tabs are then "set", called, and filled with leaders. The result looks like this:
Date.............Signature.....................................

Change/set the leader character

Macro: LEADER_CHARACTER <character>

LEADER_CHARACTER takes one argument: a single character you would like to be used for leaders. (See \*[LEADER] for an explanation of how to fill lines with leaders.)

For example, to change the leader character from mom’s default (a period) to the underscore character, enter
.LEADER_CHARACTER _

Tip: A particularly useful function of LEADER_CHARACTER is that it can be used to increase the spacing of mom’s default leaders. This is done by assigning to LEADER_CHARACTER both the period (dot) and a space. The technique requires a little low-level groffing:
.char \[leader] . \" .LEADER_CHARACTER \[leader] The .char primitive allows you to define a character called leader, to which you assign a period and a space. The \", which, in groff, is used to add non-printing comments to a line, is not strictly necessary. Its presence here lets you see that there’s a space after the period.

Drop caps

Macro: DROPCAP <dropcap letter> <number of lines to drop> [ COND <percentage> | EXT <percentage> ]

The first two arguments to DROPCAP are the letter you want to be the drop cap and the number of lines you want it to drop. By default, mom uses the current family and font for the drop cap.

The optional argument (COND or EXT) indicates that you want the drop cap condensed (narrower) or extended (wider). If you use COND or EXT, you must follow the argument with the percentage of the letter’s normal width you want it condensed or extended. No percent sign (%) is required.

Mom will do her very best to get the drop cap to line up with the first line of text indented beside it, then set the correct number of indented lines, and restore your left margin when the number of drop cap lines has been reached.

Beginning a paragraph with a drop cap “T” looks like this:
.DROPCAP T 3 COND 90 he thousand injuries of Fortunato I had borne as best I could, but when he ventured upon insult, I vowed revenge. You who so well know the nature of my soul will not suppose, however, that I gave utterance to a threat...

The drop cap, slightly condensed but in the current family and font, will be three lines tall, with whatever text fills those three lines indented to the right of the letter. The remainder of the paragraph’s text will revert to the left margin.

Note: When using the document processing macro PP, DROPCAP only works

If these conditions aren’t met, DROPCAP is silently ignored.

Warning: DROPCAP puts a bit of a strain on resource-challenged systems. If you have such a system and use drop caps extensively in a document, be prepared for a wait while mom does her thing.

Support macros for DROPCAP

Drop caps are the bane of most typesetters’ existence. It’s very difficult to get the size of the drop cap right for the number of drop lines, especially if the drop cap is in a different family from the prevailing family of running text. Not only that, but there’s the gutter around the drop cap to take into account, plus the fact that the letter may be too wide or too narrow to look anything but odd or misplaced.

Mom solves the last of these problems with the COND and EXT arguments. The rest she solves with macros that change the default behaviour of DROPCAP, namely

These macros must, of course, come before you invoke DROPCAP.

• DROPCAP_FAMILY

Set the drop cap family by giving DROPCAP_FAMILY the name of the family you want, e.g.
.DROPCAP_FAMILY H which will set the family to Helvetica for the drop cap only.

• DROPCAP_FONT

Set the drop cap font by giving DROPCAP_FONT the name of the font you want, e.g.
.DROPCAP_FONT I which will set the font to italic for the drop cap only.

• DROPCAP_ADJUST

If the size mom calculates for the drop cap isn’t precisely what you want, you can increase or decrease it with DROPCAP_ADJUST, like this: e.g.
.DROPCAP_ADJUST +1 or
.DROPCAP_ADJUST -.75

DROPCAP_ADJUST only understands points, therefore do not append any unit of measure to the argument. And always be sure to prepend the plus or minus sign, depending on whether you want the drop cap larger or smaller.

• DROPCAP_COLOR

If you’d like your drop cap colourized, simply invoke .DROPCAP_COLOR <color> with the name of a colour you’ve already created (“initialized”) with NEWCOLOR or XCOLOR. Only the drop cap will be colourized; all other text will remain at the current colour default (usually black).

• DROPCAP_GUTTER

By default, mom puts three points of space between the drop cap and the text indented beside it. If you want another value, use DROPCAP_GUTTER (with a unit of measure), like this:
.DROPCAP_GUTTER 6p

Superscript

Inlines: \*[SUP]...\*[SUPX]

Superscripts are accomplished inline. Whenever you need one, typically for numerals, all you need to do is surround the superscript with the inlines above. \*[SUP] begins superscripting; \*[SUPX] turns it off.

If your running type is pseudo-condensed or pseudo-extended and you want your superscripts to be equivalently pseudo-condensed or -extended, use \*[CONDSUP]...\*[CONDSUPX] or \*[EXTSUP]...\*[EXTSUPX].

The superscript inlines are primarily used by the document processing macros for automatic generation of numbered footnotes. However, you may find them useful for other purposes.

Note: Mom does a pretty fine job of making superscripts look good in any font and at any size. If you’re fussy, though (and I am), about precise vertical placement, kerning, weight, size, and so on, you may want to roll your own solution.

SUPERSCRIPT RAISE AMOUNT

By default, mom raises superscripts 1/3 of an em above the baseline. If you’re not happy with this default, you can change it by invoking SUPERSCRIPT_RAISE_AMOUNT with the amount you want them raised. A unit of measure must be appended directly to the amount. Thus, you want superscripts raised by 3 points instead of 1/3 em, you’d do
.SUPERSCRIPT_RAISE_AMOUNT 3p and all subsequent superscripts would be raised by 3 points.


Back to Table of Contents Top Next: Inline escapes