[Top][All Lists]

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

Re: [AUCTeX] Customizing equation/figure label strings per document

From: Ralf Angeli
Subject: Re: [AUCTeX] Customizing equation/figure label strings per document
Date: Mon, 08 Sep 2008 21:52:45 +0200

* Ritesh Sood (2008-09-08) writes:

> I want to change the equation/figure label strings in the following manner:
> Environment                   Current (default)
> Desired
> equation                          eq:1
>                                                eq:P1-1
> figure                                fig:1
>                                                fig:P1-1
>  P1- stands for Part1-, and I'd like to have P2-, P3-, etc for different
> documents.  So the thing to do would be to write an AUCTeX style file and
> drop it in style/ subdir of the document directory. Only, I don't know
> elisp, and  couldn't make out what to do even after reading the AUCTeX and
> RefTeX documentation.

AFAICS this is not so easy since the label prefixes are usually defined
per label in `reftex-label-alist{-builtin}'.  Perhaps you could define
your own function for `reftex-format-label-function' which inserts a
string of your liking into the already computed label.  If you want to
stick that into the local variables stanza you could e.g. use this:

%%% reftex-format-label-function: (lambda (label format) (let* ((parts 
(split-string label ":")) (label (concat (car parts) ":P1-" (cadr parts)))) 
(format format label)))

The function makes the assumption that each label contains a single
colon, so I am quite sure that it will eventually fail.  One would have
to add precautions for dealing with labels not following this

> Can someone please give me an elisp code snippet that i can drop in style/ ?

I don't think a style file would be the right place because styles
depend on properties of the document, like LaTeX classes or packages.

Perhaps it would be better to define the format function in your init
file as a named function and set it in the local variables stanza.  You
could also set a variable which defines the string to be inserted by the

By the way, please don't send HTML mails to this mailing list.


reply via email to

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