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
Check each paragraph in the buffer for unbalanced braces or dollar signs.
Insert ‘{}’ and position point between them (tex-insert-braces
).
Move forward past the next unmatched close brace (up-list
).
Close a block for LaTeX (tex-close-latex-block
).
In TeX, the character ‘"’ is not normally used; you use ‘``’
to start a quotation and ‘''’ to end one. TeX mode defines the key
" to insert ‘``’ after whitespace or an open brace, ‘"’
after a backslash, or ‘''’ otherwise. This is done by the command
tex-insert-quote
. 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.
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.
If you prefer to keep braces balanced at all times, you can 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. LFD
(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-buffer checks
the entire buffer, 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 pushes a mark at that spot. Scanning continues
until the whole buffer has been checked or until you type another key.
The positions of the last several paragraphs with mismatches can be
found in the mark ring (see Mark Ring).
Note that square brackets and parentheses, not just braces, are matched in TeX mode. This is wrong if you want to check 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.
In LaTeX input, ‘\begin’ and ‘\end’ commands must balance.
After you insert a ‘\begin’, use C-c C-f
(tex-close-latex-block
) to insert automatically a matching
‘\end’ (on a new line following the ‘\begin’). A blank line is
inserted between the two, and point is left there.