xref: /original-bsd/old/eqn/USD.doc/eqnguide/g3 (revision c3e32dec)
%sccs.include.proprietary.roff%

@(#)g3 8.1 (Berkeley) 06/08/93

.SC "Shorthand for In-line Equations"

In a mathematical document, it is necessary to follow mathematical conventions not just in display equations, but also in the body of the text, for example by making variable names like $x$ italic. Although this could be done by surrounding the appropriate parts with C .EQ and C .EN , the continual repetition of C .EQ and C .EN is a nuisance. Furthermore, with `-ms', C .EQ and C .EN imply a displayed equation.

C EQN provides a shorthand for short in-line expressions. You can define two characters to mark the left and right ends of an in-line equation, and then type expressions right in the middle of text lines. To set both the left and right characters to dollar signs, for example, add to the beginning of your document the three lines

1 .EQ delim %% .EN

2 Having done this, you can then say things like

1

Let %alpha sub i% be the primary variable, and let %beta% be zero. Then we can show that %x sub 1% is %>=0%.

2 This works as you might expect _ spaces, newlines, and so on are significant in the text, but not in the equation part itself. Multiple equations can occur in a single input line.

Enough room is left before and after a line that contains in-line expressions that something like $sum from i=1 to n x sub i$ does not interfere with the lines surrounding it.

To turn off the delimiters,

1 .EQ delim off .EN

2 Warning: don't use braces, tildes, circumflexes, or double quotes as delimiters _ chaos will result. .SC "Definitions"

C EQN provides a facility so you can give a frequently-used string of characters a name, and thereafter just type the name instead of the whole string. For example, if the sequence

1 x sub i sub 1 + y sub i sub 1

2 appears repeatedly throughout a paper, you can save re-typing it each time by defining it like this:

1 2 define xy 'x sub i sub 1 + y sub i sub 1'

2 This makes .ul xy a shorthand for whatever characters occur between the single quotes in the definition. You can use any character instead of quote to mark the ends of the definition, so long as it doesn't appear inside the definition.

Now you can use .ul xy like this:

1 ^EQ f(x) = xy ... ^EN

2 and so on. Each occurrence of .ul xy will expand into what it was defined as. Be careful to leave spaces or their equivalent around the name when you actually use it, so C EQN will be able to identify it as special.

There are several things to watch out for. First, although definitions can use previous definitions, as in

1 .EQ define xi ' x sub i ' define xi1 ' xi sub 1 ' .EN

2 .ul don't define something in terms of itself' A favorite error is to say

1 define X ' roman X '

2 This is a guaranteed disaster, since X .ul is now defined in terms of itself. If you say

1 define X ' roman "X" '

2 however, the quotes protect the second X, and everything works fine.

C EQN keywords can be redefined. You can make / mean .ul over by saying

1 define / ' over '

2 or redefine .ul over as / with

1 define over ' / '

2

If you need different things to print on a terminal and on the typesetter, it is sometimes worth defining a symbol differently in C NEQN and C EQN . This can be done with .ul ndefine and .ul tdefine. A definition made with .ul ndefine only takes effect if you are running C NEQN ; if you use .ul tdefine, the definition only applies for C EQN . Names defined with plain .ul define apply to both C EQN and C NEQN . .SC "Local Motions"

Although C EQN tries to get most things at the right place on the paper, it isn't perfect, and occasionally you will need to tune the output to make it just right. Small extra horizontal spaces can be obtained with tilde and circumflex. You can also say .ul back n and .ul fwd n to move small amounts horizontally. .ul n is how far to move in 1/100's of an em (an em is about the width of the letter `m'.) Thus .ul back 50 moves back about half the width of an m. Similarly you can move things up or down with .ul up n and .ul down n. As with .ul sub or .ul sup, the local motions affect the next thing in the input, and this can be something arbitrarily complicated if it is enclosed in braces.