Go to the first, previous, next, last section, table of contents.

TeX Editing Commands

Here are the special commands provided in TeX mode for editing the text of the file.

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 validate-tex-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; we use `"' to start a quotation and `"' to end one. To make editing easier under this formatting convention, TeX mode overrides the normal meaning of the key " with a command that inserts a pair of single-quotes or backquotes (tex-insert-quote). To be precise, this command inserts `"' after whitespace or an open brace, `"' after a backslash, and `"' after any other character.

If you need the character `"' itself in unusual contexts, use C-q to insert it. Also, " with a numeric argument always inserts that number of `"' characters. You can turn off the feature of " expansion by eliminating that binding in the local map (See section Customizing Key Bindings).

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 prints a message in the echo area if any mismatch is found. M-x validate-tex-region checks a region, paragraph by paragraph. When it finds a paragraph that contains a mismatch, it displays point at the beginning of the paragraph for a few seconds and sets the mark at that spot. Scanning continues until the whole buffer has been checked or until you type another key. Afterward, you can use the mark ring to find the last several paragraphs that had mismatches (see section The Mark Ring).

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.

Go to the first, previous, next, last section, table of contents.