Blame doc/preview-latex.texi

Packit f2bd10
\input texinfo
Packit f2bd10
@comment %**start of header
Packit f2bd10
@setfilename preview-latex.info
Packit f2bd10
@include version.texi
Packit f2bd10
@settitle preview-latex @value{VERSION}
Packit f2bd10
@comment %**end of header
Packit f2bd10
@include macros.texi
Packit f2bd10
@copying
Packit f2bd10
This manual is for preview-latex, a @LaTeX{} preview mode for @AUCTeX{}
Packit f2bd10
(version @value{VERSION} from @value{UPDATED}).
Packit f2bd10
Packit f2bd10
Copyright @copyright{} 2001, 2002, 2003,
Packit f2bd10
2004, 2005, 2006, 2017 Free Software Foundation, Inc.
Packit f2bd10
Packit f2bd10
@quotation
Packit f2bd10
Permission is granted to copy, distribute and/or modify this document
Packit f2bd10
under the terms of the GNU Free Documentation License, Version 1.3 or
Packit f2bd10
any later version published by the Free Software Foundation; with no
Packit f2bd10
Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.  A
Packit f2bd10
copy of the license is included in the section entitled ``GNU Free
Packit f2bd10
Documentation License.''
Packit f2bd10
@end quotation
Packit f2bd10
@end copying
Packit f2bd10
Packit f2bd10
@dircategory Emacs
Packit f2bd10
@direntry
Packit f2bd10
* preview-latex: (preview-latex).       Preview LaTeX fragments in Emacs
Packit f2bd10
@end direntry
Packit f2bd10
@dircategory TeX
Packit f2bd10
@direntry
Packit f2bd10
* preview-latex: (preview-latex).       Preview LaTeX fragments in Emacs
Packit f2bd10
@end direntry
Packit f2bd10
@c footnotestyle separate
Packit f2bd10
@c paragraphindent 2
Packit f2bd10
@syncodeindex vr cp
Packit f2bd10
@syncodeindex ky cp
Packit f2bd10
@syncodeindex fn cp
Packit f2bd10
Packit f2bd10
@iftex
Packit f2bd10
@tolerance 10000 @emergencystretch 3em
Packit f2bd10
@end iftex
Packit f2bd10
Packit f2bd10
@finalout
Packit f2bd10
@titlepage
Packit f2bd10
@title @previewlatex{}
Packit f2bd10
@subtitle A @LaTeX{} preview mode for @AUCTeX{} in Emacs.
Packit f2bd10
@subtitle Version @value{VERSION}, @value{UPDATED}
Packit f2bd10
@author Jan-@AA{}ke Larsson
Packit f2bd10
@author David Kastrup and others
Packit f2bd10
@page
Packit f2bd10
@vskip 0pt plus 1filll
Packit f2bd10
@insertcopying
Packit f2bd10
@end titlepage
Packit f2bd10
Packit f2bd10
@c @summarycontents
Packit f2bd10
@contents
Packit f2bd10
Packit f2bd10
@c Use @ifinfo _and_ @ifhtml here because Texinfo 3 cannot cope with
Packit f2bd10
@c @ifnottex around a top node.
Packit f2bd10
@ifinfo
Packit f2bd10
@node top, , (dir), (dir)
Packit f2bd10
@top @previewlatex{}
Packit f2bd10
Packit f2bd10
This manual may be copied under the conditions spelled out in
Packit f2bd10
@ref{Copying this Manual}.
Packit f2bd10
Packit f2bd10
@end ifinfo
Packit f2bd10
@ifhtml
Packit f2bd10
@node top, Copying, (dir), (dir)
Packit f2bd10
@top @previewlatex{}
Packit f2bd10
@insertcopying
Packit f2bd10
@end ifhtml
Packit f2bd10
Packit f2bd10
@contents
Packit f2bd10
Packit f2bd10
@iftex
Packit f2bd10
@unnumbered @previewlatex{}
Packit f2bd10
@end iftex
Packit f2bd10
 
