Next: Whitespace Up: Overview Previous: Tips and tricks

# Basic operations

The Alpha LaTeX macros revolve around two basic operations called insertObject and wrapObject. Basically, insertObject is a call to the primitive procedure insertText preceded by the automatic deletion of previously selected text (this behavior is easily changed, however, by resetting the flag deleteObjNoisily described in section 1.4.1). For example, if there is no current selection, choosing the command alpha from the Greek submenu of the LaTeX menu inserts the LaTeX command `\alpha` at the insertion point; otherwise, if there is a selection, it is replaced with the string ```\alpha`''. In other words, insertObject works just like the familiar Paste command on the Edit menu. It turns out that a large number of commands in `latex.tcl` rely on insertObject, but sometimes it's faster to type the desired LaTeX command directly. (Even faster is to use the corresponding command keys, but more on that later.) On the other hand, if you forget the syntax of a particular LaTeX command, it's sometimes easier to look it up on the LaTeX menu than it is in a reference manual.

The complementary operation to insertObject is called wrapObject. The difference between the two is the way the latter treats the current selection, that is, wrapObject inserts its argument at the insertion point (just like insertObject), but if there is a selection, wrapObject cuts it out (without effecting the state of the Clipboard) and inserts it in the middle of the chosen command. For example, consider the LaTeX menu command footnote on the Miscellaneous submenu (see section 2.1.3). This command inserts the string ````\footnote`{}` '' (without the double quotes, of course) into the document, positioning the insertion point between the pair of braces. The user then types the text to be footnoted and presses the <TAB> key, after which the tab stop macro finds (and deletes) the bullet at the end of the string. (Note: Use <OPT TAB> to insert a literal tab character into the document.) On the other hand, if a selection exists at the time the footnote command is issued, the selection itself is surrounded by LaTeX's `\footnote` command, and the insertion point is brought to the end of the selection automatically. Some commands, for better or worse, even go so far as to insert the selection into one of several competing positions within the command string. The fraction command on the Formulas submenu (section 2.1.4) is a good example of this type of behavior. It assumes the current selection (if there is one) is the numerator of the fraction to be typeset, cutting and pasting accordingly.

The concept of wrapping is carried one step further in the case of environments. Suppose you want to center an existing `tabular` environment, for example. Just select the `tabular` environment to be centered and choose the center command from the Environments submenu on the LaTeX menu (see section 2.1.3). The resulting `center` environment will completely surround the existing `tabular` environment, indenting the latter one tab stop to the right.

Not all environments wrap, however. Those environments whose body is very structured (such as `enumerate`, `itemize`, `description`, `thebibliography`, `tabular`, `array`, `eqnarray`, and `eqnarray*`) do not. Instead, these environments simply insert text into the document. If there happens to be a selection at the time one of these commands is issued, an alert appears asking if the selection should be deleted. To turn this alert off, simply toggle the flag deleteEnvNoisily (see section 1.4.1) in the Flags dialog on the Current Mode submenu on the Config menu.

Next: Whitespace Up: Overview Previous: Tips and tricks