views:

53

answers:

1

Hi all, I am currently using emacs and auctex to author my latex documents. This is, of course, fantastic. However, I would like to have emacs and/or auctex auto-fill the section label when using C-c C-e to make a new header. It should end up looking like this:

\section{This is a section title}
\label{sec:this-is-a-section-title}

with the label for the header the same as the title, but with no spaces. I don't know lisp or elisp, and I'd have no idea where to start. If anyone could help that would be great!

+3  A: 

If you use RefTeX then C-c ( will do what you want (giving you the opportunity to change the label if you wish). Also C-c ) will insert \ref{...}, popping up a buffer to choose which label to use. It also does other stuff including working with bibliographies. You should definitely look into it.

I think it's now part of the AUCTeX distribution so that all you should have to do is add

(add-hook 'LaTeX-mode-hook (function turn-on-reftex))
(setq reftex-plug-into-AUCTeX t)

to your .emacs.

Ivan Andrus
that is awesome. Thanks! I had no idea where to start looking for this.
Mica