[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The most commonly used commands/macros of AUCTeX are those which simply insert templates for often used TeX, LaTeX, or ConTeXt constructs, like font changes, handling of environments, etc. These features are very simple, and easy to learn, and help you avoid mistakes like mismatched braces, or ‘\begin{}’-‘\end{}’ pairs.
Apart from that this chapter contains a description of some features for entering more specialized sorts of text, for formatting the source by indenting and filling and for navigating through the document.
2.1 Insertion of Quotes, Dollars, and Braces | Inserting double quotes | |
2.2 Inserting Font Specifiers | ||
2.3 Inserting chapters, sections, etc. | ||
2.4 Inserting Environment Templates | ||
2.5 Entering Mathematics | ||
2.6 Completion | Completion of macros | |
2.7 Commenting | Commenting text | |
2.8 Indenting | Reflecting syntactic constructs with whitespace | |
2.9 Filling | Automatic and manual line breaking |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In TeX, literal double quotes ‘"like this"’ are seldom used, instead two single quotes are used ‘``like this''’. To help you insert these efficiently, AUCTeX allows you to continue to press " to insert two single quotes. To get a literal double quote, press " twice.
(") Insert the appropriate quote marks for TeX.
Inserts the value of TeX-open-quote
(normally ‘``’) or
TeX-close-quote
(normally ‘''’) depending on the context.
With prefix argument, always inserts ‘"’ characters.
String inserted by typing " to open a quotation. (See section Using AUCTeX with European Languages, for language-specific quotation mark insertion.)
String inserted by typing " to close a quotation. (See section Using AUCTeX with European Languages, for language-specific quotation mark insertion.)
Determines the behavior of ". If it is non-nil, typing "
will insert a literal double quote. The respective values of
TeX-open-quote
and TeX-close-quote
will be inserted
after typing " once again.
The ‘babel’ package provides special support for the requirements of typesetting quotation marks in many different languages. If you use this package, either directly or by loading a language-specific style file, you should also use the special commands for quote insertion instead of the standard quotes shown above. AUCTeX is able to recognize several of these languages and will change quote insertion accordingly. See section Using AUCTeX with European Languages, for details about this feature and how to control it.
In case you are using the ‘csquotes’ package, you should customize
LaTeX-csquotes-open-quote
, LaTeX-csquotes-close-quote
and
LaTeX-csquotes-quote-after-quote
. The quotation characters will
only be used if both variables—LaTeX-csquotes-open-quote
and
LaTeX-csquotes-close-quote
—are non-empty strings. But then the
‘csquotes’-related values will take precedence over the
language-specific ones.
In AUCTeX, dollar signs should match like they do in TeX. This has been partially implemented, we assume dollar signs always match within a paragraph. The first ‘$’ you insert in a paragraph will do nothing special. The second ‘$’ will match the first. This will be indicated by moving the cursor temporarily over the first dollar sign.
($) Insert dollar sign.
Show matching dollar sign if this dollar sign end the TeX math mode.
Ensure double dollar signs match up correctly by inserting extra dollar
signs when needed if TeX-math-close-double-dollar
is non-nil.
With optional arg, insert that many dollar signs.
Control the insertion of double dollar signs for delimiting display math. (Note that you should not use double dollar signs in LaTeX because this practice can lead to wrong spacing in typeset documents.) If the variable is non-nil and you enter a dollar sign that matches a double dollar sign ‘$$’ AUCTeX will automatically insert two dollar signs.
To avoid unbalanced braces, it is useful to insert them pairwise. You can do this by typing C-c {.
(C-c {) Make a pair of braces and position the cursor to type inside of them. If there is an active region, put braces around it and leave point after the closing brace.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Perhaps the most used keyboard commands of AUCTeX are the short-cuts available for easy insertion of font changing macros.
If you give an argument (that is, type C-u) to the font command,
the innermost font will be replaced, i.e. the font in the TeX group
around point will be changed. The following table shows the available
commands, with ∗
indicating the position where the text
will be inserted.
Insert bold face ‘\textbf{∗}’ text.
Insert italics ‘\textit{∗}’ text.
Insert emphasized ‘\emph{∗}’ text.
Insert slanted ‘\textsl{∗}’ text.
Insert roman \textrm{∗} text.
Insert sans serif ‘\textsf{∗}’ text.
Insert typewriter ‘\texttt{∗}’ text.
Insert SMALL CAPS ‘\textsc{∗}’ text.
Delete the innermost font specification containing point.
(C-c C-f) Insert template for font change command.
If replace is not nil, replace current font. what
determines the font to use, as specified by TeX-font-list
.
List of fonts used by TeX-font
.
Each entry is a list with three elements. The first element is the key to activate the font. The second element is the string to insert before point, and the third element is the string to insert after point. An optional fourth element means always replace if not nil.
List of fonts used by TeX-font
in LaTeX mode. It has the same
structure as TeX-font-list
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Insertion of sectioning macros, that is ‘\chapter’, ‘\section’, ‘\subsection’, etc. and accompanying ‘\label’’s may be eased by using C-c C-s. This command is highly customizable, the following describes the default behavior.
When invoking you will be asked for a section macro to insert. An appropriate default is automatically selected by AUCTeX, that is either: at the top of the document; the top level sectioning for that document style, and any other place: The same as the last occurring sectioning command.
Next, you will be asked for the actual name of that section, and
last you will be asked for a label to be associated with that section.
The label will be prefixed by the value specified in
LaTeX-section-hook
.
(C-c C-s) Insert a sectioning command.
Determine the type of section to be inserted, by the argument arg.
The following variables can be set to customize the function.
LaTeX-section-hook
Hooks to be run when inserting a section.
LaTeX-section-label
Prefix to all section references.
The precise behavior of LaTeX-section
is defined by the contents
of LaTeX-section-hook
.
List of hooks to run when a new section is inserted.
The following variables are set before the hooks are run
Numeric section level, default set by prefix arg to LaTeX-section
.
Name of the sectioning command, derived from level.
The title of the section, default to an empty string.
Entry for the table of contents list, default nil.
Position of point afterwards, default nil meaning after the inserted text.
A number of hooks are already defined. Most likely, you will be able to get the desired functionality by choosing from these hooks.
LaTeX-section-heading
Query the user about the name of the sectioning command. Modifies level and name.
LaTeX-section-title
Query the user about the title of the section. Modifies title.
LaTeX-section-toc
Query the user for the toc entry. Modifies toc.
LaTeX-section-section
Insert LaTeX section command according to name, title, and toc. If toc is nil, no toc entry is inserted. If toc or title are empty strings, done-mark will be placed at the point they should be inserted.
LaTeX-section-label
Insert a label after the section command. Controlled by the variable
LaTeX-section-label
.
To get a full featured LaTeX-section
command, insert
(setq LaTeX-section-hook '(LaTeX-section-heading LaTeX-section-title LaTeX-section-toc LaTeX-section-section LaTeX-section-label)) |
in your ‘.emacs’ file.
The behavior of LaTeX-section-label
is determined by the
variable LaTeX-section-label
.
Default prefix when asking for a label.
If it is a string, it is used unchanged for all kinds of sections. If it is nil, no label is inserted. If it is a list, the list is searched for a member whose car is equal to the name of the sectioning command being inserted. The cdr is then used as the prefix. If the name is not found, or if the cdr is nil, no label is inserted.
By default, chapters have a prefix of ‘cha:’ while sections and subsections have a prefix of ‘sec:’. Labels are not automatically inserted for other types of sections.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A large apparatus is available that supports insertions of environments, that is ‘\begin{}’ — ‘\end{}’ pairs.
AUCTeX is aware of most of the actual environments available in a specific document. This is achieved by examining your ‘\documentclass’ command, and consulting a precompiled list of environments available in a large number of styles.
You insert an environment with C-c C-e, and select an environment type. Depending on the environment, AUCTeX may ask more questions about the optional parts of the selected environment type. With C-u C-c C-e you will change the current environment.
(C-c C-e) AUCTeX will prompt you for an environment to insert. At this prompt, you may press <TAB> or <SPC> to complete a partially written name, and/or to get a list of available environments. After selection of a specific environment AUCTeX may prompt you for further specifications.
If the optional argument arg is not-nil (i.e. you have given a prefix argument), the current environment is modified and no new environment is inserted.
As a default selection, AUCTeX will suggest the environment last
inserted or, as the first choice the value of the variable
LaTeX-default-environment
.
Default environment to insert when invoking ‘LaTeX-environment’ first time.
If the document is empty, or the cursor is placed at the top of the document, AUCTeX will default to insert a ‘document’ environment.
Most of these are described further in the following sections, and you may easily specify more. See section Customizing Environments.
2.4.1 Equations | ||
2.4.2 Floats | ||
2.4.3 Itemize-like Environments | ||
2.4.4 Tabular-like Environments | ||
2.4.5 Customizing Environments |
You can close the current environment with C-c ], but we suggest that you use C-c C-e to insert complete environments instead.
(C-c ]) Insert an ‘\end’ that matches the current environment.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When inserting equation-like environments, the ‘\label’ will have a default prefix, which is controlled by the following variables:
Prefix to use for ‘equation’ labels.
Prefix to use for ‘eqnarray’ labels.
Prefix to use for amsmath equation labels. Amsmath equations include ‘align’, ‘alignat’, ‘xalignat’, ‘aligned’, ‘flalign’ and ‘gather’.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Figures and tables (i.e., floats) may also be inserted using AUCTeX. After choosing either ‘figure’ or ‘table’ in the environment list described above, you will be prompted for a number of additional things.
This is the optional argument of float environments that controls how
they are placed in the final document. In LaTeX this is a sequence
of the letters ‘htbp’ as described in the LaTeX manual. The
value will default to the value of LaTeX-float
.
This is the caption of the float. The default is to insert the caption
at the bottom of the float. You can specify floats where the caption
should be placed at the top with LaTeX-top-caption-list
.
The label of this float. The label will have a default prefix, which is
controlled by the variables LaTeX-figure-label
and
LaTeX-table-label
.
Moreover, you will be asked if you want the contents of the float environment to be horizontally centered. Upon a positive answer a ‘\centering’ macro will be inserted at the beginning of the float environment.
Default placement for floats.
Prefix to use for figure labels.
Prefix to use for table labels.
List of float environments with top caption.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
In an itemize-like environment, nodes (i.e., ‘\item’s) may be inserted using C-c <LFD>.
(C-c <LFD>) Close the current item, move to the next line and insert an appropriate ‘\item’ for the current environment. That is, ‘itemize’ and ‘enumerate’ will have ‘\item ’ inserted, while ‘description’ will have ‘\item[]’ inserted.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When inserting Tabular-like environments, that is, ‘tabular’ ‘array’ etc., you will be prompted for a template for that environment. Related variables:
Default format string for array and tabular environments.
Default position string for array and tabular environments. If nil, act like the empty string is given, but don’t prompt for a position.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
See section Adding Support for Environments, for how to customize the list of known environments.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
TeX is written by a mathematician, and has always contained good support for formatting mathematical text. AUCTeX supports this tradition, by offering a special minor mode for entering text with many mathematical symbols. You can enter this mode by typing C-c ~.
(C-c ~) Toggle LaTeX Math mode. This is a minor mode rebinding
the key LaTeX-math-abbrev-prefix
to allow easy typing of
mathematical symbols. ` will read a character from the keyboard,
and insert the symbol as specified in LaTeX-math-default
and
LaTeX-math-list
. If given a prefix argument, the symbol will be
surrounded by dollar signs.
You can use another prefix key (instead of `) by setting the
variable LaTeX-math-abbrev-prefix
.
To enable LaTeX Math mode by default, add the following in your ‘.emacs’ file:
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) |
A string containing the prefix of LaTeX-math-mode
commands; This
value defaults to `.
The string has to be a key or key sequence in a format understood by the
kbd
macro. This corresponds to the syntax usually used in the
manuals for Emacs Emacs Lisp.
The variable LaTeX-math-list
allows you to add your own mappings.
A list containing user-defined keys and commands to be used in LaTeX Math mode. Each entry should be a list of two to four elements.
First, the key to be used after LaTeX-math-abbrev-prefix
for
macro insertion. If it is nil, the symbol has no associated
keystroke (it is available in the menu, though).
Second, a string representing the name of the macro (without a leading backslash.)
Third, a string representing the name of a submenu the command should be added to. Use a list of strings in case of nested menus.
Fourth, the position of a Unicode character to be displayed in the menu alongside the macro name. This is an integer value.
Whether the LaTeX menu should try using Unicode for effect. Your Emacs built must be able to display include Unicode characters in menus for this feature.
AUCTeX’s reference card ‘tex-ref.tex’ includes a list of all math mode commands.
AUCTeX can help you write subscripts and superscripts in math
constructs by automatically inserting a pair of braces after typing
<_> or <^> respectively and putting point between the braces.
In order to enable this feature, set the variable
TeX-electric-sub-and-superscript
to a non-nil value.
If non-nil, insert braces after typing <^> and <_> in math mode.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Emacs lisp programmers probably know the lisp-complete-symbol
command, usually bound to M-<TAB>. Users of the wonderful
ispell mode know and love the ispell-complete-word
command from
that package. Similarly, AUCTeX has a TeX-complete-symbol
command, by default bound to M-<TAB> which is equivalent to
M-C-i. Using TeX-complete-symbol
makes it easier to type
and remember the names of long LaTeX macros.
In order to use TeX-complete-symbol
, you should write a backslash
and the start of the macro. Typing M-<TAB> will now complete
as much of the macro, as it unambiguously can. For example, if you type
‘‘\renewc’’ and then M-<TAB>, it will expand to
‘‘\renewcommand’’.
(M-<TAB>) Complete TeX symbol before point.
A more direct way to insert a macro is with TeX-insert-macro
,
bound to C-c C-m which is equivalent to C-c <RET>. It
has the advantage over completion that it knows about the argument of
most standard LaTeX macros, and will prompt for them. It also knows
about the type of the arguments, so it will for example give completion
for the argument to ‘\include’. Some examples are listed below.
(C-c C-m or C-c <RET>) Prompt (with completion) for the name of a TeX macro, and if AUCTeX knows the macro, prompt for each argument.
As a default selection, AUCTeX will suggest the macro last inserted
or, as the first choice the value of the variable
TeX-default-macro
.
Specifies whether TeX-insert-macro
will ask for all optional
arguments.
If set to the symbol show-optional-args
, TeX-insert-macro
asks for optional arguments of TeX macros. If set to
mandatory-args-only
, TeX-insert-macro
asks only for
mandatory arguments. When TeX-insert-macro
is called with prefix
argument (C-u), it’s the other way round.
Note that for some macros, there are special mechanisms, e.g.
LaTeX-includegraphics-options-alist
.
Default macro to insert when invoking TeX-insert-macro
first time.
A faster alternative is to bind the function TeX-electric-macro
to ‘\’. This can be done by setting the variable
TeX-electric-escape
If this is non-nil when AUCTeX is loaded, the TeX escape
character ‘\’ will be bound to TeX-electric-macro
The difference between TeX-insert-macro
and
TeX-electric-macro
is that space will complete and exit from the
minibuffer in TeX-electric-macro
. Use <TAB> if you merely
want to complete.
Prompt (with completion) for the name of a TeX macro, and if AUCTeX knows the macro, prompt for each argument. Space will complete and exit.
By default AUCTeX will put an empty set braces ‘{}’ after a
macro with no arguments to stop it from eating the next whitespace.
This can be stopped by entering LaTeX-math-mode
,
see section Entering Mathematics, or by setting TeX-insert-braces
to nil.
If non-nil, append a empty pair of braces after inserting a macro.
Completions work because AUCTeX can analyze TeX files, and store symbols in Emacs Lisp files for later retrieval. See section Automatic Customization, for more information.
AUCTeX will also make completion for many macro arguments, for
example existing labels when you enter a ‘\ref’ macro with
TeX-insert-macro
or TeX-electric-macro
, and BibTeX
entries when you enter a ‘\cite’ macro. For this kind of
completion to work, parsing must be enabled as described in
see section Automatic Parsing of TeX Files. For ‘\cite’ you must also make sure that
the BibTeX files have been saved at least once after you enabled
automatic parsing on save, and that the basename of the BibTeX file
does not conflict with the basename of one of TeX files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
It is often necessary to comment out temporarily a region of TeX or LaTeX code. This can be done with the commands C-c ; and C-c %. C-c ; will comment out all lines in the current region, while C-c % will comment out the current paragraph. Type C-c ; again to uncomment all lines of a commented region, or C-c % again to uncomment all comment lines around point. These commands will insert or remove a single ‘%’ respectively.
(C-c ;) Add or remove ‘%’ from the beginning of each line
in the current region. Uncommenting works only if the region encloses
solely commented lines. If AUCTeX should not try to guess if the
region should be commented or uncommented the commands
TeX-comment-region
and TeX-uncomment-region
can be used
to explicitly comment or uncomment the region in concern.
(C-c %) Add or remove ‘%’ from the beginning of each line in the current paragraph. When removing ‘%’ characters the paragraph is considered to consist of all preceding and succeeding lines starting with a ‘%’, until the first non-comment line.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Indentation means the addition of whitespace at the beginning of lines to reflect special syntactical constructs. This makes it easier to see the structure of the document, and to catch errors such as a missing closing brace. Thus, the indentation is done for precisely the same reasons that you would indent ordinary computer programs.
Indentation is done by LaTeX environments and by TeX groups, that
is the body of an environment is indented by the value of
LaTeX-indent-level
(default 2). Also, items of an ‘itemize-like’
environment are indented by the value of LaTeX-item-indent
,
default -2. (Items are identified with the help of
LaTeX-item-regexp
.) If more environments are nested, they are
indented ‘accumulated’ just like most programming languages usually are
seen indented in nested constructs.
You can explicitely indent single lines, usually by pressing <TAB>,
or marked regions by calling indent-region
on it. If you have
auto-fill-mode
enabled and a line is broken while you type it,
Emacs automatically cares about the indentation in the following line.
If you want to have a similar behavior upon typing <RET>, you can
customize the variable TeX-newline-function
and change the
default of newline
which does no indentation to
newline-and-indent
which indents the new line or
reindent-then-newline-and-indent
which indents both the current
and the new line.
There are certain LaTeX environments which should be indented in a
special way, like ‘tabular’ or ‘verbatim’. Those environments
may be specified in the variable LaTeX-indent-environment-list
together with their special indentation functions. Taking the
‘verbatim’ environment as an example you can see that
current-indentation
is used as the indentation function. This
will stop AUCTeX from doing any indentation in the environment if you
hit <TAB> for example.
There are environments in LaTeX-indent-environment-list
which do
not bring a special indentation function with them. This is due to the
fact that first the respective functions are not implemented yet and
second that filling will be disabled for the specified environments.
This shall prevent the source code from being messed up by accidently
filling those environments with the standard filling routine. If you
think that providing special filling routines for such environments
would be an appropriate and challenging task for you, you are invited to
contribute. (See section Filling, for further information about the filling
functionality)
The check for the indentation function may be enabled or disabled by
customizing the variable LaTeX-indent-environment-check
.
As a side note with regard to formatting special environments: Newer
Emacsen include ‘align.el’ and therefore provide some support for
formatting ‘tabular’ and ‘tabbing’ environments with the
function align-current
which will nicely align columns in the
source code.
AUCTeX is able to format commented parts of your code just as any
other part. This means LaTeX environments and TeX groups in
comments will be indented syntactically correct if the variable
LaTeX-syntactic-comments
is set to t. If you disable it,
comments will be filled like normal text and no syntactic indentation
will be done.
Following you will find a list of most commands and variables related to indenting with a small summary in each case:
LaTeX-indent-line
will indent the current line.
newline-and-indent
inserts a new line (much like <RET>) and
moves the cursor to an appropriate position by the left margin.
Most keyboards nowadays lack a linefeed key and C-j may be tedious
to type. Therefore you can customize AUCTeX to perform indentation
upon typing <RET> as well. The respective option is called
TeX-newline-function
.
Alias for <LFD>
List of environments with special indentation. The second element in each entry is the function to calculate the indentation level in columns.
The filling code currently cannot handle tabular-like environments which will be completely messed-up if you try to format them. This is why most of these environments are included in this customization option without a special indentation function. This will prevent that they get filled.
Number of spaces to add to the indentation for each ‘\begin’ not matched by a ‘\end’.
Number of spaces to add to the indentation for ‘\item’’s in list environments.
Number of spaces to add to the indentation for each ‘{’ not matched by a ‘}’.
If non-nil comments will be filled and indented according to LaTeX syntax. Otherwise they will be filled like normal text.
Used to specify the function which is called when <RET> is pressed.
This will normally be newline
which simply inserts a new line.
In case you want to have AUCTeX do indentation as well when you press
<RET>, use the built-in functions newline-and-indent
or
reindent-then-newline-and-indent
. The former inserts a new line
and indents the following line, i.e. it moves the cursor to the right
position and therefore acts as if you pressed <LFD>. The latter
function additionally indents the current line. If you choose
‘Other’, you can specify your own fancy function to be called when
<RET> is pressed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Filling deals with the insertion of line breaks to prevent lines from
becoming wider than what is specified in fill-column
. The
linebreaks will be inserted automatically if auto-fill-mode
is
enabled. In this case the source is not only filled but also indented
automatically as you write it.
auto-fill-mode
can be enabled for AUCTeX by calling
turn-on-auto-fill
in one of the hooks AUCTeX is running.
See section Modes and Hooks. As an example, if you want to enable
auto-fill-mode
in LaTeX-mode
, put the following into your
init file:
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill) |
You can manually fill explicitely marked regions, paragraphs, environments, complete sections, or the whole buffer. (Note that manual filling in AUCTeX will indent the start of the region to be filled in contrast to many other Emacs modes.)
There are some syntactical constructs which are handled specially with regard to filling. These are so-called code comments and paragraph commands.
Code comments are comments preceded by code or text in the same line.
Upon filling a region, code comments themselves will not get filled.
Filling is done from the start of the region to the line with the code
comment and continues after it. In order to prevent overfull lines in
the source code, a linebreak will be inserted before the last
non-comment word by default. This can be changed by customizing
LaTeX-fill-break-before-code-comments
. If you have overfull
lines with code comments you can fill those explicitely by calling
LaTeX-fill-paragraph
or pressing M-q with the cursor
positioned on them. This will add linebreaks in the comment and indent
subsequent comment lines to the column of the comment in the first line
of the code comment. In this special case M-q only acts on the
current line and not on the whole paragraph.
Lines with ‘\par’ are treated similarly to code comments, i.e. ‘\par’ will be treated as paragraph boundary which should not be followed by other code or text. But it is not treated as a real paragraph boundary like an empty line where filling a paragraph would stop.
Paragraph commands like ‘\section’ or ‘\noindent’ (the list of
commands is defined by LaTeX-paragraph-commands
) are often to be
placed in their own line(s). This means they should not be consecuted
with any preceding or following adjacent lines of text. AUCTeX will
prevent this from happening if you do not put any text except another
macro after the end of the last brace of the respective macro. If
there is other text after the macro, AUCTeX regards this as a sign
that the macro is part of the following paragraph.
Here are some examples:
\begin{quote} text text text text |
\begin{quote}\label{foo} text text text text |
If you press M-q on the first line in both examples, nothing will change. But if you write
\begin{quote} text text text text text |
and press M-q, you will get
\begin{quote} text text text text text |
Besides code comments and paragraph commands, another speciality of
filling in AUCTeX involves commented lines. You should be aware that
these comments are treated as islands in the rest of the LaTeX code
if syntactic filling is enabled. This means, for example, if you try to
fill an environment with LaTeX-fill-environment
and have the
cursor placed on a commented line which does not have a surrounding
environment inside the comment, AUCTeX will report an error.
The relevant commands and variables with regard to filling are:
LaTeX-fill-paragraph
will fill and indent the current paragraph.
Alias for C-c C-q C-p
LaTeX-fill-environment
will fill and indent the current
environment. This may e.g. be the ‘document’ environment, in which case
the entire document will be formatted.
LaTeX-fill-section
will fill and indent the current logical
sectional unit.
LaTeX-fill-region
will fill and indent the current region.
List of separators before or after which respectively linebreaks will be inserted if they do not fit into one line. The separators can be curly braces, brackets, switches for inline math (‘$’, ‘\(’, ‘\)’) and switches for display math (‘\[’, ‘\]’). Such formatting can be useful to make macros and math more visible or to prevent overfull lines in the LaTeX source in case a package for displaying formatted TeX output inside the Emacs buffer, like preview-latex, is used.
Code comments are comments preceded by some other text in the same line.
When a paragraph containing such a comment is to be filled, the comment
start will be seen as a border after which no line breaks will be
inserted in the same line. If the option
LaTeX-fill-break-before-code-comments
is enabled (which is the
default) and the comment does not fit into the line, a line break will
be inserted before the last non-comment word to minimize the chance that
the line becomes overfull.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Build Daemon user on November 4, 2010 using texi2html 1.82.