Next: , Up: Labels and References

3.1 Creating Labels

In order to create a label in a LaTeX document, press C-c ( (reftex-label). Just like LaTeX, RefTeX is context sensitive and will figure out the environment it currently is in and adapt the label to that environment. A label usually consists of a short prefix indicating the type of the label and a unique mark. RefTeX has three different modes to create this mark.

  1. A label can be derived from context. This means, RefTeX takes the context of the label definition and constructs a label from that1. This works best for section labels, where the section heading is used to construct a label. In fact, RefTeX's default settings use this method only for section labels. You will be asked to confirm the derived label, or edit it.
  2. We may also use a simple unique number to identify a label. This is mostly useful for labels where it is difficult to come up with a very good descriptive name. RefTeX's default settings use this method for equations, enumerate items and footnotes. The author of RefTeX tends to write documents with many equations and finds it impossible to come up with good names for each of them. These simple labels are inserted without query, and are therefore very fast. Good descriptive names are not really necessary as RefTeX will provide context to reference a label (see Referencing Labels).
  3. The third method is to ask the user for a label. This is most useful for things which are easy to describe briefly and do not turn up too frequently in a document. RefTeX uses this for figures and tables. Of course, one can enter the label directly by typing the full ‘\label{mark}’. The advantage of using reftex-label anyway is that RefTeX will know that a new label has been defined. It will then not be necessary to rescan the document in order to access this label later.

If you want to change the way certain labels are created, check out the variable reftex-insert-label-flags (see Options (Creating Labels)).

If you are using AUCTeX to write your LaTeX documents, you can set it up to delegate the creation of labels to RefTeX. See AUCTeX, for more information.


Footnotes

[1] Note that the context may contain constructs which are invalid in labels. RefTeX will therefore strip the accent from accented Latin-1 characters and remove everything else which is not valid in labels. This mechanism is safe, but may not be satisfactory for non-western languages. Check the following variables if you need to change things: reftex-translate-to-ascii-function, reftex-derive-label-parameters, reftex-label-illegal-re, reftex-abbrev-parameters.