Wednesday, March 26, 2008

Getting Beamer Frame Titles into Reftex TOC

I write most of my documents in LaTeX and AucTeX is indispensable in creating and generating the pdf files from LaTeX.

For presentations, one of the best available and actively maintained package is Beamer developed by Till Tantau. With its beamer templates it's possible to rustle up a fairly professional presentation in a few minutes. And if you like reading a few hundred pages of documentation, the payback is even better. :-)

RefTeX is a package for managing Labels, References, Citations and index entries with GNU Emacs.

When using the beamer package, the \frametitle{} has the slide headings and it makes sense to make that come up when C-c = is chorded. That is, when reftex-toc function is called, which builds the TOC for the document, the TOC buffer should show a number list of slide titles.

But RefTeX does not recognise \frametitle when it parses the document in its default settings.

Asking on the auctex mailing list, elicited the following solution

(setq reftex-section-levels '(("part" . 0)
("chapter" . 1)
("section" . 2)
("subsection" . 3)
("subsubsection" . 4)
("paragraph" . 5)
("subparagraph" . 6)
("frametitle" . 7)
("addchap" . -1)
("addsec" . -2)))

The documentation string said that the list should be sorted, so I replicated the values instead of cons'ing and cdr'ing.

Hitting C-c = after setting it and reloading the buffer, brings up the frametitles nicely.

1 comment:

Anonymous said...

Fucking amazing. I was intuitively pressing C-= and for a couple of years until I found this neat tric.