I am trying to configure RefTeX/AUCTeX so that the smart label-creation, invoked with C-c ( has the following sets of behaviors:

  • for \section-type labels, i.e., for \section, \subsection, etc. generate a label of the form: \label{sec:[[derived-from-section-name]]} where what follows the colon is derived from the section name.
  • for \items in an enumerate environment, generate a label of the form: \label{item:[[number]]}, where the number is automatically incremented from what has gone before. i.e., the first enumerate item I generate a label for gets \label{item:1}, the next one \label{item:2}, and so on.

This was standard behavior of my reftex implementation when I was using aquamacs, but I haven't been able to duplicate this in standard emacs.

Any help would be appreciated.


RefTeX has a variable called reftex-insert-label-flags. From the docstring:

reftex-insert-label-flags is a variable defined in reftex-vars.el.
Its value is ("s" "sft")
Flags governing label insertion. First flag DERIVE, second flag PROMPT.

If DERIVE is t, RefTeX will try to derive a sensible label from context. A section label for example will be derived from the section heading. The conversion of the context to a valid label is governed by the specifications given in reftex-derive-label-parameters. If RefTeX fails to derive a label, it will prompt the user. If DERIVE is nil, the label generated will consist of the prefix and a unique number, like eq:23.

If PROMPT is t, the user will be prompted for a label string. The prompt will already contain the prefix, and (if DERIVE is t) a default label derived from context. When PROMPT is nil, the default label will be inserted without query.

So the combination of DERIVE and PROMPT controls label insertion. Here is a table describing all four possibilities:

nil      nil     Insert simple label, like eq:22 or sec:13.  No query. 
nil      t       Prompt for label.
t        nil     Derive a label from context and insert without query.
t        t       Derive a label from context and prompt for confirmation.

Each flag may be set to t, nil, or a string of label type letters indicating the label types for which it should be true. The strings work like character classes. Thus, the combination may be set differently for each label type. The default settings "s" and "sft" mean: Derive section labels from headings (with confirmation). Prompt for figure and table labels. Use simple labels without confirmation for everything else. The available label types are: s (section), f (figure), t (table), i (item), e (equation), n (footnote), N (endnote), plus any definitions in ‘reftex-label-alist’.

With the standard setting, you should achieve what you're asking for. Check the value and if it's somehow changed somewhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.