[Tex/LaTex] AUCTeX region preview in Emacs

auctexemacspreview

I've installed AUCTeX and passed the circ.tex preview, however, when I'm trying to add more elements (enumerate, tabular) to preview with \PreviewEnvironment{..} in the preamble, AUCTeX ignores these lines and render only math, table, sections, and other default elements. I've tried to add custom environments in preview-default-preamble, but no success.

It's probably a part of the same problem, but if I try C-c C-p C-e (preview the environment with a pointer inside this environment), it says no enclosing outer environment found — a pretty rare error, Google finds it only in preview.el sources.

preview-image-type is set to dvipng (png and gswin32c.exe do not work properly).

Emacs 23.3 and TeX Live 2011 are the counterpart.

Best Answer

Worked through the problem and have three points to stress:

  1. \PreviewEnvironment should not work in a tex file's preamble.

  2. One way to add custom environments is by adding full \PreviewEnvironment{..} entries after the last string of the default Preview Default Preamble string (expected to be ]{preview}[2004/11/05]). It's equivalent for .emacs: (setq preview-default-preamble (quote ("\\RequirePackage[" ("," . preview-default-option-list) "]{preview}[2004/11/05]" "\\PreviewEnvironment{center}" "\\PreviewEnvironment{enumerate}"))), where center and enumerate are example custom environments. Alternatives are (preview-latex.pdf, p. 11):

    • including custom environments in local file variables
    • a configuration file in the project's directory
  3. M-x preview-environment (C-c C-p C-e) works only for the customized environments (see 2) and environments from preview-default-option-list.