Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

emacs auctex: can one auto-fill section labels?

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!

like image 307
Mica Avatar asked Mar 19 '10 16:03

Mica


1 Answers

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.

like image 106
Ivan Andrus Avatar answered Sep 27 '22 23:09

Ivan Andrus