Packit f2bd10
@previewlatex{} is a package embedding preview fragments into Emacs
Packit f2bd10
source buffers under the @AUCTeX{} editing environment for @LaTeX{}.  It
Packit f2bd10
uses @file{preview.sty} for the extraction of certain environments (most
Packit f2bd10
notably displayed formulas).  Other applications of this style file are
Packit f2bd10
possible and exist.
Packit f2bd10
Packit f2bd10
The name of the package is really @samp{preview-latex}, all in
Packit f2bd10
lowercase letters, with a hyphen.  If you typeset it, you can use a
Packit f2bd10
sans-serif font to visually offset it.
Packit f2bd10
Packit f2bd10
@menu
Packit f2bd10
* Copying::                     Copying
Packit f2bd10
* Introduction::                Getting started.
Packit f2bd10
* Installation::                Make Install.
Packit f2bd10
* Keys and lisp::               Key bindings and user-level lisp functions.
Packit f2bd10
* Simple customization::        To make it fit in.
Packit f2bd10
* Known problems::              When things go wrong.
Packit f2bd10
* For advanced users::          Internals and more customizations.
Packit f2bd10
* ToDo::                        Future development.
Packit f2bd10
* Frequently Asked Questions::  All about @previewlatex{}
Packit f2bd10
* Copying this Manual::         GNU Free Documentation License
Packit f2bd10
* Index::                       A menu of many topics.             
Packit f2bd10
@end menu
Packit f2bd10
Packit f2bd10
@node Copying, Introduction, top, top
Packit f2bd10
@unnumbered Copying
Packit f2bd10
@cindex Copying
Packit f2bd10
@cindex Copyright
Packit f2bd10
@cindex GPL
Packit f2bd10
@cindex General Public License
Packit f2bd10
@cindex License
Packit f2bd10
@cindex Free
Packit f2bd10
@cindex Free software
Packit f2bd10
@cindex Distribution
Packit f2bd10
@cindex Right
Packit f2bd10
@cindex Warranty
Packit f2bd10
Packit f2bd10
For the conditions for copying parts of @previewlatex{}, see the General
Packit f2bd10
Public Licenses referres to in the copyright notices of the files, the
Packit f2bd10
General Public Licenses accompanying them and the explanatory section in
Packit f2bd10
@ref{Copying,,,auctex,the @AUCTeX{} manual}.
Packit f2bd10
Packit f2bd10
This manual specifically is covered by the GNU Free Documentation
Packit f2bd10
License (@pxref{Copying this Manual}).
Packit f2bd10
Packit f2bd10
@node Introduction, Installation, Copying, top
Packit f2bd10
@c Used as @file{README} as well: in separate file
Packit f2bd10
@chapter Introduction
Packit f2bd10
@include preview-readme.texi
Packit f2bd10
Packit f2bd10
@node Installation, Keys and lisp, Introduction, top
Packit f2bd10
@chapter Installation
Packit f2bd10
Installation is now being covered in
Packit f2bd10
@ref{Installation,,,auctex,the @AUCTeX{} manual}.
Packit f2bd10
Packit f2bd10
@node Keys and lisp, Simple customization, Installation, top
Packit f2bd10
@chapter Key bindings and user-level lisp functions 
Packit f2bd10
Packit f2bd10
@cindex Menu entries
Packit f2bd10
@previewlatex{} adds key bindings starting with @kbd{C-c C-p} to the
Packit f2bd10
supported modes of @AUCTeX{} (@inforef{Key Index,,auctex}).  It will
Packit f2bd10
also add its own @samp{Preview} menu in the menu bar, as well as an icon
Packit f2bd10
in the toolbar.
Packit f2bd10
Packit f2bd10
The following only describes the interactive use: view the documentation
Packit f2bd10
strings with @kbd{C-h f} if you need the Lisp information.
Packit f2bd10
Packit f2bd10
@table @w
Packit f2bd10
@item @kbd{C-c C-p C-p}
Packit f2bd10
@itemx @code{preview-at-point}
Packit f2bd10
@itemx Preview/Generate previews (or toggle) at point
Packit f2bd10
If the cursor is positioned on or inside of a preview area, this
Packit f2bd10
toggles its visibility, regenerating the preview if necessary. If not,
Packit f2bd10
it will run the surroundings through preview. The surroundings include
Packit f2bd10
all areas up to the next valid preview, unless invalid previews occur
Packit f2bd10
before, in which case the area will include the last such preview in
Packit f2bd10
either direction.  And overriding any other
Packit f2bd10
action, if a region is active (@code{transient-mark-mode} or
Packit f2bd10
@code{zmacs-regions}), it is run through @code{preview-region}.
Packit f2bd10
@kindex @kbd{C-c C-p C-p}
Packit f2bd10
@findex preview-at-point
Packit f2bd10
Packit f2bd10
@item @kbd{<mouse-2>}
Packit f2bd10
The middle mouse button has a similar action bound to it as
Packit f2bd10
@code{preview-at-point}, only that it knows which preview to apply it to
Packit f2bd10
according to the position of the click.  You can click either anywhere
Packit f2bd10
on a previewed image, or when the preview is opened and showing the
Packit f2bd10
source text, you can click on the icon preceding the source text.  In
Packit f2bd10
other areas, the usual mouse key action (typically: paste) is not
Packit f2bd10
affected.
Packit f2bd10
Packit f2bd10
@item @kbd{<mouse-3>}
Packit f2bd10
The right mouse key pops up a context menu with several options:
Packit f2bd10
toggling the preview, regenerating it, removing it (leaving the
Packit f2bd10
unpreviewed text), copying the text inside of the preview, and copying
Packit f2bd10
it in a form suitable for copying as an image into a mail or news
Packit f2bd10
article.  This is a one-image variant of the following command:
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-w}
Packit f2bd10
@itemx @code{preview-copy-region-as-mml}
Packit f2bd10
@itemx Copy a region as MML
Packit f2bd10
@kindex @kbd{C-c C-p C-w}
Packit f2bd10
@findex preview-copy-region-as-mml
Packit f2bd10
This command is also available as a variant in the context menu on the
Packit f2bd10
right mouse button (where the region is the preview that has been
Packit f2bd10
clicked on).  It copies the current region into the kill buffer in a
Packit f2bd10
form suitable for copying as a text including images into a mail or news
Packit f2bd10
article using mml-mode (@pxref{Composing,,Composing,emacs-mime,Emacs
Packit f2bd10
MIME}).
Packit f2bd10
Packit f2bd10
If you regenerate or otherwise kill the preview in its source buffer
Packit f2bd10
before the mail or news gets posted, this will fail.  Also you should
Packit f2bd10
generate images you want to send with @code{preview-transparent-border}
Packit f2bd10
@vindex preview-transparent-border
Packit f2bd10
set to @code{nil}, or the images will have an ugly border.
Packit f2bd10
@previewlatex{} detects this condition and asks whether to regenerate
Packit f2bd10
the region with borders switched off.  As this is an asynchronous
Packit f2bd10
operation running in the background, you'll need to call this command
Packit f2bd10
explicitly again to get the newly generated images into the kill ring.
Packit f2bd10
Packit f2bd10
Preview your articles with @code{mml-preview} (on @kbd{C-c C-m P})
Packit f2bd10
@kindex @kbd{C-c C-m P}
Packit f2bd10
to make sure they look fine.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-e}
Packit f2bd10
@itemx @code{preview-environment}
Packit f2bd10
@itemx Preview/Generate previews for environment
Packit f2bd10
Run preview on @LaTeX{} environment.  The environments in
Packit f2bd10
@code{preview-inner-environments} are treated as inner levels so that
Packit f2bd10
for instance, the @code{split} environment in
Packit f2bd10
@code{\begin@{equation@}\begin@{split@}@dots{}\end@{split@}\end@{equation@}}
Packit f2bd10
is properly displayed.  If called with a numeric argument, the
Packit f2bd10
corresponding number of outward nested environments is treated as inner
Packit f2bd10
levels.
Packit f2bd10
@kindex @kbd{C-c C-p C-e}
Packit f2bd10
@findex preview-environment
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-s}
Packit f2bd10
@itemx @code{preview-section} 
Packit f2bd10
@itemx Preview/Generate previews for section
Packit f2bd10
Run preview on this @LaTeX{} section.
Packit f2bd10
@kindex @kbd{C-c C-p C-s}
Packit f2bd10
@findex preview-section
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-r}
Packit f2bd10
@itemx @code{preview-region}
Packit f2bd10
@itemx Preview/Generate previews for region
Packit f2bd10
Run preview on current region.
Packit f2bd10
@kindex @kbd{C-c C-p C-r}
Packit f2bd10
@findex preview-region
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-b}
Packit f2bd10
@itemx @code{preview-buffer} 
Packit f2bd10
@itemx Preview/Generate previews for buffer
Packit f2bd10
Run preview on the current buffer.
Packit f2bd10
@kindex @kbd{C-c C-p C-b}
Packit f2bd10
@findex preview-buffer
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-d}
Packit f2bd10
@itemx @code{preview-document} 
Packit f2bd10
@itemx Preview/Generate previews for document
Packit f2bd10
Run preview on the current document.
Packit f2bd10
@kindex @kbd{C-c C-p C-d}
Packit f2bd10
@findex preview-document
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-c C-p}
Packit f2bd10
@itemx @code{preview-clearout-at-point}
Packit f2bd10
@itemx Preview/Remove previews at point
Packit f2bd10
@kindex @kbd{C-c C-p C-c C-p}
Packit f2bd10
@findex preview-clearout-at-point
Packit f2bd10
Clear out (remove) the previews that are immediately adjacent to point.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-c C-s}
Packit f2bd10
@itemx @code{preview-clearout-section}
Packit f2bd10
@itemx Preview/Remove previews from section
Packit f2bd10
@kindex @kbd{C-c C-p C-c C-s}
Packit f2bd10
@findex preview-clearout-document
Packit f2bd10
Clear out all previews in current section.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-c C-r}
Packit f2bd10
@itemx @code{preview-clearout}
Packit f2bd10
@itemx Preview/Remove previews from region
Packit f2bd10
@kindex @kbd{C-c C-p C-c C-r}
Packit f2bd10
@findex preview-clearout
Packit f2bd10
Clear out all previews in the current region.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-c C-b}
Packit f2bd10
@itemx @code{preview-clearout-buffer}
Packit f2bd10
@itemx Preview/Remove previews from buffer
Packit f2bd10
@kindex @kbd{C-c C-p C-c C-b}
Packit f2bd10
@findex preview-clearout-buffer
Packit f2bd10
Clear out all previews in current buffer. This makes the current buffer
Packit f2bd10
lose all previews.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-c C-d}
Packit f2bd10
@itemx @code{preview-clearout-document}
Packit f2bd10
@itemx Preview/Remove previews from document
Packit f2bd10
@kindex @kbd{C-c C-p C-c C-d}
Packit f2bd10
@findex preview-clearout-document
Packit f2bd10
Clear out all previews in current document.  The document consists of
Packit f2bd10
all buffers that have the same master file as the current buffer.  This
Packit f2bd10
makes the current document lose all previews.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-f}
Packit f2bd10
@itemx @code{preview-cache-preamble}
Packit f2bd10
@itemx Preview/Turn preamble cache on
Packit f2bd10
@kindex @kbd{C-c C-p C-f}
Packit f2bd10
@findex preview-cache-preamble
Packit f2bd10
Dump a pregenerated format file.  For the rest of the session, this file
Packit f2bd10
is used when running on the same master file.  Use this if you know your
Packit f2bd10
@LaTeX{} takes a long time to start up, the speedup will be most
Packit f2bd10
noticeable when generating single or few previews.  If you change your
Packit f2bd10
preamble, do this again.  @previewlatex{} will try to detect the
Packit f2bd10
necessity of that automatically when editing changes to the preamble are
Packit f2bd10
done from within Emacs, but it will not notice if the preamble
Packit f2bd10
effectively changes because some included file or style file is
Packit f2bd10
tampered with.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-c C-f}
Packit f2bd10
@itemx @code{preview-cache-preamble-off}
Packit f2bd10
@itemx Preview/Turn preamble cache off
Packit f2bd10
@kindex @kbd{C-u C-c C-p C-f}
Packit f2bd10
@findex preview-cache-preamble-off
Packit f2bd10
Clear the pregenerated format file and stop using preambles for the
Packit f2bd10
current document. If the caching gives you problems, use this.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-p C-i}
Packit f2bd10
@itemx @code{preview-goto-info-page}
Packit f2bd10
@itemx Preview/Read Documentation
Packit f2bd10
@kindex @kbd{C-c C-p C-i}
Packit f2bd10
@findex preview-goto-info-page
Packit f2bd10
Read
Packit f2bd10
@ifinfo
Packit f2bd10
this
Packit f2bd10
@end ifinfo 
Packit f2bd10
@ifnotinfo
Packit f2bd10
the
Packit f2bd10
@end ifnotinfo
Packit f2bd10
info manual.
Packit f2bd10
Packit f2bd10
@item @kbd{M-x preview-report-bug @key{RET}}
Packit f2bd10
@itemx @code{preview-report-bug}
Packit f2bd10
@itemx Preview/Report Bug
Packit f2bd10
@kindex @kbd{M-x preview-report-bug @key{RET}}
Packit f2bd10
@findex preview-report-bug
Packit f2bd10
@cindex Report a bug
Packit f2bd10
This is the preferred way of reporting bugs as it will fill in what
Packit f2bd10
version of @previewlatex{} you are using as well as versions of
Packit f2bd10
relevant other software, and also some of the more important
Packit f2bd10
settings. Please use this method of reporting, if at all possible and
Packit f2bd10
before reporting a bug, have a look at @ref{Known problems}.
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-k}
Packit f2bd10
@itemx LaTeX/TeX Output/Kill Job
Packit f2bd10
@kindex @kbd{C-c C-k}
Packit f2bd10
@cindex Kill preview-generating process
Packit f2bd10
Kills the preview-generating process. This is really an @AUCTeX{}
Packit f2bd10
keybinding, but it is included here as a hint. If you are generating
Packit f2bd10
a preview and then make a change to the buffer, @previewlatex{} may be
Packit f2bd10
confused and place the previews wrong.
Packit f2bd10
@end table
Packit f2bd10
Packit f2bd10
@node Simple customization, Known problems, Keys and lisp, top
Packit f2bd10
@chapter Simple customization
Packit f2bd10
Packit f2bd10
Customization options can be found by typing @kbd{M-x customize-group
Packit f2bd10
@key{RET} preview @key{RET}}. Remember to set the option when you have
Packit f2bd10
changed it. The list of suggestions can be made very long (and is
Packit f2bd10
covered in detail in @ref{For advanced users}), but some are:
Packit f2bd10
Packit f2bd10
@itemize @bullet
Packit f2bd10
@item Change the color of the preview background
Packit f2bd10
Packit f2bd10
If you use a non-white background in Emacs, you might have color
Packit f2bd10
artifacts at the edges of your previews.  Playing around with the option
Packit f2bd10
@code{preview-transparent-color} in the @code{Preview Appearance} group
Packit f2bd10
might improve things.  With some settings, the cursor may cover the
Packit f2bd10
whole background of a preview, however.
Packit f2bd10
Packit f2bd10
This option is specific to the display engine in use.
Packit f2bd10
Packit f2bd10
@item Showing @code{\label}s
Packit f2bd10
@cindex Showing @code{\label}s
Packit f2bd10
Packit f2bd10
When using @previewlatex{}, the @code{\label}s are hidden by the
Packit f2bd10
previews.  It is possible to make them visible in the output
Packit f2bd10
by using the @LaTeX{} package @code{showkeys} alternatively
Packit f2bd10
@code{showlabels}.  However, the boxes of these labels will be outside
Packit f2bd10
the region @previewlatex{} considers as the preview image.  To enable a
Packit f2bd10
similar mechanism internal to @previewlatex{}, enable the
Packit f2bd10
@code{showlabels} option in the variable
Packit f2bd10
@code{preview-default-option-list} in the @code{Preview Latex} group.
Packit f2bd10
Packit f2bd10
It must be noted, however, that a much better idea may be to use the
Packit f2bd10
Ref@TeX{} package for managing references.  @xref{RefTeX in a
Packit f2bd10
Nutshell,,RefTeX in a Nutshell,reftex,The Ref@TeX{} Manual}.
Packit f2bd10
Packit f2bd10
@item Open previews automatically
Packit f2bd10
Packit f2bd10
The current default is to open previews automatically when you enter
Packit f2bd10
them with cursor left/right motions.  Auto-opened previews will close
Packit f2bd10
again once the cursor leaves them again (this is also done when doing
Packit f2bd10
incremental search, or query-replace operations), unless you changed
Packit f2bd10
anything in it.  In that case, you will have to regenerate the preview
Packit f2bd10
(via e.g., @kbd{C-c C-p C-p}).  Other options for
Packit f2bd10
@code{preview-auto-reveal} are available via @code{customize}.
Packit f2bd10
Packit f2bd10
@item Automatically cache preambles
Packit f2bd10
Packit f2bd10
Currently @previewlatex{} asks you whether you want to cache the
Packit f2bd10
document preamble (everything before @code{\begin@{document@}}) before
Packit f2bd10
it generates previews for a buffer the first time.  Caching the preamble
Packit f2bd10
will significantly speed up regeneration of previews.  The larger your
Packit f2bd10
preamble is, the more this will be apparent.  Once a preamble is cached,
Packit f2bd10
@previewlatex{} will try to keep track of when it is changed, and dump
Packit f2bd10
a fresh format in that case.  If you experience problems with this, or
Packit f2bd10
if you want it to happen without asking you the first time, you can
Packit f2bd10
customize the variable @code{preview-auto-cache-preamble}.
Packit f2bd10
@vindex preview-auto-cache-preamble
Packit f2bd10
@cindex Caching a preamble
Packit f2bd10
Packit f2bd10
@item Attempt to keep counters accurate when editing
Packit f2bd10
Packit f2bd10
@vindex preview-preserve-counters
Packit f2bd10
@vindex preview-required-option-list
Packit f2bd10
Since @previewlatex{} frequently runs only small regions through
Packit f2bd10
@LaTeX{}, values like equation counters are not consistent from run to
Packit f2bd10
run.  If this bothers you, customize the variable
Packit f2bd10
@code{preview-preserve-counters} to @code{t} (this is consulted by
Packit f2bd10
@code{preview-required-option-list}).  @LaTeX{} will then output a load
Packit f2bd10
of counter information during compilation, and this information will be
Packit f2bd10
used on subsequent updates to keep counters set to useful values.  The
Packit f2bd10
additional information takes additional time to analyze, but this is
Packit f2bd10
relevant mostly only when you are regenerating all previews at once, and
Packit f2bd10
maybe you will be less tempted to do so when counters appear more or
Packit f2bd10
less correct.
Packit f2bd10
Packit f2bd10
@item Preview your favourite @LaTeX{} constructs
Packit f2bd10
Packit f2bd10
If you have a certain macro or environment that you want to preview,
Packit f2bd10
first check if it can be chosen by cutomizing
Packit f2bd10
@code{preview-default-options-list} in the @code{Preview Latex} group.
Packit f2bd10
Packit f2bd10
If it is not available there, you can add it to
Packit f2bd10
@code{preview-default-preamble} also in the @code{Preview Latex} group,
Packit f2bd10
by adding a @code{\PreviewMacro} or @code{\PreviewEnvironment} entry
Packit f2bd10
(@pxref{Provided commands}) @emph{after} the @code{\RequirePackage}
Packit f2bd10
line.  For example, if you want to preview the @code{center}
Packit f2bd10
environment, press the @key{Show} button and the last @key{INS} button,
Packit f2bd10
then add
Packit f2bd10
Packit f2bd10
@example
Packit f2bd10
\PreviewEnvironment@{center@}
Packit f2bd10
@end example
Packit f2bd10
@noindent
Packit f2bd10
in the space that just opened.  Note that since @code{center} is a
Packit f2bd10
generic formatting construct of @LaTeX{}, a general configuration like
Packit f2bd10
that is not quite prudent.  You better to do this on a per-document
Packit f2bd10
base so that it is easy to disable this behavior when you find this
Packit f2bd10
particular entry gives you trouble.
Packit f2bd10
Packit f2bd10
One possibility is to save such settings in the corresponding file-local
Packit f2bd10
variable instead of your global configuration (@pxref{File
Packit f2bd10
Variables,,Local Variables in Files,emacs,GNU Emacs Manual}).  A perhaps
Packit f2bd10
more convenient place for such options would be in a configuration file
Packit f2bd10
in the same directory with your project (@pxref{Package options}).
Packit f2bd10
Packit f2bd10
The usual file for @previewlatex{} preconfiguration is
Packit f2bd10
@file{prauctex.cfg}.  If you also want to keep the systemwide defaults,
Packit f2bd10
you should add a line
Packit f2bd10
Packit f2bd10
@example
Packit f2bd10
\InputIfFileExists@{preview/prauctex.cfg@}@{@}@{@}
Packit f2bd10
@end example
Packit f2bd10
@noindent
Packit f2bd10
to your own version of @file{prauctex.cfg} (this is assuming that
Packit f2bd10
global files relating to the @code{preview} package are installed in a
Packit f2bd10
subdirectory @file{preview}, the default behavior).
Packit f2bd10
Packit f2bd10
@item Don't preview inline math
Packit f2bd10
@cindex Inline math
Packit f2bd10
Packit f2bd10
If you have performance problems because your document is full of inline
Packit f2bd10
math (@code{$@dots{}$}), or if your usage of @code{$} conflicts with
Packit f2bd10
@previewlatex{}'s, you can turn off inline math previews. In the
Packit f2bd10
@code{Preview Latex} group, remove @code{textmath} from
Packit f2bd10
@code{preview-default-option-list} by customizing this variable.
Packit f2bd10
@end itemize
Packit f2bd10
Packit f2bd10
@node Known problems, For advanced users, Simple customization, top
Packit f2bd10
@chapter Known problems
Packit f2bd10
@c also used as PROBLEMS file
Packit f2bd10
@include preview-problems.texi
Packit f2bd10
Packit f2bd10
@node For advanced users, ToDo, Known problems, top
Packit f2bd10
@chapter For advanced users
Packit f2bd10
Packit f2bd10
This package consists of two parts: a @LaTeX{} style that splits the
Packit f2bd10
output into appropriate parts with one preview object on each page, and
Packit f2bd10
an Emacs-lisp part integrating the thing into Emacs (aided by
Packit f2bd10
@AUCTeX{}).
Packit f2bd10
Packit f2bd10
@menu
Packit f2bd10
* The LaTeX style file::        
Packit f2bd10
* The Emacs interface::         
Packit f2bd10
* The preview images::             
Packit f2bd10
* Misplaced previews::          
Packit f2bd10
@end menu
Packit f2bd10
Packit f2bd10
@node The LaTeX style file, The Emacs interface, For advanced users, For advanced users
Packit f2bd10
@section The @LaTeX{} style file
Packit f2bd10
@c Autogenerated from ../preview.dtx
Packit f2bd10
@include preview-dtxdoc.texi
Packit f2bd10
Packit f2bd10
@node The Emacs interface, The preview images, The LaTeX style file, For advanced users
Packit f2bd10
@section The Emacs interface
Packit f2bd10
Packit f2bd10
You can use @kbd{M-x customize-group @key{RET} preview-latex @key{RET}}
Packit f2bd10
in order to customize these variables, or use the menus for it.  We
Packit f2bd10
explain the various available options together with explaining how they
Packit f2bd10
work together in making @previewlatex{} work as intended.
Packit f2bd10
Packit f2bd10
@vtable @code
Packit f2bd10
@item preview-LaTeX-command
Packit f2bd10
When you generate previews on a buffer or a region, the command in
Packit f2bd10
@code{preview-LaTeX-command} gets run (that variable should only be
Packit f2bd10
changed with Customize since its structure is somewhat peculiar, though
Packit f2bd10
expressive).  As usual with @AUCTeX{}, you can continue working while
Packit f2bd10
this is going on.  It is not a good idea to change the file until after
Packit f2bd10
@previewlatex{} has established where to place the previews which it can
Packit f2bd10
only do after the @LaTeX{} run completes.  This run produces a host of
Packit f2bd10
pseudo-error messages that get parsed by @previewlatex{} at the end of
Packit f2bd10
the @LaTeX{} run and give it the necessary information about where in
Packit f2bd10
the source file the @LaTeX{} code for the various previews is located
Packit f2bd10
exactly. The parsing takes a moment and will render Emacs busy.
Packit f2bd10
Packit f2bd10
@item preview-LaTeX-command-replacements
Packit f2bd10
This variable specifies transformations to be used before calling the
Packit f2bd10
configured command.  One possibility is to have @samp{\pdfoutput=0 }
Packit f2bd10
appended to every command starting with @samp{pdf}.  This particular
Packit f2bd10
setting is available as the shortcut
Packit f2bd10
@samp{preview-LaTeX-disable-pdfoutput}.  Since @previewlatex{} can work
Packit f2bd10
with @acronym{PDF} files by now, there is little incentive for using
Packit f2bd10
this option, anymore (for projects not requiring @acronym{PDF} output,
Packit f2bd10
the added speed of @samp{dvipng} might make this somewhat attractive).
Packit f2bd10
Packit f2bd10
@item preview-required-option-list
Packit f2bd10
@code{preview-LaTeX-command} uses @code{preview-required-option-list} in
Packit f2bd10
order to pass options such as @option{auctex}, @option{active} and
Packit f2bd10
@option{dvips} to the @file{preview} package.  This means that the user
Packit f2bd10
need (and should) not supply these in the document itself in case he
Packit f2bd10
wants to be able to still compile his document without it turning into
Packit f2bd10
an incoherent mass of little pictures.  These options even get passed
Packit f2bd10
in when the user loads @file{preview} explicitly in his document.
Packit f2bd10
Packit f2bd10
The default includes an option @code{counters} that is controlled by the
Packit f2bd10
boolean variable
Packit f2bd10
Packit f2bd10
@item preview-preserve-counters
Packit f2bd10
This option will cause the @file{preview} package to emit information
Packit f2bd10
that will assist in keeping things like equation counters and section
Packit f2bd10
numbers reasonably correct even when you are regenerating only single
Packit f2bd10
previews.
Packit f2bd10
Packit f2bd10
@item preview-default-option-list
Packit f2bd10
@itemx preview-default-preamble
Packit f2bd10
If the document does not call in the package @code{preview} itself (via
Packit f2bd10
@code{\usepackage}) in the preamble, the preview package is loaded using
Packit f2bd10
default options from @code{preview-default-option-list} and additional
Packit f2bd10
commands specified in @code{preview-default-preamble}.
Packit f2bd10
Packit f2bd10
@item preview-fast-conversion
Packit f2bd10
This is relevant only for @acronym{DVI} mode.  It defaults to `On' and
Packit f2bd10
results in the whole document being processed as one large PostScript
Packit f2bd10
file from which the single images are extracted with the help of parsing
Packit f2bd10
the PostScript for use of so-called @acronym{DSC} comments.  The
Packit f2bd10
bounding boxes are extracted with the help of @TeX{} instead of getting
Packit f2bd10
them from Dvips.  If you are experiencing bounding box problems, try
Packit f2bd10
setting this option to `Off'.
Packit f2bd10
Packit f2bd10
@item preview-prefer-TeX-bb
Packit f2bd10
If this option is `On', it tells @previewlatex{} never to try to extract
Packit f2bd10
bounding boxes from the bounding box comments of @acronym{EPS} files,
Packit f2bd10
but rather rely on the boxes it gets from @TeX{}.  If you activated
Packit f2bd10
@code{preview-fast-conversion}, this is done, anyhow, since there are no
Packit f2bd10
@acronym{EPS} files from which to read this information.  The option
Packit f2bd10
defaults to `Off', simply because about the only conceivable reason to
Packit f2bd10
switch off @code{preview-fast-conversion} would be that you have some
Packit f2bd10
bounding box problem and want to get Dvips' angle on that matter.
Packit f2bd10
Packit f2bd10
@item preview-scale-function
Packit f2bd10
@itemx preview-reference-face
Packit f2bd10
@itemx preview-document-pt-list
Packit f2bd10
@itemx preview-default-document-pt
Packit f2bd10
@code{preview-scale-function} determines by what factor
Packit f2bd10
images should be scaled when appearing on the screen.  If you specify a
Packit f2bd10
numerical value here, the physical size on the screen will be that of
Packit f2bd10
the original paper output scaled by the specified factor, at least if
Packit f2bd10
Emacs' information about screen size and resolution are correct.  The
Packit f2bd10
default is to let @code{preview-scale-from-face} determine the scale
Packit f2bd10
function.  This function determines the scale factor by making the
Packit f2bd10
size of the default font in the document match that of the on-screen
Packit f2bd10
fonts.
Packit f2bd10
Packit f2bd10
The size of the screen fonts is deduced from the font
Packit f2bd10
@code{preview-reference-face} (usually the default face used for
Packit f2bd10
display), the size of the default font for the document is determined
Packit f2bd10
by calling @code{preview-document-pt}.
Packit f2bd10
@findex preview-document-pt
Packit f2bd10
This function consults the members of @code{preview-document-pt-list} in
Packit f2bd10
turn until it gets the desired information.  The default consults first
Packit f2bd10
@code{preview-parsed-font-size},
Packit f2bd10
@vindex preview-parsed-font-size
Packit f2bd10
then calls @code{preview-auctex-font-size}
Packit f2bd10
@findex preview-auctex-font-size
Packit f2bd10
which asks @AUCTeX{} about any size specification like @option{12pt} to
Packit f2bd10
the documentclass that it might have detected when parsing the document, and
Packit f2bd10
finally reverts to just assuming @code{preview-default-document-pt} as
Packit f2bd10
the size used in the document (defaulting to 10pt).
Packit f2bd10
Packit f2bd10
If you find that the size of previews and the other Emacs display
Packit f2bd10
clashes, something goes wrong.  @code{preview-parsed-font-size} is
Packit f2bd10
determined at @code{\begin@{document@}} time; if the default font size
Packit f2bd10
changes after that, it will not get reported.  If you have an outdated
Packit f2bd10
version of @file{preview.sty} in your path, the size might not be
Packit f2bd10
reported at all.  If in this case @AUCTeX{} is unable to find a size
Packit f2bd10
specification, and if you are using a document class with a different
Packit f2bd10
default value (like KomaScript), the default fallback assumption will
Packit f2bd10
probably be wrong and @previewlatex{} will scale up things too large.
Packit f2bd10
So better specify those size options even when you know that @LaTeX{}
Packit f2bd10
does not need them: @previewlatex{} might benefit from them.  Another
Packit f2bd10
possibility for error is that you have not enabled @AUCTeX{}'s document
Packit f2bd10
parsing options.  The fallback method of asking @AUCTeX{} about the size
Packit f2bd10
might be disabled in future versions of @previewlatex{} since in
Packit f2bd10
general it is more reliable to get this information from the @LaTeX{}
Packit f2bd10
run itself.
Packit f2bd10
Packit f2bd10
@item preview-fast-dvips-command
Packit f2bd10
@itemx preview-dvips-command
Packit f2bd10
The regular command for turning a @acronym{DVI} file into a single
Packit f2bd10
PostScript file is @code{preview-fast-dvips-command}, while
Packit f2bd10
@code{preview-dvips-command} is used for cranking out a @acronym{DVI}
Packit f2bd10
file where every preview is in a separate @acronym{EPS} file.  Which of
Packit f2bd10
the two commands gets used depends on the setting of
Packit f2bd10
@code{preview-fast-conversion}.  The printer specified here by default
Packit f2bd10
is @option{-Pwww} by default, which will usually get you scalable fonts
Packit f2bd10
where available. If you are experiencing problems, you might want to try
Packit f2bd10
playing around with Dvips options (@inforef{Command-line options,,dvips}).
Packit f2bd10
Packit f2bd10
The conversion of the previews into PostScript or @acronym{EPS} files
Packit f2bd10
gets started after the @LaTeX{} run completes when Emacs recognizes the
Packit f2bd10
first image while parsing the error messages.  When Emacs has finished
Packit f2bd10
parsing the error messages, it activates all detected previews.  This
Packit f2bd10
entails throwing away any previous previews covering the same areas, and
Packit f2bd10
then replacing the text in its visual appearance by a placeholder
Packit f2bd10
looking like a roadworks sign.
Packit f2bd10
Packit f2bd10
@item preview-nonready-icon-specs
Packit f2bd10
This is the roadworks sign displayed while previews are being prepared.
Packit f2bd10
You may want to customize the font sizes at which @previewlatex{}
Packit f2bd10
switches over between different icon sizes, and the ascent ratio which
Packit f2bd10
determines how high above the base line the icon gets placed.
Packit f2bd10
Packit f2bd10
@item preview-error-icon-specs
Packit f2bd10
@itemx preview-icon-specs
Packit f2bd10
Those are icons placed before the source code of an opened preview and,
Packit f2bd10
respectively, the image specs to be used for PostScript errors, and a
Packit f2bd10
normal open preview in text representation.
Packit f2bd10
Packit f2bd10
@item preview-inner-environments
Packit f2bd10
This is a list of environments that are regarded as inner levels of an
Packit f2bd10
outer environment when doing @code{preview-environment}. One example
Packit f2bd10
when this is needed is in
Packit f2bd10
@code{\begin@{equation@}\begin@{split@}@dots{}\end@{split@}\end@{equation@}}, and
Packit f2bd10
accordingly @code{split} is one entry in
Packit f2bd10
@code{preview-inner-environments}.
Packit f2bd10
Packit f2bd10
@end vtable
Packit f2bd10
Packit f2bd10
@node The preview images, Misplaced previews, The Emacs interface, For advanced users
Packit f2bd10
@section The preview images
Packit f2bd10
Packit f2bd10
@vtable @code
Packit f2bd10
@item preview-image-type
Packit f2bd10
@itemx preview-image-creators
Packit f2bd10
@itemx preview-gs-image-type-alist
Packit f2bd10
What happens when @LaTeX{} is finished depends on the configuration of
Packit f2bd10
@code{preview-image-type}.  What to do for each of the various settings
Packit f2bd10
is specified in the variable @code{preview-image-creators}.  The options
Packit f2bd10
to pass into Ghostscript and what Emacs image type to use is specified
Packit f2bd10
in @code{preview-gs-image-type-alist}.
Packit f2bd10
Packit f2bd10
@code{preview-image-type} defaults to @code{png}.  For this to work,
Packit f2bd10
your version of Ghostscript needs to support the @option{png16m} device.
Packit f2bd10
If you are experiencing problems here, you might want to reconfigure
Packit f2bd10
@code{gs-image-type-alist} or @code{preview-image-type}.  Reconfiguring
Packit f2bd10
@code{preview-image-creators} is only necessary for adding additional
Packit f2bd10
image types.
Packit f2bd10
Packit f2bd10
Most devices make @previewlatex{} start up a single Ghostscript process
Packit f2bd10
for the entire preview run (as opposed to one per image) and feed it
Packit f2bd10
either sections of a @acronym{PDF} file (if PDF@LaTeX{} was used), or
Packit f2bd10
(after running Dvips) sections of a single PostScript file or separate
Packit f2bd10
@acronym{EPS} files in sequence for conversion into @acronym{PNG} format
Packit f2bd10
which can be displayed much faster by Emacs.  Actually, not in sequence
Packit f2bd10
but backwards since you are most likely editing at the end of the
Packit f2bd10
document.  And as an added convenience, any preview that happens to be
Packit f2bd10
on-screen is given higher priority so that @previewlatex{} will first
Packit f2bd10
cater for the images that are displayed. There are various options
Packit f2bd10
customizable concerning aspects of that operation, see the customization
Packit f2bd10
group @code{Preview Gs} for this.
Packit f2bd10
Packit f2bd10
Another noteworthy setting of @code{preview-image-type} is
Packit f2bd10
@samp{dvipng}: in this case, the @samp{dvipng}
Packit f2bd10
@pindex dvipng 
Packit f2bd10
program will get run on @acronym{DVI} output (see below for @acronym{PDF}).
Packit f2bd10
This is in general much faster than Dvips and Ghostscript.  In that
Packit f2bd10
case, the option
Packit f2bd10
Packit f2bd10
@item preview-dvipng-command
Packit f2bd10
will get run for doing the conversion, and it is expected that
Packit f2bd10
Packit f2bd10
@item preview-dvipng-image-type
Packit f2bd10
images get produced (@samp{dvipng} might be configured for other image
Packit f2bd10
types as well).  You will notice that @code{preview-gs-image-type-alist}
Packit f2bd10
contains an entry for @code{dvipng}: this actually has nothing to with
Packit f2bd10
@samp{dvipng} itself but specifies the image type and Ghostscript device
Packit f2bd10
option to use when @samp{dvipng} can't be used.  This will obviously be
Packit f2bd10
the case for @acronym{PDF} output by PDF@LaTeX{}, but it will also happen
Packit f2bd10
if the @acronym{DVI} file contains PostScript specials in which case the
Packit f2bd10
affected images will get run through Dvips and Ghostscript once
Packit f2bd10
@samp{dvipng} finishes.
Packit f2bd10
Packit f2bd10
@item preview-gs-options
Packit f2bd10
Most interesting to the user perhaps is the setting of this variable.
Packit f2bd10
It contains the default antialiasing settings @option{-dTextAlphaBits=4}
Packit f2bd10
and @option{-dGraphicsAlphaBits=4}.  Decreasing those values to 2 @w{or
Packit f2bd10
1} might increase Ghostscript's performance if you find it lacking.
Packit f2bd10
@end vtable
Packit f2bd10
Packit f2bd10
Running and feeding Ghostscript from @previewlatex{} happens
Packit f2bd10
asynchronously again: you can resume editing while the images arrive.
Packit f2bd10
While those pretty pictures filling in the blanks on screen tend to
Packit f2bd10
make one marvel instead of work, rendering the non-displayed images
Packit f2bd10
afterwards will not take away your attention and will eventually
Packit f2bd10
guarantee that jumping around in the document will encounter only
Packit f2bd10
prerendered images.
Packit f2bd10
Packit f2bd10
@node Misplaced previews,  , The preview images, For advanced users
Packit f2bd10
@section Misplaced previews
Packit f2bd10
Packit f2bd10
If you are reading this section, the first thing is to check that your
Packit f2bd10
problem is not caused by x-symbol in connection with an installation not
Packit f2bd10
supporting 8-bit characters (@pxref{x-symbol interoperation}).  If not,
Packit f2bd10
here's the beef:
Packit f2bd10
Packit f2bd10
As explained previously, Emacs uses pseudo-error messages generated by
Packit f2bd10
the @samp{preview} package in order to pinpoint the exact source
Packit f2bd10
location where a preview originated.  This works in running text, but
Packit f2bd10
fails when preview material happens to lie in macro arguments, like the
Packit f2bd10
contents of @code{\emph}. Those macros first read in their entire
Packit f2bd10
argument, munge it through, perhaps transform it somehow, process it and
Packit f2bd10
perhaps then typeset something. When they finally typeset something,
Packit f2bd10
where is the location where the stuff originated? @TeX{}, having read in
Packit f2bd10
the entire argument before, does not know and actually there would be no
Packit f2bd10
sane way of defining it.
Packit f2bd10
Packit f2bd10
For previews contained inside such a macro argument, the default
Packit f2bd10
behaviour of @previewlatex{} is to use a position immediately after the
Packit f2bd10
closing brace of the argument. All the previews get placed there, all at
Packit f2bd10
a zero-width position, which means that Emacs displays it in an order
Packit f2bd10
that @previewlatex{} cannot influence (currently in Emacs it is even
Packit f2bd10
possible that the order changes between runs). And since the placement
Packit f2bd10
of those previews is goofed up, you will not be able to regenerate them
Packit f2bd10
by clicking on them. The default behaviour is thus somewhat undesirable.
Packit f2bd10
Packit f2bd10
The solution (like with other preview problems) is to tell the @LaTeX{}
Packit f2bd10
@samp{preview} package how to tackle this problem (@pxref{The LaTeX
Packit f2bd10
style file}).  Simply, you don't need @code{\emph} do anything at all
Packit f2bd10
during previews! You only want the text math previewed, so the solution
Packit f2bd10
is to use @code{\PreviewMacro*\emph} in the preamble of your document
Packit f2bd10
which will make @LaTeX{} ignore @code{\emph} completely as long as it is
Packit f2bd10
not part of a larger preview (in which case it gets typeset as
Packit f2bd10
usual). Its argument thus becomes ordinary text and gets treated like
Packit f2bd10
ordinary text.
Packit f2bd10
Packit f2bd10
Note that it would be a bad idea to declare
Packit f2bd10
@code{\PreviewMacro*[@{@{@}@}]\emph} since then both @code{\emph} as
Packit f2bd10
well as its argument would be ignored instead of previewed. For
Packit f2bd10
user-level macros, this is almost never wanted, but there may be
Packit f2bd10
internal macros where you might want to ignore internal arguments.
Packit f2bd10
Packit f2bd10
The same mechanism can be used for a number of other text-formatting
Packit f2bd10
commands like @code{\textrm}, @code{\textit} and the like. While they
Packit f2bd10
all use the same internal macro @code{\text@@command}, it will not do to
Packit f2bd10
redefine just that, since they call it only after having read their
Packit f2bd10
argument in, and then it already is too late. So you need to disable
Packit f2bd10
every of those commands by hand in your document preamble.
Packit f2bd10
Packit f2bd10
Actually, we wrote all of the above just to scare you.  At least all of
Packit f2bd10
the above mentioned macros and a few more are already catered for by a
Packit f2bd10
configuration file @file{prauctex.cfg} that gets loaded by default
Packit f2bd10
unless the @samp{preview} package gets loaded with the @option{noconfig}
Packit f2bd10
option.  You can make your own copy of this file in a local directory
Packit f2bd10
and edit it in case of need.  You can also add loading of a file of your
Packit f2bd10
liking to @code{preview-default-preamble},
Packit f2bd10
@vindex preview-default-preamble
Packit f2bd10
or alternatively do the
Packit f2bd10
manual disabling of your favorite macro in
Packit f2bd10
@code{preview-default-preamble},
Packit f2bd10
@vindex preview-default-preamble
Packit f2bd10
which is customizable in the Preview Latex group.
Packit f2bd10
Packit f2bd10
@node ToDo, Frequently Asked Questions, For advanced users, top
Packit f2bd10
@c Also used as TODO: in separate file
Packit f2bd10
@appendix ToDo
Packit f2bd10
@include preview-todo.texi
Packit f2bd10
Packit f2bd10
@node Frequently Asked Questions, Copying this Manual, ToDo, top
Packit f2bd10
@c Also used as TODO: in separate file
Packit f2bd10
@appendix Frequently Asked Questions
Packit f2bd10
@include preview-faq.texi
Packit f2bd10
Packit f2bd10
@node Copying this Manual, Index, Frequently Asked Questions, top
Packit f2bd10
@c Not to be changed often, I think: in separate file.
Packit f2bd10
@appendix Copying this Manual
Packit f2bd10
Packit f2bd10
@ifinfo
Packit f2bd10
The copyright notice for this manual is:
Packit f2bd10
Packit f2bd10
@insertcopying
Packit f2bd10
@end ifinfo
Packit f2bd10
Packit f2bd10
The full license text can be read here:
Packit f2bd10
Packit f2bd10
@menu
Packit f2bd10
* GNU Free Documentation License:: License for copying this manual.
Packit f2bd10
@end menu
Packit f2bd10
Packit f2bd10
@include fdl.texi
Packit f2bd10
Packit f2bd10
@c @node Credits, Index, Internals, top
Packit f2bd10
@c @appendix Credits 
Packit f2bd10
Packit f2bd10
@node Index,  , Copying this Manual, top
Packit f2bd10
@unnumbered Index
Packit f2bd10
Packit f2bd10
@printindex cp
Packit f2bd10
Packit f2bd10
@bye