3

How can I open the equation selection buffer in RefTeX automatically when entering \eqref in Emacs? I have the following line in my .emacs file

(setq reftex-label-alist '((nil ?e nil "~\\eqref{%s}" nil nil)))

But this does not seem to work as I hoped (http://www.gnu.org/software/emacs/manual/html_node/reftex).. Now, entering \eqref and then pressing enter, will just insert an empty \eqref{} into the buffer. What I would like to happen is the equation selection buffer in RefTeX to be opened, after which I will be able to choose the label to reference from that buffer..

(Note that entering \ref (not \eqref) works as expected, that is, first I get a question: "Label type: [ efinNst]" and after having chosen the type, the selection buffer is opened)

I am using GNU Emacs version 23.3.1 on Ubuntu 12.04.

My .emacs init file is

(setq TeX-electric-escape t)
(setq reftex-label-alist '((nil ?e nil "~\\eqref{%s}" nil nil)))
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

Consider the sample file t.tex

\documentclass{amsart}
\begin{document}
\begin{align}
  \label{eq:1}  
  1+1=2
\end{align}
\end{document}

Running emacs t.tex produces the following in the Emacs message buffer:

Loading 00debian-vars...done
Loading /etc/emacs23/site-start.d/50auctex.el (source)...
Loading /usr/share/emacs/23.3/site-lisp/auctex.el (source)...done
Loading /usr/share/emacs/23.3/site-lisp/preview-latex.el (source)...done
Loading /etc/emacs23/site-start.d/50auctex.el (source)...done
Loading /etc/emacs/site-start.d/50autoconf.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...done
Loading debian-ispell...done
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...done
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...done
Loading /etc/emacs/site-start.d/50emacs-goodies-el.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Loading cjk-enc...done
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...done
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...done
Loading /etc/emacs/site-start.d/50lilypond-data.el (source)...done
Loading /etc/emacs/site-start.d/50magit.el (source)...done
Loading /etc/emacs/site-start.d/50octave3.2-emacsen.el (source)...done
Loading /etc/emacs/site-start.d/50org-mode.el (source)...done
Loading /etc/emacs/site-start.d/50psvn.el (source)...done
Loading /etc/emacs/site-start.d/50thailatex.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Automatic display of crossref information was turned on
Applying style hooks... done
Sorting environment...
Removing duplicates... done
  • 1
    If you use AUCTeX C-c ) e does the trick, without even writing \eqref. – giordano Jun 11 '13 at 10:40
  • Yes that works fine.. Thank you! (Is it possible to get the other method (in my question) also to work?) – Håkon Hægland Jun 11 '13 at 10:42
  • I don't know, on my Emacs that works as you expect. You should give more information about your configuration. – giordano Jun 11 '13 at 10:45
  • I see.. I updated my question with information about my configuration.. – Håkon Hægland Jun 11 '13 at 10:50
  • Just to understand: C-c ) e works but C-c C-m eqref RET doesn't word? Is C-c C-m eqref RET at least able to autocomplete with known citation keys? – giordano Jun 11 '13 at 12:20
2

In order to override possible other eqref macro definitions, you should add a dummy (ignore) to the definition of the macro. This code, in your .emacs, does the trick:

(add-hook 'LaTeX-mode-hook
      '(lambda ()
         (TeX-add-symbols '("eqref" TeX-arg-ref (ignore)))))

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.