Next: , Up: TeX Mode   [Contents][Index]

25.10.1 TeX Editing Commands


Insert, according to context, either ‘``’ or ‘"’ or ‘''’ (tex-insert-quote).


Insert a paragraph break (two newlines) and check the previous paragraph for unbalanced braces or dollar signs (tex-terminate-paragraph).

M-x tex-validate-region

Check each paragraph in the region for unbalanced braces or dollar signs.

C-c {

Insert ‘{}’ and position point between them (tex-insert-braces).

C-c }

Move forward past the next unmatched close brace (up-list).

In TeX, the character ‘"’ is not normally used; instead, quotations begin with ‘``’ and end with ‘''’. TeX mode therefore binds the " key to the tex-insert-quote command. This inserts ‘``’ after whitespace or an open brace, ‘"’ after a backslash, and ‘''’ after any other character.

As a special exception, if you type " when the text before point is either ‘``’ or ‘''’, Emacs replaces that preceding text with a single ‘"’ character. You can therefore type "" to insert ‘"’, should you ever need to do so. (You can also use C-q " to insert this character.)

In TeX mode, ‘$’ has a special syntax code which attempts to understand the way TeX math mode delimiters match. When you insert a ‘$’ that is meant to exit math mode, the position of the matching ‘$’ that entered math mode is displayed for a second. This is the same feature that displays the open brace that matches a close brace that is inserted. However, there is no way to tell whether a ‘$’ enters math mode or leaves it; so when you insert a ‘$’ that enters math mode, the previous ‘$’ position is shown as if it were a match, even though they are actually unrelated.

TeX uses braces as delimiters that must match. Some users prefer to keep braces balanced at all times, rather than inserting them singly. Use C-c { (tex-insert-braces) to insert a pair of braces. It leaves point between the two braces so you can insert the text that belongs inside. Afterward, use the command C-c } (up-list) to move forward past the close brace.

There are two commands for checking the matching of braces. C-j (tex-terminate-paragraph) checks the paragraph before point, and inserts two newlines to start a new paragraph. It outputs a message in the echo area if any mismatch is found. M-x tex-validate-region checks a region, paragraph by paragraph. The errors are listed in an *Occur* buffer; you can use the usual Occur mode commands in that buffer, such as C-c C-c, to visit a particular mismatch (see Other Repeating Search).

Note that Emacs commands count square brackets and parentheses in TeX mode, not just braces. This is not strictly correct for the purpose of checking TeX syntax. However, parentheses and square brackets are likely to be used in text as matching delimiters, and it is useful for the various motion commands and automatic match display to work with them.

Next: , Up: TeX Mode   [Contents][Index]