Skip to content

Key bindings and user-level lisp functions ​

preview-latex adds key bindings starting with C-c C-p to the supported modes of AUCTeX (See (auctex)Key Index). It will also add its own ‘Preview’ menu in the menu bar, as well as an icon in the toolbar.

The following only describes the interactive use: view the documentation strings with C-h f if you need the Lisp information.

C-c C-p C-p ​

preview-at-point ​

Preview/Generate previews (or toggle) at point ​

If the cursor is positioned on or inside of a preview area, this toggles its visibility, regenerating the preview if necessary. If not, it will run the surroundings through preview. The surroundings include all areas up to the next valid preview, unless invalid previews occur before, in which case the area will include the last such preview in either direction. And overriding any other action, if a region is active (transient-mark-mode), it is run through preview-region.

mouse-2 ​

The middle mouse button has a similar action bound to it as preview-at-point, only that it knows which preview to apply it to according to the position of the click. You can click either anywhere on a previewed image, or when the preview is opened and showing the source text, you can click on the icon preceding the source text. In other areas, the usual mouse key action (typically: paste) is not affected.

mouse-3 ​

The right mouse key pops up a context menu with several options: toggling the preview, regenerating it, removing it (leaving the unpreviewed text), copying the text inside of the preview, and copying it in a form suitable for copying as an image into a mail or news article. This is a one-image variant of the following command:

C-c C-p C-w ​

preview-copy-region-as-mml ​

Copy a region as MML ​

This command is also available as a variant in the context menu on the right mouse button (where the region is the preview that has been clicked on). It copies the current region into the kill buffer in a form suitable for copying as a text including images into a mail or news article using mml-mode (see Composing in Emacs MIME).

If you regenerate or otherwise kill the preview in its source buffer before the mail or news gets posted, this will fail. Also you should generate images you want to send with preview-transparent-border set to nil, or the images will have an ugly border. preview-latex detects this condition and asks whether to regenerate the region with borders switched off. As this is an asynchronous operation running in the background, you’ll need to call this command explicitly again to get the newly generated images into the kill ring.

Preview your articles with mml-preview (on C-c C-m P) to make sure they look fine.

C-c C-p C-e ​

preview-environment ​

Preview/Generate previews for environment ​

Run preview on LaTeX environment. The environments in preview-inner-environments are treated as inner levels so that for instance, the split environment in \begin{equation}\begin{split}…\end{split}\end{equation} is properly displayed. If called with a numeric argument, the corresponding number of outward nested environments is treated as inner levels.

C-c C-p C-s ​

preview-section ​

Preview/Generate previews for section ​

Run preview on this LaTeX section.

C-c C-p C-r ​

preview-region ​

Preview/Generate previews for region ​

Run preview on current region.

C-c C-p C-b ​

preview-buffer ​

Preview/Generate previews for buffer ​

Run preview on the current buffer.

C-c C-p C-d ​

preview-document ​

Preview/Generate previews for document ​

Run preview on the current document.

C-c C-p C-c C-p ​

preview-clearout-at-point ​

Preview/Remove previews at point ​

Clear out (remove) the previews that are immediately adjacent to point.

C-c C-p C-c C-s ​

preview-clearout-section ​

Preview/Remove previews from section ​

Clear out all previews in current section.

C-c C-p C-c C-r ​

preview-clearout ​

Preview/Remove previews from region ​

Clear out all previews in the current region.

C-c C-p C-c C-b ​

preview-clearout-buffer ​

Preview/Remove previews from buffer ​

Clear out all previews in current buffer. This makes the current buffer lose all previews.

C-c C-p C-c C-d ​

preview-clearout-document ​

Preview/Remove previews from document ​

Clear out all previews in current document. The document consists of all buffers that have the same master file as the current buffer. This makes the current document lose all previews.

C-c C-p C-f ​

preview-cache-preamble ​

Preview/Turn preamble cache on ​

Dump a pregenerated format file. For the rest of the session, this file is used when running on the same master file. Use this if you know your LaTeX takes a long time to start up, the speedup will be most noticeable when generating single or few previews. If you change your preamble, do this again. preview-latex will try to detect the necessity of that automatically when editing changes to the preamble are done from within Emacs, but it will not notice if the preamble effectively changes because some included file or style file is tampered with.

Note that support for preamble cache is limited for LaTeX variants. c.f. https://github.com/davidcarlisle/dpctex/issues/15

  • XeLaTeX cannot use preamble cache at all. The reason is intrinsic in XeLaTeX, so preview-latex can’t help.
  • LuaLaTeX works with preamble cache only when the preamble is simple enough, i.e., when it doesn’t load opentype fonts and it doesn’t use lua codes in preamble.

C-c C-p C-c C-f ​

preview-cache-preamble-off ​

Preview/Turn preamble cache off ​

Clear the pregenerated format file and stop using preambles for the current document. If the caching gives you problems, use this.

C-c C-p C-i ​

preview-goto-info-page ​

Preview/Read Documentation ​

Read the info manual.

M-x preview-report-bug RET ​

preview-report-bug ​

Preview/Report Bug ​

This is the preferred way of reporting bugs as it will fill in what version of preview-latex you are using as well as versions of relevant other software, and also some of the more important settings. Please use this method of reporting, if at all possible and before reporting a bug, have a look at Known problems.

C-c C-k ​

LaTeX/TeX Output/Kill Job ​

Kills the preview-generating process. This is really an AUCTeX keybinding, but it is included here as a hint. If you are generating a preview and then make a change to the buffer, preview-latex may be confused and place the previews wrong.