[Top][All Lists]

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

[AUCTeX] Referencing labels with refstyle.sty

From: Alan Ristow
Subject: [AUCTeX] Referencing labels with refstyle.sty
Date: Wed, 11 Jul 2007 15:33:08 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20070604 Thunderbird/ Mnenhy/


I often use refstyle.sty for managing cross-references. Since there doesn't seem to be a refstyle.el anywhere, I'm trying to modify my .emacs file to get RefTeX to insert references that are formatted for it. Without going into too much detail about refstyle itself, when I have:


it lets me write:


to mean:


It has similar functionality for tables, equations, sections, chapters, etc., but once I have set up for one I should be able to easily extend it to the others. Focusing only on figures for the moment, I first tried this:

(setq reftex-label-alist
      '(("figure"   ?f "fig:"  "\\figref{%s}"  caption nil)))

This gets me halfway there, inserting \figref{fig:foo} rather than the \figref{foo} that I would like. Not being much of a Lisp programmer, after some struggle I came up with

(setq reftex-label-alist
      '(("figure"   ?f "fig:"  reftex-format-ref-function  caption nil)))

(defun reftex-format-ref-function (label default)
  (concat "\\" (replace-match "ref{" nil nil label ":") "}")

My intention here was to take the "fig:foo" label and replace ":" with "ref{", leaving me with "figref{foo", which I then concatenate between "\\" and "}" to give me "\\figref{foo}". In theory, anyway -- it doesn't work, telling me "reftex-reference: Wrong type argument: stringp, reftex-format-ref-function" when I try to insert a figure reference via C-c ) f.

I've done enough programming in enough languages to suspect that this is really a rather simple task, but thanks to my poor Lisp skills I'm finding myself totally lost. I think I need some help. Am I even close to a reasonable solution?



reply via email to

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