# How to activate AUCTeX support for beamer without preamble?

Usually, AUCTeX activates beamer-specific settings (e.g. syntax highlighting) depending on \documentclass. In my LaTeX templates, however, I have separated the preamble from the rest of the document using \input{beamer-preamble}.

Here's an MWE:

\input{beamer-preamble}  % beamer-preamble.tex only contains \documentclass{beamer}
\begin{document}

\title{Some title}

\begin{frame}
\frametitle{Some frame title}
\end{frame}

\end{document}


In this example, the argument of \frametitle should be highlighted similarly to the argument of \title.

How can I tell AUCTeX to still apply the beamer-specific settings?

• Can you show your beamer-preamble and a .tex file where you use it and do the actual typesetting? – Arash Esbati Apr 26 '17 at 8:09
• @ArashEsbati I've updated the question. Interestingly, AUCTeX sometimes does it right, but not always. – Timm Apr 26 '17 at 14:13
• What is your setting of Tex-auto-local? Have you updated the local files? – Andrew Swann Apr 26 '17 at 15:23
• @AndrewSwann Tex-auto-local points to some directory under .emacs.d. In fact, when I remove the AUCTeX files there, the highlighting changes for the worse. – Timm Apr 26 '17 at 16:11
• It us usually just "auto" so that information can be stored in that subdirectory where your current tex file is. Have you changed the defaults? – Andrew Swann Apr 26 '17 at 16:38

First of all, I suggest you create a proper class file beamer-preamble.cls like this:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{beamer-preamble}
[2017/04/26 v0.1 My Beamer Preamble]


Next, you want to have an AUCTeX style file for beamer-preamble.cls. Doing M-x TeX-auto-generate RET in one way. But I recommend writing your own style file. Something like this should suffice:

(TeX-add-style-hook
"beamer-preamble"
(lambda ()
(TeX-run-style-hooks "beamer"))
LaTeX-dialect)


Customize TeX-style-private to a directory of your choice and save the code above as beamer-preamble.el there. Add this to your init file,

(setq TeX-parse-self t)


restart Emacs and open your .tex file.

• Thanks for your answer, which brought me to think about an even simpler (but more ad-hoc) solution: just add eval: (TeX-run-style-hooks "beamer") to the local variables of the file. Still, I really like the more generic approach of defining classes and including them globally. – Timm Apr 28 '17 at 19:20