0

I am working on a beamer presentation with AUCTeX on OS X. When I use preview (C-c C-p C-b) on the following document the equation is displayed right after \end{frame} and not in the line of the equation. When I use \documentclass{article} the equation is displayed correctly.

\documentclass{beamer} 
\begin{document}
\begin{frame}
\begin{equation}
a^2 + b^2 = c^2
\end{equation}
\end{frame}
\end{document}

How can I get Preview-Latex to work with beamer?

0

preview as an Emacs package depends on preview as a LaTeX package.

When you generate previews, a line \usepackage{preview} is automatically injected in your buffer before processing it with LaTeX, so that LaTeX generates the imagelets that will be inserted in your buffer instead of your whole document.

preview as a Latex package uses a set of defaults that are tailored for the most usual document classes and, so it happens, these defaults (as you've discovered) are no good for the beamer document class...

All this is documented in the fine docs for preview.sty (i.e., the file that is sourced from \usepackage{preview}). I access the docs using texdoc preview (I use a TeXlive distribution) but if you cannot find the docs on your system they are available on CTAN too...

That said, what you want to do is loading explicitly the preview LaTeX package in your document, so that you can pass to it options different from the default ones.

Here it is what works for me, you may want to modify the lists of environments to preview or not preview according to your needs. You must put these lines close to the end of the preamble in your file.

% load preview.sty at the end please
\usepackage[displaymath,textmath,sections,graphics]{preview}
\PreviewEnvironment{align*}
\PreviewEnvironment{multline*}
\PreviewEnvironment{tabular}
\PreviewEnvironment{verbatim}
\PreviewEnvironment{lstlisting}
\PreviewEnvironment*{frame}

Note the last line, the starred command (different from previous ones) means exclude the frame environment from the previewing. Omitting this line will break previewing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.