1 \input texinfo @c -*-texinfo-*-
3 @setfilename ../../info/reftex
4 @settitle RefTeX User Manual
27 \gdef\ConTeXt{Con\TeX t}
30 @include emacsver.texi
32 @set VERSION @value{EMACSVER}
33 @set AUCTEXSITE @uref{http://www.gnu.org/software/auctex/,@AUCTeX{} web site}
34 @set MAINTAINERSITE @uref{http://www.gnu.org/software/auctex/reftex.html,@RefTeX{} web page}
35 @set MAINTAINERCONTACT @uref{mailto:auctex-devel@@gnu.org,contact the maintainers}
36 @set MAINTAINER the @AUCTeX{} project
37 @set SUPPORTADDRESS @AUCTeX{} user mailing list (@email{auctex@@gnu.org})
38 @set DEVELADDRESS @AUCTeX{} developer mailing list (@email{auctex-devel@@gnu.org})
39 @set BUGADDRESS @AUCTeX{} bug mailing list (@email{bug-auctex@@gnu.org})
40 @set XEMACSFTP @uref{ftp://ftp.xemacs.org/pub/xemacs/packages/,XEmacs FTP site}
44 This manual documents @RefTeX{} (version @value{VERSION}), a package
45 to do labels, references, citations and indices for LaTeX documents
48 Copyright @copyright{} 1997-2012 Free Software Foundation, Inc.
51 Permission is granted to copy, distribute and/or modify this document
52 under the terms of the GNU Free Documentation License, Version 1.3 or
53 any later version published by the Free Software Foundation; with no
54 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
55 and with the Back-Cover Texts as in (a) below. A copy of the license
56 is included in the section entitled ``GNU Free Documentation License''.
58 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
59 modify this GNU manual. Buying copies from the FSF supports it in
60 developing GNU and promoting software freedom.''
64 @dircategory Emacs misc features
66 * RefTeX: (reftex). Emacs support for LaTeX cross-references
74 @c Subheadings inside a table. Need a difference between info and the rest.
75 @macro tablesubheading{text}
85 @title @RefTeX{} User Manual
86 @subtitle Support for @LaTeX{} labels, references, citations and index entries with GNU Emacs
87 @subtitle Version @value{VERSION}
89 @author by Carsten Dominik
91 @vskip 0pt plus 1filll
102 @RefTeX{} is a package for managing Labels, References, Citations and
103 index entries with GNU Emacs.
105 This manual documents @RefTeX{} version @value{VERSION}.
107 Don't be discouraged by the size of this manual, which covers @RefTeX{}
108 in great depth. All you need to know to use @RefTeX{} can be summarized
109 on two pages (@pxref{RefTeX in a Nutshell}). You can go back later to
110 other parts of this document when needed.
113 * Introduction:: Quick-Start information.
115 * Table of Contents:: A Tool to move around quickly.
116 * Labels and References:: Creating and referencing labels.
117 * Citations:: Creating Citations.
118 * Index Support:: Creating and Checking Index Entries.
119 * Viewing Cross-References:: Who references or cites what?
121 * RefTeXs Menu:: The Ref menu in the menubar.
122 * Key Bindings:: The default key bindings.
123 * Faces:: Fontification of RefTeX's buffers.
124 * Multifile Documents:: Document spread over many files.
125 * Language Support:: How to support other languages.
126 * Finding Files:: Included @TeX{} files and @BibTeX{} .bib files.
127 * AUCTeX:: Cooperation with @AUCTeX{}.
128 * Optimizations:: When RefTeX is too slow.
129 * Problems and Work-Arounds:: First Aid.
130 * Imprint:: Author, Web-site, Thanks
132 * Commands:: Which are the available commands.
133 * Options:: How to extend and configure RefTeX.
134 * Keymaps and Hooks:: For customization.
135 * Changes:: A List of recent changes to RefTeX.
136 * GNU Free Documentation License:: The license for this documentation.
140 * Index:: The full index.
143 --- The Detailed Node Listing ---
147 * Installation:: How to install and activate RefTeX.
148 * RefTeX in a Nutshell:: A brief summary and quick guide.
150 Labels and References
153 * Referencing Labels::
154 * Builtin Label Environments:: The environments RefTeX knows about.
155 * Defining Label Environments:: ... and environments it doesn't.
156 * Reference Info:: View the label corresponding to a \ref.
157 * Reference Styles:: Macros to be used instead of \ref.
158 * xr (LaTeX package):: References to external documents.
160 Defining Label Environments
162 * Theorem and Axiom:: Defined with @code{\newenvironment}.
163 * Quick Equation:: When a macro sets the label type.
164 * Figure Wrapper:: When a macro argument is a label.
165 * Adding Magic Words:: Other words for other languages.
166 * Using \eqref:: How to switch to this AMS-LaTeX macro.
167 * Non-Standard Environments:: Environments without \begin and \end
168 * Putting it Together:: How to combine many entries.
172 * Creating Citations:: How to create them.
173 * Citation Styles:: Natbib, Harvard, Chicago and Co.
174 * Citation Info:: View the corresponding database entry.
175 * Chapterbib and Bibunits:: Multiple bibliographies in a Document.
176 * Citations Outside LaTeX:: How to make citations in Emails etc.
177 * BibTeX Database Subsets:: Extract parts of a big database.
181 * Creating Index Entries:: Macros and completion of entries.
182 * The Index Phrases File:: A special file for global indexing.
183 * Displaying and Editing the Index:: The index editor.
184 * Builtin Index Macros:: The index macros RefTeX knows about.
185 * Defining Index Macros:: ... and macros it doesn't.
187 The Index Phrases File
189 * Collecting Phrases:: Collecting from document or external.
190 * Consistency Checks:: Check for duplicates etc.
191 * Global Indexing:: The interactive indexing process.
195 * AUCTeX-RefTeX Interface:: How both packages work together
196 * Style Files:: @AUCTeX{}'s style files can support RefTeX
197 * Bib-Cite:: Hypertext reading of a document
199 Options, Keymaps, Hooks
201 * Options (Table of Contents)::
202 * Options (Defining Label Environments)::
203 * Options (Creating Labels)::
204 * Options (Referencing Labels)::
205 * Options (Creating Citations)::
206 * Options (Index Support)::
207 * Options (Viewing Cross-References)::
208 * Options (Finding Files)::
209 * Options (Optimizations)::
210 * Options (Fontification)::
218 @node Introduction, Table of Contents, , Top
219 @chapter Introduction
222 @RefTeX{} is a specialized package for support of labels, references,
223 citations, and the index in @LaTeX{}. @RefTeX{} wraps itself round four
224 @LaTeX{} macros: @code{\label}, @code{\ref}, @code{\cite}, and
225 @code{\index}. Using these macros usually requires looking up different
226 parts of the document and searching through @BibTeX{} database files.
227 @RefTeX{} automates these time-consuming tasks almost entirely. It also
228 provides functions to display the structure of a document and to move
229 around in this structure quickly.
232 Don't be discouraged by the size of this manual, which covers @RefTeX{}
233 in great depth. All you need to know to use @RefTeX{} can be
234 summarized on two pages (@pxref{RefTeX in a Nutshell}). You can go
235 back later to other parts of this document when needed.
238 @xref{Imprint}, for information about who to contact for help, bug
239 reports or suggestions.
242 * Installation:: How to install and activate RefTeX.
243 * RefTeX in a Nutshell:: A brief summary and quick guide.
246 @node Installation, RefTeX in a Nutshell, , Introduction
247 @section Installation
250 @RefTeX{} has been bundled and pre-installed with Emacs since
251 version 20.2. It has also been bundled and pre-installed with XEmacs
252 19.16--20.x. XEmacs 21.x users want to install the corresponding
253 plug-in package which is available from the @value{XEMACSFTP}. See the
254 XEmacs 21.x documentation on package installation for details.
256 Users of earlier Emacs distributions (including Emacs 19) or people
257 craving for new features and bugs can get a copy of the @RefTeX{}
258 distribution from the maintainer's web page. @xref{Imprint}, for more
259 information. The following instructions will guide you through the
260 process of installing such a distribution.
262 @subsection Building and Installing
264 Note: Currently installation is supported for Emacs only. XEmacs users
265 might want to refer to the @RefTeX{} package available through the
266 package system of XEmacs.
268 @subsubheading Installation with make
270 In order to install RefTeX, unpack the distribution and edit the header
271 of the Makefile. Basically, you need to change the path specifications
272 for Emacs Lisp files and info files. Also, enter the name of your Emacs
273 executable (usually either @samp{emacs} or @samp{xemacs}).
282 to compile and install the code and documentation.
284 Per default @RefTeX{} is installed in its own subdirectory which might
285 not be on your load path. In this case, add it to load path with a
286 command like the following, replacing the sample directory with the one
287 where @RefTeX{} is installed in your case.
290 (add-to-list 'load-path "/path/to/reftex")
293 Put this command into your init file before other @RefTeX{}-related
296 @subsubheading Installation by Hand
298 If you want to get your hands dirty, there is also the possibility to
299 install by manually copying files.
303 Copy the reftex*.el lisp files to a directory on your load path. Make
304 sure that no old copy of @RefTeX{} shadows these files.
306 Byte compile the files. The sequence of compiling should be:
307 reftex-var.el, reftex.el, and then all the others.
309 Copy the info file reftex.info to the info directory.
312 @subsection Loading @RefTeX{}
314 In order to make the most important functions for entering @RefTeX{}
315 mode available add the following line to your init file.
321 @subsection Entering @RefTeX{} Mode
323 @findex turn-on-reftex
325 @vindex LaTeX-mode-hook
326 @vindex latex-mode-hook
327 To turn @RefTeX{} Mode on and off in a particular buffer, use
328 @kbd{M-x reftex-mode @key{RET}}. To turn on @RefTeX{} Mode for all
329 LaTeX files, add the following lines to your @file{.emacs} file:
332 (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
333 (add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
338 To get started, read the documentation, in particular the
339 summary. (@pxref{RefTeX in a Nutshell})
341 In order to produce a printed version of the documentation, use
342 @code{make pdf} to produce a reftex.pdf file. Analogously you can use
343 the @code{dvi}, @code{ps}, or @code{html} targets to create DVI,
344 PostScript or HTML files.
346 @subsection Environment
347 @cindex Finding files
348 @cindex BibTeX database files, not found
349 @cindex TeX files, not found
350 @cindex @code{TEXINPUTS}, environment variable
351 @cindex @code{BIBINPUTS}, environment variable
353 @RefTeX{} needs to access all files which are part of a multifile
354 document, and the BibTeX database files requested by the
355 @code{\bibliography} command. To find these files, @RefTeX{} will
356 require a search path, i.e. a list of directories to check. Normally
357 this list is stored in the environment variables @code{TEXINPUTS} and
358 @code{BIBINPUTS} which are also used by @RefTeX{}. However, on some
359 systems these variables do not contain the full search path. If
360 @RefTeX{} does not work for you because it cannot find some files,
361 @xref{Finding Files}.
364 @node RefTeX in a Nutshell, , Installation, Introduction
365 @section @RefTeX{} in a Nutshell
367 @cindex Getting Started
368 @cindex RefTeX in a Nutshell
369 @cindex Nutshell, RefTeX in a
373 @b{Table of Contents}@* Typing @kbd{C-c =} (@code{reftex-toc}) will show
374 a table of contents of the document. This buffer can display sections,
375 labels and index entries defined in the document. From the buffer, you
376 can jump quickly to every part of your document. Press @kbd{?} to get
380 @b{Labels and References}@* @RefTeX{} helps to create unique labels
381 and to find the correct key for references quickly. It distinguishes
382 labels for different environments, knows about all standard
383 environments (and many others), and can be configured to recognize any
384 additional labeled environments you have defined yourself (variable
385 @code{reftex-label-alist}).
389 @b{Creating Labels}@*
390 Type @kbd{C-c (} (@code{reftex-label}) to insert a label at point.
391 @RefTeX{} will either
394 derive a label from context (default for section labels)
396 prompt for a label string (default for figures and tables) or
398 insert a simple label made of a prefix and a number (all other
402 Which labels are created how is configurable with the variable
403 @code{reftex-insert-label-flags}.
406 @b{Referencing Labels}@* To make a reference, type @kbd{C-c )}
407 (@code{reftex-reference}). This shows an outline of the document with
408 all labels of a certain type (figure, equation,...) and some label
409 context. Selecting a label inserts a @code{\ref@{@var{label}@}} macro
410 into the original buffer.
415 Typing @kbd{C-c [} (@code{reftex-citation}) will let you specify a
416 regular expression to search in current @BibTeX{} database files (as
417 specified in the @code{\bibliography} command) and pull out a list of
418 matches for you to choose from. The list is @emph{formatted} and
419 sorted. The selected article is referenced as @samp{\cite@{@var{key}@}}
420 (see the variable @code{reftex-cite-format} if you want to insert
425 @RefTeX{} helps to enter index entries. It also compiles all
426 entries into an alphabetically sorted @file{*Index*} buffer which you
427 can use to check and edit the entries. @RefTeX{} knows about the
428 standard index macros and can be configured to recognize any additional
429 macros you have defined (@code{reftex-index-macros}). Multiple indices
434 @b{Creating Index Entries}@*
435 To index the current selection or the word at point, type @kbd{C-c /}
436 (@code{reftex-index-selection-or-word}). The default macro
437 @code{reftex-index-default-macro} will be used. For a more complex entry
438 type @kbd{C-c <} (@code{reftex-index}), select any of the index macros
439 and enter the arguments with completion.
442 @b{The Index Phrases File (Delayed Indexing)}@*
443 Type @kbd{C-c \} (@code{reftex-index-phrase-selection-or-word}) to add
444 the current word or selection to a special @emph{index phrase file}.
445 @RefTeX{} can later search the document for occurrences of these
446 phrases and let you interactively index the matches.
449 @b{Displaying and Editing the Index}@*
450 To display the compiled index in a special buffer, type @kbd{C-c >}
451 (@code{reftex-display-index}). From that buffer you can check and edit
456 @item @b{Viewing Cross-References}@*
457 When point is on the @var{key} argument of a cross-referencing macro
458 (@code{\label}, @code{\ref}, @code{\cite}, @code{\bibitem},
459 @code{\index}, and variations) or inside a @BibTeX{} database entry, you
460 can press @kbd{C-c &} (@code{reftex-view-crossref}) to display
461 corresponding locations in the document and associated @BibTeX{} database
463 When the enclosing macro is @code{\cite} or @code{\ref} and no other
464 message occupies the echo area, information about the citation or label
465 will automatically be displayed in the echo area.
468 @b{Multifile Documents}@*
469 Multifile Documents are fully supported. The included files must have a
470 file variable @code{TeX-master} or @code{tex-main-file} pointing to the
471 master file. @RefTeX{} provides cross-referencing information from
472 all parts of the document, and across document borders
476 @b{Document Parsing}@* @RefTeX{} needs to parse the document in
477 order to find labels and other information. It does it automatically
478 once and updates its list internally when @code{reftex-label} and
479 @code{reftex-index} are used. To enforce reparsing, call any of the
480 commands described above with a raw @kbd{C-u} prefix, or press the
481 @kbd{r} key in the label selection buffer, the table of contents
482 buffer, or the index buffer.
485 @b{@AUCTeX{}} @* If your major @LaTeX{} mode is @AUCTeX{}, @RefTeX{} can
486 cooperate with it (see variable @code{reftex-plug-into-AUCTeX}). @AUCTeX{}
487 contains style files which trigger appropriate settings in
488 @RefTeX{}, so that for many of the popular @LaTeX{} packages no
489 additional customizations will be necessary.
492 @b{Useful Settings}@*
493 To integrate RefTeX with @AUCTeX{}, use
495 (setq reftex-plug-into-AUCTeX t)
498 To make your own @LaTeX{} macro definitions known to @RefTeX{},
499 customize the variables
501 @code{reftex-label-alist} @r{(for label macros/environments)}
502 @code{reftex-section-levels} @r{(for sectioning commands)}
503 @code{reftex-cite-format} @r{(for @code{\cite}-like macros)}
504 @code{reftex-index-macros} @r{(for @code{\index}-like macros)}
505 @code{reftex-index-default-macro} @r{(to set the default macro)}
507 If you have a large number of macros defined, you may want to write
508 an @AUCTeX{} style file to support them with both @AUCTeX{} and
511 @item @b{Where Next?}@* Go ahead and use @RefTeX{}. Use its menus
512 until you have picked up the key bindings. For an overview of what you
513 can do in each of the different special buffers, press @kbd{?}. Read
514 the manual if you get stuck, or if you are curious what else might be
515 available. The first part of the manual explains in
516 a tutorial way how to use and customize @RefTeX{}. The second
517 part is a command and variable reference.
520 @node Table of Contents, Labels and References, Introduction, Top
521 @chapter Table of Contents
522 @cindex @file{*toc*} buffer
523 @cindex Structure editing
524 @cindex Table of contents buffer
528 Pressing the keys @kbd{C-c =} pops up a buffer showing the table of
529 contents of the document. By default, this @file{*toc*} buffer shows
530 only the sections of a document. Using the @kbd{l} and @kbd{i} keys you
531 can display all labels and index entries defined in the document as
534 With the cursor in any of the lines denoting a location in the
535 document, simple key strokes will display the corresponding part in
536 another window, jump to that location, or perform other actions.
539 Here is a list of special commands in the @file{*toc*} buffer. A
540 summary of this information is always available by pressing
545 @tablesubheading{General}
547 Display a summary of commands.
552 @tablesubheading{Moving around}
554 Goto next entry in the table of contents.
557 Goto previous entry in the table of contents.
560 Goto next section heading. Useful when many labels and index entries
561 separate section headings.
564 Goto previous section heading.
567 Jump to section N, using the prefix arg. For example, @kbd{3 z} jumps
570 @tablesubheading{Access to document locations}
572 Show the corresponding location in another window. This command does
573 @emph{not} select that other window.
576 Goto the location in another window.
579 Go to the location and hide the @file{*toc*} buffer. This will restore
580 the window configuration before @code{reftex-toc} (@kbd{C-c =}) was
584 @vindex reftex-highlight-selection
585 Clicking with mouse button 2 on a line has the same effect as @key{RET}.
586 See also variable @code{reftex-highlight-selection}, @ref{Options
590 @vindex reftex-toc-follow-mode
591 @vindex reftex-revisit-to-follow
592 Toggle follow mode. When follow mode is active, the other window will
593 always show the location corresponding to the line at point in the
594 @file{*toc*} buffer. This is similar to pressing @key{SPC} after each
595 cursor motion. The default for this flag can be set with the variable
596 @code{reftex-toc-follow-mode}. Note that only context in files already
597 visited is shown. @RefTeX{} will not visit a file just for follow
598 mode. See, however, the variable
599 @code{reftex-revisit-to-follow}.
602 Show calling point in another window. This is the point from where
603 @code{reftex-toc} was last called.
606 @tablesubheading{Promotion and Demotion}
609 Promote the current section. This will convert @code{\section} to
610 @code{\chapter}, @code{\subsection} to @code{\section} etc. If there is
611 an active region, all sections in the region will be promoted, including
612 the one at point. To avoid mistakes, @RefTeX{} requires a fresh
613 document scan before executing this command -- if necessary, it will
614 automatically do this scan and ask the user to repeat the promotion
618 Demote the current section. This is the opposite of promotion. It will
619 convert @code{\chapter} to @code{\section} etc. If there is an active
620 region, all sections in the region will be demoted, including the one at
624 Rename the label at point. While generally not recommended, this can be
625 useful when a package like @file{fancyref} is used where the label
626 prefix determines the wording of a reference. After a
627 promotion/demotion it may be necessary to change a few labels from
628 @samp{sec:xyz} to @samp{cha:xyz} or vice versa. This command can be
629 used to do this - it launches a query replace to rename the definition
630 and all references of a label.
632 @tablesubheading{Exiting}
634 Hide the @file{*toc*} buffer, return to the position where
635 @code{reftex-toc} was last called.
638 Kill the @file{*toc*} buffer, return to the position where
639 @code{reftex-toc} was last called.
642 Switch to the @file{*Index*} buffer of this document. With prefix
643 @samp{2}, restrict the index to the section at point in the @file{*toc*}
646 @tablesubheading{Controlling what gets displayed}
649 @vindex reftex-toc-max-level
650 Change the maximum level of toc entries displayed in the @file{*toc*}
651 buffer. Without prefix arg, all levels will be included. With prefix
652 arg (e.g @kbd{3 t}), ignore all toc entries with level greater than
653 @var{arg} (3 in this case). Chapters are level 1, sections are level 2.
654 The mode line @samp{T<>} indicator shows the current value. The default
655 depth can be configured with the variable
656 @code{reftex-toc-max-level}.
659 @vindex reftex-toc-include-file-boundaries
660 Toggle the display of the file borders of a multifile document in the
661 @file{*toc*} buffer. The default for this flag can be set with the
662 variable @code{reftex-toc-include-file-boundaries}.
665 @vindex reftex-toc-include-labels
666 Toggle the display of labels in the @file{*toc*} buffer. The default
667 for this flag can be set with the variable
668 @code{reftex-toc-include-labels}. When called with a prefix argument,
669 @RefTeX{} will prompt for a label type and include only labels of
670 the selected type in the @file{*toc*} buffer. The mode line @samp{L<>}
671 indicator shows which labels are included.
674 @vindex reftex-toc-include-index-entries
675 Toggle the display of index entries in the @file{*toc*} buffer. The
676 default for this flag can be set with the variable
677 @code{reftex-toc-include-index-entries}. When called with a prefix
678 argument, @RefTeX{} will prompt for a specific index and include
679 only entries in the selected index in the @file{*toc*} buffer. The mode
680 line @samp{I<>} indicator shows which index is used.
683 @vindex reftex-toc-include-context
684 Toggle the display of label and index context in the @file{*toc*}
685 buffer. The default for this flag can be set with the variable
686 @code{reftex-toc-include-context}.
688 @tablesubheading{Updating the buffer}
691 Rebuild the @file{*toc*} buffer. This does @emph{not} rescan the
695 @vindex reftex-enable-partial-scans
696 Reparse the @LaTeX{} document and rebuild the @file{*toc*} buffer. When
697 @code{reftex-enable-partial-scans} is non-@code{nil}, rescan only the file this
698 location is defined in, not the entire document.
701 Reparse the @emph{entire} @LaTeX{} document and rebuild the @file{*toc*}
705 Switch to the @file{*toc*} buffer of an external document. When the
706 current document is using the @code{xr} package (@pxref{xr (LaTeX
707 package)}), @RefTeX{} will switch to one of the external
711 @tablesubheading{Automatic recentering}
714 Toggle the display of a dedicated frame displaying just the @file{*toc*}
715 buffer. Follow mode and visiting locations will not work that frame,
716 but automatic recentering will make this frame always show your current
717 editing location in the document (see below).
720 Toggle the automatic recentering of the @file{*toc*} buffer. When this
721 option is on, moving around in the document will cause the @file{*toc*}
722 to always highlight the current section. By default, this option is
723 active while the dedicated @file{*TOC*} frame exists. See also the
724 variable @code{reftex-auto-recenter-toc}.
728 @vindex reftex-toc-map
729 In order to define additional commands for the @file{*toc*} buffer, the
730 keymap @code{reftex-toc-map} may be used.
732 @findex reftex-toc-recenter
733 @vindex reftex-auto-recenter-toc
734 @vindex reftex-idle-time
735 @cindex @file{*toc*} buffer, recentering
736 @cindex Table of contents buffer, recentering
738 If you call @code{reftex-toc} while the @file{*toc*} buffer already
739 exists, the cursor will immediately jump to the right place, i.e. the
740 section from which @code{reftex-toc} was called will be highlighted.
741 The command @kbd{C-c -} (@code{reftex-toc-recenter}) will only redisplay
742 the @file{*toc*} buffer and highlight the correct line without actually
743 selecting the @file{*toc*} window. This can be useful to quickly find
744 out where in the document you currently are. You can also automate this
745 by asking RefTeX to keep track of your current editing position in the
746 TOC. The TOC window will then be updated whenever you stop typing for
747 more than @code{reftex-idle-time} seconds. By default this works only
748 with the dedicated @file{*TOC*} frame. But you can also force automatic
749 recentering of the TOC window on the current frame with
751 (setq reftex-auto-recenter-toc t)
755 @cindex Sectioning commands
756 @cindex KOMA-Script, LaTeX classes
757 @cindex LaTeX classes, KOMA-Script
758 @cindex TOC entries for environments
759 @vindex reftex-section-levels
760 The section macros recognized by @RefTeX{} are all @LaTeX{} section
761 macros (from @code{\part} to @code{\subsubparagraph}) and the commands
762 @code{\addchap} and @code{\addsec} from the KOMA-Script classes.
763 Additional macros can be configured with the variable
764 @code{reftex-section-levels}. It is also possible to add certain @LaTeX{}
765 environments to the table of contents. This is probably only useful for
766 theorem-like environments. @xref{Defining Label Environments}, for an
769 @node Labels and References, Citations, Table of Contents, Top
770 @chapter Labels and References
771 @cindex Labels in LaTeX
772 @cindex References in LaTeX
773 @cindex Label category
774 @cindex Label environment
775 @cindex @code{\label}
777 @LaTeX{} provides a powerful mechanism to deal with cross-references in a
778 document. When writing a document, any part of it can be marked with a
779 label, like @samp{\label@{mark@}}. @LaTeX{} records the current value of a
780 certain counter when a label is defined. Later references to this label
781 (like @samp{\ref@{mark@}}) will produce the recorded value of the
784 Labels can be used to mark sections, figures, tables, equations,
785 footnotes, items in enumerate lists etc. @LaTeX{} is context sensitive in
786 doing this: A label defined in a figure environment automatically
787 records the figure counter, not the section counter.
789 Several different environments can share a common counter and therefore
790 a common label category. For example labels in both @code{equation} and
791 @code{eqnarray} environments record the value of the same counter -- the
796 * Referencing Labels::
797 * Builtin Label Environments:: The environments RefTeX knows about.
798 * Defining Label Environments:: ... and environments it doesn't.
799 * Reference Info:: View the label corresponding to a \ref.
800 * Reference Styles:: Macros to be used instead of \ref.
801 * xr (LaTeX package):: References to external documents.
804 @node Creating Labels, Referencing Labels, , Labels and References
805 @section Creating Labels
806 @cindex Creating labels
807 @cindex Labels, creating
808 @cindex Labels, deriving from context
812 In order to create a label in a @LaTeX{} document, press @kbd{C-c (}
813 (@code{reftex-label}). Just like @LaTeX{}, @RefTeX{} is context sensitive
814 and will figure out the environment it currently is in and adapt the
815 label to that environment. A label usually consists of a short prefix
816 indicating the type of the label and a unique mark. @RefTeX{} has
817 three different modes to create this mark.
821 @vindex reftex-translate-to-ascii-function
822 @vindex reftex-derive-label-parameters
823 @vindex reftex-label-illegal-re
824 @vindex reftex-abbrev-parameters
825 A label can be derived from context. This means, @RefTeX{} takes
826 the context of the label definition and constructs a label from
827 that@footnote{Note that the context may contain constructs which are
828 invalid in labels. @RefTeX{} will therefore strip the accent from
829 accented Latin-1 characters and remove everything else which is not
830 valid in labels. This mechanism is safe, but may not be satisfactory
831 for non-western languages. Check the following variables if you need to
832 change things: @code{reftex-translate-to-ascii-function},
833 @code{reftex-derive-label-parameters}, @code{reftex-label-illegal-re},
834 @code{reftex-abbrev-parameters}.}. This works best for section labels,
835 where the section heading is used to construct a label. In fact,
836 @RefTeX{}'s default settings use this method only for section
837 labels. You will be asked to confirm the derived label, or edit
841 We may also use a simple unique number to identify a label. This is
842 mostly useful for labels where it is difficult to come up with a very
843 good descriptive name. @RefTeX{}'s default settings use this method
844 for equations, enumerate items and footnotes. The author of @RefTeX{}
845 tends to write documents with many equations and finds it impossible
846 to come up with good names for each of them. These simple labels are
847 inserted without query, and are therefore very fast. Good descriptive
848 names are not really necessary as @RefTeX{} will provide context to
849 reference a label (@pxref{Referencing Labels}).
852 The third method is to ask the user for a label. This is most
853 useful for things which are easy to describe briefly and do not turn up
854 too frequently in a document. @RefTeX{} uses this for figures and
855 tables. Of course, one can enter the label directly by typing the full
856 @samp{\label@{mark@}}. The advantage of using @code{reftex-label}
857 anyway is that @RefTeX{} will know that a new label has been defined.
858 It will then not be necessary to rescan the document in order to access
862 @vindex reftex-insert-label-flags
863 If you want to change the way certain labels are created, check out the
864 variable @code{reftex-insert-label-flags} (@pxref{Options (Creating
867 If you are using @AUCTeX{} to write your @LaTeX{} documents, you can
868 set it up to delegate the creation of labels to
869 @RefTeX{}. @xref{AUCTeX}, for more information.
871 @node Referencing Labels, Builtin Label Environments, Creating Labels, Labels and References
872 @section Referencing Labels
873 @cindex Referencing labels
874 @cindex Labels, referencing
875 @cindex Selection buffer, labels
876 @cindex Selection process
879 @findex reftex-reference
881 @vindex reftex-trust-label-prefix
882 @RefTeX{} scans the document in order to find all labels. To make
883 referencing labels easier, it assigns to each label a category, the
884 @emph{label type} (for example section, table, figure, equation, etc.).
885 In order to determine the label type, @RefTeX{} parses around each label
886 to see in what kind of environments it is located. You can speed up
887 the parsing by using type-specific prefixes for labels and configuring
888 the variable @code{reftex-trust-label-prefix}.
890 Referencing Labels is really at the heart of @RefTeX{}. Press @kbd{C-c
891 )} in order to reference a label (@code{reftex-reference}). This will
892 start a selection process and finally insert the complete
893 @samp{\ref@{label@}} into the buffer.
895 @vindex reftex-ref-macro-prompt
896 First, you can select which reference macro you want to use,
897 e.g. @samp{\ref} or @samp{\pageref}. Later in the process you have
898 another chance to make this selection and you can therefore disable this
899 step by customizing @code{reftex-ref-macro-prompt} if you find it too
900 intrusive. @xref{Reference Styles}.
902 Then, @RefTeX{} will determine the label category which is required.
903 Often that can be figured out from context. For example, if you write
904 @samp{As shown in eq.} and then press @kbd{C-c )}, @RefTeX{} knows that
905 an equation label is going to be referenced. If it cannot figure out
906 what label category is needed, it will query for one.
908 You will then be presented with a label selection menu. This is a
909 special buffer which contains an outline of the document along with all
910 labels of the given label category. In addition, next to the label
911 there will be one line of context of the label definition, which is some
912 text in the buffer near the label definition. Usually this is
913 sufficient to identify the label. If you are unsure about a certain
914 label, pressing @key{SPC} will show the label definition point in
917 In order to reference a label, move the cursor to the correct label and
918 press @key{RET}. You can also reference several labels with a single
919 call to @code{reftex-reference} by marking entries with the @kbd{m}
923 Here is a list of special commands in the selection buffer. A summary
924 of this information is always available from the selection process by
930 @tablesubheading{General}
932 Show a summary of available commands.
937 @tablesubheading{Moving around}
942 Go to previous label.
945 Jump back to the position where you last left the selection buffer.
946 Normally this should get you back to the last referenced label.
949 Goto next section heading.
952 Goto previous section heading.
955 Jump to section N, using the prefix arg. For example @kbd{3 z} jumps to
958 @tablesubheading{Displaying Context}
960 Show the surroundings of the definition of the current label in another
961 window. See also the @kbd{f} key.
964 @vindex reftex-revisit-to-follow
965 Toggle follow mode. When follow mode is active, the other window will
966 always display the full context of the current label. This is similar
967 to pressing @key{SPC} after each cursor motion. Note that only context
968 in files already visited is shown. @RefTeX{} will not visit a file
969 just for follow mode. See, however, the variable
970 @code{reftex-revisit-to-follow}.
973 Show insertion point in another window. This is the point from where you
974 called @code{reftex-reference}.
976 @tablesubheading{Selecting a label and creating the reference}
978 Insert a reference to the label at point into the buffer from which the
979 selection process was started. When entries have been marked, @key{RET}
980 references all marked labels.
983 @vindex reftex-highlight-selection
984 Clicking with mouse button 2 on a label will accept it like @key{RET}
985 would. See also variable @code{reftex-highlight-selection},
986 @ref{Options (Misc)}.
988 @vindex reftex-multiref-punctuation
990 Mark the current entry. When several entries have been marked, pressing
991 @kbd{RET} will accept all of them and place them into several
992 @code{\ref} macros. The special markers @samp{,-+} also store a
993 separator to be inserted before the corresponding reference. So marking
994 six entries with the keys @samp{m , , - , +} will give a reference list
995 like this (see the variable @code{reftex-multiref-punctuation})
997 In eqs. (1), (2), (3)--(4), (5) and (6)
1001 Unmark a marked entry.
1003 @c FIXME: Do we need `A' as well for consistency?
1004 @cindex LaTeX packages, @code{saferef}
1005 @cindex @code{saferef}, LaTeX package
1007 Accept the marked entries and put all labels as a comma-separated list
1008 into one @emph{single} @code{\ref} macro. Some packages like
1009 @file{saferef.sty} support multiple references in this way.
1012 Use the last referenced label(s) again. This is equivalent to moving to
1013 that label and pressing @key{RET}.
1016 Enter a label with completion. This may also be a label which does not
1017 yet exist in the document.
1020 Cycle forward through active reference macros. The selected macro is
1021 displayed by the @samp{S<...>} indicator in the mode line of the
1022 selection buffer. This mechanism comes in handy if you are using
1023 @LaTeX{} packages like @code{varioref} or @code{fancyref} and want to
1024 use the special referencing macros they provide (e.g. @code{\vref} or
1025 @code{\fref}) instead of @code{\ref}.
1028 Cycle backward through active reference macros.
1030 @tablesubheading{Exiting}
1033 Exit the selection process without inserting any reference into the
1036 @tablesubheading{Controlling what gets displayed}
1037 @vindex reftex-label-menu-flags
1038 The defaults for the following flags can be configured with the variable
1039 @code{reftex-label-menu-flags} (@pxref{Options (Referencing Labels)}).
1042 Toggle the display of the one-line label definition context in the
1046 Toggle the display of the file borders of a multifile document in the
1050 Toggle the display of the table of contents in the selection buffer.
1051 With prefix @var{arg}, change the maximum level of toc entries displayed
1052 to @var{arg}. Chapters are level 1, sections are level 2.
1055 Toggle the display of a label counter in the selection buffer.
1058 Toggle the display of labels hidden in comments in the selection
1059 buffers. Sometimes, you may have commented out parts of your document.
1060 If these parts contain label definitions, @RefTeX{} can still display
1061 and reference these labels.
1063 @tablesubheading{Updating the buffer}
1065 Update the menu. This will rebuilt the menu from the internal label
1066 list, but not reparse the document (see @kbd{r}).
1069 @vindex reftex-enable-partial-scans
1070 Reparse the document to update the information on all labels and rebuild
1071 the menu. If the variable @code{reftex-enable-partial-scans} is
1072 non-@code{nil} and your document is a multifile document, this will
1073 reparse only a part of the document (the file in which the label at
1077 Reparse the @emph{entire} document.
1080 Switch the label category. After prompting for another label category,
1081 a menu for that category will be shown.
1084 Reference a label from an external document. With the @LaTeX{} package
1085 @code{xr} it is possible to reference labels defined in another
1086 document. This key will switch to the label menu of an external
1087 document and let you select a label from there (@pxref{xr (LaTeX
1092 @vindex reftex-select-label-map
1093 In order to define additional commands for the selection process, the
1094 keymap @code{reftex-select-label-map} may be used.
1096 @node Builtin Label Environments, Defining Label Environments, Referencing Labels, Labels and References
1097 @section Builtin Label Environments
1098 @cindex Builtin label environments
1099 @cindex Label environments, builtin
1100 @cindex Environments, builtin
1101 @vindex reftex-label-alist
1102 @vindex reftex-label-alist-builtin
1104 @RefTeX{} needs to be aware of the environments which can be referenced
1105 with a label (i.e. which carry their own counters). By default, @RefTeX{}
1106 recognizes all labeled environments and macros discussed in @cite{The
1107 @LaTeX{} Companion by Goossens, Mittelbach & Samarin, Addison-Wesley
1112 @cindex @code{figure}, LaTeX environment
1113 @cindex @code{figure*}, LaTeX environment
1114 @cindex @code{table}, LaTeX environment
1115 @cindex @code{table*}, LaTeX environment
1116 @cindex @code{equation}, LaTeX environment
1117 @cindex @code{eqnarray}, LaTeX environment
1118 @cindex @code{enumerate}, LaTeX environment
1119 @cindex @code{\footnote}, LaTeX macro
1120 @cindex LaTeX macro @code{footnote}
1122 @code{figure}, @code{figure*}, @code{table}, @code{table*}, @code{equation},
1123 @code{eqnarray}, @code{enumerate}, the @code{\footnote} macro (this is
1124 the @LaTeX{} core stuff)
1127 @cindex @code{amsmath}, LaTeX package
1128 @cindex LaTeX packages, @code{amsmath}
1129 @cindex @code{align}, AMS-LaTeX environment
1130 @cindex @code{gather}, AMS-LaTeX environment
1131 @cindex @code{multline}, AMS-LaTeX environment
1132 @cindex @code{flalign}, AMS-LaTeX environment
1133 @cindex @code{alignat}, AMS-LaTeX environment
1134 @cindex @code{xalignat}, AMS-LaTeX environment
1135 @cindex @code{xxalignat}, AMS-LaTeX environment
1136 @cindex @code{subequations}, AMS-LaTeX environment
1137 @code{align}, @code{gather}, @code{multline}, @code{flalign},
1138 @code{alignat}, @code{xalignat}, @code{xxalignat}, @code{subequations}
1139 (from AMS-@LaTeX{}'s @file{amsmath.sty} package)
1141 @cindex @code{endnote}, LaTeX package
1142 @cindex LaTeX packages, @code{endnote}
1143 @cindex @code{\endnote}, LaTeX macro
1144 the @code{\endnote} macro (from @file{endnotes.sty})
1146 @cindex @code{fancybox}, LaTeX package
1147 @cindex LaTeX packages, @code{fancybox}
1148 @cindex @code{Beqnarray}, LaTeX environment
1149 @code{Beqnarray} (@file{fancybox.sty})
1151 @cindex @code{floatfig}, LaTeX package
1152 @cindex LaTeX packages, @code{floatfig}
1153 @cindex @code{floatingfig}, LaTeX environment
1154 @code{floatingfig} (@file{floatfig.sty})
1156 @cindex @code{longtable}, LaTeX package
1157 @cindex LaTeX packages, @code{longtable}
1158 @cindex @code{longtable}, LaTeX environment
1159 @code{longtable} (@file{longtable.sty})
1161 @cindex @code{picinpar}, LaTeX package
1162 @cindex LaTeX packages, @code{picinpar}
1163 @cindex @code{figwindow}, LaTeX environment
1164 @cindex @code{tabwindow}, LaTeX environment
1165 @code{figwindow}, @code{tabwindow} (@file{picinpar.sty})
1167 @cindex @code{sidecap}, LaTeX package
1168 @cindex LaTeX packages, @code{sidecap}
1169 @cindex @code{SCfigure}, LaTeX environment
1170 @cindex @code{SCtable}, LaTeX environment
1171 @code{SCfigure}, @code{SCtable} (@file{sidecap.sty})
1173 @cindex @code{rotating}, LaTeX package
1174 @cindex LaTeX packages, @code{rotating}
1175 @cindex @code{sidewaysfigure}, LaTeX environment
1176 @cindex @code{sidewaystable}, LaTeX environment
1177 @code{sidewaysfigure}, @code{sidewaystable} (@file{rotating.sty})
1179 @cindex @code{subfig}, LaTeX package
1180 @cindex LaTeX packages, @code{subfigure}
1181 @cindex @code{subfigure}, LaTeX environment
1182 @cindex @code{subfigure*}, LaTeX environment
1183 @code{subfigure}, @code{subfigure*}, the @code{\subfigure} macro
1184 (@file{subfigure.sty})
1186 @cindex @code{supertab}, LaTeX package
1187 @cindex LaTeX packages, @code{supertab}
1188 @cindex @code{supertabular}, LaTeX environment
1189 @code{supertabular} (@file{supertab.sty})
1191 @cindex @code{wrapfig}, LaTeX package
1192 @cindex LaTeX packages, @code{wrapfig}
1193 @cindex @code{wrapfigure}, LaTeX environment
1194 @code{wrapfigure} (@file{wrapfig.sty})
1197 If you want to use other labeled environments, defined with
1198 @code{\newtheorem}, @RefTeX{} needs to be configured to recognize
1199 them (@pxref{Defining Label Environments}).
1201 @node Defining Label Environments, Reference Info, Builtin Label Environments, Labels and References
1202 @section Defining Label Environments
1203 @cindex Label environments, defining
1205 @vindex reftex-label-alist
1206 @RefTeX{} can be configured to recognize additional labeled
1207 environments and macros. This is done with the variable
1208 @code{reftex-label-alist} (@pxref{Options (Defining Label
1209 Environments)}). If you are not familiar with Lisp, you can use the
1210 @code{custom} library to configure this rather complex variable. To do
1214 @kbd{M-x customize-variable @key{RET} reftex-label-alist @key{RET}}
1217 @vindex reftex-label-alist-builtin
1218 Here we will discuss a few examples, in order to make things clearer.
1219 It can also be instructive to look at the constant
1220 @code{reftex-label-alist-builtin} which contains the entries for
1221 all the builtin environments and macros (@pxref{Builtin Label
1225 * Theorem and Axiom:: Defined with @code{\newenvironment}.
1226 * Quick Equation:: When a macro sets the label type.
1227 * Figure Wrapper:: When a macro argument is a label.
1228 * Adding Magic Words:: Other words for other languages.
1229 * Using \eqref:: How to switch to this AMS-@LaTeX{} macro.
1230 * Non-Standard Environments:: Environments without \begin and \end
1231 * Putting it Together:: How to combine many entries.
1234 @node Theorem and Axiom, Quick Equation, , Defining Label Environments
1235 @subsection Theorem and Axiom Environments
1236 @cindex @code{theorem}, newtheorem
1237 @cindex @code{axiom}, newtheorem
1238 @cindex @code{\newtheorem}
1240 Suppose you are using @code{\newtheorem} in @LaTeX{} in order to define two
1241 new environments, @code{theorem} and @code{axiom}
1244 \newtheorem@{axiom@}@{Axiom@}
1245 \newtheorem@{theorem@}@{Theorem@}
1249 to be used like this:
1258 So we need to tell @RefTeX{} that @code{theorem} and @code{axiom} are new
1259 labeled environments which define their own label categories. We can
1260 either use Lisp to do this (e.g. in @file{.emacs}) or use the custom
1261 library. With Lisp it would look like this
1264 (setq reftex-label-alist
1265 '(("axiom" ?a "ax:" "~\\ref@{%s@}" nil ("axiom" "ax.") -2)
1266 ("theorem" ?h "thr:" "~\\ref@{%s@}" t ("theorem" "th.") -3)))
1269 The type indicator characters @code{?a} and @code{?h} are used for
1270 prompts when @RefTeX{} queries for a label type. @code{?h}
1271 was chosen for @code{theorem} since @code{?t} is already taken by
1272 @code{table}. Note that also @code{?s}, @code{?f}, @code{?e},
1273 @code{?i}, @code{?n} are already used for standard environments.
1276 The labels for Axioms and Theorems will have the prefixes @samp{ax:} and
1277 @samp{thr:}, respectively. @xref{AUCTeX}, for information on how
1278 @AUCTeX{} can use @RefTeX{} to automatically create labels when a new
1279 environment is inserted into a buffer. Additionally, the following
1280 needs to be added to one's .emacs file before @AUCTeX{} will
1281 automatically create labels for the new environments.
1284 (add-hook 'LaTeX-mode-hook
1286 (LaTeX-add-environments
1287 '("axiom" LaTeX-env-label)
1288 '("theorem" LaTeX-env-label))))
1293 The @samp{~\ref@{%s@}} is a format string indicating how to insert
1294 references to these labels.
1297 The next item indicates how to grab context of the label definition.
1300 @code{t} means to get it from a default location (from the beginning of
1301 a @code{\macro} or after the @code{\begin} statement). @code{t} is
1302 @emph{not} a good choice for eqnarray and similar environments.
1304 @code{nil} means to use the text right after the label definition.
1306 For more complex ways of getting context, see the variable
1307 @code{reftex-label-alist} (@ref{Options (Defining Label
1311 The following list of strings is used to guess the correct label type
1312 from the word before point when creating a reference. For example if you
1313 write: @samp{As we have shown in Theorem} and then press @kbd{C-c )},
1314 @RefTeX{} will know that you are looking for a theorem label and
1315 restrict the menu to only these labels without even asking.
1317 The final item in each entry is the level at which the environment
1318 should produce entries in the table of context buffer. If the number is
1319 positive, the environment will produce numbered entries (like
1320 @code{\section}), if it is negative the entries will be unnumbered (like
1321 @code{\section*}). Use this only for environments which structure the
1322 document similar to sectioning commands. For everything else, omit the
1325 To do the same configuration with @code{customize}, you need to click on
1326 the @code{[INS]} button twice to create two templates and fill them in
1330 Reftex Label Alist: [Hide]
1331 [INS] [DEL] Package or Detailed : [Value Menu] Detailed:
1332 Environment or \macro : [Value Menu] String: axiom
1333 Type specification : [Value Menu] Char : a
1334 Label prefix string : [Value Menu] String: ax:
1335 Label reference format: [Value Menu] String: ~\ref@{%s@}
1336 Context method : [Value Menu] After label
1338 [INS] [DEL] String: axiom
1339 [INS] [DEL] String: ax.
1341 [X] Make TOC entry : [Value Menu] Level: -2
1342 [INS] [DEL] Package or Detailed : [Value Menu] Detailed:
1343 Environment or \macro : [Value Menu] String: theorem
1344 Type specification : [Value Menu] Char : h
1345 Label prefix string : [Value Menu] String: thr:
1346 Label reference format: [Value Menu] String: ~\ref@{%s@}
1347 Context method : [Value Menu] Default position
1349 [INS] [DEL] String: theorem
1350 [INS] [DEL] String: theor.
1351 [INS] [DEL] String: th.
1353 [X] Make TOC entry : [Value Menu] Level: -3
1356 @vindex reftex-insert-label-flags
1357 @vindex reftex-label-menu-flags
1358 Depending on how you would like the label insertion and selection for
1359 the new environments to work, you might want to add the letters @samp{a}
1360 and @samp{h} to some of the flags in the variables
1361 @code{reftex-insert-label-flags} (@pxref{Options (Creating Labels)})
1362 and @code{reftex-label-menu-flags} (@pxref{Options (Referencing
1366 @node Quick Equation, Figure Wrapper, Theorem and Axiom , Defining Label Environments
1367 @subsection Quick Equation Macro
1368 @cindex Quick equation macro
1369 @cindex Macros as environment wrappers
1371 Suppose you would like to have a macro for quick equations. It
1372 could be defined like this:
1375 \newcommand@{\quickeq@}[1]@{\begin@{equation@} #1 \end@{equation@}@}
1382 Einstein's equation is \quickeq@{E=mc^2 \label@{eq:einstein@}@}.
1385 We need to tell @RefTeX{} that any label defined in the argument of the
1386 @code{\quickeq} is an equation label. Here is how to do this with lisp:
1389 (setq reftex-label-alist '(("\\quickeq@{@}" ?e nil nil 1 nil)))
1392 The first element in this list is now the macro with empty braces as an
1393 @emph{image} of the macro arguments. @code{?e} indicates that this is
1394 an equation label, the different @code{nil} elements indicate to use the
1395 default values for equations. The @samp{1} as the fifth element
1396 indicates that the context of the label definition should be the first
1397 argument of the macro.
1399 Here is again how this would look in the customization buffer:
1402 Reftex Label Alist: [Hide]
1403 [INS] [DEL] Package or Detailed : [Value Menu] Detailed:
1404 Environment or \macro : [Value Menu] String: \quickeq@{@}
1405 Type specification : [Value Menu] Char : e
1406 Label prefix string : [Value Menu] Default
1407 Label reference format: [Value Menu] Default
1408 Context method : [Value Menu] Macro arg nr: 1
1411 [ ] Make TOC entry : [Value Menu] No entry
1414 @node Figure Wrapper, Adding Magic Words, Quick Equation, Defining Label Environments
1415 @subsection Figure Wrapping Macro
1416 @cindex Macros as environment wrappers
1417 @cindex Figure wrapping macro
1419 Suppose you want to make figures not directly with the figure
1420 environment, but with a macro like
1423 \newcommand@{\myfig@}[5][tbp]@{%
1424 \begin@{figure@}[#1]
1432 which would be called like
1435 \myfig[htp]@{filename@}@{caption text@}@{label@}@{1@}
1438 Now we need to tell @RefTeX{} that the fourth argument of the
1439 @code{\myfig} macro @emph{is itself} a figure label, and where to find
1443 (setq reftex-label-alist
1444 '(("\\myfig[]@{@}@{@}@{*@}@{@}" ?f nil nil 3)))
1447 The empty pairs of brackets indicate the different arguments of the
1448 @code{\myfig} macro. The @samp{*} marks the label argument. @code{?f}
1449 indicates that this is a figure label which will be listed together with
1450 labels from normal figure environments. The @code{nil} entries for
1451 prefix and reference format mean to use the defaults for figure labels.
1452 The @samp{3} for the context method means to grab the third macro argument
1455 As a side effect of this configuration, @code{reftex-label} will now
1456 insert the required naked label (without the @code{\label} macro) when
1457 point is directly after the opening parenthesis of a @code{\myfig} macro
1460 Again, here the configuration in the customization buffer:
1463 [INS] [DEL] Package or Detailed : [Value Menu] Detailed:
1464 Environment or \macro : [Value Menu] String: \myfig[]@{@}@{@}@{*@}@{@}
1465 Type specification : [Value Menu] Char : f
1466 Label prefix string : [Value Menu] Default
1467 Label reference format: [Value Menu] Default
1468 Context method : [Value Menu] Macro arg nr: 3
1471 [ ] Make TOC entry : [Value Menu] No entry
1474 @node Adding Magic Words, Using \eqref, Figure Wrapper, Defining Label Environments
1475 @subsection Adding Magic Words
1477 @cindex German magic words
1478 @cindex Label category
1480 Sometimes you don't want to define a new label environment or macro, but
1481 just change the information associated with a label category. Maybe you
1482 want to add some magic words, for another language. Changing only the
1483 information associated with a label category is done by giving
1484 @code{nil} for the environment name and then specify the items you want
1485 to define. Here is an example which adds German magic words to all
1486 predefined label categories.
1489 (setq reftex-label-alist
1490 '((nil ?s nil nil nil ("Kapitel" "Kap." "Abschnitt" "Teil"))
1491 (nil ?e nil nil nil ("Gleichung" "Gl."))
1492 (nil ?t nil nil nil ("Tabelle"))
1493 (nil ?f nil nil nil ("Figur" "Abbildung" "Abb."))
1494 (nil ?n nil nil nil ("Anmerkung" "Anm."))
1495 (nil ?i nil nil nil ("Punkt"))))
1498 @node Using \eqref, Non-Standard Environments, Adding Magic Words, Defining Label Environments
1499 @subsection Using @code{\eqref}
1500 @cindex @code{\eqref}, AMS-LaTeX macro
1502 @cindex Label category
1504 Another case where one only wants to change the information associated
1505 with the label category is to change the macro which is used for
1506 referencing the label. When working with the AMS-@LaTeX{}, you might
1507 prefer @code{\eqref} for doing equation references. Here is how to
1511 (setq reftex-label-alist '((nil ?e nil "~\\eqref@{%s@}" nil nil)))
1514 @RefTeX{} has also a predefined symbol for this special purpose. The
1515 following is equivalent to the line above.
1518 (setq reftex-label-alist '(AMSTeX))
1521 Note that this is automatically done by the @file{amsmath.el} style file
1522 of @AUCTeX{} (@pxref{Style Files}) -- so if you use @AUCTeX{},
1523 this configuration will not be necessary.
1525 @node Non-Standard Environments, Putting it Together, Using \eqref, Defining Label Environments
1526 @subsection Non-standard Environments
1527 @cindex Non-standard environments
1528 @cindex Environments without @code{\begin}
1529 @cindex Special parser functions
1530 @cindex Parser functions, for special environments
1532 Some @LaTeX{} packages define environment-like structures without using the
1533 standard @samp{\begin..\end} structure. @RefTeX{} cannot parse
1534 these directly, but you can write your own special-purpose parser and
1535 use it instead of the name of an environment in an entry for
1536 @code{reftex-label-alist}. The function should check if point is
1537 currently in the special environment it was written to detect. If so,
1538 it must return a buffer position indicating the start of this
1539 environment. The return value must be @code{nil} on failure to detect
1540 the environment. The function is called with one argument @var{bound}.
1541 If non-@code{nil}, @var{bound} is a boundary for backwards searches
1542 which should be observed. We will discuss two examples.
1544 @cindex LaTeX commands, abbreviated
1546 Some people define abbreviations for
1547 environments, like @code{\be} for @code{\begin@{equation@}}, and
1548 @code{\ee} for @code{\end@{equation@}}. The parser function would have
1549 to search backward for these macros. When the first match is
1550 @code{\ee}, point is not in this environment. When the first match is
1551 @code{\be}, point is in this environment and the function must return
1552 the beginning of the match. To avoid scanning too far, we can also look
1553 for empty lines which cannot occur inside an equation environment.
1557 ;; Setup entry in reftex-label-alist, using all defaults for equations
1558 (setq reftex-label-alist '((detect-be-ee ?e nil nil nil nil)))
1560 (defun detect-be-ee (bound)
1561 ;; Search backward for the macros or an empty line
1562 (if (re-search-backward
1563 "\\(^[ \t]*\n\\|\\\\ee\\>\\)\\|\\(\\\\be\\>\\)" bound t)
1564 (if (match-beginning 2)
1565 (match-beginning 2) ; Return start of environment
1566 nil) ; Return nil because env is closed
1567 nil)) ; Return nil for not found
1570 @cindex @code{linguex}, LaTeX package
1571 @cindex LaTeX packages, @code{linguex}
1572 A more complex example is the @file{linguex.sty} package which defines
1573 list macros @samp{\ex.}, @samp{\a.}, @samp{\b.} etc. for lists which are
1574 terminated by @samp{\z.} or by an empty line.
1577 \ex. \label@{ex:12@} Some text in an exotic language ...
1578 \a. \label@{ex:13@} more stuff
1579 \b. \label@{ex:14@} still more stuff
1580 \a. List on a deeper level
1582 \b. and the third one
1584 \b. Third item on this level.
1586 ... text after the empty line terminating all lists
1589 The difficulty is that the @samp{\a.} lists can nest and that an empty
1590 line terminates all list levels in one go. So we have to count nesting
1591 levels between @samp{\a.} and @samp{\z.}. Here is the implementation
1595 (setq reftex-label-alist
1596 '((detect-linguex ?x "ex:" "~\\ref@{%s@}" nil ("Example" "Ex."))))
1598 (defun detect-linguex (bound)
1602 ;; Search backward for all possible delimiters
1604 (concat "\\(^[ \t]*\n\\)\\|\\(\\\\z\\.\\)\\|"
1605 "\\(\\ex[ig]?\\.\\)\\|\\(\\\\a\\.\\)")
1607 ;; Check which delimiter was matched.
1609 ((match-beginning 1)
1610 ;; empty line terminates all - return nil
1612 ((match-beginning 2)
1613 ;; \z. terminates one list level - decrease nesting count
1615 ((match-beginning 3)
1616 ;; \ex. : return match unless there was a \z. on this level
1617 (throw 'exit (if (>= cnt 0) (match-beginning 3) nil)))
1618 ((match-beginning 4)
1619 ;; \a. : return match when on level 0, otherwise
1620 ;; increment nesting count
1622 (throw 'exit (match-beginning 4))
1626 @node Putting it Together, , Non-Standard Environments, Defining Label Environments
1627 @subsection Putting it all together
1629 When you have to put several entries into @code{reftex-label-alist}, just
1630 put them after each other in a list, or create that many templates in
1631 the customization buffer. Here is a lisp example which uses several of
1632 the entries described above:
1635 (setq reftex-label-alist
1636 '(("axiom" ?a "ax:" "~\\ref@{%s@}" nil ("axiom" "ax.") -2)
1637 ("theorem" ?h "thr:" "~\\ref@{%s@}" t ("theorem" "theor." "th.") -3)
1638 ("\\quickeq@{@}" ?e nil nil 1 nil)
1640 ("\\myfig[]@{@}@{@}@{*@}@{@}" ?f nil nil 3)
1641 (detect-linguex ?x "ex:" "~\\ref@{%s@}" nil ("Example" "Ex."))))
1644 @node Reference Info, Reference Styles, Defining Label Environments, Labels and References
1645 @section Reference Info
1646 @findex reftex-view-crossref
1647 @findex reftex-mouse-view-crossref
1648 @cindex Cross-references, displaying
1649 @cindex Reference info
1650 @cindex Displaying cross-references
1651 @cindex Viewing cross-references
1655 When point is idle for more than @code{reftex-idle-time} seconds on the
1656 argument of a @code{\ref} macro, the echo area will display some
1657 information about the label referenced there. Note that the information
1658 is only displayed if the echo area is not occupied by a different
1661 @RefTeX{} can also display the label definition corresponding to a
1662 @code{\ref} macro, or all reference locations corresponding to a
1663 @code{\label} macro. @xref{Viewing Cross-References}, for more
1666 @node Reference Styles, xr (LaTeX package), Reference Info, Labels and References
1667 @section Reference Styles
1669 In case you defined your own macros for referencing or you are using
1670 @LaTeX{} packages providing specialized macros to be used instead of
1671 @code{\ref}, @RefTeX{} provides ways to select and insert them in a
1674 @RefTeX{} comes equipped with a set of so-called reference styles where
1675 each relates to one or more reference macros. The standard macros
1676 @samp{\ref} and @samp{\pageref} or provided by the ``Default'' style.
1677 The ``Varioref'' style offers macros for the @samp{varioref} @LaTeX{}
1678 package (@samp{\vref}, @samp{\Vref}, @samp{\Ref}, @samp{\vpageref}),
1679 ``Fancyref'' for the @samp{fancyref} package (@samp{\fref},
1680 @samp{\Fref}) and ``Hyperref'' for the @samp{hyperref} package
1681 (@samp{\autoref}, @samp{\autopageref}).
1683 @vindex reftex-ref-style-default-list
1684 A style can be toggled by selecting the respective entry in the
1685 @samp{Reference Style} menu. Changes made through the menu will only
1686 last for the Emacs session. In order to configure a preference
1687 permanently, the variable @code{reftex-ref-style-default-list} should be
1688 customized. This variable specifies the list of styles to be activated.
1689 It can also be set as a file variable if the preference should be set
1690 for a specific file.
1692 @vindex reftex-ref-style-alist
1693 In case the built-in styles do not suffice, you can add additional
1694 macros and styles to the variable @code{reftex-ref-style-alist}. Those
1695 do not necessarily have to be related to a certain @LaTeX{} package but
1696 can follow an arbitrary grouping rule. For example you could define a
1697 style called ``Personal'' for your personal referencing macros. (When
1698 changing the variable you should be aware that other Emacs packages,
1699 like @AUCTeX{}, might rely on the entries from the default value to be
1702 Once a style is active the macros it relates to are available for
1703 selection when you are about to insert a reference. In general this
1704 process involves three steps: the selection of a reference macro, a
1705 label type and a label. Reference macros can be chosen in the first and
1708 @vindex reftex-ref-macro-prompt
1709 In the first step you will be presented with a list of macros from which
1710 you can select one by typing a single key. If you dislike having an
1711 extra step for reference macro selection, you can disable it by
1712 customizing @code{reftex-ref-macro-prompt} and relying only on the
1713 selection facilities provided in the last step.
1715 In the last step, i.e. the label selection, two key bindings are
1716 provided to set the reference macro. Type @key{v} in order to cycle
1717 forward through the list of available macros or @key{V} to cycle
1718 backward. The mode line of the selection buffer shows the macro
1721 In case you are not satisfied with the order of macros when cycling
1722 through them you should adapt the order of entries in the variable
1723 @code{reftex-ref-style-alist} to fit your liking.
1725 For each entry in @code{reftex-ref-style-alist} a function with the name
1726 @code{reftex-<package>-<macro>} (e.g. @code{reftex-varioref-vref}) will
1727 be created automatically by @RefTeX{}. These functions can be used
1728 instead of @kbd{C-c )} and provide an alternative way of having your
1729 favorite referencing macro preselected and if cycling through the macros
1730 seems inconvenient to you.@footnote{You could e.g. bind
1731 @code{reftex-varioref-vref} to @kbd{C-c v} and
1732 @code{reftex-fancyref-fref} to @kbd{C-c f}.}
1734 @cindex @code{varioref}, LaTeX package
1735 @cindex LaTeX packages, @code{varioref}
1736 @cindex @code{fancyref}, LaTeX package
1737 @cindex LaTeX packages, @code{fancyref}
1738 @vindex reftex-vref-is-default (deprecated)
1739 @vindex reftex-fref-is-default (deprecated)
1740 In former versions of @RefTeX{} only support for @code{varioref} and
1741 @code{fancyref} was included. @code{varioref} is a @LaTeX{} package to
1742 create cross-references with page information. @code{fancyref} is a
1743 package where a macro call like @code{\fref@{@var{fig:map-of-germany}@}}
1744 creates not only the number of the referenced counter but also the
1745 complete text around it, like @samp{Figure 3 on the preceding page}. In
1746 order to make it work you need to use label prefixes like @samp{fig:}
1747 consistently -- something @RefTeX{} does automatically. For each of
1748 these packages a variable could be configured to make its macros to take
1749 precedence over @code{\ref}. Those were @code{reftex-vref-is-default}
1750 and @code{reftex-fref-is-default} respectively. While still working,
1751 these variables are deprecated now. Instead of setting them, the
1752 variable @code{reftex-ref-style-default-list} should be adapted now.
1754 @node xr (LaTeX package), , Reference Styles, Labels and References
1755 @section @code{xr}: Cross-Document References
1756 @cindex @code{xr}, LaTeX package
1757 @cindex LaTeX packages, @code{xr}
1758 @cindex @code{\externaldocument}
1759 @cindex External documents
1760 @cindex References to external documents
1761 @cindex Cross-document references
1763 The @LaTeX{} package @code{xr} makes it possible to create references to
1764 labels defined in external documents. The preamble of a document using
1765 @code{xr} will contain something like this:
1769 \externaldocument[V1-]@{volume1@}
1770 \externaldocument[V3-]@{volume3@}
1774 and we can make references to any labels defined in these
1775 external documents by using the prefixes @samp{V1-} and @samp{V3-},
1778 @RefTeX{} can be used to create such references as well. Start the
1779 referencing process normally, by pressing @kbd{C-c )}. Select a label
1780 type if necessary. When you see the label selection buffer, pressing
1781 @kbd{x} will switch to the label selection buffer of one of the external
1782 documents. You may then select a label as before and @RefTeX{} will
1783 insert it along with the required prefix.
1785 For this kind of inter-document cross-references, saving of parsing
1786 information and the use of multiple selection buffers can mean a large
1787 speed-up (@pxref{Optimizations}).
1789 @node Citations, Index Support, Labels and References, Top
1792 @cindex @code{\cite}
1794 Citations in @LaTeX{} are done with the @code{\cite} macro or variations of
1795 it. The argument of the macro is a citation key which identifies an
1796 article or book in either a @BibTeX{} database file or in an explicit
1797 @code{thebibliography} environment in the document. @RefTeX{}'s
1798 support for citations helps to select the correct key quickly.
1801 * Creating Citations:: How to create them.
1802 * Citation Styles:: Natbib, Harvard, Chicago and Co.
1803 * Citation Info:: View the corresponding database entry.
1804 * Chapterbib and Bibunits:: Multiple bibliographies in a Document.
1805 * Citations Outside LaTeX:: How to make citations in Emails etc.
1806 * BibTeX Database Subsets:: Extract parts of a big database.
1809 @node Creating Citations, Citation Styles, , Citations
1810 @section Creating Citations
1811 @cindex Creating citations
1812 @cindex Citations, creating
1813 @findex reftex-citation
1815 @cindex Selection buffer, citations
1816 @cindex Selection process
1818 In order to create a citation, press @kbd{C-c [}. @RefTeX{} then
1819 prompts for a regular expression which will be used to search through
1820 the database and present the list of matches to choose from in a
1821 selection process similar to that for selecting labels
1822 (@pxref{Referencing Labels}).
1824 The regular expression uses an extended syntax: @samp{&&} defines a
1825 logic @code{and} for regular expressions. For example
1826 @samp{Einstein&&Bose} will match all articles which mention
1827 Bose-Einstein condensation, or which are co-authored by Bose and
1828 Einstein. When entering the regular expression, you can complete on
1829 known citation keys. @RefTeX{} also offers a default when prompting for
1830 a regular expression. This default is the word before the cursor or the
1831 word before the current @samp{\cite} command. Sometimes this may be a
1834 @cindex @code{\bibliography}
1835 @cindex @code{thebibliography}, LaTeX environment
1836 @cindex @code{BIBINPUTS}, environment variable
1837 @cindex @code{TEXBIB}, environment variable
1838 @RefTeX{} prefers to use @BibTeX{} database files specified with a
1839 @code{\bibliography} macro to collect its information. Just like
1840 @BibTeX{}, it will search for the specified files in the current directory
1841 and along the path given in the environment variable @code{BIBINPUTS}.
1842 If you do not use @BibTeX{}, but the document contains an explicit
1843 @code{thebibliography} environment, @RefTeX{} will collect its
1844 information from there. Note that in this case the information
1845 presented in the selection buffer will just be a copy of relevant
1846 @code{\bibitem} entries, not the structured listing available with
1847 @BibTeX{} database files.
1850 In the selection buffer, the following keys provide special commands. A
1851 summary of this information is always available from the selection
1852 process by pressing @kbd{?}.
1855 @tablesubheading{General}
1857 Show a summary of available commands.
1862 @tablesubheading{Moving around}
1867 Go to previous article.
1869 @tablesubheading{Access to full database entries}
1871 Show the database entry corresponding to the article at point, in
1872 another window. See also the @kbd{f} key.
1875 Toggle follow mode. When follow mode is active, the other window will
1876 always display the full database entry of the current article. This is
1877 equivalent to pressing @key{SPC} after each cursor motion. With @BibTeX{}
1878 entries, follow mode can be rather slow.
1880 @tablesubheading{Selecting entries and creating the citation}
1882 Insert a citation referencing the article at point into the buffer from
1883 which the selection process was started.
1886 @vindex reftex-highlight-selection
1887 Clicking with mouse button 2 on a citation will accept it like @key{RET}
1888 would. See also variable @code{reftex-highlight-selection}, @ref{Options
1892 Mark the current entry. When one or several entries are marked,
1893 pressing @kbd{a} or @kbd{A} accepts all marked entries. Also,
1894 @key{RET} behaves like the @kbd{a} key.
1897 Unmark a marked entry.
1900 Accept all (marked) entries in the selection buffer and create a single
1901 @code{\cite} macro referring to them.
1904 Accept all (marked) entries in the selection buffer and create a
1905 separate @code{\cite} macro for each of it.
1908 Create a new @BibTeX{} database file which contains all @i{marked} entries
1909 in the selection buffer. If no entries are marked, all entries are
1913 Create a new @BibTeX{} database file which contains all @i{unmarked}
1914 entries in the selection buffer. If no entries are marked, all entries
1918 Enter a citation key with completion. This may also be a key which does
1922 Show insertion point in another window. This is the point from where you
1923 called @code{reftex-citation}.
1925 @tablesubheading{Exiting}
1927 Exit the selection process without inserting a citation into the
1930 @tablesubheading{Updating the buffer}
1933 Start over with a new regular expression. The full database will be
1934 rescanned with the new expression (see also @kbd{r}).
1936 @c FIXME: Should we use something else here? r is usually rescan!
1938 Refine the current selection with another regular expression. This will
1939 @emph{not} rescan the entire database, but just the already selected
1944 @vindex reftex-select-bib-map
1945 In order to define additional commands for this selection process, the
1946 keymap @code{reftex-select-bib-map} may be used.
1948 Note that if you do not use Emacs to edit the @BibTeX{} database files,
1949 @RefTeX{} will ask if the related buffers should be updated once it
1950 detects that the files were changed externally. If you do not want to
1951 be bothered by such queries, you can activate Auto Revert mode for these
1952 buffers by adding the following expression to your init file:
1955 (add-hook 'bibtex-mode-hook 'turn-on-auto-revert-mode)
1959 @node Citation Styles, Citation Info, Creating Citations, Citations
1960 @section Citation Styles
1961 @cindex Citation styles
1962 @cindex Citation styles, @code{natbib}
1963 @cindex Citation styles, @code{harvard}
1964 @cindex Citation styles, @code{chicago}
1965 @cindex Citation styles, @code{jurabib}
1966 @cindex Citation styles, @ConTeXt{}
1967 @cindex @code{natbib}, citation style
1968 @cindex @code{harvard}, citation style
1969 @cindex @code{chicago}, citation style
1970 @cindex @code{jurabib}, citation style
1971 @cindex @ConTeXt{}, citation style
1973 @vindex reftex-cite-format
1974 The standard @LaTeX{} macro @code{\cite} works well with numeric or
1975 simple key citations. To deal with the more complex task of author-year
1976 citations as used in many natural sciences, a variety of packages has
1977 been developed which define derived forms of the @code{\cite} macro.
1978 @RefTeX{} can be configured to produce these citation macros as well by
1979 setting the variable @code{reftex-cite-format}. For the most commonly
1980 used @LaTeX{} packages (@code{natbib}, @code{harvard}, @code{chicago},
1981 @code{jurabib}) and for @ConTeXt{} this may be done from the menu, under
1982 @code{Ref->Citation Styles}. Since there are usually several macros to
1983 create the citations, executing @code{reftex-citation} (@kbd{C-c [})
1984 starts by prompting for the correct macro. For the Natbib style, this
1988 SELECT A CITATION FORMAT
1995 [e] \citep[e.g.][]@{%l@}
1996 [s] \citep[see][]@{%l@}
1997 [a] \citeauthor@{%l@}
1998 [A] \citeauthor*@{%l@}
2002 @vindex reftex-cite-prompt-optional-args
2003 If citation formats contain empty pairs of square brackets, @RefTeX{}
2004 will prompt for values of these optional arguments if you call the
2005 @code{reftex-citation} command with a @kbd{C-u} prefix.
2006 Following the most generic of these packages, @code{natbib}, the builtin
2007 citation packages always accept the @kbd{t} key for a @emph{textual}
2008 citation (like: @code{Jones et al. (1997) have shown...}) as well as
2009 the @kbd{p} key for a parenthetical citation (like: @code{As shown
2010 earlier (Jones et al, 1997)}).
2012 To make one of these styles the default, customize the variable
2013 @code{reftex-cite-format} or put into @file{.emacs}:
2016 (setq reftex-cite-format 'natbib)
2019 You can also use @AUCTeX{} style files to automatically set the
2020 citation style based on the @code{usepackage} commands in a given
2021 document. @xref{Style Files}, for information on how to set up the style
2024 @node Citation Info, Chapterbib and Bibunits, Citation Styles, Citations
2025 @section Citation Info
2026 @cindex Displaying citations
2027 @cindex Citations, displaying
2028 @cindex Citation info
2029 @cindex Viewing citations
2032 @findex reftex-view-crossref
2033 @findex reftex-mouse-view-crossref
2035 When point is idle for more than @code{reftex-idle-time} seconds on the
2036 argument of a @code{\cite} macro, the echo area will display some
2037 information about the article cited there. Note that the information is
2038 only displayed if the echo area is not occupied by a different message.
2040 @RefTeX{} can also display the @code{\bibitem} or @BibTeX{} database
2041 entry corresponding to a @code{\cite} macro, or all citation locations
2042 corresponding to a @code{\bibitem} or @BibTeX{} database entry.
2043 @xref{Viewing Cross-References}.
2045 @node Chapterbib and Bibunits, Citations Outside LaTeX, Citation Info, Citations
2046 @section Chapterbib and Bibunits
2047 @cindex @code{chapterbib}, LaTeX package
2048 @cindex @code{bibunits}, LaTeX package
2049 @cindex Bibliographies, multiple
2051 @code{chapterbib} and @code{bibunits} are two @LaTeX{} packages which
2052 produce multiple bibliographies in a document. This is no problem for
2053 @RefTeX{} as long as all bibliographies use the same @BibTeX{} database
2054 files. If they do not, it is best to have each document part in a
2055 separate file (as it is required for @code{chapterbib} anyway). Then
2056 @RefTeX{} will still scan the locally relevant databases correctly. If
2057 you have multiple bibliographies within a @emph{single file}, this may
2058 or may not be the case.
2060 @node Citations Outside LaTeX, BibTeX Database Subsets, Chapterbib and Bibunits, Citations
2061 @section Citations outside @LaTeX{}
2062 @cindex Citations outside LaTeX
2063 @vindex reftex-default-bibliography
2065 The command @code{reftex-citation} can also be executed outside a @LaTeX{}
2066 buffer. This can be useful to reference articles in the mail buffer and
2067 other documents. You should @emph{not} enter @code{reftex-mode} for
2068 this, just execute the command. The list of @BibTeX{} files will in this
2069 case be taken from the variable @code{reftex-default-bibliography}.
2070 Setting the variable @code{reftex-cite-format} to the symbol
2071 @code{locally} does a decent job of putting all relevant information
2072 about a citation directly into the buffer. Here is the lisp code to add
2073 the @kbd{C-c [} binding to the mail buffer. It also provides a local
2074 binding for @code{reftex-cite-format}.
2077 (add-hook 'mail-setup-hook
2078 (lambda () (define-key mail-mode-map "\C-c["
2081 (let ((reftex-cite-format 'locally))
2082 (reftex-citation))))))
2085 @node BibTeX Database Subsets, , Citations Outside LaTeX, Citations
2086 @section Database Subsets
2087 @cindex BibTeX database subsets
2088 @findex reftex-create-bibtex-file
2090 @RefTeX{} offers two ways to create a new @BibTeX{} database file.
2092 The first option produces a file which contains only the entries
2093 actually referenced in the current document. This can be useful if
2094 the database is only meant for a single document and you want to clean
2095 it of old and unused ballast. It can also be useful while writing a
2096 document together with collaborators, in order to avoid sending around
2097 the entire (possibly very large) database. To create the file, use
2098 @kbd{M-x reftex-create-bibtex-file}, also available from the menu
2099 under @code{Ref->Global Actions->Create Bibtex File}. The command will
2100 prompt for a @BibTeX{} file name and write the extracted entries to that
2103 The second option makes use of the selection process started by the
2104 command @kbd{C-c [} (@pxref{Creating Citations}). This command uses a
2105 regular expression to select entries, and lists them in a formatted
2106 selection buffer. After pressing the @kbd{e} key (mnemonics: Export),
2107 the command will prompt for the name of a new @BibTeX{} file and write
2108 the selected entries to that file. You can also first mark some
2109 entries in the selection buffer with the @kbd{m} key and then export
2110 either the @i{marked} entries (with the @kbd{e} key) or the
2111 @i{unmarked} entries (with the @kbd{E} key).
2113 @node Index Support, Viewing Cross-References, Citations, Top
2114 @chapter Index Support
2115 @cindex Index Support
2116 @cindex @code{\index}
2118 @LaTeX{} has builtin support for creating an Index. The @LaTeX{} core
2119 supports two different indices, the standard index and a glossary. With
2120 the help of special @LaTeX{} packages (@file{multind.sty} or
2121 @file{index.sty}), any number of indices can be supported.
2123 Index entries are created with the @code{\index@{@var{entry}@}} macro.
2124 All entries defined in a document are written out to the @file{.aux}
2125 file. A separate tool must be used to convert this information into a
2126 nicely formatted index. Tools used with @LaTeX{} include @code{MakeIndex}
2129 Indexing is a very difficult task. It must follow strict conventions to
2130 make the index consistent and complete. There are basically two
2131 approaches one can follow, and both have their merits.
2135 Part of the indexing should already be done with the markup. The
2136 document structure should be reflected in the index, so when starting
2137 new sections, the basic topics of the section should be indexed. If the
2138 document contains definitions, theorems or the like, these should all
2139 correspond to appropriate index entries. This part of the index can
2140 very well be developed along with the document. Often it is worthwhile
2141 to define special purpose macros which define an item and at the same
2142 time make an index entry, possibly with special formatting to make the
2143 reference page in the index bold or underlined. To make @RefTeX{}
2144 support for indexing possible, these special macros must be added to
2145 @RefTeX{}'s configuration (@pxref{Defining Index Macros}).
2148 The rest of the index is often just a collection of where in the
2149 document certain words or phrases are being used. This part is
2150 difficult to develop along with the document, because consistent entries
2151 for each occurrence are needed and are best selected when the document
2152 is ready. @RefTeX{} supports this with an @emph{index phrases file}
2153 which collects phrases and helps indexing the phrases globally.
2156 Before you start, you need to make sure that @RefTeX{} knows about
2157 the index style being used in the current document. @RefTeX{} has
2158 builtin support for the default @code{\index} and @code{\glossary}
2159 macros. Other @LaTeX{} packages, like the @file{multind} or @file{index}
2160 package, redefine the @code{\index} macro to have an additional
2161 argument, and @RefTeX{} needs to be configured for those. A
2162 sufficiently new version of @AUCTeX{} (9.10c or later) will do this
2163 automatically. If you really don't use @AUCTeX{} (you should!), this
2164 configuration needs to be done by hand with the menu (@code{Ref->Index
2165 Style}), or globally for all your documents with
2168 (setq reftex-index-macros '(multind)) @r{or}
2169 (setq reftex-index-macros '(index))
2173 * Creating Index Entries:: Macros and completion of entries.
2174 * The Index Phrases File:: A special file for global indexing.
2175 * Displaying and Editing the Index:: The index editor.
2176 * Builtin Index Macros:: The index macros RefTeX knows about.
2177 * Defining Index Macros:: ... and macros it doesn't.
2180 @node Creating Index Entries, The Index Phrases File, , Index Support
2181 @section Creating Index Entries
2182 @cindex Creating index entries
2183 @cindex Index entries, creating
2185 @findex reftex-index
2187 @findex reftex-index-selection-or-word
2189 In order to index the current selection or the word at the cursor press
2190 @kbd{C-c /} (@code{reftex-index-selection-or-word}). This causes the
2191 selection or word @samp{@var{word}} to be replaced with
2192 @samp{\index@{@var{word}@}@var{word}}. The macro which is used
2193 (@code{\index} by default) can be configured with the variable
2194 @code{reftex-index-default-macro}. When the command is called with a
2195 prefix argument (@kbd{C-u C-c /}), you get a chance to edit the
2196 generated index entry. Use this to change the case of the word or to
2197 make the entry a subentry, for example by entering
2198 @samp{main!sub!@var{word}}. When called with two raw @kbd{C-u} prefixes
2199 (@kbd{C-u C-u C-c /}), you will be asked for the index macro as well.
2200 When there is nothing selected and no word at point, this command will
2201 just call @code{reftex-index}, described below.
2203 In order to create a general index entry, press @kbd{C-c <}
2204 (@code{reftex-index}). @RefTeX{} will prompt for one of the
2205 available index macros and for its arguments. Completion will be
2206 available for the index entry and, if applicable, the index tag. The
2207 index tag is a string identifying one of multiple indices. With the
2208 @file{multind} and @file{index} packages, this tag is the first argument
2209 to the redefined @code{\index} macro.
2211 @node The Index Phrases File, Displaying and Editing the Index, Creating Index Entries, Index Support
2212 @section The Index Phrases File
2213 @cindex Index phrase file
2216 @findex reftex-index-visit-phrases-buffer
2217 @cindex Macro definition lines, in phrase buffer
2219 @RefTeX{} maintains a file in which phrases can be collected for
2220 later indexing. The file is located in the same directory as the master
2221 file of the document and has the extension @file{.rip} (@b{R}eftex
2222 @b{I}ndex @b{P}hrases). You can create or visit the file with @kbd{C-c
2223 |} (@code{reftex-index-visit-phrases-buffer}). If the file is empty it
2224 is initialized by inserting a file header which contains the definition
2225 of the available index macros. This list is initialized from
2226 @code{reftex-index-macros} (@pxref{Defining Index Macros}). You can
2227 edit the header as needed, but if you define new @LaTeX{} indexing macros,
2228 don't forget to add them to @code{reftex-index-macros} as well. Here is
2229 a phrase file header example:
2232 % -*- mode: reftex-index-phrases -*-
2233 % Key Macro Format Repeat
2234 %----------------------------------------------------------
2235 >>>INDEX_MACRO_DEFINITION: i \index@{%s@} t
2236 >>>INDEX_MACRO_DEFINITION: I \index*@{%s@} nil
2237 >>>INDEX_MACRO_DEFINITION: g \glossary@{%s@} t
2238 >>>INDEX_MACRO_DEFINITION: n \index*[name]@{%s@} nil
2239 %----------------------------------------------------------
2242 The macro definition lines consist of a unique letter identifying a
2243 macro, a format string and the @var{repeat} flag, all separated by
2244 @key{TAB}. The format string shows how the macro is to be applied, the
2245 @samp{%s} will be replaced with the index entry. The repeat flag
2246 indicates if @var{word} is indexed by the macro as
2247 @samp{\index@{@var{word}@}} (@var{repeat} = @code{nil}) or as
2248 @samp{\index@{@var{word}@}@var{word}} (@var{repeat} = @code{t}). In the
2249 above example it is assumed that the macro @code{\index*@{@var{word}@}}
2250 already typesets its argument in the text, so that it is unnecessary to
2251 repeat @var{word} outside the macro.
2254 * Collecting Phrases:: Collecting from document or external.
2255 * Consistency Checks:: Check for duplicates etc.
2256 * Global Indexing:: The interactive indexing process.
2259 @node Collecting Phrases, Consistency Checks, , The Index Phrases File
2260 @subsection Collecting Phrases
2261 @cindex Collecting index phrases
2262 @cindex Index phrases, collection
2263 @cindex Phrases, collecting
2265 Phrases for indexing can be collected while writing the document. The
2266 command @kbd{C-c \} (@code{reftex-index-phrase-selection-or-word})
2267 copies the current selection (if active) or the word near point into the
2268 phrases buffer. It then selects this buffer, so that the phrase line
2269 can be edited. To return to the @LaTeX{} document, press @kbd{C-c C-c}
2270 (@code{reftex-index-phrases-save-and-return}).
2272 You can also prepare the list of index phrases in a different way and
2273 copy it into the phrases file. For example you might want to start from
2274 a word list of the document and remove all words which should not be
2277 The phrase lines in the phrase buffer must have a specific format.
2278 @RefTeX{} will use font-lock to indicate if a line has the proper
2279 format. A phrase line looks like this:
2282 [@var{key}] <TABs> @var{phrase} [<TABs> @var{arg}[&&@var{arg}]... [ || @var{arg}]...]
2285 @code{<TABs>} stands for white space containing at least one @key{TAB}.
2286 @var{key} must be at the start of the line and is the character
2287 identifying one of the macros defined in the file header. It is
2288 optional - when omitted, the first macro definition line in the file
2289 will be used for this phrase. The @var{phrase} is the phrase to be
2290 searched for when indexing. It may contain several words separated by
2291 spaces. By default the search phrase is also the text entered as
2292 argument of the index macro. If you want the index entry to be
2293 different from the search phrase, enter another @key{TAB} and the index
2294 argument @var{arg}. If you want to have each match produce several
2295 index entries, separate the different index arguments with @samp{ &&
2296 }@footnote{@samp{&&} with optional spaces, see
2297 @code{reftex-index-phrases-logical-and-regexp}.}. If you want to be
2298 able to choose at each match between several different index arguments,
2299 separate them with @samp{ || }@footnote{@samp{||} with optional spaces,
2300 see @code{reftex-index-phrases-logical-or-regexp}.}. Here is an
2304 %--------------------------------------------------------------------
2308 Jupiter Planets!Jupiter
2309 i Mars Planets!Mars || Gods!Mars || Chocolate Bars!Mars
2310 i Pluto Planets!Pluto && Kuiper Belt Objects!Pluto
2314 So @samp{Sun} will be indexed directly as @samp{\index*@{Sun@}}, while
2315 @samp{Planet} will be indexed as @samp{\index@{Planets@}Planet}.
2316 @samp{Vega} will be indexed as a subitem of @samp{Stars}. The
2317 @samp{Jupiter} line will also use the @samp{i} macro as it was the first
2318 macro definition in the file header (see above example). At each
2319 occurrence of @samp{Mars} you will be able choose between indexing it as
2320 a subitem of @samp{Planets}, @samp{Gods} or @samp{Chocolate Bars}.
2321 Finally, every occurrence of @samp{Pluto} will be indexed as
2322 @samp{\index@{Planets!Pluto@}\index@{Kuiper Belt Objects!Pluto@}Pluto}
2323 and will therefore create two different index entries.
2325 @node Consistency Checks, Global Indexing, Collecting Phrases, The Index Phrases File
2326 @subsection Consistency Checks
2327 @cindex Index phrases, consistency checks
2328 @cindex Phrases, consistency checks
2329 @cindex Consistency check for index phrases
2332 Before indexing the phrases in the phrases buffer, they should be
2333 checked carefully for consistency. A first step is to sort the phrases
2334 alphabetically - this is done with the command @kbd{C-c C-s}
2335 (@code{reftex-index-sort-phrases}). It will sort all phrases in the
2336 buffer alphabetically by search phrase. If you want to group certain
2337 phrases and only sort within the groups, insert empty lines between the
2338 groups. Sorting will only change the sequence of phrases within each
2339 group (see the variable @code{reftex-index-phrases-sort-in-blocks}).
2342 A useful command is @kbd{C-c C-i} (@code{reftex-index-phrases-info})
2343 which lists information about the phrase at point, including an example
2344 of how the index entry will look like and the number of expected matches
2348 Another important check is to find out if there are double or
2349 overlapping entries in the buffer. For example if you are first
2350 searching and indexing @samp{Mars} and then @samp{Planet Mars}, the
2351 second phrase will not match because of the index macro inserted before
2352 @samp{Mars} earlier. The command @kbd{C-c C-t}
2353 (@code{reftex-index-find-next-conflict-phrase}) finds the next phrase in
2354 the buffer which is either duplicate or a subphrase of another phrase.
2355 In order to check the whole buffer like this, start at the beginning and
2356 execute this command repeatedly.
2358 @node Global Indexing, , Consistency Checks, The Index Phrases File
2359 @subsection Global Indexing
2360 @cindex Global indexing
2361 @cindex Indexing, global
2362 @cindex Indexing, from @file{phrases} buffer
2364 Once the index phrases have been collected and organized, you are set
2365 for global indexing. I recommend to do this only on an otherwise
2366 finished document. Global indexing starts from the phrases buffer.
2367 There are several commands which start indexing: @kbd{C-c C-x} acts on
2368 the current phrase line, @kbd{C-c C-r} on all lines in the current
2369 region and @kbd{C-c C-a} on all phrase lines in the buffer. It is
2370 probably good to do indexing in small chunks since your concentration
2371 may not last long enough to do everything in one go.
2373 @RefTeX{} will start at the first phrase line and search the phrase
2374 globally in the whole document. At each match it will stop, compute the
2375 replacement string and offer you the following choices@footnote{Windows
2376 users: Restrict yourself to the described keys during indexing. Pressing
2377 @key{Help} at the indexing prompt can apparently hang Emacs.}:
2381 Replace this match with the proposed string.
2385 Replace this and all further matches in this file.
2387 Skip this match, start with next file.
2389 Skip this match, start with next phrase.
2391 Select a different indexing macro for this match.
2393 Select one of multiple index keys (those separated with @samp{||}).
2395 Edit the replacement text.
2397 Recursive edit. Use @kbd{C-M-c} to return to the indexing process.
2399 Save this buffer and ask again about the current match.
2401 Save all document buffers and ask again about the current match.
2403 Abort the indexing process.
2406 The @samp{Find and Index in Document} menu in the phrases buffer also
2407 lists a few options for the indexing process. The options have
2408 associated customization variables to set the defaults (@pxref{Options
2409 (Index Support)}). Here is a short explanation of what the options do:
2412 @item Match Whole Words
2413 When searching for index phrases, make sure whole words are matched.
2414 This should probably always be on.
2415 @item Case Sensitive Search
2416 Search case sensitively for phrases. I recommend to have this setting
2417 off, in order to match the capitalized words at the beginning of a
2418 sentence, and even typos. You can always say @emph{no} at a match you
2420 @item Wrap Long Lines
2421 Inserting index macros increases the line length. Turn this option on
2422 to allow @RefTeX{} to wrap long lines.
2423 @item Skip Indexed Matches
2424 When this is on, @RefTeX{} will at each match try to figure out if
2425 this match is already indexed. A match is considered indexed if it is
2426 either the argument of an index macro, or if an index macro is directly
2427 (without whitespace separation) before or after the match. Index macros
2428 are those configured in @code{reftex-index-macros}. Intended for
2429 re-indexing a documents after changes have been made.
2432 Even though indexing should be the last thing you do to a document, you
2433 are bound to make changes afterwards. Indexing then has to be applied
2434 to the changed regions. The command
2435 @code{reftex-index-phrases-apply-to-region} is designed for this
2436 purpose. When called from a @LaTeX{} document with active region, it will
2437 apply @code{reftex-index-all-phrases} to the current region.
2439 @node Displaying and Editing the Index, Builtin Index Macros, The Index Phrases File, Index Support
2440 @section Displaying and Editing the Index
2441 @cindex Displaying the Index
2442 @cindex Editing the Index
2443 @cindex Index entries, creating
2444 @cindex Index, displaying
2445 @cindex Index, editing
2447 @findex reftex-display-index
2449 In order to compile and display the index, press @kbd{C-c >}. If the
2450 document uses multiple indices, @RefTeX{} will ask you to select
2451 one. Then, all index entries will be sorted alphabetically and
2452 displayed in a special buffer, the @file{*Index*} buffer. From that
2453 buffer you can check and edit each entry.
2455 The index can be restricted to the current section or the region. Then
2456 only entries in that part of the document will go into the compiled
2457 index. To restrict to the current section, use a numeric prefix
2458 @samp{2}, thus press @kbd{C-u 2 C-c >}. To restrict to the current
2459 region, make the region active and use a numeric prefix @samp{3} (press
2460 @kbd{C-u 3 C-c >}). From within the @file{*Index*} buffer the
2461 restriction can be moved from one section to the next by pressing the
2462 @kbd{<} and @kbd{>} keys.
2464 One caveat: @RefTeX{} finds the definition point of an index entry
2465 by searching near the buffer position where it had found to macro during
2466 scanning. If you have several identical index entries in the same
2467 buffer and significant changes have shifted the entries around, you must
2468 rescan the buffer to ensure the correspondence between the
2469 @file{*Index*} buffer and the definition locations. It is therefore
2470 advisable to rescan the document (with @kbd{r} or @kbd{C-u r})
2471 frequently while editing the index from the @file{*Index*}
2475 Here is a list of special commands available in the @file{*Index*} buffer. A
2476 summary of this information is always available by pressing
2480 @tablesubheading{General}
2482 Display a summary of commands.
2487 @tablesubheading{Moving around}
2489 Pressing any capital letter will jump to the corresponding section in
2490 the @file{*Index*} buffer. The exclamation mark is special and jumps to
2491 the first entries alphabetically sorted below @samp{A}. These are
2492 usually non-alphanumeric characters.
2496 Go to previous entry.
2498 @tablesubheading{Access to document locations}
2500 Show the place in the document where this index entry is defined.
2503 Go to the definition of the current index entry in another
2507 Go to the definition of the current index entry and hide the
2508 @file{*Index*} buffer window.
2511 @vindex reftex-index-follow-mode
2512 @vindex reftex-revisit-to-follow
2513 Toggle follow mode. When follow mode is active, the other window will
2514 always show the location corresponding to the line in the @file{*Index*}
2515 buffer at point. This is similar to pressing @key{SPC} after each
2516 cursor motion. The default for this flag can be set with the variable
2517 @code{reftex-index-follow-mode}. Note that only context in files
2518 already visited is shown. @RefTeX{} will not visit a file just for
2519 follow mode. See, however, the variable
2520 @code{reftex-revisit-to-follow}.
2522 @tablesubheading{Entry editing}
2524 Edit the current index entry. In the minibuffer, you can edit the
2525 index macro which defines this entry.
2528 Kill the index entry. Currently not implemented because I don't know
2529 how to implement an @code{undo} function for this.
2532 Edit the @var{key} part of the entry. This is the initial part of the
2533 entry which determines the location of the entry in the index.
2536 Edit the @var{attribute} part of the entry. This is the part after the
2537 vertical bar. With @code{MakeIndex}, this part is an encapsulating
2538 macro. With @code{xindy}, it is called @emph{attribute} and is a
2539 property of the index entry that can lead to special formatting. When
2540 called with @kbd{C-u} prefix, kill the entire @var{attribute}
2544 Edit the @var{visual} part of the entry. This is the part after the
2545 @samp{@@} which is used by @code{MakeIndex} to change the visual
2546 appearance of the entry in the index. When called with @kbd{C-u}
2547 prefix, kill the entire @var{visual} part.
2550 Toggle the beginning of page range property @samp{|(} of the
2554 Toggle the end of page range property @samp{|)} of the entry.
2557 Make the current entry a subentry. This command will prompt for the
2558 superordinate entry and insert it.
2561 Remove the highest superordinate entry. If the current entry is a
2562 subitem (@samp{aaa!bbb!ccc}), this function moves it up the hierarchy
2565 @tablesubheading{Exiting}
2567 Hide the @file{*Index*} buffer.
2570 Kill the @file{*Index*} buffer.
2573 Switch to the Table of Contents buffer of this document.
2575 @tablesubheading{Controlling what gets displayed}
2577 @vindex reftex-index-include-context
2578 Toggle the display of short context in the @file{*Index*} buffer. The
2579 default for this flag can be set with the variable
2580 @code{reftex-index-include-context}.
2583 Restrict the index to a single document section. The corresponding
2584 section number will be displayed in the @code{R<>} indicator in the
2585 mode line and in the header of the @file{*Index*} buffer.
2588 Widen the index to contain all entries of the document.
2591 When the index is currently restricted, move the restriction to the
2595 When the index is currently restricted, move the restriction to the
2598 @tablesubheading{Updating the buffer}
2600 Rebuild the @file{*Index*} buffer. This does @emph{not} rescan the
2601 document. However, it sorts the entries again, so that edited entries
2602 will move to the correct position.
2605 @vindex reftex-enable-partial-scans
2606 Reparse the @LaTeX{} document and rebuild the @file{*Index*} buffer. When
2607 @code{reftex-enable-partial-scans} is non-@code{nil}, rescan only the file this
2608 location is defined in, not the entire document.
2611 Reparse the @emph{entire} @LaTeX{} document and rebuild the @file{*Index*}
2615 Switch to a different index (for documents with multiple
2620 @node Builtin Index Macros, Defining Index Macros, Displaying and Editing the Index, Index Support
2621 @section Builtin Index Macros
2622 @cindex Builtin index macros
2623 @cindex Index macros, builtin
2624 @vindex reftex-index-macros
2625 @cindex @code{multind}, LaTeX package
2626 @cindex @code{index}, LaTeX package
2627 @cindex LaTeX packages, @code{multind}
2628 @cindex LaTeX packages, @code{index}
2630 @RefTeX{} by default recognizes the @code{\index} and
2631 @code{\glossary} macros which are defined in the @LaTeX{} core. It has
2632 also builtin support for the re-implementations of @code{\index}
2633 in the @file{multind} and @file{index} packages. However, since
2634 the different definitions of the @code{\index} macro are incompatible,
2635 you will have to explicitly specify the index style used.
2636 @xref{Creating Index Entries}, for information on how to do that.
2638 @node Defining Index Macros, , Builtin Index Macros, Index Support
2639 @section Defining Index Macros
2640 @cindex Defining Index Macros
2641 @cindex Index macros, defining
2642 @vindex reftex-index-macros
2644 When writing a document with an index you will probably define
2645 additional macros which make entries into the index.
2646 Let's look at an example.
2649 \newcommand@{\ix@}[1]@{#1\index@{#1@}@}
2650 \newcommand@{\nindex@}[1]@{\textit@{#1@}\index[name]@{#1@}@}
2651 \newcommand@{\astobj@}[1]@{\index@{Astronomical Objects!#1@}@}
2654 The first macro @code{\ix} typesets its argument in the text and places
2655 it into the index. The second macro @code{\nindex} typesets its
2656 argument in the text and places it into a separate index with the tag
2657 @samp{name}@footnote{We are using the syntax of the @file{index} package
2658 here.}. The last macro also places its argument into the index, but as
2659 subitems under the main index entry @samp{Astronomical Objects}. Here
2660 is how to make @RefTeX{} recognize and correctly interpret these
2661 macros, first with Emacs Lisp.
2664 (setq reftex-index-macros
2665 '(("\\ix@{*@}" "idx" ?x "" nil nil)
2666 ("\\nindex@{*@}" "name" ?n "" nil nil)
2667 ("\\astobj@{*@}" "idx" ?o "Astronomical Objects!" nil t)))
2670 Note that the index tag is @samp{idx} for the main index, and
2671 @samp{name} for the name index. @samp{idx} and @samp{glo} are reserved
2672 for the default index and for the glossary.
2674 The character arguments @code{?x}, @code{?n}, and @code{?o} are for
2675 quick identification of these macros when @RefTeX{} inserts new
2676 index entries with @code{reftex-index}. These codes need to be
2677 unique. @code{?i}, @code{?I}, and @code{?g} are reserved for the
2678 @code{\index}, @code{\index*}, and @code{\glossary} macros,
2681 The following string is empty unless your macro adds a superordinate
2682 entry to the index key - this is the case for the @code{\astobj} macro.
2684 The next entry can be a hook function to exclude certain matches, it
2685 almost always can be @code{nil}.
2687 The final element in the list indicates if the text being indexed needs
2688 to be repeated outside the macro. For the normal index macros, this
2689 should be @code{t}. Only if the macro typesets the entry in the text
2690 (like @code{\ix} and @code{\nindex} in the example do), this should be
2693 To do the same thing with customize, you need to fill in the templates
2699 Macro with args: \ix@{*@}
2700 Index Tag : [Value Menu] String: idx
2703 Exclusion hook : nil
2704 Repeat Outside : [Toggle] off (nil)
2706 Macro with args: \nindex@{*@}
2707 Index Tag : [Value Menu] String: name
2710 Exclusion hook : nil
2711 Repeat Outside : [Toggle] off (nil)
2713 Macro with args: \astobj@{*@}
2714 Index Tag : [Value Menu] String: idx
2716 Key Prefix : Astronomical Objects!
2717 Exclusion hook : nil
2718 Repeat Outside : [Toggle] on (non-nil)
2722 With the macro @code{\ix} defined, you may want to change the default
2723 macro used for indexing a text phrase (@pxref{Creating Index Entries}).
2724 This would be done like this
2727 (setq reftex-index-default-macro '(?x "idx"))
2730 which specifies that the macro identified with the character @code{?x} (the
2731 @code{\ix} macro) should be used for indexing phrases and words already
2732 in the buffer with @kbd{C-c /} (@code{reftex-index-selection-or-word}).
2733 The index tag is "idx".
2735 @node Viewing Cross-References, RefTeXs Menu, Index Support, Top
2736 @chapter Viewing Cross-References
2737 @findex reftex-view-crossref
2738 @findex reftex-mouse-view-crossref
2742 @RefTeX{} can display cross-referencing information. This means,
2743 if two document locations are linked, @RefTeX{} can display the
2744 matching location(s) in another window. The @code{\label} and @code{\ref}
2745 macros are one way of establishing such a link. Also, a @code{\cite}
2746 macro is linked to the corresponding @code{\bibitem} macro or a @BibTeX{}
2749 The feature is invoked by pressing @kbd{C-c &}
2750 (@code{reftex-view-crossref}) while point is on the @var{key} argument
2751 of a macro involved in cross-referencing. You can also click with
2752 @kbd{S-mouse-2} on the macro argument. Here is what will happen for
2753 individual classes of macros:
2759 Display the corresponding label definition. All usual
2760 variants@footnote{all macros that start with @samp{ref} or end with
2761 @samp{ref} or @samp{refrange}} of the @code{\ref} macro are active for
2762 cross-reference display. This works also for labels defined in an
2763 external document when the current document refers to them through the
2764 @code{xr} interface (@pxref{xr (LaTeX package)}).
2767 @cindex @code{\label}
2768 @vindex reftex-label-alist
2769 Display a document location which references this label. Pressing
2770 @kbd{C-c &} several times moves through the entire document and finds
2771 all locations. Not only the @code{\label} macro but also other macros
2772 with label arguments (as configured with @code{reftex-label-alist}) are
2773 active for cross-reference display.
2776 @cindex @code{\cite}
2777 Display the corresponding @BibTeX{} database entry or @code{\bibitem}.
2778 All usual variants@footnote{all macros that either start or end with
2779 @samp{cite}} of the @code{\cite} macro are active for cross-reference
2782 @item @code{\bibitem}
2783 @cindex @code{\bibitem}
2784 Display a document location which cites this article. Pressing
2785 @kbd{C-c &} several times moves through the entire document and finds
2789 @cindex BibTeX buffer, viewing cite locations from
2790 @cindex Viewing cite locations from BibTeX buffer
2791 @kbd{C-c &} is also active in @BibTeX{} buffers. All locations in a
2792 document where the database entry at point is cited will be displayed.
2793 On first use, @RefTeX{} will prompt for a buffer which belongs to
2794 the document you want to search. Subsequent calls will use the same
2795 document, until you break this link with a prefix argument to @kbd{C-c
2799 @cindex @code{\index}
2800 Display other locations in the document which are marked by an index
2801 macro with the same key argument. Along with the standard @code{\index}
2802 and @code{\glossary} macros, all macros configured in
2803 @code{reftex-index-macros} will be recognized.
2806 @vindex reftex-view-crossref-extra
2807 While the display of cross referencing information for the above
2808 mentioned macros is hard-coded, you can configure additional relations
2809 in the variable @code{reftex-view-crossref-extra}.
2812 @chapter All the Rest
2815 @node RefTeXs Menu, Key Bindings, Viewing Cross-References, Top
2816 @section @RefTeX{}'s Menu
2817 @cindex RefTeXs Menu
2818 @cindex Menu, in the menu bar
2820 @RefTeX{} installs a @code{Ref} menu in the menu bar on systems
2821 which support this. From this menu you can access all of
2822 @RefTeX{}'s commands and a few of its options. There is also a
2823 @code{Customize} submenu which can be used to access @RefTeX{}'s
2824 entire set of options.
2826 @node Key Bindings, Faces, RefTeXs Menu, Top
2827 @section Default Key Bindings
2828 @cindex Key Bindings, summary
2830 Here is a summary of the available key bindings.
2845 @kbd{C-c =} @code{reftex-toc}
2846 @kbd{C-c -} @code{reftex-toc-recenter}
2847 @kbd{C-c (} @code{reftex-label}
2848 @kbd{C-c )} @code{reftex-reference}
2849 @kbd{C-c [} @code{reftex-citation}
2850 @kbd{C-c &} @code{reftex-view-crossref}
2851 @kbd{S-mouse-2} @code{reftex-mouse-view-crossref}
2852 @kbd{C-c /} @code{reftex-index-selection-or-word}
2853 @kbd{C-c \} @code{reftex-index-phrase-selection-or-word}
2854 @kbd{C-c |} @code{reftex-index-visit-phrases-buffer}
2855 @kbd{C-c <} @code{reftex-index}
2856 @kbd{C-c >} @code{reftex-display-index}
2859 Note that the @kbd{S-mouse-2} binding is only provided if this key is
2860 not already used by some other package. @RefTeX{} will not override an
2861 existing binding to @kbd{S-mouse-2}.
2863 Personally, I also bind some functions in the users @kbd{C-c} map for
2866 @c FIXME: Do we need bindings for the Index macros here as well?
2867 @c C-c i C-c I or so????
2868 @c How about key bindings for reftex-reset-mode and reftex-parse-document?
2877 @kbd{C-c t} @code{reftex-toc}
2878 @kbd{C-c l} @code{reftex-label}
2879 @kbd{C-c r} @code{reftex-reference}
2880 @kbd{C-c c} @code{reftex-citation}
2881 @kbd{C-c v} @code{reftex-view-crossref}
2882 @kbd{C-c s} @code{reftex-search-document}
2883 @kbd{C-c g} @code{reftex-grep-document}
2886 @noindent These keys are reserved for the user, so I cannot bind them by
2887 default. If you want to have these key bindings available, set in your
2890 @vindex reftex-extra-bindings
2892 (setq reftex-extra-bindings t)
2895 @vindex reftex-load-hook
2896 Changing and adding to @RefTeX{}'s key bindings is best done in the hook
2897 @code{reftex-load-hook}. For information on the keymaps
2898 which should be used to add keys, see @ref{Keymaps and Hooks}.
2900 @node Faces, AUCTeX, Key Bindings, Top
2904 @RefTeX{} uses faces when available to structure the selection and
2905 table of contents buffers. It does not create its own faces, but uses
2906 the ones defined in @file{font-lock.el}. Therefore, @RefTeX{} will
2907 use faces only when @code{font-lock} is loaded. This seems to be
2908 reasonable because people who like faces will very likely have it
2909 loaded. If you wish to turn off fontification or change the involved
2910 faces, see @ref{Options (Fontification)}.
2912 @node Multifile Documents, Language Support, AUCTeX, Top
2913 @section Multifile Documents
2914 @cindex Multifile documents
2915 @cindex Documents, spread over files
2917 The following is relevant when working with documents spread over many
2922 @RefTeX{} has full support for multifile documents. You can edit parts of
2923 several (multifile) documents at the same time without conflicts.
2924 @RefTeX{} provides functions to run @code{grep}, @code{search} and
2925 @code{query-replace} on all files which are part of a multifile
2929 @vindex tex-main-file
2931 All files belonging to a multifile document should define a File
2932 Variable (@code{TeX-master} for @AUCTeX{} or @code{tex-main-file} for the
2933 standard Emacs @LaTeX{} mode) containing the name of the master file. For
2934 example, to set the file variable @code{TeX-master}, include something
2935 like the following at the end of each @TeX{} file:
2938 %%% Local Variables: ***
2940 %%% TeX-master: "thesis.tex" ***
2944 @AUCTeX{} with the setting
2947 (setq-default TeX-master nil)
2950 will actually ask you for each new file about the master file and insert
2951 this comment automatically. For more details see the documentation of
2952 the @AUCTeX{} (@pxref{Multifile,,,auctex, The AUCTeX User Manual}), the
2953 documentation about the Emacs (La)TeX mode (@pxref{TeX Print,,,emacs,
2954 The GNU Emacs Manual}) and the Emacs documentation on File Variables
2955 (@pxref{File Variables,,,emacs, The GNU Emacs Manual}).
2958 The context of a label definition must be found in the same file as the
2959 label itself in order to be processed correctly by @RefTeX{}. The only
2960 exception is that section labels referring to a section statement
2961 outside the current file can still use that section title as
2965 @node Language Support, Finding Files, Multifile Documents, Top
2966 @section Language Support
2967 @cindex Language support
2969 Some parts of @RefTeX{} are language dependent. The default
2970 settings work well for English. If you are writing in a different
2971 language, the following hints may be useful:
2975 @vindex reftex-derive-label-parameters
2976 @vindex reftex-abbrev-parameters
2977 The mechanism to derive a label from context includes the abbreviation
2978 of words and omission of unimportant words. These mechanisms may have
2979 to be changed for other languages. See the variables
2980 @code{reftex-derive-label-parameters} and @code{reftex-abbrev-parameters}.
2983 @vindex reftex-translate-to-ascii-function
2984 @vindex reftex-label-illegal-re
2985 Also, when a label is derived from context, @RefTeX{} clears the
2986 context string from non-ASCII characters in order to make a valid label.
2987 If there should ever be a version of @TeX{} which allows extended
2988 characters @emph{in labels}, then we will have to look at the
2989 variables @code{reftex-translate-to-ascii-function} and
2990 @code{reftex-label-illegal-re}.
2993 When a label is referenced, @RefTeX{} looks at the word before point
2994 to guess which label type is required. These @emph{magic words} are
2995 different in every language. For an example of how to add magic words,
2996 see @ref{Adding Magic Words}.
2998 @vindex reftex-multiref-punctuation
2999 @vindex reftex-cite-punctuation
3001 @RefTeX{} inserts ``punctuation'' for multiple references and
3002 for the author list in citations. Some of this may be language
3003 dependent. See the variables @code{reftex-multiref-punctuation} and
3004 @code{reftex-cite-punctuation}.
3007 @node Finding Files, Optimizations, Language Support, Top
3008 @section Finding Files
3009 @cindex Finding files
3011 In order to find files included in a document via @code{\input} or
3012 @code{\include}, @RefTeX{} searches all directories specified in the
3013 environment variable @code{TEXINPUTS}. Similarly, it will search the
3014 path specified in the variables @code{BIBINPUTS} and @code{TEXBIB} for
3015 @BibTeX{} database files.
3017 When searching, @RefTeX{} will also expand recursive path
3018 definitions (directories ending in @samp{//} or @samp{!!}). But it will
3019 only search and expand directories @emph{explicitly} given in these
3020 variables. This may cause problems under the following circumstances:
3024 Most @TeX{} system have a default search path for both @TeX{} files and @BibTeX{}
3025 files which is defined in some setup file. Usually this default path is
3026 for system files which @RefTeX{} does not need to see. But if your
3027 document needs @TeX{} files or @BibTeX{} database files in a directory only
3028 given in the default search path, @RefTeX{} will fail to find them.
3030 Some @TeX{} systems do not use environment variables at all in order to
3031 specify the search path. Both default and user search path are then
3032 defined in setup files.
3036 There are three ways to solve this problem:
3040 Specify all relevant directories explicitly in the environment
3041 variables. If for some reason you don't want to mess with the default
3042 variables @code{TEXINPUTS} and @code{BIBINPUTS}, define your own
3043 variables and configure @RefTeX{} to use them instead:
3046 (setq reftex-texpath-environment-variables '("MYTEXINPUTS"))
3047 (setq reftex-bibpath-environment-variables '("MYBIBINPUTS"))
3051 Specify the full search path directly in @RefTeX{}'s variables.
3054 (setq reftex-texpath-environment-variables
3055 '("./inp:/home/cd/tex//:/usr/local/tex//"))
3056 (setq reftex-bibpath-environment-variables
3057 '("/home/cd/tex/lit/"))
3061 Some @TeX{} systems provide stand-alone programs to do the file search just
3062 like @TeX{} and @BibTeX{}. E.g. Thomas Esser's @code{teTeX} uses the
3063 @code{kpathsearch} library which provides the command @code{kpsewhich}
3064 to search for files. @RefTeX{} can be configured to use this
3065 program. Note that the exact syntax of the @code{kpsewhich}
3066 command depends upon the version of that program.
3069 (setq reftex-use-external-file-finders t)
3070 (setq reftex-external-file-finders
3071 '(("tex" . "kpsewhich -format=.tex %f")
3072 ("bib" . "kpsewhich -format=.bib %f")))
3077 @vindex reftex-file-extensions
3078 @vindex TeX-file-extensions
3079 Some people like to use RefTeX with noweb files, which usually have the
3080 extension @file{.nw}. In order to deal with such files, the new
3081 extension must be added to the list of valid extensions in the variable
3082 @code{reftex-file-extensions}. When working with @AUCTeX{} as major mode,
3083 the new extension must also be known to @AUCTeX{} via the variable
3084 @code{TeX-file-extension}. For example:
3087 (setq reftex-file-extensions
3088 '(("nw" "tex" ".tex" ".ltx") ("bib" ".bib")))
3089 (setq TeX-file-extensions
3090 '( "nw" "tex" "sty" "cls" "ltx" "texi" "texinfo"))
3093 @node Optimizations, Problems and Work-Arounds, Finding Files, Top
3094 @section Optimizations
3095 @cindex Optimizations
3097 @b{Note added 2002. Computers have gotten a lot faster, so most of the
3098 optimizations discussed below will not be necessary on new machines. I
3099 am leaving this stuff in the manual for people who want to write thick
3100 books, where some of it still might be useful.}
3102 Implementing the principle of least surprises, the default settings of
3103 @RefTeX{} ensure a safe ride for beginners and casual users. However,
3104 when using @RefTeX{} for a large project and/or on a small computer,
3105 there are ways to improve speed or memory usage.
3109 @b{Removing Lookup Buffers}@*
3110 @cindex Removing lookup buffers
3111 @RefTeX{} will load other parts of a multifile document as well as @BibTeX{}
3112 database files for lookup purposes. These buffers are kept, so that
3113 subsequent use of the same files is fast. If you can't afford keeping
3114 these buffers around, and if you can live with a speed penalty, try
3116 @vindex reftex-keep-temporary-buffers
3118 (setq reftex-keep-temporary-buffers nil)
3122 @b{Partial Document Scans}@*
3123 @cindex Partial documents scans
3124 @cindex Document scanning, partial
3125 A @kbd{C-u} prefix on the major @RefTeX{} commands @code{reftex-label}
3126 (@kbd{C-u C-c (}), @code{reftex-reference} (@kbd{C-u C-c )}),
3127 @code{reftex-citation} (@kbd{C-u C-c [}), @code{reftex-toc} (@kbd{C-u C-c
3128 =}), and @code{reftex-view-crossref} (@kbd{C-u C-c &}) initiates
3129 re-parsing of the entire document in order to update the parsing
3130 information. For a large document this can be unnecessary, in
3131 particular if only one file has changed. @RefTeX{} can be configured
3132 to do partial scans instead of full ones. @kbd{C-u} re-parsing then
3133 does apply only to the current buffer and files included from it.
3134 Likewise, the @kbd{r} key in both the label selection buffer and the
3135 table-of-contents buffer will only prompt scanning of the file in which
3136 the label or section macro near the cursor was defined. Re-parsing of
3137 the entire document is still available by using @kbd{C-u C-u} as a
3138 prefix, or the capital @kbd{R} key in the menus. To use this feature,
3141 @vindex reftex-enable-partial-scans
3143 (setq reftex-enable-partial-scans t)
3147 @b{Saving Parser Information}@*
3148 @cindex Saving parser information
3149 @cindex Parse information, saving to a file
3150 @vindex reftex-parse-file-extension
3151 Even with partial scans enabled, @RefTeX{} still has to make one full
3152 scan, when you start working with a document. To avoid this, parsing
3153 information can be stored in a file. The file @file{MASTER.rel} is used
3154 for storing information about a document with master file
3155 @file{MASTER.tex}. It is written automatically when you kill a buffer
3156 in @code{reftex-mode} or when you exit Emacs. The information is
3157 restored when you begin working with a document in a new editing
3158 session. To use this feature, put into @file{.emacs}:
3160 @vindex reftex-save-parse-info
3162 (setq reftex-save-parse-info t)
3166 @b{Identifying label types by prefix}@*
3167 @cindex Parse information, saving to a file
3168 @vindex reftex-trust-label-prefix
3169 @RefTeX{} normally parses around each label to check in which
3170 environment this label is located, in order to assign a label type to
3171 the label. If your document contains thousands of labels, document
3172 parsing will take considerable time. If you have been using label prefixes
3173 like tab: and fn: consistently, you can tell @RefTeX{} to get the
3174 label type directly from the prefix, without additional parsing. This
3175 will be faster and also allow labels to end up in the correct category
3176 if for some reason it is not possible to derive the correct type from
3177 context. For example, to enable this feature for footnote and
3178 equation labels, use
3181 (setq reftex-trust-label-prefix '("fn:" "eq:"))
3185 @b{Automatic Document Scans}@*
3186 @cindex Automatic document scans
3187 @cindex Document scanning, automatic
3188 At rare occasions, @RefTeX{} will automatically rescan a part of the
3189 document. If this gets into your way, it can be turned off with
3191 @vindex reftex-allow-automatic-rescan
3193 (setq reftex-allow-automatic-rescan nil)
3196 @RefTeX{} will then occasionally annotate new labels in the selection
3197 buffer, saying that their position in the label list in uncertain. A
3198 manual document scan will fix this.
3201 @b{Multiple Selection Buffers}@*
3202 @cindex Multiple selection buffers
3203 @cindex Selection buffers, multiple
3204 Normally, the selection buffer @file{*RefTeX Select*} is re-created for
3205 every selection process. In documents with very many labels this can
3206 take several seconds. @RefTeX{} provides an option to create a
3207 separate selection buffer for each label type and to keep this buffer
3208 from one selection to the next. These buffers are updated automatically
3209 only when a new label has been added in the buffers category with
3210 @code{reftex-label}. Updating the buffer takes as long as recreating it
3211 - so the time saving is limited to cases where no new labels of that
3212 category have been added. To turn on this feature, use
3214 @vindex reftex-use-multiple-selection-buffers
3216 (setq reftex-use-multiple-selection-buffers t)
3220 @cindex Selection buffers, updating
3221 You can also inhibit the automatic updating entirely. Then the
3222 selection buffer will always pop up very fast, but may not contain the
3223 most recently defined labels. You can always update the buffer by hand,
3224 with the @kbd{g} key. To get this behavior, use instead
3226 @vindex reftex-auto-update-selection-buffers
3228 (setq reftex-use-multiple-selection-buffers t
3229 reftex-auto-update-selection-buffers nil)
3235 @b{As a summary}, here are the settings I recommend for heavy use of
3236 @RefTeX{} with large documents:
3240 (setq reftex-enable-partial-scans t
3241 reftex-save-parse-info t
3242 reftex-use-multiple-selection-buffers t)
3246 @node AUCTeX, Multifile Documents, Faces, Top
3248 @cindex @code{AUCTeX}, Emacs package
3249 @cindex Emacs packages, @code{AUCTeX}
3251 @AUCTeX{} is without doubt the best major mode for editing @TeX{} and @LaTeX{}
3252 files with Emacs (@pxref{Top,AUCTeX,,auctex, The AUCTeX User Manual}).
3253 If @AUCTeX{} is not part of your Emacs distribution, you can get
3254 it@footnote{XEmacs 21.x users may want to install the corresponding
3255 XEmacs package.} by FTP from the @value{AUCTEXSITE}.
3258 * AUCTeX-RefTeX Interface:: How both packages work together
3259 * Style Files:: @AUCTeX{}'s style files can support RefTeX
3260 * Bib-Cite:: Hypertext reading of a document
3263 @node AUCTeX-RefTeX Interface, Style Files, , AUCTeX
3264 @subsection The @AUCTeX{}-@RefTeX{} Interface
3266 @RefTeX{} contains code to interface with @AUCTeX{}. When this
3267 interface is turned on, both packages will interact closely. Instead of
3268 using @RefTeX{}'s commands directly, you can then also use them
3269 indirectly as part of the @AUCTeX{}
3270 environment@footnote{@RefTeX{} 4.0 and @AUCTeX{} 9.10c will be
3271 needed for all of this to work. Parts of it work also with earlier
3272 versions.}. The interface is turned on with
3275 (setq reftex-plug-into-AUCTeX t)
3278 If you need finer control about which parts of the interface are used
3279 and which not, read the docstring of the variable
3280 @code{reftex-plug-into-AUCTeX} or customize it with @kbd{M-x
3281 customize-variable @key{RET} reftex-plug-into-AUCTeX @key{RET}}.
3283 The following list describes the individual parts of the interface.
3287 @findex reftex-label
3288 @vindex LaTeX-label-function, @r{AUCTeX}
3291 @findex LaTeX-section, @r{AUCTeX}
3292 @findex TeX-insert-macro, @r{AUCTeX}
3293 @b{@AUCTeX{} calls @code{reftex-label} to insert labels}@*
3294 When a new section is created with @kbd{C-c C-s}, or a new environment
3295 is inserted with @kbd{C-c C-e}, @AUCTeX{} normally prompts for a label to
3296 go with it. With the interface, @code{reftex-label} is called instead.
3297 For example, if you type @kbd{C-c C-e equation @key{RET}}, @AUCTeX{} and
3298 @RefTeX{} will insert
3308 without further prompts.
3310 Similarly, when you type @kbd{C-c C-s section @key{RET}}, @RefTeX{}
3311 will offer its default label which is derived from the section title.
3314 @b{@AUCTeX{} tells @RefTeX{} about new sections}@*
3315 When creating a new section with @kbd{C-c C-s}, @RefTeX{} will not
3316 have to rescan the buffer in order to see it.
3319 @findex reftex-arg-label
3320 @findex TeX-arg-label, @r{AUCTeX function}
3321 @findex reftex-arg-ref
3322 @findex TeX-arg-ref, @r{AUCTeX function}
3323 @findex reftex-arg-cite
3324 @findex TeX-arg-cite, @r{AUCTeX function}
3325 @findex reftex-arg-index
3326 @findex TeX-arg-index, @r{AUCTeX function}
3327 @findex TeX-insert-macro, @r{AUCTeX function}
3328 @kindex C-c @key{RET}
3329 @b{@RefTeX{} supplies macro arguments}@* When you insert a macro
3330 interactively with @kbd{C-c @key{RET}}, @AUCTeX{} normally prompts for
3331 macro arguments. Internally, it uses the functions
3332 @code{TeX-arg-label}, @code{TeX-arg-cite}, and @code{TeX-arg-index} to
3333 prompt for arguments which are labels, citation keys and index entries.
3334 The interface takes over these functions@footnote{@code{fset} is used to
3335 do this, which is not reversible. However, @RefTeX{} implements the
3336 old functionality when you later decide to turn off the interface.} and
3337 supplies the macro arguments with @b{@RefTeX{}'s} mechanisms. For
3338 example, when you type @kbd{C-c @key{RET} ref @key{RET}}, @RefTeX{}
3339 will supply its label selection process (@pxref{Referencing
3343 @b{@RefTeX{} tells @AUCTeX{} about new labels, citation and index keys}@*
3344 @RefTeX{} will add all newly created labels to @AUCTeX{}'s completion list.
3347 @node Style Files, Bib-Cite, AUCTeX-RefTeX Interface, AUCTeX
3348 @subsection Style Files
3349 @cindex Style files, AUCTeX
3350 @findex TeX-add-style-hook, @r{AUCTeX}
3351 Style files are Emacs Lisp files which are evaluated by @AUCTeX{} in
3352 association with the @code{\documentclass} and @code{\usepackage}
3353 commands of a document (@pxref{Style Files,,,auctex}). Support for
3354 @RefTeX{} in such a style file is useful when the @LaTeX{} style
3355 defines macros or environments connected with labels, citations, or the
3356 index. Many style files (e.g. @file{amsmath.el} or @file{natbib.el})
3357 distributed with @AUCTeX{} already support @RefTeX{} in this
3360 Before calling a @RefTeX{} function, the style hook should always
3361 test for the availability of the function, so that the style file will
3362 also work for people who do not use @RefTeX{}.
3364 Additions made with style files in the way described below remain local
3365 to the current document. For example, if one package uses AMSTeX, the
3366 style file will make @RefTeX{} switch over to @code{\eqref}, but
3367 this will not affect other documents.
3369 @findex reftex-add-label-environments
3370 @findex reftex-add-to-label-alist
3371 A style hook may contain calls to
3372 @code{reftex-add-label-environments}@footnote{This used to be the
3373 function @code{reftex-add-to-label-alist} which is still available as an
3374 alias for compatibility.} which defines additions to
3375 @code{reftex-label-alist}. The argument taken by this function must have
3376 the same format as @code{reftex-label-alist}. The @file{amsmath.el}
3377 style file of @AUCTeX{} for example contains the following:
3381 (TeX-add-style-hook "amsmath"
3383 (if (fboundp 'reftex-add-label-environments)
3384 (reftex-add-label-environments '(AMSTeX)))))
3389 @findex LaTeX-add-environments, @r{AUCTeX}
3390 while a package @code{myprop} defining a @code{proposition} environment
3391 with @code{\newtheorem} might use
3395 (TeX-add-style-hook "myprop"
3397 (LaTeX-add-environments '("proposition" LaTeX-env-label))
3398 (if (fboundp 'reftex-add-label-environments)
3399 (reftex-add-label-environments
3400 '(("proposition" ?p "prop:" "~\\ref@{%s@}" t
3401 ("Proposition" "Prop.") -3))))))
3405 @findex reftex-set-cite-format
3406 Similarly, a style hook may contain a call to
3407 @code{reftex-set-cite-format} to set the citation format. The style
3408 file @file{natbib.el} for the Natbib citation style does switch
3409 @RefTeX{}'s citation format like this:
3412 (TeX-add-style-hook "natbib"
3414 (if (fboundp 'reftex-set-cite-format)
3415 (reftex-set-cite-format 'natbib))))
3418 @findex reftex-add-index-macros
3419 The hook may contain a call to @code{reftex-add-index-macros} to
3420 define additional @code{\index}-like macros. The argument must have
3421 the same format as @code{reftex-index-macros}. It may be a symbol, to
3422 trigger support for one of the builtin index packages. For example,
3423 the style @file{multind.el} contains
3426 (TeX-add-style-hook "multind"
3428 (and (fboundp 'reftex-add-index-macros)
3429 (reftex-add-index-macros '(multind)))))
3432 If you have your own package @file{myindex} which defines the
3433 following macros to be used with the @LaTeX{} @file{index.sty} file
3435 \newcommand@{\molec@}[1]@{#1\index@{Molecules!#1@}@}
3436 \newcommand@{\aindex@}[1]@{#1\index[author]@{#1@}
3439 you could write this in the style file @file{myindex.el}:
3442 (TeX-add-style-hook "myindex"
3445 '("molec" TeX-arg-index)
3446 '("aindex" TeX-arg-index))
3447 (if (fboundp 'reftex-add-index-macros)
3448 (reftex-add-index-macros
3449 '(("molec@{*@}" "idx" ?m "Molecules!" nil nil)
3450 ("aindex@{*@}" "author" ?a "" nil nil))))))
3453 @findex reftex-add-section-levels
3454 Finally the hook may contain a call to @code{reftex-add-section-levels}
3455 to define additional section statements. For example, the FoilTeX class
3456 has just two headers, @code{\foilhead} and @code{\rotatefoilhead}. Here
3457 is a style file @file{foils.el} that will inform @RefTeX{} about these:
3460 (TeX-add-style-hook "foils"
3462 (if (fboundp 'reftex-add-section-levels)
3463 (reftex-add-section-levels '(("foilhead" . 3)
3464 ("rotatefoilhead" . 3))))))
3467 @node Bib-Cite, , Style Files, AUCTeX
3468 @subsection Bib-Cite
3469 @cindex @code{bib-cite}, Emacs package
3470 @cindex Emacs packages, @code{bib-cite}
3472 Once you have written a document with labels, references and citations,
3473 it can be nice to read it like a hypertext document. @RefTeX{} has
3474 support for that: @code{reftex-view-crossref} (bound to @kbd{C-c
3475 &}), @code{reftex-mouse-view-crossref} (bound to @kbd{S-mouse-2}), and
3476 @code{reftex-search-document}. A somewhat fancier interface with mouse
3477 highlighting is provided (among other things) by Peter S. Galbraith's
3478 @file{bib-cite.el}. There is some overlap in the functionalities of
3479 Bib-cite and @RefTeX{}. Bib-cite.el comes bundled with
3482 Bib-cite version 3.06 and later can be configured so that bib-cite's
3483 mouse functions use @RefTeX{} for displaying references and citations.
3484 This can be useful in particular when working with the @LaTeX{} @code{xr}
3485 package or with an explicit @code{thebibliography} environment (rather
3486 than @BibTeX{}). Bib-cite cannot handle those, but @RefTeX{} does. To
3487 make use of this feature, try
3489 @vindex bib-cite-use-reftex-view-crossref
3491 (setq bib-cite-use-reftex-view-crossref t)
3495 @node Problems and Work-Arounds, Imprint, Optimizations, Top
3496 @section Problems and Work-arounds
3497 @cindex Problems and work-arounds
3501 @b{@LaTeX{} commands}@*
3502 @cindex LaTeX commands, not found
3503 @code{\input}, @code{\include}, and @code{\section} (etc.) statements
3504 have to be first on a line (except for white space).
3507 @b{Commented regions}@*
3508 @cindex Labels, commented out
3509 @RefTeX{} sees also labels in regions commented out and will refuse to
3510 make duplicates of such labels. This is considered to be a feature.
3513 @b{Wrong section numbers}@*
3514 @cindex Section numbers, wrong
3515 @vindex reftex-enable-partial-scans
3516 When using partial scans (@code{reftex-enable-partial-scans}), the section
3517 numbers in the table of contents may eventually become wrong. A full
3521 @b{Local settings}@*
3522 @cindex Settings, local
3523 @findex reftex-add-label-environments
3524 @findex reftex-set-cite-format
3525 @findex reftex-add-section-levels
3526 The label environment definitions in @code{reftex-label-alist} are
3527 global and apply to all documents. If you need to make definitions
3528 local to a document, because they would interfere with settings in other
3529 documents, you should use @AUCTeX{} and set up style files with calls to
3530 @code{reftex-add-label-environments}, @code{reftex-set-cite-format},
3531 @code{reftex-add-index-macros}, and @code{reftex-add-section-levels}.
3532 Settings made with these functions remain local to the current
3533 document. @xref{AUCTeX}.
3536 @b{Funny display in selection buffer}@*
3537 @cindex @code{x-symbol}, Emacs package
3538 @cindex Emacs packages, @code{x-symbol}
3539 @cindex @code{isotex}, Emacs package
3540 @cindex Emacs packages, @code{isotex}
3541 @cindex @code{iso-cvt}, Emacs package
3542 @cindex Emacs packages, @code{iso-cvt}
3543 When using packages which make the buffer representation of a file
3544 different from its disk representation (e.g. x-symbol, isotex,
3545 iso-cvt) you may find that @RefTeX{}'s parsing information sometimes
3546 reflects the disk state of a file. This happens only in @emph{unvisited}
3547 parts of a multifile document, because @RefTeX{} visits these files
3548 literally for speed reasons. Then both short context and section
3549 headings may look different from what you usually see on your screen.
3550 In rare cases @code{reftex-toc} may have problems to jump to an affected
3551 section heading. There are three possible ways to deal with
3555 @vindex reftex-keep-temporary-buffers
3556 @code{(setq reftex-keep-temporary-buffers t)}@*
3557 This implies that @RefTeX{} will load all parts of a multifile
3558 document into Emacs (i.e. there won't be any temporary buffers).
3560 @vindex reftex-initialize-temporary-buffers
3561 @code{(setq reftex-initialize-temporary-buffers t)}@*
3562 This means full initialization of temporary buffers. It involves
3563 a penalty when the same unvisited file is used for lookup often.
3565 Set @code{reftex-initialize-temporary-buffers} to a list of hook
3566 functions doing a minimal initialization.
3568 @vindex reftex-refontify-context
3569 See also the variable @code{reftex-refontify-context}.
3572 @b{Labels as arguments to \begin}@*
3573 @cindex @code{pf}, LaTeX package
3574 @cindex LaTeX packages, @code{pf}
3575 Some packages use an additional argument to a @code{\begin} macro
3576 to specify a label. E.g. Lamport's @file{pf.sty} uses both
3578 \step@{@var{label}@}@{@var{claim}@} and \begin@{step+@}@{@var{label}@}
3584 We need to trick @RefTeX{} into swallowing this:
3588 ;; Configuration for Lamport's pf.sty
3589 (setq reftex-label-alist
3590 '(("\\step@{*@}@{@}" ?p "st:" "~\\stepref@{%s@}" 2 ("Step" "St."))
3591 ("\\begin@{step+@}@{*@}" ?p "st:" "~\\stepref@{%s@}" 1000)))
3596 The first line is just a normal configuration for a macro. For the
3597 @code{step+} environment we actually tell @RefTeX{} to look for the
3598 @emph{macro} @samp{\begin@{step+@}} and interpret the @emph{first}
3599 argument (which really is a second argument to the macro @code{\begin})
3600 as a label of type @code{?p}. Argument count for this macro starts only
3601 after the @samp{@{step+@}}, also when specifying how to get
3605 @b{Idle timers in XEmacs}@*
3606 @cindex Idle timer restart
3607 @vindex reftex-use-itimer-in-xemacs
3608 In XEmacs, idle timer restart does not work reliably after fast
3609 keystrokes. Therefore @RefTeX{} currently uses the post command
3610 hook to start the timer used for automatic crossref information. When
3611 this bug gets fixed, a real idle timer can be requested with
3613 (setq reftex-use-itimer-in-xemacs t)
3619 @cindex Key bindings, problems with Viper mode
3620 @findex viper-harness-minor-mode
3621 With @i{Viper} mode prior to Vipers version 3.01, you need to protect
3622 @RefTeX{}'s keymaps with
3625 (viper-harness-minor-mode "reftex")
3631 @node Imprint, Commands, Problems and Work-Arounds, Top
3635 @cindex Acknowledgments
3638 @cindex @code{http}, @RefTeX{} home page
3639 @cindex @code{ftp}, @RefTeX{} site
3641 @RefTeX{} was written by @i{Carsten Dominik}
3642 @email{dominik@@science.uva.nl}, with contributions by @i{Stephen
3643 Eglen}. @RefTeX{} is currently maintained by @value{MAINTAINER}, see
3644 the @value{MAINTAINERSITE} for detailed information.
3646 If you have questions about @RefTeX{}, you can send email to the
3647 @value{SUPPORTADDRESS}. If you want to contribute code or ideas, write
3648 to the @value{DEVELADDRESS}. And in the rare case of finding a bug,
3649 please use @kbd{M-x reftex-report-bug @key{RET}} which will prepare a
3650 bug report with useful information about your setup. Remember to add
3651 essential information like a recipe for reproducing the bug, what you
3652 expected to happen, and what actually happened. Send the bug report to
3653 the @value{BUGADDRESS}.
3655 There are also several Usenet groups which have competent readers who
3656 might be able to help: @code{comp.emacs}, @code{gnu.emacs.help},
3657 @code{comp.emacs.xemacs}, and @code{comp.text.tex}.
3659 Thanks to the people on the Net who have used @RefTeX{} and helped
3660 developing it with their reports. In particular thanks to @i{Ralf
3661 Angeli, Fran Burstall, Alastair Burt, Lars Clausen, Soren Dayton,
3662 Stephen Eglen, Karl Eichwalder, Erik Frisk, Peter Galbraith, Kai
3663 Grossjohann, Frank Harrell, Till A. Heilmann, Peter Heslin, Stephan
3664 Heuel, Alan Ho, Lute Kamstra, Dieter Kraft, David Kastrup, Adrian Lanz,
3665 Juri Linkov, Wolfgang Mayer, Rory Molinari, Stefan Monnier, Laurent
3666 Mugnier, Dan Nicolaescu, Sudeep Kumar Palat, Daniel Polani, Alan Shutko,
3667 Robin Socha, Richard Stanton, Allan Strand, Jan Vroonhof, Christoph
3668 Wedler, Alan Williams, Roland Winkler, Hans-Christoph Wirth, Eli
3671 The @code{view-crossref} feature was inspired by @i{Peter Galbraith's}
3674 Finally thanks to @i{Uwe Bolick} who first got me interested in
3675 supporting @LaTeX{} labels and references with an editor (which was
3676 MicroEmacs at the time).
3678 @node Commands, Options, Imprint, Top
3680 @cindex Commands, list of
3682 Here is a summary of @RefTeX{}'s commands which can be executed from
3683 @LaTeX{} files. Command which are executed from the special buffers are
3684 not described here. All commands are available from the @code{Ref}
3685 menu. See @xref{Key Bindings}.
3687 @deffn Command reftex-toc
3688 Show the table of contents for the current document. When called with
3689 one ore two @kbd{C-u} prefixes, rescan the document first.
3692 @deffn Command reftex-label
3693 Insert a unique label. With one or two @kbd{C-u} prefixes, enforce
3694 document rescan first.
3697 @deffn Command reftex-reference
3698 Start a selection process to select a label, and insert a reference to
3699 it. With one or two @kbd{C-u} prefixes, enforce document rescan first.
3702 @deffn Command reftex-citation
3703 Make a citation using @BibTeX{} database files. After prompting for a regular
3704 expression, scans the buffers with @BibTeX{} entries (taken from the
3705 @code{\bibliography} command or a @code{thebibliography} environment)
3706 and offers the matching entries for selection. The selected entry is
3707 formatted according to @code{reftex-cite-format} and inserted into the
3709 When called with a @kbd{C-u} prefix, prompt for optional arguments in
3710 cite macros. When called with a numeric prefix, make that many citations.
3711 When called with point inside the braces of a @code{\cite} command, it
3712 will add another key, ignoring the value of
3713 @code{reftex-cite-format}. @*
3714 The regular expression uses an expanded syntax: @samp{&&} is interpreted
3715 as @code{and}. Thus, @samp{aaaa&&bbb} matches entries which contain
3716 both @samp{aaaa} and @samp{bbb}. While entering the regexp, completion
3717 on knows citation keys is possible. @samp{=} is a good regular
3718 expression to match all entries in all files.
3721 @deffn Command reftex-index
3722 Query for an index macro and insert it along with its arguments. The
3723 index macros available are those defined in @code{reftex-index-macro} or
3724 by a call to @code{reftex-add-index-macros}, typically from an @AUCTeX{}
3725 style file. @RefTeX{} provides completion for the index tag and the
3726 index key, and will prompt for other arguments.
3729 @deffn Command reftex-index-selection-or-word
3730 Put current selection or the word near point into the default index
3731 macro. This uses the information in @code{reftex-index-default-macro}
3732 to make an index entry. The phrase indexed is the current selection or
3733 the word near point. When called with one @kbd{C-u} prefix, let the
3734 user have a chance to edit the index entry. When called with 2
3735 @kbd{C-u} as prefix, also ask for the index macro and other stuff. When
3736 called inside @TeX{} math mode as determined by the @file{texmathp.el}
3737 library which is part of @AUCTeX{}, the string is first processed with the
3738 @code{reftex-index-math-format}, which see.
3741 @deffn Command reftex-index-phrase-selection-or-word
3742 Add current selection or the word at point to the phrases buffer.
3743 When you are in transient-mark-mode and the region is active, the
3744 selection will be used - otherwise the word at point.
3745 You get a chance to edit the entry in the phrases buffer - to save the
3746 buffer and return to the @LaTeX{} document, finish with @kbd{C-c C-c}.
3749 @deffn Command reftex-index-visit-phrases-buffer
3750 Switch to the phrases buffer, initialize if empty.
3753 @deffn Command reftex-index-phrases-apply-to-region
3754 Index all index phrases in the current region.
3755 This works exactly like global indexing from the index phrases buffer,
3756 but operation is restricted to the current region.
3759 @deffn Command reftex-display-index
3760 Display a buffer with an index compiled from the current document.
3761 When the document has multiple indices, first prompts for the correct one.
3762 When index support is turned off, offer to turn it on.
3763 With one or two @kbd{C-u} prefixes, rescan document first.
3764 With prefix 2, restrict index to current document section.
3765 With prefix 3, restrict index to active region.
3768 @deffn Command reftex-view-crossref
3769 View cross reference of macro at point. Point must be on the @var{key}
3770 argument. Works with the macros @code{\label}, @code{\ref},
3771 @code{\cite}, @code{\bibitem}, @code{\index} and many derivatives of
3772 these. Where it makes sense, subsequent calls show additional
3773 locations. See also the variable @code{reftex-view-crossref-extra} and
3774 the command @code{reftex-view-crossref-from-bibtex}. With one or two
3775 @kbd{C-u} prefixes, enforce rescanning of the document. With argument
3776 2, select the window showing the cross reference.
3779 @deffn Command reftex-view-crossref-from-bibtex
3780 View location in a @LaTeX{} document which cites the @BibTeX{} entry at point.
3781 Since @BibTeX{} files can be used by many @LaTeX{} documents, this function
3782 prompts upon first use for a buffer in @RefTeX{} mode. To reset this
3783 link to a document, call the function with a prefix arg. Calling
3784 this function several times find successive citation locations.
3787 @deffn Command reftex-create-tags-file
3788 Create TAGS file by running @code{etags} on the current document. The
3789 TAGS file is also immediately visited with
3790 @code{visit-tags-table}.
3793 @deffn Command reftex-grep-document
3794 Run grep query through all files related to this document.
3795 With prefix arg, force to rescan document.
3796 No active TAGS table is required.
3799 @deffn Command reftex-search-document
3800 Regexp search through all files of the current document.
3801 Starts always in the master file. Stops when a match is found.
3802 No active TAGS table is required.
3805 @deffn Command reftex-query-replace-document
3806 Run a query-replace-regexp of @var{from} with @var{to} over the entire
3807 document. With prefix arg, replace only word-delimited matches. No
3808 active TAGS table is required.
3811 @deffn Command reftex-isearch-minor-mode
3812 Toggle a minor mode which enables incremental search to work globally
3813 on the entire multifile document. Files will be searched in the
3814 sequence they appear in the document.
3817 @deffn Command reftex-goto-label
3818 Prompt for a label (with completion) and jump to the location of this
3819 label. Optional prefix argument @var{other-window} goes to the label in
3824 @deffn Command reftex-change-label
3825 Query replace @var{from} with @var{to} in all @code{\label} and
3826 @code{\ref} commands. Works on the entire multifile document. No
3827 active TAGS table is required.
3830 @deffn Command reftex-renumber-simple-labels
3831 Renumber all simple labels in the document to make them sequentially.
3832 Simple labels are the ones created by RefTeX, consisting only of the
3833 prefix and a number. After the command completes, all these labels will
3834 have sequential numbers throughout the document. Any references to the
3835 labels will be changed as well. For this, @RefTeX{} looks at the
3836 arguments of any macros which either start or end with the string
3837 @samp{ref}. This command should be used with care, in particular in
3838 multifile documents. You should not use it if another document refers
3839 to this one with the @code{xr} package.
3842 @deffn Command reftex-find-duplicate-labels
3843 Produce a list of all duplicate labels in the document.
3846 @deffn Command reftex-create-bibtex-file
3847 @vindex reftex-create-bibtex-header
3848 @vindex reftex-create-bibtex-footer
3849 Create a new @BibTeX{} database file with all entries referenced in
3850 document. The command prompts for a filename and writes the collected
3851 entries to that file. Only entries referenced in the current document
3852 with any @code{\cite}-like macros are used. The sequence in the new
3853 file is the same as it was in the old database.
3855 Entries referenced from other entries must appear after all referencing
3858 You can define strings to be used as header or footer for the created
3859 files in the variables @code{reftex-create-bibtex-header} or
3860 @code{reftex-create-bibtex-footer} respectively.
3863 @deffn Command reftex-customize
3864 Run the customize browser on the @RefTeX{} group.
3866 @deffn Command reftex-show-commentary
3867 Show the commentary section from @file{reftex.el}.
3869 @deffn Command reftex-info
3870 Run info on the top @RefTeX{} node.
3872 @deffn Command reftex-parse-document
3873 Parse the entire document in order to update the parsing information.
3875 @deffn Command reftex-reset-mode
3876 Enforce rebuilding of several internal lists and variables. Also
3877 removes the parse file associated with the current document.
3880 @node Options, Keymaps and Hooks, Commands, Top
3881 @chapter Options, Keymaps, Hooks
3882 @cindex Options, list of
3884 Here is a complete list of @RefTeX{}'s configuration variables. All
3885 variables have customize support - so if you are not familiar with Emacs
3886 Lisp (and even if you are) you might find it more comfortable to use
3887 @code{customize} to look at and change these variables. @kbd{M-x
3888 reftex-customize} will get you there.
3891 * Options (Table of Contents)::
3892 * Options (Defining Label Environments)::
3893 * Options (Creating Labels)::
3894 * Options (Referencing Labels)::
3895 * Options (Creating Citations)::
3896 * Options (Index Support)::
3897 * Options (Viewing Cross-References)::
3898 * Options (Finding Files)::
3899 * Options (Optimizations)::
3900 * Options (Fontification)::
3904 @node Options (Table of Contents), Options (Defining Label Environments), , Options
3905 @section Table of Contents
3906 @cindex Options, table of contents
3907 @cindex Table of contents, options
3909 @defopt reftex-include-file-commands
3910 List of @LaTeX{} commands which input another file.
3911 The file name is expected after the command, either in braces or separated
3915 @defopt reftex-max-section-depth
3916 Maximum depth of section levels in document structure.
3917 Standard @LaTeX{} needs 7, default is 12.
3920 @defopt reftex-section-levels
3921 Commands and levels used for defining sections in the document. The
3922 @code{car} of each cons cell is the name of the section macro. The
3923 @code{cdr} is a number indicating its level. A negative level means the
3924 same as the positive value, but the section will never get a number.
3925 The @code{cdr} may also be a function which then has to return the
3926 level. This list is also used for promotion and demotion of sectioning
3927 commands. If you are using a document class which has several sets of
3928 sectioning commands, promotion only works correctly if this list is
3929 sorted first by set, then within each set by level. The promotion
3930 commands always select the nearest entry with the correct new level.
3934 @defopt reftex-toc-max-level
3935 The maximum level of toc entries which will be included in the TOC.
3936 Section headings with a bigger level will be ignored. In RefTeX,
3937 chapters are level 1, sections level 2 etc. This variable can be
3938 changed from within the @file{*toc*} buffer with the @kbd{t} key.
3941 @defopt reftex-part-resets-chapter
3942 Non-@code{nil} means, @code{\part} is like any other sectioning command.
3943 This means, part numbers will be included in the numbering of chapters, and
3944 chapter counters will be reset for each part.
3945 When @code{nil} (the default), parts are special, do not reset the
3946 chapter counter and also do not show up in chapter numbers.
3949 @defopt reftex-auto-recenter-toc
3950 Non-@code{nil} means, turn automatic recentering of @file{*TOC*} window on.
3951 When active, the @file{*TOC*} window will always show the section you
3952 are currently working in. Recentering happens whenever Emacs is idle for
3953 more than @code{reftex-idle-time} seconds.
3955 Value @code{t} means, turn on immediately when RefTeX gets started. Then,
3956 recentering will work for any toc window created during the session.
3958 Value @code{frame} (the default) means, turn automatic recentering on
3959 only while the dedicated TOC frame does exist, and do the recentering
3960 only in that frame. So when creating that frame (with @kbd{d} key in an
3961 ordinary TOC window), the automatic recentering is turned on. When the
3962 frame gets destroyed, automatic recentering is turned off again.
3964 This feature can be turned on and off from the menu
3968 @defopt reftex-toc-split-windows-horizontally
3969 Non-@code{nil} means, create TOC window by splitting window
3970 horizontally. The default is to split vertically.
3973 @defopt reftex-toc-split-windows-fraction
3974 Fraction of the width or height of the frame to be used for TOC window.
3977 @defopt reftex-toc-keep-other-windows
3978 Non-@code{nil} means, split the selected window to display the
3979 @file{*toc*} buffer. This helps to keep the window configuration, but
3980 makes the @file{*toc*} small. When @code{nil}, all other windows except
3981 the selected one will be deleted, so that the @file{*toc*} window fills
3985 @defopt reftex-toc-include-file-boundaries
3986 Non-@code{nil} means, include file boundaries in @file{*toc*} buffer.
3987 This flag can be toggled from within the @file{*toc*} buffer with the
3991 @defopt reftex-toc-include-labels
3992 Non-@code{nil} means, include labels in @file{*toc*} buffer. This flag
3993 can be toggled from within the @file{*toc*} buffer with the @kbd{l}
3997 @defopt reftex-toc-include-index-entries
3998 Non-@code{nil} means, include index entries in @file{*toc*} buffer.
3999 This flag can be toggled from within the @file{*toc*} buffer with the
4003 @defopt reftex-toc-include-context
4004 Non-@code{nil} means, include context with labels in the @file{*toc*}
4005 buffer. Context will only be shown if the labels are visible as well.
4006 This flag can be toggled from within the @file{*toc*} buffer with the
4010 @defopt reftex-toc-follow-mode
4011 Non-@code{nil} means, point in @file{*toc*} buffer (the
4012 table-of-contents buffer) will cause other window to follow. The other
4013 window will show the corresponding part of the document. This flag can
4014 be toggled from within the @file{*toc*} buffer with the @kbd{f}
4018 @deffn {Normal Hook} reftex-toc-mode-hook
4019 Normal hook which is run when a @file{*toc*} buffer is
4023 @deffn Keymap reftex-toc-map
4024 The keymap which is active in the @file{*toc*} buffer.
4025 (@pxref{Table of Contents}).
4028 @node Options (Defining Label Environments), Options (Creating Labels), Options (Table of Contents), Options
4029 @section Defining Label Environments
4030 @cindex Options, defining label environments
4031 @cindex Defining label environments, options
4033 @defopt reftex-default-label-alist-entries
4034 Default label alist specifications. It is a list of symbols with
4035 associations in the constant @code{reftex-label-alist-builtin}.
4036 @code{LaTeX} should always be the last entry.
4039 @defopt reftex-label-alist
4040 Set this variable to define additions and changes to the defaults in
4041 @code{reftex-default-label-alist-entries}. The only things you
4042 @emph{must not} change is that @code{?s} is the type indicator for
4043 section labels, and @key{SPC} for the @code{any} label type. These are
4044 hard-coded at other places in the code.
4046 The value of the variable must be a list of items. Each item is a list
4047 itself and has the following structure:
4050 (@var{env-or-macro} @var{type-key} @var{label-prefix} @var{reference-format}
4051 @var{context-method} (@var{magic-word} ... ) @var{toc-level})
4054 Each list entry describes either an environment carrying a counter for
4055 use with @code{\label} and @code{\ref}, or a @LaTeX{} macro defining a
4056 label as (or inside) one of its arguments. The elements of each list
4060 @item @var{env-or-macro}
4061 Name of the environment (like @samp{table}) or macro (like
4062 @samp{\myfig}). For macros, indicate the arguments, as in
4063 @samp{\myfig[]@{@}@{@}@{*@}@{@}}. Use square brackets for optional
4064 arguments, a star to mark the label argument, if any. The macro does
4065 not have to have a label argument - you could also use
4066 @samp{\label@{...@}} inside one of its arguments.
4068 Special names: @code{section} for section labels, @code{any} to define a
4069 group which contains all labels.
4071 This may also be a function to do local parsing and identify point to be
4072 in a non-standard label environment. The function must take an
4073 argument @var{bound} and limit backward searches to this value. It
4074 should return either nil or a cons cell @code{(@var{function}
4075 . @var{position})} with the function symbol and the position where the
4076 special environment starts. See the Info documentation for an
4079 Finally this may also be @code{nil} if the entry is only meant to change
4080 some settings associated with the type indicator character (see
4083 @item @var{type-key}
4084 Type indicator character, like @code{?t}, must be a printable ASCII
4085 character. The type indicator is a single character which defines a
4086 label type. Any label inside the environment or macro is assumed to
4087 belong to this type. The same character may occur several times in this
4088 list, to cover cases in which different environments carry the same
4089 label type (like @code{equation} and @code{eqnarray}). If the type
4090 indicator is @code{nil} and the macro has a label argument @samp{@{*@}},
4091 the macro defines neutral labels just like @code{\label}. In this case
4092 the remainder of this entry is ignored.
4094 @item @var{label-prefix}
4095 Label prefix string, like @samp{tab:}. The prefix is a short string
4096 used as the start of a label. It may be the empty string. The prefix
4097 may contain the following @samp{%} escapes:
4100 %f Current file name, directory and extension stripped.
4101 %F Current file name relative to master file directory.
4102 %m Master file name, directory and extension stripped.
4103 %M Directory name (without path) where master file is located.
4104 %u User login name, on systems which support this.
4105 %S A section prefix derived with variable @code{reftex-section-prefixes}.
4109 Example: In a file @file{intro.tex}, @samp{eq:%f:} will become
4112 @item @var{reference-format}
4113 Format string for reference insertion in buffer. @samp{%s} will be
4114 replaced by the label. When the format starts with @samp{~}, this
4115 @samp{~} will only be inserted when the character before point is
4116 @emph{not} a whitespace.
4118 @item @var{context-method}
4119 Indication on how to find the short context.
4122 If @code{nil}, use the text following the @samp{\label@{...@}} macro.
4127 the section heading for section labels.
4129 text following the @samp{\begin@{...@}} statement of environments (not
4130 a good choice for environments like eqnarray or enumerate, where one has
4131 several labels in a single environment).
4133 text after the macro name (starting with the first arg) for
4137 If an integer, use the nth argument of the macro. As a special case,
4138 1000 means to get text after the last macro argument.
4140 If a string, use as regexp to search @emph{backward} from the label.
4141 Context is then the text following the end of the match. E.g. setting
4142 this to @samp{\\caption[[@{]} will use the caption in a figure or table
4143 environment. @samp{\\begin@{eqnarray@}\|\\\\} works for
4146 If any of @code{caption}, @code{item}, @code{eqnarray-like},
4147 @code{alignat-like}, this symbol will internally be translated into an
4148 appropriate regexp (see also the variable
4149 @code{reftex-default-context-regexps}).
4151 If a function, call this function with the name of the environment/macro
4152 as argument. On call, point will be just after the @code{\label} macro.
4153 The function is expected to return a suitable context string. It should
4154 throw an exception (error) when failing to find context. As an example,
4155 here is a function returning the 10 chars following the label macro as
4159 (defun my-context-function (env-or-mac)
4160 (if (> (point-max) (+ 10 (point)))
4161 (buffer-substring (point) (+ 10 (point)))
4162 (error "Buffer too small")))
4166 Label context is used in two ways by @RefTeX{}: For display in the label
4167 menu, and to derive a label string. If you want to use a different
4168 method for each of these, specify them as a dotted pair.
4169 E.g. @code{(nil . t)} uses the text after the label (@code{nil}) for
4170 display, and text from the default position (@code{t}) to derive a label
4171 string. This is actually used for section labels.
4173 @item @var{magic-word-list}
4174 List of magic words which identify a reference to be of this type. If
4175 the word before point is equal to one of these words when calling
4176 @code{reftex-reference}, the label list offered will be automatically
4177 restricted to labels of the correct type. If the first element of this
4178 word list is the symbol `regexp', the strings are interpreted as regular
4181 @item @var{toc-level}
4182 The integer level at which this environment should be added to the table
4183 of contents. See also @code{reftex-section-levels}. A positive value
4184 will number the entries mixed with the sectioning commands of the same
4185 level. A negative value will make unnumbered entries. Useful only for
4186 theorem-like environments which structure the document. Will be ignored
4187 for macros. When omitted or @code{nil}, no TOC entries will be
4191 If the type indicator characters of two or more entries are the same,
4195 the first non-@code{nil} format and prefix
4197 the magic words of all involved entries.
4200 Any list entry may also be a symbol. If that has an association in
4201 @code{reftex-label-alist-builtin}, the @code{cddr} of that association is
4202 spliced into the list. However, builtin defaults should normally be set
4203 with the variable @code{reftex-default-label-alist-entries}.
4206 @defopt reftex-section-prefixes
4207 Prefixes for section labels. When the label prefix given in an entry in
4208 @code{reftex-label-alist} contains @samp{%S}, this list is used to
4209 determine the correct prefix string depending on the current section
4210 level. The list is an alist, with each entry of the form
4211 @w{@code{(@var{key} . @var{prefix})}}. Possible keys are sectioning macro
4212 names like @samp{chapter}, integer section levels (as given in
4213 @code{reftex-section-levels}), and @code{t} for the default.
4216 @defopt reftex-default-context-regexps
4217 Alist with default regular expressions for finding context. The emacs
4218 lisp form @w{@code{(format regexp (regexp-quote environment))}} is used
4219 to calculate the final regular expression - so @samp{%s} will be
4220 replaced with the environment or macro.
4223 @defopt reftex-trust-label-prefix
4224 Non-@code{nil} means, trust the label prefix when determining label type.
4225 It is customary to use special label prefixes to distinguish different label
4226 types. The label prefixes have no syntactic meaning in @LaTeX{} (unless
4227 special packages like fancyref) are being used. RefTeX can and by
4228 default does parse around each label to detect the correct label type,
4229 but this process can be slow when a document contains thousands of
4230 labels. If you use label prefixes consistently, you may speed up
4231 document parsing by setting this variable to a non-nil value. RefTeX
4232 will then compare the label prefix with the prefixes found in
4233 `reftex-label-alist' and derive the correct label type in this way.
4234 Possible values for this option are:
4237 t @r{This means to trust any label prefixes found.}
4238 regexp @r{If a regexp, only prefixes matched by the regexp are trusted.}
4239 list @r{List of accepted prefixes, as strings. The colon is part of}
4240 @r{the prefix, e.g. ("fn:" "eqn:" "item:").}
4241 nil @r{Never trust a label prefix.}
4243 The only disadvantage of using this feature is that the label context
4244 displayed in the label selection buffer along with each label is
4245 simply some text after the label definition. This is no problem if you
4246 place labels keeping this in mind (e.g. @i{before} the equation, @i{at
4247 the beginning} of a fig/tab caption ...). Anyway, it is probably best
4248 to use the regexp or the list value types to fine-tune this feature.
4249 For example, if your document contains thousands of footnotes with
4250 labels fn:xxx, you may want to set this variable to the value "^fn:$" or
4251 ("fn:"). Then RefTeX will still do extensive parsing for any
4252 non-footnote labels.
4255 @node Options (Creating Labels), Options (Referencing Labels), Options (Defining Label Environments), Options
4256 @section Creating Labels
4257 @cindex Options, creating labels
4258 @cindex Creating labels, options
4260 @defopt reftex-insert-label-flags
4261 Flags governing label insertion. The value has the form
4264 (@var{derive} @var{prompt})
4267 If @var{derive} is @code{t}, @RefTeX{} will try to derive a sensible
4268 label from context. A section label for example will be derived from
4269 the section heading. The conversion of the context to a valid label is
4270 governed by the specifications given in
4271 @code{reftex-derive-label-parameters}. If @var{derive} is @code{nil},
4272 the default label will consist of the prefix and a unique number, like
4275 If @var{prompt} is @code{t}, the user will be prompted for a label
4276 string. When @var{prompt} is @code{nil}, the default label will be
4277 inserted without query.
4279 So the combination of @var{derive} and @var{prompt} controls label
4280 insertion. Here is a table describing all four possibilities:
4284 @var{derive} @var{prompt} @var{action}
4285 -----------------------------------------------------------
4286 nil nil @r{Insert simple label, like @samp{eq:22} or @samp{sec:13}. No query.}
4287 nil t @r{Prompt for label.}
4288 t nil @r{Derive a label from context and insert. No query.}
4289 t t @r{Derive a label from context, prompt for confirmation.}
4293 Each flag may be set to @code{t}, @code{nil}, or a string of label type
4294 letters indicating the label types for which it should be true. Thus,
4295 the combination may be set differently for each label type. The default
4296 settings @samp{"s"} and @samp{"sft"} mean: Derive section labels from
4297 headings (with confirmation). Prompt for figure and table labels. Use
4298 simple labels without confirmation for everything else.
4300 The available label types are: @code{s} (section), @code{f} (figure),
4301 @code{t} (table), @code{i} (item), @code{e} (equation), @code{n}
4302 (footnote), @code{N} (endnote) plus any definitions in
4303 @code{reftex-label-alist}.
4306 @deffn Hook reftex-format-label-function
4307 If non-@code{nil}, should be a function which produces the string to
4308 insert as a label definition. The function will be called with two
4309 arguments, the @var{label} and the @var{default-format} (usually
4310 @samp{\label@{%s@}}). It should return the string to insert into the
4314 @deffn Hook reftex-string-to-label-function
4315 Function to turn an arbitrary string into a valid label.
4316 @RefTeX{}'s default function uses the variable
4317 @code{reftex-derive-label-parameters}.
4320 @deffn Hook reftex-translate-to-ascii-function
4321 Filter function which will process a context string before it is used to
4322 derive a label from it. The intended application is to convert ISO or
4323 Mule characters into something valid in labels. The default function
4324 @code{reftex-latin1-to-ascii} removes the accents from Latin-1
4325 characters. X-Symbol (>=2.6) sets this variable to the much more
4326 general @code{x-symbol-translate-to-ascii}.
4329 @defopt reftex-derive-label-parameters
4330 Parameters for converting a string into a label. This variable is a
4331 list of the following items:
4334 Number of words to use.
4336 Maximum number of characters in a label string.
4338 @code{nil}: Throw away any words containing characters invalid in labels.@*
4339 @code{t}: Throw away only the invalid characters, not the whole word.
4341 @code{nil}: Never abbreviate words.@*
4342 @code{t}: Always abbreviate words (see @code{reftex-abbrev-parameters}).@*
4343 @code{1}: Abbreviate words if necessary to shorten label string.
4344 @item @var{separator}
4345 String separating different words in the label.
4346 @item @var{ignorewords}
4347 List of words which should not be part of labels.
4348 @item @var{downcase}
4349 @code{t}: Downcase words before putting them into the label.@*
4353 @defopt reftex-label-illegal-re
4354 Regexp matching characters not valid in labels.
4357 @defopt reftex-abbrev-parameters
4358 Parameters for abbreviation of words. A list of four parameters.
4360 @item @var{min-chars}
4361 Minimum number of characters remaining after abbreviation.
4362 @item @var{min-kill}
4363 Minimum number of characters to remove when abbreviating words.
4365 Character class before abbrev point in word.
4367 Character class after abbrev point in word.
4371 @node Options (Referencing Labels), Options (Creating Citations), Options (Creating Labels), Options
4372 @section Referencing Labels
4373 @cindex Options, referencing labels
4374 @cindex Referencing labels, options
4376 @defopt reftex-label-menu-flags
4377 List of flags governing the label menu makeup. The flags are:
4379 @item @var{table-of-contents}
4380 Show the labels embedded in a table of context.
4381 @item @var{section-numbers}
4382 Include section numbers (like 4.1.3) in table of contents.
4383 @item @var{counters}
4384 Show counters. This just numbers the labels in the menu.
4385 @item @var{no-context}
4386 Non-@code{nil} means do @emph{not} show the short context.
4388 Follow full context in other window.
4389 @item @var{show-commented}
4390 Show labels from regions which are commented out.
4391 @item @var{match-everywhere}
4393 @item @var{show-files}
4394 Show begin and end of included files.
4397 Each of these flags can be set to @code{t} or @code{nil}, or to a string
4398 of type letters indicating the label types for which it should be true.
4399 These strings work like character classes in regular expressions. Thus,
4400 setting one of the flags to @samp{"sf"} makes the flag true for section
4401 and figure labels, @code{nil} for everything else. Setting it to
4402 @samp{"^sf"} makes it the other way round.
4404 The available label types are: @code{s} (section), @code{f} (figure),
4405 @code{t} (table), @code{i} (item), @code{e} (equation), @code{n}
4406 (footnote), plus any definitions in @code{reftex-label-alist}.
4408 Most options can also be switched from the label menu itself - so if you
4409 decide here to not have a table of contents in the label menu, you can
4410 still get one interactively during selection from the label menu.
4413 @defopt reftex-multiref-punctuation
4414 Punctuation strings for multiple references. When marking is used in
4415 the selection buffer to select several references, this variable
4416 associates the 3 marking characters @samp{,-+} with prefix strings to be
4417 inserted into the buffer before the corresponding @code{\ref} macro.
4418 This is used to string together whole reference sets, like
4419 @samp{eqs. 1,2,3-5,6 and 7} in a single call to
4420 @code{reftex-reference}.
4423 @defopt reftex-ref-style-alist
4424 Alist of reference styles. Each element is a list of the style name,
4425 the name of the @LaTeX{} package associated with the style or @code{t}
4426 for any package, and an alist of macros where the first entry of each
4427 item is the reference macro and the second a key for selecting the macro
4428 when the macro type is being prompted for. (See also
4429 @code{reftex-ref-macro-prompt}.) The keys, represented as characters,
4433 @defopt reftex-ref-style-default-list
4434 List of reference styles to be activated by default. The order is
4435 significant and controls the order in which macros can be cycled in the
4436 buffer for selecting a label. The entries in the list have to match the
4437 respective reference style names used in the variable
4438 @code{reftex-ref-style-alist}.
4441 @defopt reftex-ref-macro-prompt
4442 Controls if @code{reftex-reference} prompts for the reference macro.
4445 @deffn Hook reftex-format-ref-function
4446 If non-@code{nil}, should be a function which produces the string to
4447 insert as a reference. Note that the insertion format can also be
4448 changed with @code{reftex-label-alist}. This hook also is used by the
4449 special commands to insert e.g. @code{\vref} and @code{\fref}
4450 references, so even if you set this, your setting will be ignored by the
4451 special commands. The function will be called with three arguments, the
4452 @var{label}, the @var{default format} which normally is
4453 @samp{~\ref@{%s@}} and the @var{reference style}. The function should
4454 return the string to insert into the buffer.
4457 @defopt reftex-level-indent
4458 Number of spaces to be used for indentation per section level.
4461 @defopt reftex-guess-label-type
4462 Non-@code{nil} means, @code{reftex-reference} will try to guess the
4463 label type. To do that, @RefTeX{} will look at the word before the
4464 cursor and compare it with the magic words given in
4465 @code{reftex-label-alist}. When it finds a match, @RefTeX{} will
4466 immediately offer the correct label menu - otherwise it will prompt you
4467 for a label type. If you set this variable to @code{nil}, @RefTeX{}
4468 will always prompt for a label type.
4471 @deffn {Normal Hook} reftex-display-copied-context-hook
4472 Normal Hook which is run before context is displayed anywhere. Designed
4473 for @w{@code{X-Symbol}}, but may have other uses as well.
4476 @deffn Hook reftex-pre-refontification-functions
4477 @code{X-Symbol} specific hook. Probably not useful for other purposes.
4478 The functions get two arguments, the buffer from where the command
4479 started and a symbol indicating in what context the hook is
4483 @deffn {Normal Hook} reftex-select-label-mode-hook
4484 Normal hook which is run when a selection buffer enters
4485 @code{reftex-select-label-mode}.
4488 @deffn Keymap reftex-select-label-map
4489 The keymap which is active in the labels selection process
4490 (@pxref{Referencing Labels}).
4493 @node Options (Creating Citations), Options (Index Support), Options (Referencing Labels), Options
4494 @section Creating Citations
4495 @cindex Options, creating citations
4496 @cindex Creating citations, options
4498 @defopt reftex-bibliography-commands
4499 @LaTeX{} commands which specify the @BibTeX{} databases to use with the document.
4502 @defopt reftex-bibfile-ignore-regexps
4503 List of regular expressions to exclude files in
4504 @code{\\bibliography@{..@}}. File names matched by any of these regexps
4505 will not be parsed. Intended for files which contain only
4506 @code{@@string} macro definitions and the like, which are ignored by
4510 @defopt reftex-default-bibliography
4511 List of @BibTeX{} database files which should be used if none are specified.
4512 When @code{reftex-citation} is called from a document with neither
4513 a @samp{\bibliography@{...@}} statement nor a @code{thebibliography}
4514 environment, @RefTeX{} will scan these files instead. Intended for
4515 using @code{reftex-citation} in non-@LaTeX{} files. The files will be
4516 searched along the BIBINPUTS or TEXBIB path.
4519 @defopt reftex-sort-bibtex-matches
4520 Sorting of the entries found in @BibTeX{} databases by reftex-citation.
4523 nil @r{Do not sort entries.}
4524 author @r{Sort entries by author name.}
4525 year @r{Sort entries by increasing year.}
4526 reverse-year @r{Sort entries by decreasing year.}
4530 @defopt reftex-cite-format
4531 The format of citations to be inserted into the buffer. It can be a
4532 string, an alist or a symbol. In the simplest case this is just the string
4533 @samp{\cite@{%l@}}, which is also the default. See the definition of
4534 @code{reftex-cite-format-builtin} for more complex examples.
4536 If @code{reftex-cite-format} is a string, it will be used as the format.
4537 In the format, the following percent escapes will be expanded.
4541 The @BibTeX{} label of the citation.
4543 List of author names, see also @code{reftex-cite-punctuation}.
4545 Like %a, but abbreviate more than 2 authors like Jones et al.
4547 First author name only.
4549 Works like @samp{%a}, but on list of editor names. (@samp{%2e} and
4550 @samp{%E} work a well).
4553 It is also possible to access all other @BibTeX{} database fields:
4556 %b booktitle %c chapter %d edition %h howpublished
4557 %i institution %j journal %k key %m month
4558 %n number %o organization %p pages %P first page
4559 %r address %s school %u publisher %t title
4561 %B booktitle, abbreviated %T title, abbreviated
4565 Usually, only @samp{%l} is needed. The other stuff is mainly for the
4566 echo area display, and for @code{(setq reftex-comment-citations t)}.
4568 @samp{%<} as a special operator kills punctuation and space around it
4569 after the string has been formatted.
4571 A pair of square brackets indicates an optional argument, and RefTeX
4572 will prompt for the values of these arguments.
4574 Beware that all this only works with @BibTeX{} database files. When
4575 citations are made from the @code{\bibitems} in an explicit
4576 @code{thebibliography} environment, only @samp{%l} is available.
4578 If @code{reftex-cite-format} is an alist of characters and strings, the
4579 user will be prompted for a character to select one of the possible
4582 In order to configure this variable, you can either set
4583 @code{reftex-cite-format} directly yourself or set it to the
4584 @emph{symbol} of one of the predefined styles. The predefined symbols
4585 are those which have an association in the constant
4586 @code{reftex-cite-format-builtin}) E.g.: @code{(setq reftex-cite-format
4590 @deffn Hook reftex-format-cite-function
4591 If non-@code{nil}, should be a function which produces the string to
4592 insert as a citation. Note that the citation format can also be changed
4593 with the variable @code{reftex-cite-format}. The function will be
4594 called with two arguments, the @var{citation-key} and the
4595 @var{default-format} (taken from @code{reftex-cite-format}). It should
4596 return the string to insert into the buffer.
4599 @defopt reftex-cite-prompt-optional-args
4600 Non-@code{nil} means, prompt for empty optional arguments in cite macros.
4601 When an entry in @code{reftex-cite-format} ist given with square brackets to
4602 indicate optional arguments (for example @samp{\\cite[][]@{%l@}}), RefTeX can
4603 prompt for values. Possible values are:
4605 nil @r{Never prompt for optional arguments}
4607 maybe @r{Prompt only if @code{reftex-citation} was called with C-u prefix arg}@end example
4608 Unnecessary empty optional arguments are removed before insertion into
4609 the buffer. See @code{reftex-cite-cleanup-optional-args}.
4612 @defopt reftex-cite-cleanup-optional-args
4613 Non-@code{nil} means, remove empty optional arguments from cite macros
4617 @defopt reftex-comment-citations
4618 Non-@code{nil} means add a comment for each citation describing the full
4619 entry. The comment is formatted according to
4620 @code{reftex-cite-comment-format}.
4623 @defopt reftex-cite-comment-format
4624 Citation format used for commented citations. Must @emph{not} contain
4625 @samp{%l}. See the variable @code{reftex-cite-format} for possible
4629 @defopt reftex-cite-punctuation
4630 Punctuation for formatting of name lists in citations. This is a list
4634 normal names separator, like @samp{, } in Jones, Brown and Miller
4636 final names separator, like @samp{ and } in Jones, Brown and Miller
4638 The @samp{et al.} string, like @samp{ @{\it et al.@}} in
4639 Jones @{\it et al.@}
4643 @deffn {Normal Hook} reftex-select-bib-mode-hook
4644 Normal hook which is run when a selection buffer enters
4645 @code{reftex-select-bib-mode}.
4648 @deffn Keymap reftex-select-bib-map
4649 The keymap which is active in the citation-key selection process
4650 (@pxref{Creating Citations}).
4653 @defopt reftex-cite-key-separator
4654 String used to separate several keys in a single @samp{\\cite} macro.
4655 Per default this is @samp{","} but if you often have to deal with a lot
4656 of entries and need to break the macro across several lines you might
4657 want to change it to @samp{", "}.
4660 @defopt reftex-create-bibtex-header
4661 Header to insert in BibTeX files generated by
4662 @code{reftex-create-bibtex-file}.
4665 @defopt reftex-create-bibtex-footer
4666 Footer to insert in BibTeX files generated by
4667 @code{reftex-create-bibtex-file}.
4671 @node Options (Index Support), Options (Viewing Cross-References), Options (Creating Citations), Options
4672 @section Index Support
4673 @cindex Options, Index support
4674 @cindex Index support, options
4676 @defopt reftex-support-index
4677 Non-@code{nil} means, index entries are parsed as well. Index support
4678 is resource intensive and the internal structure holding the parsed
4679 information can become quite big. Therefore it can be turned off. When
4680 this is @code{nil} and you execute a command which requires index
4681 support, you will be asked for confirmation to turn it on and rescan the
4685 @defopt reftex-index-special-chars
4686 List of special characters in index entries, given as strings. These
4687 correspond to the @code{MakeIndex} keywords
4688 @code{(@var{level} @var{encap} @var{actual} @var{quote} @var{escape})}.
4691 @defopt reftex-index-macros
4692 List of macros which define index entries. The structure of each entry
4695 (@var{macro} @var{index-tag} @var{key} @var{prefix} @var{exclude} @var{repeat})
4698 @var{macro} is the macro. Arguments should be denoted by empty braces,
4699 as for example in @samp{\index[]@{*@}}. Use square brackets to denote
4700 optional arguments. The star marks where the index key is.
4702 @var{index-tag} is a short name of the index. @samp{idx} and @samp{glo}
4703 are reserved for the default index and the glossary. Other indices can
4704 be defined as well. If this is an integer, the Nth argument of the
4705 macro holds the index tag.
4707 @var{key} is a character which is used to identify the macro for input
4708 with @code{reftex-index}. @samp{?i}, @samp{?I}, and @samp{?g} are
4709 reserved for default index and glossary.
4711 @var{prefix} can be a prefix which is added to the @var{key} part of the
4712 index entry. If you have a macro
4713 @code{\newcommand@{\molec@}[1]@{#1\index@{Molecules!#1@}}, this prefix
4714 should be @samp{Molecules!}.
4716 @var{exclude} can be a function. If this function exists and returns a
4717 non-@code{nil} value, the index entry at point is ignored. This was
4718 implemented to support the (deprecated) @samp{^} and @samp{_} shortcuts
4719 in the @LaTeX{}2e @code{index} package.
4721 @var{repeat}, if non-@code{nil}, means the index macro does not typeset
4722 the entry in the text, so that the text has to be repeated outside the
4723 index macro. Needed for @code{reftex-index-selection-or-word} and for
4724 indexing from the phrase buffer.
4726 The final entry may also be a symbol. It must have an association in
4727 the variable @code{reftex-index-macros-builtin} to specify the main
4728 indexing package you are using. Valid values are currently
4730 default @r{The @LaTeX{} default - unnecessary to specify this one}
4731 multind @r{The multind.sty package}
4732 index @r{The index.sty package}
4733 index-shortcut @r{The index.sty packages with the ^ and _ shortcuts.}
4734 @r{Should not be used - only for old documents}
4736 Note that @AUCTeX{} sets these things internally for @RefTeX{} as well,
4737 so with a sufficiently new version of @AUCTeX{}, you should not set the
4741 @defopt reftex-index-default-macro
4742 The default index macro for @code{reftex-index-selection-or-word}.
4743 This is a list with @code{(@var{macro-key} @var{default-tag})}.
4745 @var{macro-key} is a character identifying an index macro - see
4746 @code{reftex-index-macros}.
4748 @var{default-tag} is the tag to be used if the macro requires a
4749 @var{tag} argument. When this is @code{nil} and a @var{tag} is needed,
4750 @RefTeX{} will ask for it. When this is the empty string and the
4751 TAG argument of the index macro is optional, the TAG argument will be
4755 @defopt reftex-index-default-tag
4756 Default index tag. When working with multiple indexes, RefTeX queries
4757 for an index tag when creating index entries or displaying a specific
4758 index. This variable controls the default offered for these queries.
4759 The default can be selected with @key{RET} during selection or
4760 completion. Valid values of this variable are:
4762 nil @r{Do not provide a default index}
4763 "tag" @r{The default index tag given as a string, e.g. "idx"}
4764 last @r{The last used index tag will be offered as default}
4768 @defopt reftex-index-math-format
4769 Format of index entries when copied from inside math mode. When
4770 @code{reftex-index-selection-or-word} is executed inside @TeX{} math mode,
4771 the index key copied from the buffer is processed with this format
4772 string through the @code{format} function. This can be used to add the
4773 math delimiters (e.g. @samp{$}) to the string. Requires the
4774 @file{texmathp.el} library which is part of @AUCTeX{}.
4777 @defopt reftex-index-phrase-file-extension
4778 File extension for the index phrase file. This extension will be added
4779 to the base name of the master file.
4782 @defopt reftex-index-phrases-logical-and-regexp
4783 Regexp matching the @samp{and} operator for index arguments in phrases
4784 file. When several index arguments in a phrase line are separated by
4785 this operator, each part will generate an index macro. So each match of
4786 the search phrase will produce @emph{several} different index entries.
4787 Make sure this does no match things which are not separators. This
4788 logical @samp{and} has higher priority than the logical @samp{or}
4789 specified in @code{reftex-index-phrases-logical-or-regexp}.
4792 @defopt reftex-index-phrases-logical-or-regexp
4793 Regexp matching the @samp{or} operator for index arguments in phrases
4794 file. When several index arguments in a phrase line are separated by
4795 this operator, the user will be asked to select one of them at each
4796 match of the search phrase. The first index arg will be the default. A
4797 number key @kbd{1}--@kbd{9} must be pressed to switch to another. Make
4798 sure this does no match things which are not separators. The logical
4799 @samp{and} specified in @code{reftex-index-phrases-logical-or-regexp}
4800 has higher priority than this logical @samp{or}.
4803 @defopt reftex-index-phrases-search-whole-words
4804 Non-@code{nil} means phrases search will look for whole words, not subwords.
4805 This works by requiring word boundaries at the beginning and end of
4806 the search string. When the search phrase already has a non-word-char
4807 at one of these points, no word boundary is required there.
4810 @defopt reftex-index-phrases-case-fold-search
4811 Non-@code{nil} means, searching for index phrases will ignore
4815 @defopt reftex-index-verify-function
4816 A function which is called at each match during global indexing.
4817 If the function returns nil, the current match is skipped.
4820 @defopt reftex-index-phrases-skip-indexed-matches
4821 Non-@code{nil} means, skip matches which appear to be indexed already.
4822 When doing global indexing from the phrases buffer, searches for some
4823 phrases may match at places where that phrase was already indexed. In
4824 particular when indexing an already processed document again, this
4825 will even be the norm. When this variable is non-@code{nil},
4826 @RefTeX{} checks if the match is an index macro argument, or if an
4827 index macro is directly before or after the phrase. If that is the
4828 case, that match will be ignored.
4831 @defopt reftex-index-phrases-wrap-long-lines
4832 Non-@code{nil} means, when indexing from the phrases buffer, wrap lines.
4833 Inserting indexing commands in a line makes the line longer - often
4834 so long that it does not fit onto the screen. When this variable is
4835 non-@code{nil}, newlines will be added as necessary before and/or after the
4836 indexing command to keep lines short. However, the matched text
4837 phrase and its index command will always end up on a single line.
4840 @defopt reftex-index-phrases-sort-prefers-entry
4841 Non-@code{nil} means when sorting phrase lines, the explicit index entry
4842 is used. Phrase lines in the phrases buffer contain a search phrase, and
4843 sorting is normally based on these. Some phrase lines also have
4844 an explicit index argument specified. When this variable is
4845 non-@code{nil}, the index argument will be used for sorting.
4848 @defopt reftex-index-phrases-sort-in-blocks
4849 Non-@code{nil} means, empty and comment lines separate phrase buffer
4850 into blocks. Sorting will then preserve blocks, so that lines are
4851 re-arranged only within blocks.
4854 @defopt reftex-index-phrases-map
4855 Keymap for the Index Phrases buffer.
4858 @defopt reftex-index-phrases-mode-hook
4859 Normal hook which is run when a buffer is put into
4860 @code{reftex-index-phrases-mode}.
4863 @defopt reftex-index-section-letters
4864 The letters which denote sections in the index. Usually these are all
4865 capital letters. Don't use any downcase letters. Order is not
4866 significant, the index will be sorted by whatever the sort function
4867 thinks is correct. In addition to these letters, @RefTeX{} will
4868 create a group @samp{!} which contains all entries sorted below the
4869 lowest specified letter. In the @file{*Index*} buffer, pressing any of
4870 these capital letters or @kbd{!} will jump to that section.
4873 @defopt reftex-index-include-context
4874 Non-@code{nil} means, display the index definition context in the
4875 @file{*Index*} buffer. This flag may also be toggled from the
4876 @file{*Index*} buffer with the @kbd{c} key.
4879 @defopt reftex-index-follow-mode
4880 Non-@code{nil} means, point in @file{*Index*} buffer will cause other
4881 window to follow. The other window will show the corresponding part of
4882 the document. This flag can be toggled from within the @file{*Index*}
4883 buffer with the @kbd{f} key.
4886 @deffn Keymap reftex-index-map
4887 The keymap which is active in the @file{*Index*} buffer
4888 (@pxref{Index Support}).
4891 @node Options (Viewing Cross-References), Options (Finding Files), Options (Index Support), Options
4892 @section Viewing Cross-References
4893 @cindex Options, viewing cross-references
4894 @cindex Viewing cross-references, options
4896 @defopt reftex-view-crossref-extra
4897 Macros which can be used for the display of cross references.
4898 This is used when `reftex-view-crossref' is called with point in an
4899 argument of a macro. Note that crossref viewing for citations,
4900 references (both ways) and index entries is hard-coded. This variable
4901 is only to configure additional structures for which crossreference
4902 viewing can be useful. Each entry has the structure
4904 (@var{macro-re} @var{search-re} @var{highlight}).
4906 @var{macro-re} is matched against the macro. @var{search-re} is the
4907 regexp used to search for cross references. @samp{%s} in this regexp is
4908 replaced with the macro argument at point. @var{highlight} is an
4909 integer indicating which subgroup of the match should be highlighted.
4912 @defopt reftex-auto-view-crossref
4913 Non-@code{nil} means, initially turn automatic viewing of crossref info
4914 on. Automatic viewing of crossref info normally uses the echo area.
4915 Whenever point is idle for more than @code{reftex-idle-time} seconds on
4916 the argument of a @code{\ref} or @code{\cite} macro, and no other
4917 message is being displayed, the echo area will display information about
4918 that cross reference. You can also set the variable to the symbol
4919 @code{window}. In this case a small temporary window is used for the
4920 display. This feature can be turned on and off from the menu
4924 @defopt reftex-idle-time
4925 Time (secs) Emacs has to be idle before automatic crossref display
4926 or toc recentering is done.
4929 @defopt reftex-cite-view-format
4930 Citation format used to display citation info in the message area. See
4931 the variable @code{reftex-cite-format} for possible percent
4935 @defopt reftex-revisit-to-echo
4936 Non-@code{nil} means, automatic citation display will revisit files if
4937 necessary. When nil, citation display in echo area will only be active
4938 for cached echo strings (see @code{reftex-cache-cite-echo}), or for
4939 @BibTeX{} database files which are already visited by a live associated
4943 @defopt reftex-cache-cite-echo
4944 Non-@code{nil} means, the information displayed in the echo area for
4945 cite macros (see variable @code{reftex-auto-view-crossref}) is cached and
4946 saved along with the parsing information. The cache survives document
4947 scans. In order to clear it, use @kbd{M-x reftex-reset-mode}.
4950 @node Options (Finding Files), Options (Optimizations), Options (Viewing Cross-References), Options
4951 @section Finding Files
4952 @cindex Options, Finding Files
4953 @cindex Finding files, options
4955 @defopt reftex-texpath-environment-variables
4956 List of specifications how to retrieve the search path for @TeX{} files.
4957 Several entries are possible.
4960 If an element is the name of an environment variable, its content is
4963 If an element starts with an exclamation mark, it is used as a command
4964 to retrieve the path. A typical command with the kpathsearch library
4965 would be @w{@code{"!kpsewhich -show-path=.tex"}}.
4967 Otherwise the element itself is interpreted as a path.
4969 Multiple directories can be separated by the system dependent
4970 @code{path-separator}. Directories ending in @samp{//} or @samp{!!} will
4971 be expanded recursively. See also @code{reftex-use-external-file-finders}.
4974 @defopt reftex-bibpath-environment-variables
4975 List of specifications how to retrieve the search path for @BibTeX{}
4976 files. Several entries are possible.
4979 If an element is the name of an environment variable, its content is
4982 If an element starts with an exclamation mark, it is used as a command
4983 to retrieve the path. A typical command with the kpathsearch library
4984 would be @w{@code{"!kpsewhich -show-path=.bib"}}.
4986 Otherwise the element itself is interpreted as a path.
4988 Multiple directories can be separated by the system dependent
4989 @code{path-separator}. Directories ending in @samp{//} or @samp{!!} will
4990 be expanded recursively. See also @code{reftex-use-external-file-finders}.
4993 @defopt reftex-file-extensions
4994 Association list with file extensions for different file types.
4995 This is a list of items, each item is like:
4996 @code{(@var{type} . (@var{def-ext} @var{other-ext} ...))}
4998 @var{type}: @r{File type like @code{"bib"} or @code{"tex"}.}
4999 @var{def-ext}: @r{The default extension for that file type, like @code{".tex"} or @code{".bib"}.}
5000 @var{other-ext}: @r{Any number of other valid extensions for this file type.}
5002 When a files is searched and it does not have any of the valid extensions,
5003 we try the default extension first, and then the naked file name.
5006 @defopt reftex-search-unrecursed-path-first
5007 Non-@code{nil} means, search all specified directories before trying
5008 recursion. Thus, in a path @samp{.//:/tex/}, search first @samp{./},
5009 then @samp{/tex/}, and then all subdirectories of @samp{./}. If this
5010 option is @code{nil}, the subdirectories of @samp{./} are searched
5011 before @samp{/tex/}. This is mainly for speed - most of the time the
5012 recursive path is for the system files and not for the user files. Set
5013 this to @code{nil} if the default makes @RefTeX{} finding files with
5014 equal names in wrong sequence.
5017 @defopt reftex-use-external-file-finders
5018 Non-@code{nil} means, use external programs to find files. Normally,
5019 @RefTeX{} searches the paths given in the environment variables
5020 @code{TEXINPUTS} and @code{BIBINPUTS} to find @TeX{} files and @BibTeX{}
5021 database files. With this option turned on, it calls an external
5022 program specified in the option @code{reftex-external-file-finders}
5023 instead. As a side effect, the variables
5024 @code{reftex-texpath-environment-variables} and
5025 @code{reftex-bibpath-environment-variables} will be ignored.
5028 @defopt reftex-external-file-finders
5029 Association list with external programs to call for finding files. Each
5030 entry is a cons cell @w{@code{(@var{type} . @var{program})}}.
5031 @var{type} is either @code{"tex"} or @code{"bib"}. @var{program} is a
5032 string containing the external program to use with any arguments.
5033 @code{%f} will be replaced by the name of the file to be found. Note
5034 that these commands will be executed directly, not via a shell. Only
5035 relevant when @code{reftex-use-external-file-finders} is
5040 @node Options (Optimizations), Options (Fontification), Options (Finding Files), Options
5041 @section Optimizations
5042 @cindex Options, optimizations
5043 @cindex Optimizations, options
5045 @defopt reftex-keep-temporary-buffers
5046 Non-@code{nil} means, keep buffers created for parsing and lookup.
5047 @RefTeX{} sometimes needs to visit files related to the current
5048 document. We distinguish files visited for
5051 Parts of a multifile document loaded when (re)-parsing the
5054 @BibTeX{} database files and @TeX{} files loaded to find a reference, to
5055 display label context, etc.
5057 The created buffers can be kept for later use, or be thrown away
5058 immediately after use, depending on the value of this variable:
5062 Throw away as much as possible.
5066 Throw away buffers created for parsing, but keep the ones created for
5070 If a buffer is to be kept, the file is visited normally (which is
5071 potentially slow but will happen only once). If a buffer is to be thrown
5072 away, the initialization of the buffer depends upon the variable
5073 @code{reftex-initialize-temporary-buffers}.
5076 @defopt reftex-initialize-temporary-buffers
5077 Non-@code{nil} means do initializations even when visiting file
5078 temporarily. When @code{nil}, @RefTeX{} may turn off find-file hooks and
5079 other stuff to briefly visit a file. When @code{t}, the full default
5080 initializations are done (@code{find-file-hook} etc.). Instead of
5081 @code{t} or @code{nil}, this variable may also be a list of hook
5082 functions to do a minimal initialization.
5085 @defopt reftex-no-include-regexps
5086 List of regular expressions to exclude certain input files from parsing.
5087 If the name of a file included via @code{\include} or @code{\input} is
5088 matched by any of the regular expressions in this list, that file is not
5089 parsed by @RefTeX{}.
5092 @defopt reftex-enable-partial-scans
5093 Non-@code{nil} means, re-parse only 1 file when asked to re-parse.
5094 Re-parsing is normally requested with a @kbd{C-u} prefix to many @RefTeX{}
5095 commands, or with the @kbd{r} key in menus. When this option is
5096 @code{t} in a multifile document, we will only parse the current buffer,
5097 or the file associated with the label or section heading near point in a
5098 menu. Requesting re-parsing of an entire multifile document then
5099 requires a @kbd{C-u C-u} prefix or the capital @kbd{R} key in
5103 @defopt reftex-save-parse-info
5104 Non-@code{nil} means, save information gathered with parsing in files.
5105 The file @file{MASTER.rel} in the same directory as @file{MASTER.tex} is
5106 used to save the information. When this variable is @code{t},
5109 accessing the parsing information for the first time in an editing
5110 session will read that file (if available) instead of parsing the
5113 exiting Emacs or killing a buffer in reftex-mode will cause a new
5114 version of the file to be written.
5118 @defopt reftex-parse-file-extension
5119 File extension for the file in which parser information is stored.
5120 This extension is added to the base name of the master file.
5123 @defopt reftex-allow-automatic-rescan
5124 Non-@code{nil} means, @RefTeX{} may rescan the document when this seems
5125 necessary. Applies (currently) only in rare cases, when a new label
5126 cannot be placed with certainty into the internal label list.
5129 @defopt reftex-use-multiple-selection-buffers
5130 Non-@code{nil} means use a separate selection buffer for each label
5131 type. These buffers are kept from one selection to the next and need
5132 not to be created for each use - so the menu generally comes up faster.
5133 The selection buffers will be erased (and therefore updated)
5134 automatically when new labels in its category are added. See the
5135 variable @code{reftex-auto-update-selection-buffers}.
5138 @defopt reftex-auto-update-selection-buffers
5139 Non-@code{nil} means, selection buffers will be updated automatically.
5140 When a new label is defined with @code{reftex-label}, all selection
5141 buffers associated with that label category are emptied, in order to
5142 force an update upon next use. When @code{nil}, the buffers are left
5143 alone and have to be updated by hand, with the @kbd{g} key from the
5144 label selection process. The value of this variable will only have any
5145 effect when @code{reftex-use-multiple-selection-buffers} is
5149 @node Options (Fontification), Options (Misc), Options (Optimizations), Options
5150 @section Fontification
5151 @cindex Options, fontification
5152 @cindex Fontification, options
5154 @defopt reftex-use-fonts
5155 Non-@code{nil} means, use fonts in label menu and on-the-fly help.
5156 Font-lock must be loaded as well to actually get fontified
5157 display. After changing this option, a rescan may be necessary to
5161 @defopt reftex-refontify-context
5162 Non-@code{nil} means, re-fontify the context in the label menu with
5163 font-lock. This slightly slows down the creation of the label menu. It
5164 is only necessary when you definitely want the context fontified.
5166 This option may have 3 different values:
5173 Refontify when necessary, e.g. with old versions of the x-symbol
5176 The option is ignored when @code{reftex-use-fonts} is @code{nil}.
5179 @defopt reftex-highlight-selection
5180 Non-@code{nil} means, highlight selected text in selection and
5181 @file{*toc*} buffers. Normally, the text near the cursor is the
5182 @emph{selected} text, and it is highlighted. This is the entry most
5183 keys in the selection and @file{*toc*} buffers act on. However, if you
5184 mainly use the mouse to select an item, you may find it nice to have
5185 mouse-triggered highlighting @emph{instead} or @emph{as well}. The
5186 variable may have one of these values:
5189 nil @r{No highlighting.}
5190 cursor @r{Highlighting is cursor driven.}
5191 mouse @r{Highlighting is mouse driven.}
5192 both @r{Both cursor and mouse trigger highlighting.}
5195 Changing this variable requires to rebuild the selection and *toc*
5196 buffers to become effective (keys @kbd{g} or @kbd{r}).
5199 @defopt reftex-cursor-selected-face
5200 Face name to highlight cursor selected item in toc and selection buffers.
5201 See also the variable @code{reftex-highlight-selection}.
5203 @defopt reftex-mouse-selected-face
5204 Face name to highlight mouse selected item in toc and selection buffers.
5205 See also the variable @code{reftex-highlight-selection}.
5207 @defopt reftex-file-boundary-face
5208 Face name for file boundaries in selection buffer.
5210 @defopt reftex-label-face
5211 Face name for labels in selection buffer.
5213 @defopt reftex-section-heading-face
5214 Face name for section headings in toc and selection buffers.
5216 @defopt reftex-toc-header-face
5217 Face name for the header of a toc buffer.
5219 @defopt reftex-bib-author-face
5220 Face name for author names in bib selection buffer.
5222 @defopt reftex-bib-year-face
5223 Face name for year in bib selection buffer.
5225 @defopt reftex-bib-title-face
5226 Face name for article title in bib selection buffer.
5228 @defopt reftex-bib-extra-face
5229 Face name for bibliographic information in bib selection buffer.
5231 @defopt reftex-select-mark-face
5232 Face name for marked entries in the selection buffers.
5234 @defopt reftex-index-header-face
5235 Face name for the header of an index buffer.
5237 @defopt reftex-index-section-face
5238 Face name for the start of a new letter section in the index.
5240 @defopt reftex-index-tag-face
5241 Face name for index names (for multiple indices).
5243 @defopt reftex-index-face
5244 Face name for index entries.
5247 @node Options (Misc), , Options (Fontification), Options
5248 @section Miscellaneous
5249 @cindex Options, misc
5251 @defopt reftex-extra-bindings
5252 Non-@code{nil} means, make additional key bindings on startup. These
5253 extra bindings are located in the users @samp{C-c letter}
5254 map. @xref{Key Bindings}.
5257 @defopt reftex-plug-into-AUCTeX
5258 Plug-in flags for @AUCTeX{} interface. This variable is a list of
5259 5 boolean flags. When a flag is non-@code{nil}, @RefTeX{}
5263 - supply labels in new sections and environments (flag 1)
5264 - supply arguments for macros like @code{\label} (flag 2)
5265 - supply arguments for macros like @code{\ref} (flag 3)
5266 - supply arguments for macros like @code{\cite} (flag 4)
5267 - supply arguments for macros like @code{\index} (flag 5)
5270 You may also set the variable itself to t or nil in order to turn all
5271 options on or off, respectively.@*
5272 Supplying labels in new sections and environments applies when creating
5273 sections with @kbd{C-c C-s} and environments with @kbd{C-c C-e}.@*
5274 Supplying macro arguments applies when you insert such a macro
5275 interactively with @kbd{C-c @key{RET}}.@*
5276 See the @AUCTeX{} documentation for more information.
5279 @defopt reftex-revisit-to-follow
5280 Non-@code{nil} means, follow-mode will revisit files if necessary.
5281 When nil, follow-mode will be suspended for stuff in unvisited files.
5284 @defopt reftex-allow-detached-macro-args
5285 Non-@code{nil} means, allow arguments of macros to be detached by
5286 whitespace. When this is @code{t}, the @samp{aaa} in @w{@samp{\bbb
5287 [xxx] @{aaa@}}} will be considered an argument of @code{\bb}. Note that
5288 this will be the case even if @code{\bb} is defined with zero or one
5292 @node Keymaps and Hooks, Changes, Options, Top
5293 @section Keymaps and Hooks
5296 @RefTeX{} has the usual general keymap, load hook and mode hook.
5298 @deffn Keymap reftex-mode-map
5299 The keymap for @RefTeX{} mode.
5302 @deffn {Normal Hook} reftex-load-hook
5303 Normal hook which is being run when loading @file{reftex.el}.
5306 @deffn {Normal Hook} reftex-mode-hook
5307 Normal hook which is being run when turning on @RefTeX{} mode.
5310 Furthermore, the four modes used for referencing labels, creating
5311 citations, the table of contents buffer and the phrases buffer have
5312 their own keymaps and mode hooks. See the respective sections. There
5313 are many more hooks which are described in the relevant sections about
5314 options for a specific part of @RefTeX{}.
5316 @node Changes, GNU Free Documentation License, Keymaps and Hooks, Top
5320 Here is a list of recent changes to @RefTeX{}.
5322 @noindent @b{Version 4.33}
5328 Parse files are created in a way that does not interfere with recentf
5332 @noindent @b{Version 4.32}
5336 First release by @AUCTeX{} project.
5338 Installation routine rewritten after structure of source package
5341 Activation of @RefTeX{} changed, so make sure you read the installation
5342 instructions and remove obsolete cruft related to @RefTeX{} from your
5345 Fixed bug where point would end up in the wrong buffer when jumping
5346 between several @LaTeX{} and phrases buffers.
5348 Fixed bug where @BibTeX{} keys with hyphens were parsed incorrectly.
5350 Some performance improvements.
5352 The separator used between multiple citations in a \cite macro can now
5353 be changed by customizing the variable @code{reftex-cite-key-separator}.
5356 @noindent @b{Version 4.28}
5358 @item Support for the Jurabib package.
5359 @item Improvements when selecting several items in a selection buffer.
5362 @noindent @b{Version 4.26}
5365 Support for global incremental search.
5367 Some improvements for XEmacs compatibility.
5370 @noindent @b{Version 4.25}
5373 Fixed bug with @samp{%F} in a label prefix. Added new escapes
5374 @samp{%m} and @samp{%M} for mater file name and master directory.
5377 @noindent @b{Version 4.24}
5380 Inserting citation commands now prompts for optional arguments
5381 when called with a prefix argument. Related new options are
5382 @code{reftex-cite-prompt-optional-args} and
5383 @code{reftex-cite-cleanup-optional-args}.
5385 New option @code{reftex-trust-label-prefix}. Configure this variable
5386 if you'd like RefTeX to base its classification of labels on prefixes.
5387 This can speed-up document parsing, but may in some cases reduce the
5388 quality of the context used by RefTeX to describe a label.
5390 Fixed bug in @code{reftex-create-bibtex-file} when @code{reftex-comment-citations}
5393 Fixed bugs in indexing: Case-sensitive search, quotes before and/or
5394 after words. Disabled indexing in comment lines.
5397 @noindent @b{Version 4.22}
5400 New command @code{reftex-create-bibtex-file} to create a new database
5401 with all entries referenced in the current document.
5403 New keys @kbd{e} and @kbd{E} allow to produce a BibTeX database file
5404 from entries marked in a citation selection buffer.
5407 @noindent @b{Version 4.21}
5410 Renaming labels from the toc buffer with key @kbd{M-%}.
5413 @noindent @b{Version 4.20}
5416 Structure editing capabilities. The command keys @kbd{<} and @kbd{>} in
5417 the TOC buffer promote/demote the section at point or all sections in
5420 New option @code{reftex-toc-split-windows-fraction} to set the size of
5421 the window used by the TOC. This makes the old variable
5422 @code{reftex-toc-split-windows-horizontally-fraction} obsolete.
5424 A dedicated frame can show the TOC with the current section
5425 always automatically highlighted. The frame is created and
5426 deleted from the toc buffer with the @kbd{d} key.
5429 @noindent @b{Version 4.19}
5432 New command `reftex-toc-recenter' (@kbd{C-c -}) which shows the current
5433 section in the TOC buffer without selecting the TOC window.
5435 Recentering happens automatically in idle time when the option
5436 @code{reftex-auto-recenter-toc} is turned on.
5438 Fixed several bugs related to automatic cursor positioning in the TOC
5441 The highlight in the TOC buffer stays when the focus moves to a
5444 New command `reftex-goto-label'.
5446 Part numbers are no longer included in chapter numbers, and a new
5447 part does not reset the chapter counter. See new option
5448 @code{reftex-part-resets-chapter}.
5451 @noindent @b{Version 4.18}
5454 @code{reftex-citation} uses the word before the cursor as a default
5457 Simplified several regular expressions for speed.
5459 Better support for chapterbib.
5462 @noindent @b{Version 4.17}
5465 The toc window can be split off horizontally. See new options
5466 @code{reftex-toc-split-windows-horizontally},
5467 @code{reftex-toc-split-windows-horizontally-fraction}.
5469 It is possible to specify a function which verifies an index match
5470 during global indexing. See new option @code{reftex-index-verify-function}.
5472 The macros which input a file in LaTeX (like \input, \include) can
5473 be configured. See new option @code{reftex-include-file-commands}.
5475 The macros which specify the bibliography file (like \bibliography) can
5476 be configured. See new option @code{reftex-bibliography-commands}.
5478 The regular expression used to search for the \bibliography macro has
5479 been relaxed to allow for @samp{@{\bibliography@{...@}@}} needed by
5485 @noindent @b{Version 4.15}
5488 Fixed bug with parsing of BibTeX files, when fields contain quotes or
5489 unmatched parenthesis.
5493 Improved interaction with Emacs LaTeX mode.
5496 @noindent @b{Version 4.12}
5499 Support for @file{bibentry} citation style.
5502 @noindent @b{Version 4.11}
5505 Fixed bug which would parse @samp{\Section} just like @samp{\section}.
5508 @noindent @b{Version 4.10}
5511 Renamed @file{reftex-vcr.el} to @file{reftex-dcr.el} because of conflict
5512 with @file{reftex-vars.el} on DOS machines.
5514 New options @code{reftex-parse-file-extension} and
5515 @code{reftex-index-phrase-file-extension}.
5520 @noindent @b{Version 4.09}
5523 New option @code{reftex-toc-max-level} to limit the depth of the toc.
5524 New key binding @kbd{t} in the @file{*toc*} buffer to change this
5527 RefTeX maintains an @file{Index Phrases} file in which phrases can be
5528 collected. When the document is ready, RefTeX can search all
5529 these phrases and assist indexing all matches.
5531 The variables @code{reftex-index-macros} and
5532 @code{reftex-index-default-macro} have changed their syntax slightly.
5533 The @var{repeat} parameter has move from the latter to the former.
5534 Also calls to @code{reftex-add-index-macros} from AUCTeX style files
5537 The variable @code{reftex-section-levels} no longer contains the
5538 default stuff which has been moved to a constant.
5540 Environments like theorems can be placed into the TOC by putting
5541 entries for @samp{"begin@{theorem@}"} in
5542 @code{reftex-section-levels}.
5545 @noindent @b{Version 4.06}
5548 @code{reftex-section-levels} can contain a function to compute the level
5549 of a sectioning command.
5551 Multiple @code{thebibliography} environments recognized.
5554 @noindent @b{Version 4.04}
5557 New option @code{reftex-index-default-tag} implements a default for queries.
5560 @noindent @b{Version 4.02}
5563 macros ending in @samp{refrange} are considered to contain references.
5565 Index entries made with @code{reftex-index-selection-or-word} in TeX
5566 math mode automatically get enclosing @samp{$} to preserve math mode. See
5567 new option @code{reftex-index-math-format}. Requires AUCTeX.
5570 @noindent @b{Version 4.01}
5573 New command @code{reftex-index-globally} to index a word in many
5574 places in the document. Also available from the index buffer with
5577 The first item in a @code{reftex-label-alist} entry may now also be a parser
5578 function to do non-standard parsing.
5580 @code{reftex-auto-view-crossref} no longer interferes with
5581 @code{pop-up-frames} (patch from Stefan Monnier).
5584 @noindent @b{Version 4.00}
5587 RefTeX has been split into several smaller files which are autoloaded on
5590 Index support, along with many new options.
5592 The selection of keys for @code{\ref} and @code{\cite} now allows to
5593 select multiple items by marking entries with the @kbd{m} key.
5598 @noindent @b{Version 3.43}
5601 Viewing cross-references generalized. Now works on @code{\label},
5602 @code{\ref}, @code{\cite}, @code{\bibitem}, @code{\index}, variations of
5603 these, and from BibTeX buffers.
5605 New option @code{reftex-view-crossref-extra}.
5607 Support for the additional sectioning commands @code{\addchap} and
5608 @code{\addsec} which are defined in the LaTeX KOMA-Script classes.
5610 Files in @code{reftex-default-bibliography} will be searched along
5611 @code{BIBINPUTS} path.
5613 Reading a parse file now checks consistency.
5616 @noindent @b{Version 3.42}
5619 File search further refined. New option @code{reftex-file-extensions}.
5621 @file{*toc*} buffer can show the file boundaries of a multifile
5622 document, all labels and associated context. New keys @kbd{i}, @kbd{l},
5623 and @kbd{c}. New options @code{reftex-toc-include-labels},
5624 @code{reftex-toc-include-context},
5625 @code{reftex-toc-include-file-boundaries}.
5628 @noindent @b{Version 3.41}
5631 New options @code{reftex-texpath-environment-variables},
5632 @code{reftex-use-external-file-finders},
5633 @code{reftex-external-file-finders},
5634 @code{reftex-search-unrecursed-path-first}.
5636 @emph{kpathsearch} support. See new options and
5637 @code{reftex-bibpath-environment-variables}.
5640 @noindent @b{Version 3.38}
5643 @code{reftex-view-crossref} no longer moves to find a macro. Point has
5644 to be on the macro argument.
5647 @noindent @b{Version 3.36}
5650 New value @code{window} for option @code{reftex-auto-view-crossref}.
5653 @noindent @b{Version 3.35}
5656 ISO 8859 Latin-1 chars are converted to ASCII to derive better labels.
5657 This takes back the related changes in 3.34 for safety reasons.
5660 @noindent @b{Version 3.34}
5663 Additional flag in @code{reftex-derive-label-parameters} do make only
5664 lowercase labels (default @code{t}).
5666 All @file{.rel} files have a final newline to avoid queries.
5668 Single byte representations of accented European letters (ISO-8859-1)
5669 are now valid in labels.
5672 @noindent @b{Version 3.33}
5675 Multiple selection buffers are now hidden buffers (they start with a
5678 Fixed bug with file search when TEXINPUTS environment variable is empty.
5681 @noindent @b{Version 3.30}
5684 In @code{reftex-citation}, the regular expression used to scan BibTeX
5685 files can be specified using completion on known citation keys.
5687 New keys @kbd{a} and @kbd{A} in BibTeX selection process to cite @emph{all}
5690 New command @code{reftex-renumber-simple-labels} to renumber simple
5691 labels like @samp{eq:13} sequentially through a document.
5694 @noindent @b{Version 3.28}
5697 Auto view crossref for XEmacs uses @code{post-command-hook} to restart the
5698 timer, since itimer restart is not reliable.
5700 Option @code{reftex-bibfile-ignore-list} renamed to @code{-regexps}.
5702 Expansion of recursive tex and bib path rewritten.
5704 Fixed problem where @RefTeX{} did not scan unsaved buffers.
5706 Fixed bug with section numbering after *-red sections.
5709 @noindent @b{Version 3.27}
5712 Macros can define @emph{neutral} labels, just like @code{\label}
5715 New option @code{reftex-allow-detached-macro-args}, default @code{nil}!
5718 @noindent @b{Version 3.26}
5721 [X]Emacs 19 no longer supported. Use 3.22 for Emacs 19.
5723 New hooks @code{reftex-translate-to-ascii-function},
5724 @code{reftex-string-to-label-function}.
5726 Made sure automatic crossref display will not visit/scan files.
5729 @noindent @b{Version 3.25}
5732 Echoing of citation info caches the info for displayed entries.
5733 New option @code{reftex-cache-cite-echo}.
5735 @kbd{M-x reftex-reset-mode} now also removes the file with parsing
5738 Default of @code{reftex-revisit-to-follow} changed to nil.
5741 @noindent @b{Version 3.24}
5744 New option @code{reftex-revisit-to-echo}.
5746 Interface with X-Symbol (>=2.6) is now complete and stable.
5748 Adapted to new outline, which uses overlays.
5750 File names in @code{\bibliography} may now have the @code{.bib}
5753 Fixed Bug with parsing "single file" from master file buffer.
5756 @noindent @b{Version 3.23}
5759 Parse files @file{MASTER.rel} made compatible between Emacs and XEmacs.
5761 @code{kill-emacs-hook} and @code{kill-buffer-hook} now write the parse
5764 The cursor inside a @code{\ref} or @code{\cite} macro can now trigger
5765 automatic display of crossref information in the echo area. See
5766 variable @code{reftex-auto-view-crossref}.
5768 AUCTeX interface updates:
5771 AUCTeX 9.9c and later notifies @RefTeX{} about new sections.
5773 @RefTeX{} notifies AUCTeX about new labels.
5775 @code{TeX-arg-ref} no longer used (introduction was unnecessary).
5777 @code{reftex-arg-label} and @code{reftex-arg-cite} fixed up.
5779 Settings added to @RefTeX{} via style files remain local.
5782 Fixed bug with @code{reftex-citation} in non-latex buffers.
5784 Fixed bug with syntax table and context refontification.
5786 Safety-net for name change of @code{font-lock-reference-face}.
5789 @noindent @b{Version 3.22}
5792 Fixed bug with empty context strings.
5794 @code{reftex-mouse-view-crossref} is now bound by default at
5798 @noindent @b{Version 3.21}
5801 New options for all faces used by @RefTeX{}. They're in the
5802 customization group @code{reftex-fontification-configurations}.
5805 @noindent @b{Version 3.19}
5808 Fixed bug with AUCTeX @code{TeX-master}.
5811 @noindent @b{Version 3.18}
5814 The selection now uses a recursive edit, much like minibuffer input.
5815 This removes all restrictions during selection. E.g. you can now
5816 switch buffers at will, use the mouse etc.
5818 New option @code{reftex-highlight-selection}.
5820 @kbd{mouse-2} can be used to select in selection and @file{*toc*}
5823 Fixed some problems regarding the interaction with VIPER mode.
5825 Follow-mode is now only used after point motion.
5827 @RefTeX{} now finally does not fontify temporary files anymore.
5830 @noindent @b{Version 3.17}
5833 Additional bindings in selection and @file{*toc*} buffers. @kbd{g}
5836 New command @code{reftex-save-all-document-buffers}.
5838 Magic word matching made more intelligent.
5840 Selection process can switch to completion (with @key{TAB}).
5842 @code{\appendix} is now recognized and influences section numbering.
5844 File commentary shortened considerably (use Info documentation).
5846 New option @code{reftex-no-include-regexps} to skip some include files.
5848 New option @code{reftex-revisit-to-follow}.
5851 @noindent @b{Version 3.16}
5854 New hooks @code{reftex-format-label-function},
5855 @code{reftex-format-ref-function}, @code{reftex-format-cite-function}.
5857 TeXInfo documentation completed.
5859 Some restrictions in Label inserting and referencing removed.
5861 New variable @code{reftex-default-bibliography}.
5864 @noindent @b{Version 3.14}
5867 Selection buffers can be kept between selections: this is faster.
5868 See new variable @code{reftex-use-multiple-selection-buffers}.
5870 Prefix interpretation of reftex-view-crossref changed.
5872 Support for the @code{varioref} package (@kbd{v} key in selection
5876 @noindent @b{Version 3.12}
5879 There are 3 new keymaps for customization: @code{reftex-toc-map},
5880 @code{reftex-select-label-map}, @code{reftex-select-bib-map}.
5882 Refontification uses more standard font-lock stuff.
5884 When no BibTeX database files are specified, citations can also use
5885 @code{\bibitem} entries from a @code{thebibliography} environment.
5888 @noindent @b{Version 3.11}
5891 Fixed bug which led to naked label in (e.g.) footnotes.
5893 Added scroll-other-window functions to RefTeX-Select.
5896 @noindent @b{Version 3.10}
5899 Fixed a bug which made reftex 3.07 fail on [X]Emacs version 19.
5901 Removed unimportant code which caused OS/2 Emacs to crash.
5903 All customization variables now accessible from menu.
5906 @noindent @b{Version 3.07}
5909 @code{Ref} menu improved.
5912 @noindent @b{Version 3.05}
5915 Compatibility code now first checks for XEmacs feature.
5918 @noindent @b{Version 3.04}
5921 Fixed BUG in the @emph{xr} support.
5924 @noindent @b{Version 3.03}
5927 Support for the LaTeX package @code{xr}, for inter-document
5930 A few (minor) Mule-related changes.
5932 Fixed bug which could cause @emph{huge} @file{.rel} files.
5934 Search for input and @file{.bib} files with recursive path definitions.
5937 @noindent @b{Version 3.00}
5940 @RefTeX{} should work better for very large projects:
5942 The new parser works without creating a master buffer.
5944 Rescanning can be limited to a part of a multifile document.
5946 Information from the parser can be stored in a file.
5948 @RefTeX{} can deal with macros having a naked label as an argument.
5950 Macros may have white space and newlines between arguments.
5952 Multiple identical section headings no longer confuse
5955 @RefTeX{} should work correctly in combination with buffer-altering
5956 packages like outline, folding, x-symbol, iso-cvt, isotex, etc.
5958 All labeled environments discussed in @emph{The LaTeX Companion} by
5959 Goossens, Mittelbach & Samarin, Addison-Wesley 1994) are part of
5960 @RefTeX{}'s defaults.
5963 @noindent @b{Version 2.17}
5966 Label prefix expands % escapes with current file name and other stuff.
5968 Citation format now with % escapes. This is not backward
5971 TEXINPUTS variable recognized when looking for input files.
5973 Context can be the nth argument of a macro.
5975 Searching in the select buffer is now possible (@kbd{C-s} and
5978 Display and derive-label can use two different context methods.
5980 AMSmath @code{xalignat} and @code{xxalignat} added.
5983 @noindent @b{Version 2.14}
5986 Variable @code{reftex-plug-into-AUCTeX} simplifies cooperation with
5990 @noindent @b{Version 2.11}
5993 Submitted for inclusion to Emacs and XEmacs.
5996 @noindent @b{Version 2.07}
5999 New functions @code{reftex-search-document},
6000 @code{reftex-query-replace-document}.
6003 @noindent @b{Version 2.05}
6006 Support for @file{custom.el}.
6008 New function @code{reftex-grep-document} (thanks to Stephen Eglen).
6011 @noindent @b{Version 2.03}
6014 @code{figure*}, @code{table*}, @code{sidewaysfigure/table} added to
6015 default environments.
6017 @code{reftex-bibfile-ignore-list} introduced (thanks to Rory Molinari).
6019 New functions @code{reftex-arg-label}, @code{reftex-arg-ref},
6020 @code{reftex-arg-cite}.
6022 Emacs/XEmacs compatibility reworked. XEmacs 19.15 now is
6025 @code{reftex-add-to-label-alist} (to be called from AUCTeX style
6028 Finding context with a hook function.
6030 Sorting BibTeX entries (new variable:
6031 @code{reftex-sort-bibtex-matches}).
6034 @noindent @b{Version 2.00}
6037 Labels can be derived from context (default for sections).
6039 Configuration of label insertion and label referencing revised.
6041 Crossref fields in BibTeX database entries.
6043 @code{reftex-toc} introduced (thanks to Stephen Eglen).
6046 @noindent @b{Version 1.09}
6049 Support for @code{tex-main-file}, an analogue for
6055 @noindent @b{Version 1.07}
6058 @RefTeX{} gets its own menu.
6061 @noindent @b{Version 1.05}
6067 @noindent @b{Version 1.04}
6070 Macros as wrappers, AMSTeX support, delayed context parsing for
6075 @noindent @b{Version 1.00}
6078 released on 7 Jan 1997.
6081 @node GNU Free Documentation License, Index, Changes, Top
6082 @appendix GNU Free Documentation License
6083 @include doclicense.texi
6085 @node Index, , GNU Free Documentation License, Top