This is ../info/reftex, produced by makeinfo version 4.2 from reftex.texi. INFO-DIR-SECTION Emacs START-INFO-DIR-ENTRY * RefTeX: (reftex). Emacs support for LaTeX cross-references and citations. END-INFO-DIR-ENTRY This file documents RefTeX, a package to do labels, references, citations and indices for LaTeX documents with Emacs. This is edition 4.16 of the RefTeX User Manual for RefTeX 4.16 Copyright (c) 1997, 1998, 1999, 2000 2001 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover texts being "A GNU Manual", and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled "GNU Free Documentation License" in the Emacs manual. (a) The FSF's Back-Cover Text is: "You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development." This document is part of a collection distributed under the GNU Free Documentation License. If you want to distribute this document separately from the collection, you can do so by adding a copy of the license to the document, as described in section 6 of the license.  File: reftex, Node: varioref (LaTeX package), Next: fancyref (LaTeX package), Prev: xr (LaTeX package), Up: Labels and References `varioref': Variable Page References ==================================== `varioref' is a frequently used LaTeX package to create cross-references with page information. When you want to make a reference with the `\vref' macro, just press the `v' key in the selection buffer to toggle between `\ref' and `\vref' (*note Referencing Labels::). The mode line of the selection buffer shows the current status of this switch. If you find that you almost always use `\vref', you may want to make it the default by customizing the variable `reftex-vref-is-default'. If this toggling seems too inconvenient, you can also use the command `reftex-varioref-vref'(1). Or use AUCTeX to create your macros (*note AUCTeX::). ---------- Footnotes ---------- (1) bind it to `C-c v'.  File: reftex, Node: fancyref (LaTeX package), Prev: varioref (LaTeX package), Up: Labels and References `fancyref': Fancy Cross References ================================== `fancyref' is a LaTeX package where a macro call like `\fref{FIG:MAP-OF-GERMANY}' creates not only the number of the referenced counter but also the complete text around it, like `Figure 3 on the preceding page'. In order to make it work you need to use label prefixes like `fig:' consistently - something RefTeX does automatically. When you want to make a reference with the `\fref' macro, just press the `V' key in the selection buffer to cycle between `\ref', `\fref' and `\Fref' (*note Referencing Labels::). The mode line of the selection buffer shows the current status of this switch. If this cycling seems inconvenient, you can also use the commands `reftex-fancyref-fref' and `reftex-fancyref-Fref'(1). Or use AUCTeX to create your macros (*note AUCTeX::). ---------- Footnotes ---------- (1) bind them to `C-c f' and `C-c F'.  File: reftex, Node: Citations, Next: Index Support, Prev: Labels and References, Up: Top Citations ********* Citations in LaTeX are done with the `\cite' macro or variations of it. The argument of the macro is a citation key which identifies an article or book in either a BibTeX database file or in an explicit `thebibliography' environment in the document. RefTeX's support for citations helps to select the correct key quickly. * Menu: * Creating Citations:: How to create them. * Citation Styles:: Natbib, Harvard, Chicago and Co. * Citation Info:: View the corresponding database entry. * Chapterbib and Bibunits:: Multiple bibliographies in a Document. * Citations Outside LaTeX:: How to make citations in Emails etc.  File: reftex, Node: Creating Citations, Next: Citation Styles, Up: Citations Creating Citations ================== In order to create a citation, press `C-c ['. RefTeX then prompts for a regular expression which will be used to search through the database and present the list of matches to choose from in a selection process similar to that for selecting labels (*note Referencing Labels::). The regular expression uses an extended syntax: `&&' defines a logic `and' for regular expressions. For example `Einstein&&Bose' will match all articles which mention Bose-Einstein condensation, or which are co-authored by Bose and Einstein. When entering the regular expression, you can complete on known citation keys. RefTeX prefers to use BibTeX database files specified with a `\bibliography' macro to collect its information. Just like BibTeX, it will search for the specified files in the current directory and along the path given in the environment variable `BIBINPUTS'. If you do not use BibTeX, but the document contains an explicit `thebibliography' environment, RefTeX will collect its information from there. Note that in this case the information presented in the selection buffer will just be a copy of relevant `\bibitem' entries, not the structured listing available with BibTeX database files. In the selection buffer, the following keys provide special commands. A summary of this information is always available from the selection process by pressing `?'. General ....... `?' Show a summary of available commands. `0-9,-' Prefix argument. Moving around ............. `n' Go to next article. `p' Go to previous article. Access to full database entries ............................... `' Show the database entry corresponding to the article at point, in another window. See also the `f' key. `f' Toggle follow mode. When follow mode is active, the other window will always display the full database entry of the current article. This is equivalent to pressing after each cursor motion. With BibTeX entries, follow mode can be rather slow. Selecting entries and creating the citation ........................................... `' Insert a citation referencing the article at point into the buffer from which the selection process was started. `mouse-2' Clicking with mouse button 2 on a citation will accept it like would. See also variable `reftex-highlight-selection', *Note Options (Misc)::. `m' Mark the current entry. When one or several entries are marked, pressing `a' or `A' accepts all marked entries. Also, behaves like the `a' key. `u' Unmark a marked entry. `a' Accept all (marked) entries in the selection buffer and create a single `\cite' macro referring to them. `A' Accept all (marked) entries in the selection buffer and create a separate `\cite' macro for each of it. `' Enter a citation key with completion. This may also be a key which does not yet exist. `.' Show insertion point in another window. This is the point from where you called `reftex-citation'. Exiting ....... `q' Exit the selection process without inserting a citation into the buffer. Updating the buffer ................... `g' Start over with a new regular expression. The full database will be rescanned with the new expression (see also `r'). `r' Refine the current selection with another regular expression. This will _not_ rescan the entire database, but just the already selected entries. In order to define additional commands for this selection process, the keymap `reftex-select-bib-map' may be used.  File: reftex, Node: Citation Styles, Next: Citation Info, Prev: Creating Citations, Up: Citations Citation Styles =============== The standard LaTeX macro `\cite' works well with numeric or simple key citations. To deal with the more complex task of author-year citations as used in many natural sciences, a variety of packages has been developed which define derived forms of the `\cite' macro. RefTeX can be configured to produce these citation macros as well by setting the variable `reftex-cite-format'. For the most commonly used packages (`natbib', `harvard', `chicago') this may be done from the menu, under `Ref->Citation Styles'. Since there are usually several macros to create the citations, executing `reftex-citation' (`C-c [') starts by prompting for the correct macro. For the Natbib style, this looks like this: SELECT A CITATION FORMAT [^M] \cite{%l} [t] \citet{%l} [T] \citet*{%l} [p] \citep{%l} [P] \citep*{%l} [e] \citep[e.g.][]{%l} [s] \citep[see][]{%l} [a] \citeauthor{%l} [A] \citeauthor*{%l} [y] \citeyear{%l} Following the most generic of these packages, `natbib', the builtin citation packages always accept the `t' key for a _textual_ citation (like: `Jones et al. (1997) have shown...') as well as the `p' key for a parenthetical citation (like: `As shown earlier (Jones et al, 1997)'). To make one of these styles the default, customize the variable `reftex-cite-format' or put into `.emacs': (setq reftex-cite-format 'natbib) You can also use AUCTeX style files to automatically set the citation style based on the `usepackage' commands in a given document. *Note Style Files::, for information on how to set up the style files correctly.  File: reftex, Node: Citation Info, Next: Chapterbib and Bibunits, Prev: Citation Styles, Up: Citations Top Citation Info ============= When point is idle on the argument of a `\cite' macro, the echo area will display some information about the article cited there. Note that the information is only displayed if the echo area is not occupied by a different message. RefTeX can also display the `\bibitem' or BibTeX database entry corresponding to a `\cite' macro, or all citation locations corresponding to a `\bibitem' or BibTeX database entry. *Note Viewing Cross-References::.  File: reftex, Node: Chapterbib and Bibunits, Next: Citations Outside LaTeX, Prev: Citation Info, Up: Citations Chapterbib and Bibunits ======================= `chapterbib' and `bibunits' are two LaTeX packages which produce multiple bibliographies in a document. This is no problem for RefTeX as long as all bibliographies use the same BibTeX database files. If they do not, it is best to have each document part in a separate file (as it is required for `chapterbib' anyway). Then RefTeX will still scan the locally relevant databases correctly. If you have multiple bibliographies within a _single file_, this may or may not be the case.  File: reftex, Node: Citations Outside LaTeX, Prev: Chapterbib and Bibunits, Up: Citations Citations outside LaTeX ======================= The command `reftex-citation' can also be executed outside a LaTeX buffer. This can be useful to reference articles in the mail buffer and other documents. You should _not_ enter `reftex-mode' for this, just execute the command. The list of BibTeX files will in this case be taken from the variable `reftex-default-bibliography'. Setting the variable `reftex-cite-format' to the symbol `locally' does a decent job of putting all relevant information about a citation directly into the buffer. Here is the lisp code to add the `C-c [' binding to the mail buffer. It also provides a local binding for `reftex-cite-format'. (add-hook 'mail-setup-hook (lambda () (define-key mail-mode-map "\C-c[" (lambda () (interactive) (require 'reftex) (let ((reftex-cite-format 'locally)) (reftex-citation))))))  File: reftex, Node: Index Support, Next: Viewing Cross-References, Prev: Citations, Up: Top Index Support ************* LaTeX has builtin support for creating an Index. The LaTeX core supports two different indices, the standard index and a glossary. With the help of special LaTeX packages (`multind.sty' or `index.sty'), any number of indices can be supported. Index entries are created with the `\index{ENTRY}' macro. All entries defined in a document are written out to the `.aux' file. A separate tool must be used to convert this information into a nicely formatted index. Tools used with LaTeX include `MakeIndex' and `xindy'. Indexing is a very difficult task. It must follow strict conventions to make the index consistent and complete. There are basically two approaches one can follow, and both have their merits. 1. Part of the indexing should already be done with the markup. The document structure should be reflected in the index, so when starting new sections, the basic topics of the section should be indexed. If the document contains definitions, theorems or the like, these should all correspond to appropriate index entries. This part of the index can very well be developed along with the document. Often it is worthwhile to define special purpose macros which define an item and at the same time make an index entry, possibly with special formatting to make the reference page in the index bold or underlined. To make RefTeX support for indexing possible, these special macros must be added to RefTeX's configuration (*note Defining Index Macros::). 2. The rest of the index is often just a collection of where in the document certain words or phrases are being used. This part is difficult to develop along with the document, because consistent entries for each occurrence are needed and are best selected when the document is ready. RefTeX supports this with an _index phrases file_ which collects phrases and helps indexing the phrases globally. Before you start, you need to make sure that RefTeX knows about the index style being used in the current document. RefTeX has builtin support for the default `\index' and `\glossary' macros. Other LaTeX packages, like the `multind' or `index' package, redefine the `\index' macro to have an additional argument, and RefTeX needs to be configured for those. A sufficiently new version of AUCTeX (9.10c or later) will do this automatically. If you really don't use AUCTeX (you should!), this configuration needs to be done by hand with the menu (`Ref->Index Style'), or globally for all your documents with (setq reftex-index-macros '(multind)) or (setq reftex-index-macros '(index)) * Menu: * Creating Index Entries:: Macros and completion of entries. * The Index Phrases File:: A special file for global indexing. * Displaying and Editing the Index:: The index editor. * Builtin Index Macros:: The index macros RefTeX knows about. * Defining Index Macros:: ... and macros it doesn't.  File: reftex, Node: Creating Index Entries, Next: The Index Phrases File, Up: Index Support Creating Index Entries ====================== In order to index the current selection or the word at the cursor press `C-c /' (`reftex-index-selection-or-word'). This causes the selection or word `WORD' to be replaced with `\index{WORD}WORD'. The macro which is used (`\index' by default) can be configured with the variable `reftex-index-default-macro'. When the command is called with a prefix argument (`C-u C-c /'), you get a chance to edit the generated index entry. Use this to change the case of the word or to make the entry a subentry, for example by entering `main!sub!WORD'. When called with two raw `C-u' prefixes (`C-u C-u C-c /'), you will be asked for the index macro as well. When there is nothing selected and no word at point, this command will just call `reftex-index', described below. In order to create a general index entry, press `C-c <' (`reftex-index'). RefTeX will prompt for one of the available index macros and for its arguments. Completion will be available for the index entry and, if applicable, the index tag. The index tag is a string identifying one of multiple indices. With the `multind' and `index' packages, this tag is the first argument to the redefined `\index' macro.  File: reftex, Node: The Index Phrases File, Next: Displaying and Editing the Index, Prev: Creating Index Entries, Up: Index Support The Index Phrases File ====================== RefTeX maintains a file in which phrases can be collected for later indexing. The file is located in the same directory as the master file of the document and has the extension `.rip' (Reftex Index Phrases). You can create or visit the file with `C-c |' (`reftex-index-visit-phrases-buffer'). If the file is empty it is initialized by inserting a file header which contains the definition of the available index macros. This list is initialized from `reftex-index-macros' (*note Defining Index Macros::). You can edit the header as needed, but if you define new LaTeX indexing macros, don't forget to add them to `reftex-index-macros' as well. Here is a phrase file header example: % -*- mode: reftex-index-phrases -*- % Key Macro Format Repeat %---------------------------------------------------------- >>>INDEX_MACRO_DEFINITION: i \index{%s} t >>>INDEX_MACRO_DEFINITION: I \index*{%s} nil >>>INDEX_MACRO_DEFINITION: g \glossary{%s} t >>>INDEX_MACRO_DEFINITION: n \index*[name]{%s} nil %---------------------------------------------------------- The macro definition lines consist of a unique letter identifying a macro, a format string and the REPEAT flag, all separated by . The format string shows how the macro is to be applied, the `%s' will be replaced with the index entry. The repeat flag indicates if WORD is indexed by the macro as `\index{WORD}' (REPEAT = `nil') or as `\index{WORD}WORD' (REPEAT = `t'). In the above example it is assumed that the macro `\index*{WORD}' already typesets its argument in the text, so that it is unnecessary to repeat WORD outside the macro. * Menu: * Collecting Phrases:: Collecting from document or external. * Consistency Checks:: Check for duplicates etc. * Global Indexing:: The interactive indexing process.  File: reftex, Node: Collecting Phrases, Next: Consistency Checks, Up: The Index Phrases File Collecting Phrases ------------------ Phrases for indexing can be collected while writing the document. The command `C-c \' (`reftex-index-phrase-selection-or-word') copies the current selection (if active) or the word near point into the phrases buffer. It then selects this buffer, so that the phrase line can be edited. To return to the LaTeX document, press `C-c C-c' (`reftex-index-phrases-save-and-return'). You can also prepare the list of index phrases in a different way and copy it into the phrases file. For example you might want to start from a word list of the document and remove all words which should not be indexed. The phrase lines in the phrase buffer must have a specific format. RefTeX will use font-lock to indicate if a line has the proper format. A phrase line looks like this: [KEY] PHRASE [ ARG[&&ARG]... [ || ARG]...] `' stands for white space containing at least one . KEY must be at the start of the line and is the character identifying one of the macros defined in the file header. It is optional - when omitted, the first macro definition line in the file will be used for this phrase. The PHRASE is the phrase to be searched for when indexing. It may contain several words separated by spaces. By default the search phrase is also the text entered as argument of the index macro. If you want the index entry to be different from the search phrase, enter another and the index argument ARG. If you want to have each match produce several index entries, separate the different index arguments with ` && '(1). If you want to be able to choose at each match between several different index arguments, separate them with ` || '(2). Here is an example: %-------------------------------------------------------------------- I Sun i Planet Planets i Vega Stars!Vega Jupiter Planets!Jupiter i Mars Planets!Mars || Gods!Mars || Chocolate Bars!Mars i Pluto Planets!Pluto && Kuiper Belt Objects!Pluto So `Sun' will be indexed directly as `\index*{Sun}', while `Planet' will be indexed as `\index{Planets}Planet'. `Vega' will be indexed as a subitem of `Stars'. The `Jupiter' line will also use the `i' macro as it was the first macro definition in the file header (see above example). At each occurrence of `Mars' you will be able choose between indexing it as a subitem of `Planets', `Gods' or `Chocolate Bars'. Finally, every occurrence of `Pluto' will be indexed as `\index{Planets!Pluto}\index{Kuiper Belt Objects!Pluto}Pluto' and will therefore create two different index entries. ---------- Footnotes ---------- (1) `&&' with optional spaces, see `reftex-index-phrases-logical-and-regexp'. (2) `||' with optional spaces, see `reftex-index-phrases-logical-or-regexp'.  File: reftex, Node: Consistency Checks, Next: Global Indexing, Prev: Collecting Phrases, Up: The Index Phrases File Consistency Checks ------------------ Before indexing the phrases in the phrases buffer, they should be checked carefully for consistency. A first step is to sort the phrases alphabetically - this is done with the command `C-c C-s' (`reftex-index-sort-phrases'). It will sort all phrases in the buffer alphabetically by search phrase. If you want to group certain phrases and only sort within the groups, insert empty lines between the groups. Sorting will only change the sequence of phrases within each group (see the variable `reftex-index-phrases-sort-in-blocks'). A useful command is `C-c C-i' (`reftex-index-phrases-info') which lists information about the phrase at point, including an example of how the index entry will look like and the number of expected matches in the document. Another important check is to find out if there are double or overlapping entries in the buffer. For example if you are first searching and indexing `Mars' and then `Planet Mars', the second phrase will not match because of the index macro inserted before `Mars' earlier. The command `C-c C-t' (`reftex-index-find-next-conflict-phrase') finds the next phrase in the buffer which is either duplicate or a subphrase of another phrase. In order to check the whole buffer like this, start at the beginning and execute this command repeatedly.  File: reftex, Node: Global Indexing, Prev: Consistency Checks, Up: The Index Phrases File Global Indexing --------------- Once the index phrases have been collected and organized, you are set for global indexing. I recommend to do this only on an otherwise finished document. Global indexing starts from the phrases buffer. There are several commands which start indexing: `C-c C-x' acts on the current phrase line, `C-c C-r' on all lines in the current region and `C-c C-a' on all phrase lines in the buffer. It is probably good to do indexing in small chunks since your concentration may not last long enough to do everything in one go. RefTeX will start at the first phrase line and search the phrase globally in the whole document. At each match it will stop, compute the replacement string and offer you the following choices(1): `y' Replace this match with the proposed string. `n' Skip this match. `!' Replace this and all further matches in this file. `q' Skip this match, start with next file. `Q' Skip this match, start with next phrase. `o' Select a different indexing macro for this match. `1-9' Select one of multiple index keys (those separated with `||'). `e' Edit the replacement text. `C-r' Recursive edit. Use `M-C-c' to return to the indexing process. `s' Save this buffer and ask again about the current match. `S' Save all document buffers and ask again about the current match. `C-g' Abort the indexing process. The `Find and Index in Document' menu in the phrases buffer also lists a few options for the indexing process. The options have associated customization variables to set the defaults (*note Options (Index Support)::). Here is a short explanation of what the options do: Match Whole Words When searching for index phrases, make sure whole words are matched. This should probably always be on. Case Sensitive Search Search case sensitively for phrases. I recommend to have this setting off, in order to match the capitalized words at the beginning of a sentence, and even typos. You can always say _no_ at a match you do not like. Wrap Long Lines Inserting index macros increases the line length. Turn this option on to allow RefTeX to wrap long lines. Skip Indexed Matches When this is on, RefTeX will at each match try to figure out if this match is already indexed. A match is considered indexed if it is either the argument of an index macro, or if an index macro is directly (without whitespace separation) before or after the match. Index macros are those configured in `reftex-index-macros'. Intended for re-indexing a documents after changes have been made. Even though indexing should be the last thing you do to a document, you are bound to make changes afterwards. Indexing then has to be applied to the changed regions. The command `reftex-index-phrases-apply-to-region' is designed for this purpose. When called from a LaTeX document with active region, it will apply `reftex-index-all-phrases' to the current region. ---------- Footnotes ---------- (1) Windows users: Restrict yourself to the described keys during indexing. Pressing at the indexing prompt can apparently hang Emacs.  File: reftex, Node: Displaying and Editing the Index, Next: Builtin Index Macros, Prev: The Index Phrases File, Up: Index Support Displaying and Editing the Index ================================ In order to compile and display the index, press `C-c >'. If the document uses multiple indices, RefTeX will ask you to select one. Then, all index entries will be sorted alphabetically and displayed in a special buffer, the `*Index*' buffer. From that buffer you can check and edit each entry. The index can be restricted to the current section or the region. Then only entries in that part of the document will go into the compiled index. To restrict to the current section, use a numeric prefix `2', thus press `C-u 2 C-c >'. To restrict to the current region, make the region active and use a numeric prefix `3' (press `C-u 3 C-c >'). From within the `*Index*' buffer the restriction can be moved from one section to the next by pressing the `<' and `>' keys. One caveat: RefTeX finds the definition point of an index entry by searching near the buffer position where it had found to macro during scanning. If you have several identical index entries in the same buffer and significant changes have shifted the entries around, you must rescan the buffer to ensure the correspondence between the `*Index*' buffer and the definition locations. It is therefore advisable to rescan the document (with `r' or `C-u r') frequently while editing the index from the `*Index*' buffer. Here is a list of special commands available in the `*Index*' buffer. A summary of this information is always available by pressing `?'. General ....... `?' Display a summary of commands. `0-9, -' Prefix argument. Moving around ............. `! A..Z' Pressing any capital letter will jump to the corresponding section in the `*Index*' buffer. The exclamation mark is special and jumps to the first entries alphabetically sorted below `A'. These are usually non-alphanumeric characters. `n' Go to next entry. `p' Go to previous entry. Access to document locations ............................ `' Show the place in the document where this index entry is defined. `' Go to the definition of the current index entry in another window. `' Go to the definition of the current index entry and hide the `*Index*' buffer window. `f' Toggle follow mode. When follow mode is active, the other window will always show the location corresponding to the line in the `*Index*' buffer at point. This is similar to pressing after each cursor motion. The default for this flag can be set with the variable `reftex-index-follow-mode'. Note that only context in files already visited is shown. RefTeX will not visit a file just for follow mode. See, however, the variable `reftex-revisit-to-follow'. Entry editing ............. `e' Edit the current index entry. In the minibuffer, you can edit the index macro which defines this entry. `C-k' Kill the index entry. Currently not implemented because I don't know how to implement an `undo' function for this. `*' Edit the KEY part of the entry. This is the initial part of the entry which determines the location of the entry in the index. `|' Edit the ATTRIBUTE part of the entry. This is the part after the vertical bar. With `MakeIndex', this part is an encapsulating macro. With `xindy', it is called _attribute_ and is a property of the index entry that can lead to special formatting. When called with `C-u' prefix, kill the entire ATTRIBUTE part. `@' Edit the VISUAL part of the entry. This is the part after the `@' which is used by `MakeIndex' to change the visual appearance of the entry in the index. When called with `C-u' prefix, kill the entire VISUAL part. `(' Toggle the beginning of page range property `|(' of the entry. `)' Toggle the end of page range property `|)' of the entry. `_' Make the current entry a subentry. This command will prompt for the superordinate entry and insert it. `^' Remove the highest superordinate entry. If the current entry is a subitem (`aaa!bbb!ccc'), this function moves it up the hierarchy (`bbb!ccc'). Exiting ....... `q' Hide the `*Index*' buffer. `k' Kill the `*Index*' buffer. `C-c =' Switch to the Table of Contents buffer of this document. Controlling what gets displayed ............................... `c' Toggle the display of short context in the `*Index*' buffer. The default for this flag can be set with the variable `reftex-index-include-context'. `}' Restrict the index to a single document section. The corresponding section number will be displayed in the `R<>' indicator in the mode line and in the header of the `*Index*' buffer. `{' Widen the index to contain all entries of the document. `<' When the index is currently restricted, move the restriction to the previous section. `>' When the index is currently restricted, move the restriction to the next section. Updating the buffer ................... `g' Rebuild the `*Index*' buffer. This does _not_ rescan the document. However, it sorts the entries again, so that edited entries will move to the correct position. `r' Reparse the LaTeX document and rebuild the `*Index*' buffer. When `reftex-enable-partial-scans' is non-nil, rescan only the file this location is defined in, not the entire document. `C-u r' Reparse the _entire_ LaTeX document and rebuild the `*Index*' buffer. `s' Switch to a different index (for documents with multiple indices).  File: reftex, Node: Builtin Index Macros, Next: Defining Index Macros, Prev: Displaying and Editing the Index, Up: Index Support Builtin Index Macros ==================== RefTeX by default recognizes the `\index' and `\glossary' macros which are defined in the LaTeX core. It has also builtin support for the re-implementations of `\index' in the `multind' and `index' packages. However, since the different definitions of the `\index' macro are incompatible, you will have to explicitly specify the index style used. *Note Creating Index Entries::, for information on how to do that.  File: reftex, Node: Defining Index Macros, Prev: Builtin Index Macros, Up: Index Support Defining Index Macros ===================== When writing a document with an index you will probably define additional macros which make entries into the index. Let's look at an example. \newcommand{\ix}[1]{#1\index{#1}} \newcommand{\nindex}[1]{\textit{#1}\index[name]{#1}} \newcommand{\astobj}[1]{\index{Astronomical Objects!#1}} The first macro `\ix' typesets its argument in the text and places it into the index. The second macro `\nindex' typesets its argument in the text and places it into a separate index with the tag `name'(1). The last macro also places its argument into the index, but as subitems under the main index entry `Astronomical Objects'. Here is how to make RefTeX recognize and correctly interpret these macros, first with Emacs Lisp. (setq reftex-index-macros '(("\\ix{*}" "idx" ?x "" nil nil) ("\\nindex{*}" "name" ?n "" nil nil) ("\\astobj{*}" "idx" ?o "Astronomical Objects!" nil t))) Note that the index tag is `idx' for the main index, and `name' for the name index. `idx' and `glo' are reserved for the default index and for the glossary. The character arguments `?x', `?n', and `?o' are for quick identification of these macros when RefTeX inserts new index entries with `reftex-index'. These codes need to be unique. `?i', `?I', and `?g' are reserved for the `\index', `\index*', and `\glossary' macros, respectively. The following string is empty unless your macro adds a superordinate entry to the index key - this is the case for the `\astobj' macro. The next entry can be a hook function to exclude certain matches, it almost always can be `nil'. The final element in the list indicates if the text being indexed needs to be repeated outside the macro. For the normal index macros, this should be `t'. Only if the macro typesets the entry in the text (like `\ix' and `\nindex' in the example do), this should be `nil'. To do the same thing with customize, you need to fill in the templates like this: Repeat: [INS] [DEL] List: Macro with args: \ix{*} Index Tag : [Value Menu] String: idx Access Key : x Key Prefix : Exclusion hook : nil Repeat Outside : [Toggle] off (nil) [INS] [DEL] List: Macro with args: \nindex{*} Index Tag : [Value Menu] String: name Access Key : n Key Prefix : Exclusion hook : nil Repeat Outside : [Toggle] off (nil) [INS] [DEL] List: Macro with args: \astobj{*} Index Tag : [Value Menu] String: idx Access Key : o Key Prefix : Astronomical Objects! Exclusion hook : nil Repeat Outside : [Toggle] on (non-nil) [INS] With the macro `\ix' defined, you may want to change the default macro used for indexing a text phrase (*note Creating Index Entries::). This would be done like this (setq reftex-index-default-macro '(?x "idx")) which specifies that the macro identified with the character `?x' (the `\ix' macro) should be used for indexing phrases and words already in the buffer with `C-c /' (`reftex-index-selection-or-word'). The index tag is "idx". ---------- Footnotes ---------- (1) We are using the syntax of the `index' package here.  File: reftex, Node: Viewing Cross-References, Next: RefTeXs Menu, Prev: Index Support, Up: Top Viewing Cross-References ************************ RefTeX can display cross-referencing information. This means, if two document locations are linked, RefTeX can display the matching location(s) in another window. The `\label' and `\ref' macros are one way of establishing such a link. Also, a `\cite' macro is linked to the corresponding `\bibitem' macro or a BibTeX database entry. The feature is invoked by pressing `C-c &' (`reftex-view-crossref') while point is on the KEY argument of a macro involved in cross-referencing. You can also click with `S-mouse-2' on the macro argument. Here is what will happen for individual classes of macros: `\ref' Display the corresponding label definition. All usual variants(1) of the `\ref' macro are active for cross-reference display. This works also for labels defined in an external document when the current document refers to them through the `xr' interface (*note xr (LaTeX package)::). `\label' Display a document location which references this label. Pressing `C-c &' several times moves through the entire document and finds all locations. Not only the `\label' macro but also other macros with label arguments (as configured with `reftex-label-alist') are active for cross-reference display. `\cite' Display the corresponding BibTeX database entry or `\bibitem'. All usual variants(2) of the `\cite' macro are active for cross-reference display. `\bibitem' Display a document location which cites this article. Pressing `C-c &' several times moves through the entire document and finds all locations. BibTeX `C-c &' is also active in BibTeX buffers. All locations in a document where the database entry at point is cited will be displayed. On first use, RefTeX will prompt for a buffer which belongs to the document you want to search. Subsequent calls will use the same document, until you break this link with a prefix argument to `C-c &'. `\index' Display other locations in the document which are marked by an index macro with the same key argument. Along with the standard `\index' and `\glossary' macros, all macros configured in `reftex-index-macros' will be recognized. While the display of cross referencing information for the above mentioned macros is hard-coded, you can configure additional relations in the variable `reftex-view-crossref-extra'. ---------- Footnotes ---------- (1) all macros that start with `ref' or end with `ref' or `refrange' (2) all macros that either start or end with `cite'  File: reftex, Node: RefTeXs Menu, Next: Key Bindings, Prev: Viewing Cross-References, Up: Top RefTeX's Menu ============= RefTeX installs a `Ref' menu in the menu bar on systems which support this. From this menu you can access all of RefTeX's commands and a few of its options. There is also a `Customize' submenu which can be used to access RefTeX's entire set of options.  File: reftex, Node: Key Bindings, Next: Faces, Prev: RefTeXs Menu, Up: Top Default Key Bindings ==================== Here is a summary of the available key bindings. C-c = `reftex-toc' C-c ( `reftex-label' C-c ) `reftex-reference' C-c [ `reftex-citation' C-c & `reftex-view-crossref' S-mouse-2 `reftex-mouse-view-crossref' C-c / `reftex-index-selection-or-word' C-c \ `reftex-index-phrase-selection-or-word' C-c | `reftex-index-visit-phrases-buffer' C-c < `reftex-index' C-c > `reftex-display-index' Note that the `S-mouse-2' binding is only provided if this key is not already used by some other package. RefTeX will not override an existing binding to `S-mouse-2'. Personally, I also bind some functions in the users `C-c' map for easier access. C-c t `reftex-toc' C-c l `reftex-label' C-c r `reftex-reference' C-c c `reftex-citation' C-c v `reftex-view-crossref' C-c s `reftex-search-document' C-c g `reftex-grep-document' These keys are reserved for the user, so I cannot bind them by default. If you want to have these key bindings available, set in your `.emacs' file: (setq reftex-extra-bindings t) Changing and adding to RefTeX's key bindings is best done in the hook `reftex-load-hook'. For information on the keymaps which should be used to add keys, see *Note Keymaps and Hooks::.  File: reftex, Node: Faces, Next: AUCTeX, Prev: Key Bindings, Up: Top Faces ===== RefTeX uses faces when available to structure the selection and table of contents buffers. It does not create its own faces, but uses the ones defined in `font-lock.el'. Therefore, RefTeX will use faces only when `font-lock' is loaded. This seems to be reasonable because people who like faces will very likely have it loaded. If you wish to turn off fontification or change the involved faces, see *Note Options (Fontification)::.  File: reftex, Node: Multifile Documents, Next: Language Support, Prev: AUCTeX, Up: Top Multifile Documents =================== The following is relevant when working with documents spread over many files: * RefTeX has full support for multifile documents. You can edit parts of several (multifile) documents at the same time without conflicts. RefTeX provides functions to run `grep', `search' and `query-replace' on all files which are part of a multifile document. * All files belonging to a multifile document should define a File Variable (`TeX-master' for AUCTeX or `tex-main-file' for the standard Emacs LaTeX mode) containing the name of the master file. For example, to set the file variable `TeX-master', include something like the following at the end of each TeX file: %%% Local Variables: *** %%% mode:latex *** %%% TeX-master: "thesis.tex" *** %%% End: *** AUCTeX with the setting (setq-default TeX-master nil) will actually ask you for each new file about the master file and insert this comment automatically. For more details see the documentation of the AUCTeX (*note Multifile: (auctex)Multifile.), the documentation about the Emacs (La)TeX mode (*note TeX Print: (emacs)TeX Print.) and the Emacs documentation on File Variables (*note File Variables: (emacs)File Variables.). * The context of a label definition must be found in the same file as the label itself in order to be processed correctly by RefTeX. The only exception is that section labels referring to a section statement outside the current file can still use that section title as context.  File: reftex, Node: Language Support, Next: Finding Files, Prev: Multifile Documents, Up: Top Language Support ================ Some parts of RefTeX are language dependent. The default settings work well for English. If you are writing in a different language, the following hints may be useful: * The mechanism to derive a label from context includes the abbreviation of words and omission of unimportant words. These mechanisms may have to be changed for other languages. See the variables `reftex-derive-label-parameters' and `reftex-abbrev-parameters'. * Also, when a label is derived from context, RefTeX clears the context string from non-ASCII characters in order to make a legal label. If there should ever be a version of TeX which allows extended characters _in labels_, then we will have to look at the variables `reftex-translate-to-ascii-function' and `reftex-label-illegal-re'. * When a label is referenced, RefTeX looks at the word before point to guess which label type is required. These _magic words_ are different in every language. For an example of how to add magic words, see *Note Adding Magic Words::. * RefTeX inserts "punctuation" for multiple references and for the author list in citations. Some of this may be language dependent. See the variables `reftex-multiref-punctuation' and `reftex-cite-punctuation'.  File: reftex, Node: Finding Files, Next: Optimizations, Prev: Language Support, Up: Top Finding Files ============= In order to find files included in a document via `\input' or `\include', RefTeX searches all directories specified in the environment variable `TEXINPUTS'. Similarly, it will search the path specified in the variables `BIBINPUTS' and `TEXBIB' for BibTeX database files. When searching, RefTeX will also expand recursive path definitions (directories ending in `//' or `!!'). But it will only search and expand directories _explicitly_ given in these variables. This may cause problems under the following circumstances: * Most TeX system have a default search path for both TeX files and BibTeX files which is defined in some setup file. Usually this default path is for system files which RefTeX does not need to see. But if your document needs TeX files or BibTeX database files in a directory only given in the default search path, RefTeX will fail to find them. * Some TeX systems do not use environment variables at all in order to specify the search path. Both default and user search path are then defined in setup files. There are three ways to solve this problem: * Specify all relevant directories explicitly in the environment variables. If for some reason you don't want to mess with the default variables `TEXINPUTS' and `BIBINPUTS', define your own variables and configure RefTeX to use them instead: (setq reftex-texpath-environment-variables '("MYTEXINPUTS")) (setq reftex-bibpath-environment-variables '("MYBIBINPUTS")) * Specify the full search path directly in RefTeX's variables. (setq reftex-texpath-environment-variables '("./inp:/home/cd/tex//:/usr/local/tex//")) (setq reftex-bibpath-environment-variables '("/home/cd/tex/lit/")) * Some TeX systems provide stand-alone programs to do the file search just like TeX and BibTeX. E.g. Thomas Esser's `teTeX' uses the `kpathsearch' library which provides the command `kpsewhich' to search for files. RefTeX can be configured to use this program. Note that the exact syntax of the `kpsewhich' command depends upon the version of that program. (setq reftex-use-external-file-finders t) (setq reftex-external-file-finders '(("tex" . "kpsewhich -format=.tex %f") ("bib" . "kpsewhich -format=.bib %f")))