[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Viewing the Formatted Output

AUCTeX allows you to start external programs for previewing the formatted output of your document.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2.1 Starting Viewers

Viewers are normally invoked by pressing C-c C-c once the document is formatted, which will propose the View command, or by activating the respective entry in the Command menu. Alternatively you can type C-c C-v which calls the function TeX-view.

Command: TeX-view

(C-c C-v) Start a viewer without confirmation. The viewer is started either on a region or the master file, depending on the last command issued. This is especially useful for jumping to the location corresponding to point in the viewer when using TeX-source-correlate-mode.

AUCTeX will try to guess which type of viewer (DVI, PostScript or PDF) has to be used and what options are to be passed over to it. This decision is based on the output files present in the working directory as well as the class and style options used in the document. For example, if there is a DVI file in your working directory, a DVI viewer will be invoked. In case of a PDF file it will be a PDF viewer. If you specified a special paper format like ‘a5paper’ or use the ‘landscape’ option, this will be passed to the viewer by the appropriate options. Especially some DVI viewers depend on this kind of information in order to display your document correctly. In case you are using ‘pstricks’ or ‘psfrag’ in your document, a DVI viewer cannot display the contents correctly and a PostScript viewer will be invoked instead.

The association between the tests for the conditions mentioned above and the viewers is made in the variable TeX-view-program-selection. Therefore this variable is the starting point for customization if you want to use other viewers than the ones suggested by default.

User Option: TeX-view-program-selection

This is a list of predicates and viewers which is evaluated from front to back in order to find out which viewer to call under the given conditions. In the first element of each list item you can reference one or more predicates defined in TeX-view-predicate-list or TeX-view-predicate-list-builtin. In the second element you can reference a viewer defined in TeX-view-program-list or TeX-view-program-list-builtin. The viewer of the first item with a positively evaluated predicate is selected.

So TeX-view-program-selection only contains references to the actual implementations of predicates and viewer commands respectively which can be found elsewhere. AUCTeX comes with a set of preconfigured predicates and viewer commands which are stored in the variables TeX-view-predicate-list-builtin and TeX-view-program-list-builtin respectively. If you are not satisfied with those and want to overwrite one of them or add your own definitions, you can do so via the variables TeX-view-predicate-list and TeX-view-program-list.

User Option: TeX-view-predicate-list

This is a list of predicates for viewer selection and invocation. The first element of each list item is a symbol and the second element a Lisp form to be evaluated. The form should return nil if the predicate is not fulfilled.

A built-in predicate from TeX-view-predicate-list-builtin can be overwritten by defining a new predicate with the same symbol.

User Option: TeX-view-program-list

This is a list of viewer specifications each consisting of a symbolic name and either a command line or a function to be invoked when the viewer is called. If a command line is used, parts of it can be conditionalized by prefixing them with predicates from TeX-view-predicate-list or TeX-view-predicate-list-builtin. (See the doc string for the exact format to use.) The command line can also contain placeholders as defined in TeX-expand-list which are expanded before the viewer is called.

A built-in viewer spec from TeX-view-program-list-builtin can be overwritten by defining a new viewer spec with the same name.

Note that the viewer selection and invocation as described above will only work if certain default settings in AUCTeX are intact. For one, the whole viewer selection machinery will only be triggered if the ‘%V’ expander in TeX-expand-list is unchanged. So if you have trouble with the viewer invocation you might check if there is an older customization of the variable in place. In addition, the use of a function in TeX-view-program-list only works if the View command in TeX-command-list makes use of the hook TeX-run-discard-or-function.

Note also that the implementation described above replaces an older one which was less flexible. This old implementation works with the variables TeX-output-view-style and TeX-view-style which are used to associate file types and style options with viewers. If desired you can reactivate it by using the placeholder ‘%vv’ for the View command in TeX-command-list. Note however, that it is bound to be removed from AUCTeX once the new implementation proved to be satisfactory. For the time being, find a short description of the mentioned customization options below.

User Option: TeX-output-view-style

List of output file extensions, style options and view options. Each item of the list consists of three elements. If the first element (a regular expression) matches the output file extension, and the second element (a regular expression) matches the name of one of the style options, any occurrence of the string %V in a command in TeX-command-list will be replaced with the third element.

User Option: TeX-view-style

List of style options and view options. This is the predecessor of TeX-output-view-style which does not provide the possibility to specify output file extensions. It is used as a fallback in case none of the alternatives specified in TeX-output-view-style match. In case none of the entries in TeX-view-style match either, no suggestion for a viewer is made.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2.2 Forward and Inverse Search

Forward and inverse search refer to the correlation between the document source in the editor and the typeset document in the viewer. Forward search allows you to jump to the place in the previewed document corresponding to a certain line in the document source and inverse search vice versa.

AUCTeX supports three methods for forward and inverse search: source specials (only DVI output), the pdfsync LaTeX package (only PDF output) and SyncTeX (any type of output). If you want to make use of forward and inverse searching with source specials or SyncTeX, switch on TeX-source-correlate-mode. See section Options for TeX Processors, on how to do that. The use of the pdfsync package is detected automatically if document parsing is enabled.

Forward search happens automatically upon calling the viewer, e.g. by typing C-c C-v (TeX-view). This will open the viewer or bring it to front and display the output page corresponding to the position of point in the source file. AUCTeX will automatically pass the necessary command line options to the viewer for this to happen.

Upon opening the viewer you will be asked if you want to start a server process (Gnuserv or Emacs server) which is necessary for inverse search. This happens only if there is no server running already. You can customize the variable TeX-source-correlate-start-server to inhibit the question and always or never start the server respectively.

User Option: TeX-source-correlate-start-server

If TeX-source-correlate-mode is active and a viewer is invoked, the default behavior is to ask if a server process should be started. Set this variable to t if the question should be inhibited and the server should always be started. Set it to nil if the server should never be started. Inverse search will not be available in the latter case.

Inverse search, i.e. jumping to the part of your document source in Emacs corresponding to a certain position in the viewer, is triggered from the viewer, typically by a mouse click. Refer to the documentation of your viewer to find out how it has to be configured and what you have to do exactly. In xdvi you normally have to use C-down-mouse-1.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on December 22, 2011 using texi2html 1.82.