]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex/doc/preview-latex.texi
35085be8b60395fe43f1b27bdc26d5ee6931446f
[gnu-emacs-elpa] / packages / auctex / doc / preview-latex.texi
1 \input texinfo
2 @comment %**start of header
3 @setfilename preview-latex.info
4 @include version.texi
5 @settitle preview-latex @value{VERSION}
6 @comment %**end of header
7 @include macros.texi
8 @copying
9 This manual is for preview-latex, a @LaTeX{} preview mode for @AUCTeX{}
10 (version @value{VERSION} from @value{UPDATED}).
11
12 Copyright @copyright{} 2001, 2002, 2003,
13 2004, 2005, 2006 Free Software Foundation, Inc.
14
15 @quotation
16 Permission is granted to copy, distribute and/or modify this document
17 under the terms of the GNU Free Documentation License, Version 1.3 or
18 any later version published by the Free Software Foundation; with no
19 Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A
20 copy of the license is included in the section entitled ``GNU Free
21 Documentation License.''
22 @end quotation
23 @end copying
24
25 @dircategory Emacs
26 @direntry
27 * preview-latex: (preview-latex). Preview LaTeX fragments in Emacs
28 @end direntry
29 @dircategory TeX
30 @direntry
31 * preview-latex: (preview-latex). Preview LaTeX fragments in Emacs
32 @end direntry
33 @c footnotestyle separate
34 @c paragraphindent 2
35 @syncodeindex vr cp
36 @syncodeindex ky cp
37 @syncodeindex fn cp
38
39 @iftex
40 @tolerance 10000 @emergencystretch 3em
41 @end iftex
42
43 @finalout
44 @titlepage
45 @title @previewlatex{}
46 @subtitle A @LaTeX{} preview mode for @AUCTeX{} in Emacs.
47 @subtitle Version @value{VERSION}, @value{UPDATED}
48 @author Jan-@AA{}ke Larsson
49 @author David Kastrup and others
50 @page
51 @vskip 0pt plus 1filll
52 @insertcopying
53 @end titlepage
54
55 @c @summarycontents
56 @contents
57
58 @c Use @ifinfo _and_ @ifhtml here because Texinfo 3 cannot cope with
59 @c @ifnottex around a top node.
60 @ifinfo
61 @node top, , (dir), (dir)
62 @top @previewlatex{}
63
64 This manual may be copied under the conditions spelled out in
65 @ref{Copying this Manual}.
66
67 @end ifinfo
68 @ifhtml
69 @node top, Copying, (dir), (dir)
70 @top @previewlatex{}
71 @insertcopying
72 @end ifhtml
73
74 @contents
75
76 @iftex
77 @unnumbered @previewlatex{}
78 @end iftex
79
80 @previewlatex{} is a package embedding preview fragments into Emacs
81 source buffers under the @AUCTeX{} editing environment for @LaTeX{}. It
82 uses @file{preview.sty} for the extraction of certain environments (most
83 notably displayed formulas). Other applications of this style file are
84 possible and exist.
85
86 The name of the package is really @samp{preview-latex}, all in
87 lowercase letters, with a hyphen. If you typeset it, you can use a
88 sans-serif font to visually offset it.
89
90 @menu
91 * Copying:: Copying
92 * Introduction:: Getting started.
93 * Installation:: Make Install.
94 * Keys and lisp:: Key bindings and user-level lisp functions.
95 * Simple customization:: To make it fit in.
96 * Known problems:: When things go wrong.
97 * For advanced users:: Internals and more customizations.
98 * ToDo:: Future development.
99 * Frequently Asked Questions:: All about @previewlatex{}
100 * Copying this Manual:: GNU Free Documentation License
101 * Index:: A menu of many topics.
102 @end menu
103
104 @node Copying, Introduction, top, top
105 @unnumbered Copying
106 @cindex Copying
107 @cindex Copyright
108 @cindex GPL
109 @cindex General Public License
110 @cindex License
111 @cindex Free
112 @cindex Free software
113 @cindex Distribution
114 @cindex Right
115 @cindex Warranty
116
117 For the conditions for copying parts of @previewlatex{}, see the General
118 Public Licenses referres to in the copyright notices of the files, the
119 General Public Licenses accompanying them and the explanatory section in
120 @ref{Copying,,,auctex,the @AUCTeX{} manual}.
121
122 This manual specifically is covered by the GNU Free Documentation
123 License (@pxref{Copying this Manual}).
124
125 @node Introduction, Installation, Copying, top
126 @c Used as @file{README} as well: in separate file
127 @chapter Introduction
128 @include preview-readme.texi
129
130 @node Installation, Keys and lisp, Introduction, top
131 @chapter Installation
132 Installation is now being covered in
133 @ref{Installation,,,auctex,the @AUCTeX{} manual}.
134
135 @node Keys and lisp, Simple customization, Installation, top
136 @chapter Key bindings and user-level lisp functions
137
138 @cindex Menu entries
139 @previewlatex{} adds key bindings starting with @kbd{C-c C-p} to the
140 supported modes of @AUCTeX{} (@inforef{Key Index,,auctex}). It will
141 also add its own @samp{Preview} menu in the menu bar, as well as an icon
142 in the toolbar.
143
144 The following only describes the interactive use: view the documentation
145 strings with @kbd{C-h f} if you need the Lisp information.
146
147 @table @w
148 @item @kbd{C-c C-p C-p}
149 @itemx @code{preview-at-point}
150 @itemx Preview/Generate previews (or toggle) at point
151 If the cursor is positioned on or inside of a preview area, this
152 toggles its visibility, regenerating the preview if necessary. If not,
153 it will run the surroundings through preview. The surroundings include
154 all areas up to the next valid preview, unless invalid previews occur
155 before, in which case the area will include the last such preview in
156 either direction. And overriding any other
157 action, if a region is active (@code{transient-mark-mode} or
158 @code{zmacs-regions}), it is run through @code{preview-region}.
159 @kindex @kbd{C-c C-p C-p}
160 @findex preview-at-point
161
162 @item @kbd{<mouse-2>}
163 The middle mouse button has a similar action bound to it as
164 @code{preview-at-point}, only that it knows which preview to apply it to
165 according to the position of the click. You can click either anywhere
166 on a previewed image, or when the preview is opened and showing the
167 source text, you can click on the icon preceding the source text. In
168 other areas, the usual mouse key action (typically: paste) is not
169 affected.
170
171 @item @kbd{<mouse-3>}
172 The right mouse key pops up a context menu with several options:
173 toggling the preview, regenerating it, removing it (leaving the
174 unpreviewed text), copying the text inside of the preview, and copying
175 it in a form suitable for copying as an image into a mail or news
176 article. This is a one-image variant of the following command:
177
178 @item @kbd{C-c C-p C-w}
179 @itemx @code{preview-copy-region-as-mml}
180 @itemx Copy a region as MML
181 @kindex @kbd{C-c C-p C-w}
182 @findex preview-copy-region-as-mml
183 This command is also available as a variant in the context menu on the
184 right mouse button (where the region is the preview that has been
185 clicked on). It copies the current region into the kill buffer in a
186 form suitable for copying as a text including images into a mail or news
187 article using mml-mode (@pxref{Composing,,Composing,emacs-mime,Emacs
188 MIME}).
189
190 If you regenerate or otherwise kill the preview in its source buffer
191 before the mail or news gets posted, this will fail. Also you should
192 generate images you want to send with @code{preview-transparent-border}
193 @vindex preview-transparent-border
194 set to @code{nil}, or the images will have an ugly border.
195 @previewlatex{} detects this condition and asks whether to regenerate
196 the region with borders switched off. As this is an asynchronous
197 operation running in the background, you'll need to call this command
198 explicitly again to get the newly generated images into the kill ring.
199
200 Preview your articles with @code{mml-preview} (on @kbd{M-m P}, or
201 @kbd{C-c C-m P} in @w{Emacs 22})
202 @kindex @kbd{M-m P}
203 @kindex @kbd{C-c C-m P}
204 to make sure they look fine.
205
206 @item @kbd{C-c C-p C-e}
207 @itemx @code{preview-environment}
208 @itemx Preview/Generate previews for environment
209 Run preview on @LaTeX{} environment. The environments in
210 @code{preview-inner-environments} are treated as inner levels so that
211 for instance, the @code{split} environment in
212 @code{\begin@{equation@}\begin@{split@}@dots{}\end@{split@}\end@{equation@}}
213 is properly displayed. If called with a numeric argument, the
214 corresponding number of outward nested environments is treated as inner
215 levels.
216 @kindex @kbd{C-c C-p C-e}
217 @findex preview-environment
218
219 @item @kbd{C-c C-p C-s}
220 @itemx @code{preview-section}
221 @itemx Preview/Generate previews for section
222 Run preview on this @LaTeX{} section.
223 @kindex @kbd{C-c C-p C-s}
224 @findex preview-section
225
226 @item @kbd{C-c C-p C-r}
227 @itemx @code{preview-region}
228 @itemx Preview/Generate previews for region
229 Run preview on current region.
230 @kindex @kbd{C-c C-p C-r}
231 @findex preview-region
232
233 @item @kbd{C-c C-p C-b}
234 @itemx @code{preview-buffer}
235 @itemx Preview/Generate previews for buffer
236 Run preview on the current buffer.
237 @kindex @kbd{C-c C-p C-b}
238 @findex preview-buffer
239
240 @item @kbd{C-c C-p C-d}
241 @itemx @code{preview-document}
242 @itemx Preview/Generate previews for document
243 Run preview on the current document.
244 @kindex @kbd{C-c C-p C-d}
245 @findex preview-document
246
247 @item @kbd{C-c C-p C-c C-p}
248 @itemx @code{preview-clearout-at-point}
249 @itemx Preview/Remove previews at point
250 @kindex @kbd{C-c C-p C-c C-p}
251 @findex preview-clearout-at-point
252 Clear out (remove) the previews that are immediately adjacent to point.
253
254 @item @kbd{C-c C-p C-c C-s}
255 @itemx @code{preview-clearout-section}
256 @itemx Preview/Remove previews from section
257 @kindex @kbd{C-c C-p C-c C-s}
258 @findex preview-clearout-document
259 Clear out all previews in current section.
260
261 @item @kbd{C-c C-p C-c C-r}
262 @itemx @code{preview-clearout}
263 @itemx Preview/Remove previews from region
264 @kindex @kbd{C-c C-p C-c C-r}
265 @findex preview-clearout
266 Clear out all previews in the current region.
267
268 @item @kbd{C-c C-p C-c C-b}
269 @itemx @code{preview-clearout-buffer}
270 @itemx Preview/Remove previews from buffer
271 @kindex @kbd{C-c C-p C-c C-b}
272 @findex preview-clearout-buffer
273 Clear out all previews in current buffer. This makes the current buffer
274 lose all previews.
275
276 @item @kbd{C-c C-p C-c C-d}
277 @itemx @code{preview-clearout-document}
278 @itemx Preview/Remove previews from document
279 @kindex @kbd{C-c C-p C-c C-d}
280 @findex preview-clearout-document
281 Clear out all previews in current document. The document consists of
282 all buffers that have the same master file as the current buffer. This
283 makes the current document lose all previews.
284
285 @item @kbd{C-c C-p C-f}
286 @itemx @code{preview-cache-preamble}
287 @itemx Preview/Turn preamble cache on
288 @kindex @kbd{C-c C-p C-f}
289 @findex preview-cache-preamble
290 Dump a pregenerated format file. For the rest of the session, this file
291 is used when running on the same master file. Use this if you know your
292 @LaTeX{} takes a long time to start up, the speedup will be most
293 noticeable when generating single or few previews. If you change your
294 preamble, do this again. @previewlatex{} will try to detect the
295 necessity of that automatically when editing changes to the preamble are
296 done from within Emacs, but it will not notice if the preamble
297 effectively changes because some included file or style file is
298 tampered with.
299
300 @item @kbd{C-c C-p C-c C-f}
301 @itemx @code{preview-cache-preamble-off}
302 @itemx Preview/Turn preamble cache off
303 @kindex @kbd{C-u C-c C-p C-f}
304 @findex preview-cache-preamble-off
305 Clear the pregenerated format file and stop using preambles for the
306 current document. If the caching gives you problems, use this.
307
308 @item @kbd{C-c C-p C-i}
309 @itemx @code{preview-goto-info-page}
310 @itemx Preview/Read Documentation
311 @kindex @kbd{C-c C-p C-i}
312 @findex preview-goto-info-page
313 Read
314 @ifinfo
315 this
316 @end ifinfo
317 @ifnotinfo
318 the
319 @end ifnotinfo
320 info manual.
321
322 @item @kbd{M-x preview-report-bug @key{RET}}
323 @itemx @code{preview-report-bug}
324 @itemx Preview/Report Bug
325 @kindex @kbd{M-x preview-report-bug @key{RET}}
326 @findex preview-report-bug
327 @cindex Report a bug
328 This is the preferred way of reporting bugs as it will fill in what
329 version of @previewlatex{} you are using as well as versions of
330 relevant other software, and also some of the more important
331 settings. Please use this method of reporting, if at all possible and
332 before reporting a bug, have a look at @ref{Known problems}.
333
334 @item @kbd{C-c C-k}
335 @itemx LaTeX/TeX Output/Kill Job
336 @kindex @kbd{C-c C-k}
337 @cindex Kill preview-generating process
338 Kills the preview-generating process. This is really an @AUCTeX{}
339 keybinding, but it is included here as a hint. If you are generating
340 a preview and then make a change to the buffer, @previewlatex{} may be
341 confused and place the previews wrong.
342 @end table
343
344 @node Simple customization, Known problems, Keys and lisp, top
345 @chapter Simple customization
346
347 Customization options can be found by typing @kbd{M-x customize-group
348 @key{RET} preview @key{RET}}. Remember to set the option when you have
349 changed it. The list of suggestions can be made very long (and is
350 covered in detail in @ref{For advanced users}), but some are:
351
352 @itemize @bullet
353 @item Change the color of the preview background
354
355 If you use a non-white background in Emacs, you might have color
356 artifacts at the edges of your previews. Playing around with the option
357 @code{preview-transparent-color} in the @code{Preview Appearance} group
358 might improve things. With some settings, the cursor may cover the
359 whole background of a preview, however.
360
361 This option is specific to the display engine in use. Its default is
362 different in @w{Emacs 21} and @w{Emacs 22}, and it is not available in
363 XEmacs.
364
365 @item Showing @code{\label}s
366 @cindex Showing @code{\label}s
367
368 When using @previewlatex{}, the @code{\label}s are hidden by the
369 previews. It is possible to make them visible in the output
370 by using the @LaTeX{} package @code{showkeys} alternatively
371 @code{showlabels}. However, the boxes of these labels will be outside
372 the region @previewlatex{} considers as the preview image. To enable a
373 similar mechanism internal to @previewlatex{}, enable the
374 @code{showlabels} option in the variable
375 @code{preview-default-option-list} in the @code{Preview Latex} group.
376
377 It must be noted, however, that a much better idea may be to use the
378 Ref@TeX{} package for managing references. @xref{RefTeX in a
379 Nutshell,,RefTeX in a Nutshell,reftex,The Ref@TeX{} Manual}.
380
381 @item Open previews automatically
382
383 The current default is to open previews automatically when you enter
384 them with cursor left/right motions. Auto-opened previews will close
385 again once the cursor leaves them again (this is also done when doing
386 incremental search, or query-replace operations), unless you changed
387 anything in it. In that case, you will have to regenerate the preview
388 (via e.g., @kbd{C-c C-p C-p}). Other options for
389 @code{preview-auto-reveal} are available via @code{customize}.
390
391 @item Automatically cache preambles
392
393 Currently @previewlatex{} asks you whether you want to cache the
394 document preamble (everything before @code{\begin@{document@}}) before
395 it generates previews for a buffer the first time. Caching the preamble
396 will significantly speed up regeneration of previews. The larger your
397 preamble is, the more this will be apparent. Once a preamble is cached,
398 @previewlatex{} will try to keep track of when it is changed, and dump
399 a fresh format in that case. If you experience problems with this, or
400 if you want it to happen without asking you the first time, you can
401 customize the variable @code{preview-auto-cache-preamble}.
402 @vindex preview-auto-cache-preamble
403 @cindex Caching a preamble
404
405 @item Attempt to keep counters accurate when editing
406
407 @vindex preview-preserve-counters
408 @vindex preview-required-option-list
409 Since @previewlatex{} frequently runs only small regions through
410 @LaTeX{}, values like equation counters are not consistent from run to
411 run. If this bothers you, customize the variable
412 @code{preview-preserve-counters} to @code{t} (this is consulted by
413 @code{preview-required-option-list}). @LaTeX{} will then output a load
414 of counter information during compilation, and this information will be
415 used on subsequent updates to keep counters set to useful values. The
416 additional information takes additional time to analyze, but this is
417 relevant mostly only when you are regenerating all previews at once, and
418 maybe you will be less tempted to do so when counters appear more or
419 less correct.
420
421 @item Preview your favourite @LaTeX{} constructs
422
423 If you have a certain macro or environment that you want to preview,
424 first check if it can be chosen by cutomizing
425 @code{preview-default-options-list} in the @code{Preview Latex} group.
426
427 If it is not available there, you can add it to
428 @code{preview-default-preamble} also in the @code{Preview Latex} group,
429 by adding a @code{\PreviewMacro} or @code{\PreviewEnvironment} entry
430 (@pxref{Provided commands}) @emph{after} the @code{\RequirePackage}
431 line. For example, if you want to preview the @code{center}
432 environment, press the @key{Show} button and the last @key{INS} button,
433 then add
434
435 @example
436 \PreviewEnvironment@{center@}
437 @end example
438 @noindent
439 in the space that just opened. Note that since @code{center} is a
440 generic formatting construct of @LaTeX{}, a general configuration like
441 that is not quite prudent. You better to do this on a per-document
442 base so that it is easy to disable this behavior when you find this
443 particular entry gives you trouble.
444
445 One possibility is to save such settings in the corresponding file-local
446 variable instead of your global configuration (@pxref{File
447 Variables,,Local Variables in Files,emacs,GNU Emacs Manual}). A perhaps
448 more convenient place for such options would be in a configuration file
449 in the same directory with your project (@pxref{Package options}).
450
451 The usual file for @previewlatex{} preconfiguration is
452 @file{prauctex.cfg}. If you also want to keep the systemwide defaults,
453 you should add a line
454
455 @example
456 \InputIfFileExists@{preview/prauctex.cfg@}@{@}@{@}
457 @end example
458 @noindent
459 to your own version of @file{prauctex.cfg} (this is assuming that
460 global files relating to the @code{preview} package are installed in a
461 subdirectory @file{preview}, the default behavior).
462
463 @item Don't preview inline math
464 @cindex Inline math
465
466 If you have performance problems because your document is full of inline
467 math (@code{$@dots{}$}), or if your usage of @code{$} conflicts with
468 @previewlatex{}'s, you can turn off inline math previews. In the
469 @code{Preview Latex} group, remove @code{textmath} from
470 @code{preview-default-option-list} by customizing this variable.
471 @end itemize
472
473 @node Known problems, For advanced users, Simple customization, top
474 @chapter Known problems
475 @c also used as PROBLEMS file
476 @include preview-problems.texi
477
478 @node For advanced users, ToDo, Known problems, top
479 @chapter For advanced users
480
481 This package consists of two parts: a @LaTeX{} style that splits the
482 output into appropriate parts with one preview object on each page, and
483 an Emacs-lisp part integrating the thing into Emacs (aided by
484 @AUCTeX{}).
485
486 @menu
487 * The LaTeX style file::
488 * The Emacs interface::
489 * The preview images::
490 * Misplaced previews::
491 @end menu
492
493 @node The LaTeX style file, The Emacs interface, For advanced users, For advanced users
494 @section The @LaTeX{} style file
495 @c Autogenerated from ../preview.dtx
496 @include preview-dtxdoc.texi
497
498 @node The Emacs interface, The preview images, The LaTeX style file, For advanced users
499 @section The Emacs interface
500
501 You can use @kbd{M-x customize-group @key{RET} preview-latex @key{RET}}
502 in order to customize these variables, or use the menus for it. We
503 explain the various available options together with explaining how they
504 work together in making @previewlatex{} work as intended.
505
506 @vtable @code
507 @item preview-LaTeX-command
508 When you generate previews on a buffer or a region, the command in
509 @code{preview-LaTeX-command} gets run (that variable should only be
510 changed with Customize since its structure is somewhat peculiar, though
511 expressive). As usual with @AUCTeX{}, you can continue working while
512 this is going on. It is not a good idea to change the file until after
513 @previewlatex{} has established where to place the previews which it can
514 only do after the @LaTeX{} run completes. This run produces a host of
515 pseudo-error messages that get parsed by @previewlatex{} at the end of
516 the @LaTeX{} run and give it the necessary information about where in
517 the source file the @LaTeX{} code for the various previews is located
518 exactly. The parsing takes a moment and will render Emacs busy.
519
520 @item preview-LaTeX-command-replacements
521 This variable specifies transformations to be used before calling the
522 configured command. One possibility is to have @samp{\pdfoutput=0 }
523 appended to every command starting with @samp{pdf}. This particular
524 setting is available as the shortcut
525 @samp{preview-LaTeX-disable-pdfoutput}. Since @previewlatex{} can work
526 with @acronym{PDF} files by now, there is little incentive for using
527 this option, anymore (for projects not requiring @acronym{PDF} output,
528 the added speed of @samp{dvipng} might make this somewhat attractive).
529
530 @item preview-required-option-list
531 @code{preview-LaTeX-command} uses @code{preview-required-option-list} in
532 order to pass options such as @option{auctex}, @option{active} and
533 @option{dvips} to the @file{preview} package. This means that the user
534 need (and should) not supply these in the document itself in case he
535 wants to be able to still compile his document without it turning into
536 an incoherent mass of little pictures. These options even get passed
537 in when the user loads @file{preview} explicitly in his document.
538
539 The default includes an option @code{counters} that is controlled by the
540 boolean variable
541
542 @item preview-preserve-counters
543 This option will cause the @file{preview} package to emit information
544 that will assist in keeping things like equation counters and section
545 numbers reasonably correct even when you are regenerating only single
546 previews.
547
548 @item preview-default-option-list
549 @itemx preview-default-preamble
550 If the document does not call in the package @code{preview} itself (via
551 @code{\usepackage}) in the preamble, the preview package is loaded using
552 default options from @code{preview-default-option-list} and additional
553 commands specified in @code{preview-default-preamble}.
554
555 @item preview-fast-conversion
556 This is relevant only for @acronym{DVI} mode. It defaults to `On' and
557 results in the whole document being processed as one large PostScript
558 file from which the single images are extracted with the help of parsing
559 the PostScript for use of so-called @acronym{DSC} comments. The
560 bounding boxes are extracted with the help of @TeX{} instead of getting
561 them from Dvips. If you are experiencing bounding box problems, try
562 setting this option to `Off'.
563
564 @item preview-prefer-TeX-bb
565 If this option is `On', it tells @previewlatex{} never to try to extract
566 bounding boxes from the bounding box comments of @acronym{EPS} files,
567 but rather rely on the boxes it gets from @TeX{}. If you activated
568 @code{preview-fast-conversion}, this is done, anyhow, since there are no
569 @acronym{EPS} files from which to read this information. The option
570 defaults to `Off', simply because about the only conceivable reason to
571 switch off @code{preview-fast-conversion} would be that you have some
572 bounding box problem and want to get Dvips' angle on that matter.
573
574 @item preview-scale-function
575 @itemx preview-reference-face
576 @itemx preview-document-pt-list
577 @itemx preview-default-document-pt
578 @code{preview-scale-function} determines by what factor
579 images should be scaled when appearing on the screen. If you specify a
580 numerical value here, the physical size on the screen will be that of
581 the original paper output scaled by the specified factor, at least if
582 Emacs' information about screen size and resolution are correct. The
583 default is to let @code{preview-scale-from-face} determine the scale
584 function. This function determines the scale factor by making the
585 size of the default font in the document match that of the on-screen
586 fonts.
587
588 The size of the screen fonts is deduced from the font
589 @code{preview-reference-face} (usually the default face used for
590 display), the size of the default font for the document is determined
591 by calling @code{preview-document-pt}.
592 @findex preview-document-pt
593 This function consults the members of @code{preview-document-pt-list} in
594 turn until it gets the desired information. The default consults first
595 @code{preview-parsed-font-size},
596 @vindex preview-parsed-font-size
597 then calls @code{preview-auctex-font-size}
598 @findex preview-auctex-font-size
599 which asks @AUCTeX{} about any size specification like @option{12pt} to
600 the documentclass that it might have detected when parsing the document, and
601 finally reverts to just assuming @code{preview-default-document-pt} as
602 the size used in the document (defaulting to 10pt).
603
604 If you find that the size of previews and the other Emacs display
605 clashes, something goes wrong. @code{preview-parsed-font-size} is
606 determined at @code{\begin@{document@}} time; if the default font size
607 changes after that, it will not get reported. If you have an outdated
608 version of @file{preview.sty} in your path, the size might not be
609 reported at all. If in this case @AUCTeX{} is unable to find a size
610 specification, and if you are using a document class with a different
611 default value (like KomaScript), the default fallback assumption will
612 probably be wrong and @previewlatex{} will scale up things too large.
613 So better specify those size options even when you know that @LaTeX{}
614 does not need them: @previewlatex{} might benefit from them. Another
615 possibility for error is that you have not enabled @AUCTeX{}'s document
616 parsing options. The fallback method of asking @AUCTeX{} about the size
617 might be disabled in future versions of @previewlatex{} since in
618 general it is more reliable to get this information from the @LaTeX{}
619 run itself.
620
621 @item preview-fast-dvips-command
622 @itemx preview-dvips-command
623 The regular command for turning a @acronym{DVI} file into a single
624 PostScript file is @code{preview-fast-dvips-command}, while
625 @code{preview-dvips-command} is used for cranking out a @acronym{DVI}
626 file where every preview is in a separate @acronym{EPS} file. Which of
627 the two commands gets used depends on the setting of
628 @code{preview-fast-conversion}. The printer specified here by default
629 is @option{-Pwww} by default, which will usually get you scalable fonts
630 where available. If you are experiencing problems, you might want to try
631 playing around with Dvips options (@inforef{Command-line options,,dvips}).
632
633 The conversion of the previews into PostScript or @acronym{EPS} files
634 gets started after the @LaTeX{} run completes when Emacs recognizes the
635 first image while parsing the error messages. When Emacs has finished
636 parsing the error messages, it activates all detected previews. This
637 entails throwing away any previous previews covering the same areas, and
638 then replacing the text in its visual appearance by a placeholder
639 looking like a roadworks sign.
640
641 @item preview-nonready-icon-specs
642 This is the roadworks sign displayed while previews are being prepared.
643 You may want to customize the font sizes at which @previewlatex{}
644 switches over between different icon sizes, and the ascent ratio which
645 determines how high above the base line the icon gets placed.
646
647 @item preview-error-icon-specs
648 @itemx preview-icon-specs
649 Those are icons placed before the source code of an opened preview and,
650 respectively, the image specs to be used for PostScript errors, and a
651 normal open preview in text representation.
652
653 @item preview-inner-environments
654 This is a list of environments that are regarded as inner levels of an
655 outer environment when doing @code{preview-environment}. One example
656 when this is needed is in
657 @code{\begin@{equation@}\begin@{split@}@dots{}\end@{split@}\end@{equation@}}, and
658 accordingly @code{split} is one entry in
659 @code{preview-inner-environments}.
660
661 @item preview-use-balloon-help
662 If you turn this XEmacs-only option `on', then moving the mouse over
663 previews and icons will show appropriate help texts. This works by
664 switching on @code{balloon-help-mode} in the buffer if it is not already
665 enabled. The default now is `off' since some users reported problems
666 with their version of XEmacs. @w{GNU Emacs} has its corresponding
667 @code{tooltip-mode} enabled by default and in usable condition.
668
669 @end vtable
670
671 @node The preview images, Misplaced previews, The Emacs interface, For advanced users
672 @section The preview images
673
674 @vtable @code
675 @item preview-image-type
676 @itemx preview-image-creators
677 @itemx preview-gs-image-type-alist
678 What happens when @LaTeX{} is finished depends on the configuration of
679 @code{preview-image-type}. What to do for each of the various settings
680 is specified in the variable @code{preview-image-creators}. The options
681 to pass into Ghostscript and what Emacs image type to use is specified
682 in @code{preview-gs-image-type-alist}.
683
684 @code{preview-image-type} defaults to @code{png}. For this to work,
685 your version of Ghostscript needs to support the @option{png16m} device.
686 If you are experiencing problems here, you might want to reconfigure
687 @code{gs-image-type-alist} or @code{preview-image-type}. Reconfiguring
688 @code{preview-image-creators} is only necessary for adding additional
689 image types.
690
691 Most devices make @previewlatex{} start up a single Ghostscript process
692 for the entire preview run (as opposed to one per image) and feed it
693 either sections of a @acronym{PDF} file (if PDF@LaTeX{} was used), or
694 (after running Dvips) sections of a single PostScript file or separate
695 @acronym{EPS} files in sequence for conversion into @acronym{PNG} format
696 which can be displayed much faster by Emacs. Actually, not in sequence
697 but backwards since you are most likely editing at the end of the
698 document. And as an added convenience, any preview that happens to be
699 on-screen is given higher priority so that @previewlatex{} will first
700 cater for the images that are displayed. There are various options
701 customizable concerning aspects of that operation, see the customization
702 group @code{Preview Gs} for this.
703
704 Another noteworthy setting of @code{preview-image-type} is
705 @samp{dvipng}: in this case, the @samp{dvipng}@pindex{dvipng} program
706 will get run on @acronym{DVI} output (see below for @acronym{PDF}).
707 This is in general much faster than Dvips and Ghostscript. In that
708 case, the option
709
710 @item preview-dvipng-command
711 will get run for doing the conversion, and it is expected that
712
713 @item preview-dvipng-image-type
714 images get produced (@samp{dvipng} might be configured for other image
715 types as well). You will notice that @code{preview-gs-image-type-alist}
716 contains an entry for @code{dvipng}: this actually has nothing to with
717 @samp{dvipng} itself but specifies the image type and Ghostscript device
718 option to use when @samp{dvipng} can't be used. This will obviously be
719 the case for @acronym{PDF} output by PDF@LaTeX{}, but it will also happen
720 if the @acronym{DVI} file contains PostScript specials in which case the
721 affected images will get run through Dvips and Ghostscript once
722 @samp{dvipng} finishes.
723
724 @item preview-gs-options
725 Most interesting to the user perhaps is the setting of this variable.
726 It contains the default antialiasing settings @option{-dTextAlphaBits=4}
727 and @option{-dGraphicsAlphaBits=4}. Decreasing those values to 2 @w{or
728 1} might increase Ghostscript's performance if you find it lacking.
729 @end vtable
730
731 Running and feeding Ghostscript from @previewlatex{} happens
732 asynchronously again: you can resume editing while the images arrive.
733 While those pretty pictures filling in the blanks on screen tend to
734 make one marvel instead of work, rendering the non-displayed images
735 afterwards will not take away your attention and will eventually
736 guarantee that jumping around in the document will encounter only
737 prerendered images.
738
739 @node Misplaced previews, , The preview images, For advanced users
740 @section Misplaced previews
741
742 If you are reading this section, the first thing is to check that your
743 problem is not caused by x-symbol in connection with an installation not
744 supporting 8-bit characters (@pxref{x-symbol interoperation}). If not,
745 here's the beef:
746
747 As explained previously, Emacs uses pseudo-error messages generated by
748 the @samp{preview} package in order to pinpoint the exact source
749 location where a preview originated. This works in running text, but
750 fails when preview material happens to lie in macro arguments, like the
751 contents of @code{\emph}. Those macros first read in their entire
752 argument, munge it through, perhaps transform it somehow, process it and
753 perhaps then typeset something. When they finally typeset something,
754 where is the location where the stuff originated? @TeX{}, having read in
755 the entire argument before, does not know and actually there would be no
756 sane way of defining it.
757
758 For previews contained inside such a macro argument, the default
759 behaviour of @previewlatex{} is to use a position immediately after the
760 closing brace of the argument. All the previews get placed there, all at
761 a zero-width position, which means that Emacs displays it in an order
762 that @previewlatex{} cannot influence (currently in Emacs it is even
763 possible that the order changes between runs). And since the placement
764 of those previews is goofed up, you will not be able to regenerate them
765 by clicking on them. The default behaviour is thus somewhat undesirable.
766
767 The solution (like with other preview problems) is to tell the @LaTeX{}
768 @samp{preview} package how to tackle this problem (@pxref{The LaTeX
769 style file}). Simply, you don't need @code{\emph} do anything at all
770 during previews! You only want the text math previewed, so the solution
771 is to use @code{\PreviewMacro*\emph} in the preamble of your document
772 which will make @LaTeX{} ignore @code{\emph} completely as long as it is
773 not part of a larger preview (in which case it gets typeset as
774 usual). Its argument thus becomes ordinary text and gets treated like
775 ordinary text.
776
777 Note that it would be a bad idea to declare
778 @code{\PreviewMacro*[@{@{@}@}]\emph} since then both @code{\emph} as
779 well as its argument would be ignored instead of previewed. For
780 user-level macros, this is almost never wanted, but there may be
781 internal macros where you might want to ignore internal arguments.
782
783 The same mechanism can be used for a number of other text-formatting
784 commands like @code{\textrm}, @code{\textit} and the like. While they
785 all use the same internal macro @code{\text@@command}, it will not do to
786 redefine just that, since they call it only after having read their
787 argument in, and then it already is too late. So you need to disable
788 every of those commands by hand in your document preamble.
789
790 Actually, we wrote all of the above just to scare you. At least all of
791 the above mentioned macros and a few more are already catered for by a
792 configuration file @file{prauctex.cfg} that gets loaded by default
793 unless the @samp{preview} package gets loaded with the @option{noconfig}
794 option. You can make your own copy of this file in a local directory
795 and edit it in case of need. You can also add loading of a file of your
796 liking to @code{preview-default-preamble},
797 @vindex preview-default-preamble
798 or alternatively do the
799 manual disabling of your favorite macro in
800 @code{preview-default-preamble},
801 @vindex preview-default-preamble
802 which is customizable in the Preview Latex group.
803
804 @node ToDo, Frequently Asked Questions, For advanced users, top
805 @c Also used as TODO: in separate file
806 @appendix ToDo
807 @include preview-todo.texi
808
809 @node Frequently Asked Questions, Copying this Manual, ToDo, top
810 @c Also used as TODO: in separate file
811 @appendix Frequently Asked Questions
812 @include preview-faq.texi
813
814 @node Copying this Manual, Index, Frequently Asked Questions, top
815 @c Not to be changed often, I think: in separate file.
816 @appendix Copying this Manual
817
818 @ifinfo
819 The copyright notice for this manual is:
820
821 @insertcopying
822 @end ifinfo
823
824 The full license text can be read here:
825
826 @menu
827 * GNU Free Documentation License:: License for copying this manual.
828 @end menu
829
830 @include fdl.texi
831
832 @c @node Credits, Index, Internals, top
833 @c @appendix Credits
834
835 @node Index, , Copying this Manual, top
836 @unnumbered Index
837
838 @printindex cp
839
840 @bye