auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Adding new environments with label support


From: Tassilo Horn
Subject: Re: [AUCTeX] Adding new environments with label support
Date: Thu, 25 Apr 2013 17:13:17 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3.50 (gnu/linux)

"address@hidden" <address@hidden> writes:

Hi!

> (add-hook 'LaTeX-mode-hook
>           (lambda ()
>             (LaTeX-add-environments
>              '("axiom" LaTeX-env-label)
>              '("assumption" LaTeX-env-label))))
> (setq reftex-label-alist
>       '(("axiom"   ?a "ax:"  "~\\ref{%s}" nil ("axiom"   "ax."))
>         ("assumption"   ?s "asp:"  "~\\ref{%s}" nil ("assumption"
> "assum."))))
>
> I also set reftex-plug-into-AUCTeX to t.
>
> When pressing C-c C-e, the label for the axiom environment will be
> automatically numbered based on the current document, but the label for the
> assumption environment requires manual input. Both environments are defined
> in the document.
>
> I don't know what the difference is. Am I missing something in my .emacs
> file? Any help is greatly appreciated.

The reason is the ?a versus the ?s.  The ?a is unique in
`reftex-label-alist' and `reftex-label-alist-builtin', whereas ?s is
already used for sections.  And sections are a special case where
auto-generated label names are explicitly turned off.

,----[ C-h v reftex-insert-label-flags RET ]
| reftex-insert-label-flags is a variable defined in `reftex-vars.el'.
| Its value is ("s" "sft")
| 
| Documentation:
| 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:
| 
| DERIVE   PROMPT      ACTION
| -------------------------------------------------------------------------
|  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'.
`----

Well, that's actually quite complicated, so what I've written above is
more or less correct.  The solution to your problem is to use another
type-key like ?A, and then it'll work as you expect.

Bye,
Tassilo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]