Skip to content

Customization

B.4.1 How to include additional environments like enumerate

By default, preview-latex is intended mainly for displaying mathematical formulas, so environments like enumerate or tabular (except where contained in a float) are not included. You can include them however manually by adding the lines:

latex
\usepackage[displaymath,textmath,sections,graphics,floats]{preview}
\PreviewEnvironment{enumerate}

in your document header, that is before

latex
\begin{document}

In general, preview should be loaded as the last thing before the start of document.

Be aware that

latex
\PreviewEnvironment{...}

does not accept a comma separated list! Also note that by putting more and more

latex
\PreviewEnvironment{...}

in your document, it will look more and more like a DVI file preview when running preview-latex. Since each preview is treated as one large monolithic block by Emacs, one should really restrict previews to those elements where the improvement in visual representation more than makes up for the decreased editability.

B.4.2 What if I don’t want to change the document?

The easiest way is to generate a configuration file in the current directory. You can basically either create prdefault.cfg which is used for any use of the ‘preview’ package, or you can use prauctex.cfg which only applies to the use from with Emacs. Let us assume you use the latter. In that case you should write something like

latex
\InputIfFileExists{preview/prauctex.cfg}{}{}
\PreviewEnvironment{enumerate}

in it. The first line inputs the system-wide default configuration (the file name should match that, but not your own prauctex.cfg), then you add your own stuff.

B.4.3 Suddenly I get gazillions of ridiculous pages?!?

When preview-latex works on extracting its stuff, it typesets each single preview on a page of its own. This only happens when actual previews get generated. Now if you want to configure preview-latex in your document, you need to add your own \usepackage call to ‘preview’ so that it will be able to interpret its various definition commands. It is an error to add the active option to this invocation: you don’t want the package to be active unless preview-latex itself enables the previewing operation (which it will).

B.4.4 Does preview-latex work with presentation classes?

preview-latex should work with most presentation classes. However, since those classes often have macros or pseudo environments encompassing a complete slide, you will need to use the customization facilities of preview.sty to tell it how to resolve this, whether you want no previews, previews of whole slides or previews of inner material.

B.4.5 Does preview-latex work with the TikZ package?

preview-latex doesn’t have support for the tikzpicture environment built-in. It can be included manually by adding the lines:

latex
\usepackage[displaymath,sections,graphics,floats,textmath]{preview}
\PreviewEnvironment[{[]}]{tikzpicture}

to the document preamble.

Things get more complicated when the code inside the tikzpicture environment contains $ $ for inserting inline math and preview-latex is instructed to insert previews for it into the buffer. In this case, you can disable previews for inline math by changing the lines above to:

latex
\usepackage[displaymath,sections,graphics,floats
  % textmath   %% Don't preview inline math
]{preview}
\PreviewEnvironment[{[]}]{tikzpicture}

Another solution is to source out the TikZ pictures into an external file which uses the standalone class, process them and insert them back into the main file as figures with the \includegraphics macro. In this case, previewing of inline math will work as usual.