2

I use imenu in auctex. For beamer slides, it only offers me the \section-commands as entry points. How can I teach imenu to also offer all frames? (Which is an environment: \begin{frame}....\end{frame}?

Timm
  • 1,549
  • 12
  • 23

3 Answers3

3

You need to make AUCTeX aware of the frame environment, i.e., \frametitle:

(add-to-list 'TeX-outline-extra '("\\\\frametitle\\b" 4))

From the documentation on Tex-outline-extra:

List of extra TeX outline levels.

Each element is a list with two entries. The first entry is the regular expression matching a header, and the second is the level of the header. See ‘LaTeX-section-list’ for existing header levels.

Similarly, you need to explicitely tell reftex to show \frametitle in its TOC:

(setq reftex-section-levels '(("part" . 0)
                              ("chapter" . 1)
                              ("section" . 2)
                              ("subsection" . 3)
                              ("subsubsection" . 4)
                              ("frametitle" . -3)
                              ("paragraph" . 5)
                              ("subparagraph" . 6)
                              ("addchap" . -1)
                              ("addsec" . -2)))
Timm
  • 1,549
  • 12
  • 23
  • This is great, thank you! But I use frame environments. I tried: `(add-to-list 'TeX-outline-extra '("\\\\begin{frame}{\\(.*?\\)}" 4))`. The result is a list with items all named 'frame', and they all point to the first frame. So how can I tell imenu which part of the regexp contains the header name? And how do I teach imenu to jump to the corrseponding line? – Jörg Volbers Nov 13 '17 at 08:04
  • If you instead use `(add-to-list 'TeX-outline-extra '("\\\\begin{frame}\\(\\[.*\\]\\)?" 4))` the entries in imenu will point to different frames. Still their title doesn't show up there. – Timm Nov 13 '17 at 09:02
  • Thanks, I'll accept that answer. The solution still is not perfect, maybe someone finds out how to add the frame title to the imenu listing. – Jörg Volbers Nov 14 '17 at 09:42
0

I use some dummy commands to mark my outline. The solution is not perfect, but it is usable.

I configure TeX-outline-extra this way:

(add-to-list 'TeX-outline-extra '("imenu" 1))
(add-to-list 'TeX-outline-extra '("imenuOne" 1))
(add-to-list 'TeX-outline-extra '("imenuTwo" 2))
(add-to-list 'TeX-outline-extra '("imenuThree" 3))
(add-to-list 'TeX-outline-extra '("imenuFour" 4))

In my tex file I add:

\newcommand{\imenu}[1]{#1}
\newcommand{\imenuOne}[1]{#1}
\newcommand{\imenuTwo}[1]{#1}
\newcommand{\imenuThree}[1]{#1}
\newcommand{\imenuFour}[1]{#1}

Now I can add an outline level anywhere, like this:

\begin{homeworkProblem}[\imenu{The first problem}]
0

I know this question is more than 2 years old, but I had the same question myself, and none of the above answers worked for me. Here's the workaround I used.

I think auctex sets imenu-create-index-function to LaTeX-imenu-create-index-function. In my LaTeX-mode-hook, I reset it as shown below and use a variant of the regexps given in the answers above.

(setq-local imenu-create-index-function
            'imenu-default-create-index-function)
(setq-local imenu-generic-expression
                    '((nil ; put in top-level menu
                       "^\\\\begin{frame}\\(\\[[a-z,]+\\]\\)?{\\(.+\\)}"
                       2   ; which bracketed expression goes in title
                       )))

Now my imenu shows the frame titles as entries.