Go to the first, previous, next, last section, table of contents.
You can invoke TeX as an inferior of Emacs on either the entire contents of the buffer or just a region at a time. Running TeX in this way on just one chapter is a good way to see what your changes look like without taking the time to format the entire file.
tex-region
).
tex-buffer
).
tex-bibtex-file
).
tex-file
).
tex-recenter-output-buffer
).
tex-kill-job
).
tex-print
).
tex-view
).
tex-show-print-queue
).
You can pass the current buffer through an inferior TeX by means of
C-c C-b (tex-buffer
). The formatted output appears in a
temporary file; to print it, type C-c C-p (tex-print
).
Afterward, you can use C-c C-q (tex-show-print-queue
) to
view the progress of your output towards being printed. If your terminal
has the ability to display TeX output files, you can preview the
output on the terminal with C-c C-v (tex-view
).
You can specify the directory to use for running TeX by setting the
variable tex-directory
. "."
is the default value. If
your environment variable TEXINPUTS
contains relative directory
names, or if your files contains `\input' commands with relative
file names, then tex-directory
must be "."
or you
will get the wrong results. Otherwise, it is safe to specify some other
directory, such as "/tmp"
.
If you want to specify which shell commands are used in the inferior TeX,
you can do so by setting the values of the variables tex-run-command
,
latex-run-command
, slitex-run-command
,
tex-dvi-print-command
, tex-dvi-view-command
, and
tex-show-queue-command
. You must set the value of
tex-dvi-view-command
for your particular terminal; this variable
has no default value. The other variables have default values that may
(or may not) be appropriate for your system.
Normally, the file name given to these commands comes at the end of the command string; for example, `latex filename'. In some cases, however, the file name needs to be embedded in the command; an example is when you need to provide the file name as an argument to one command whose output is piped to another. You can specify where to put the file name with `*' in the command string. For example,
(setq tex-dvi-print-command "dvips -f * | lpr")
The terminal output from TeX, including any error messages, appears in a buffer called `*tex-shell*'. If TeX gets an error, you can switch to this buffer and feed it input (this works as in Shell mode; see section Interactive Inferior Shell). Without switching to this buffer you can scroll it so that its last line is visible by typing C-c C-l.
Type C-c C-k (tex-kill-job
) to kill the TeX process if
you see that its output is no longer useful. Using C-c C-b or
C-c C-r also kills any TeX process still running.
You can also pass an arbitrary region through an inferior TeX by typing
C-c C-r (tex-region
). This is tricky, however, because most files
of TeX input contain commands at the beginning to set parameters and
define macros, without which no later part of the file will format
correctly. To solve this problem, C-c C-r allows you to designate a
part of the file as containing essential commands; it is included before
the specified region as part of the input to TeX. The designated part
of the file is called the header.
To indicate the bounds of the header in Plain TeX mode, you insert two special strings in the file. Insert `%**start of header' before the header, and `%**end of header' after it. Each string must appear entirely on one line, but there may be other text on the line before or after. The lines containing the two strings are included in the header. If `%**start of header' does not appear within the first 100 lines of the buffer, C-c C-r assumes that there is no header.
In LaTeX mode, the header begins with `\documentstyle' and ends with `\begin{document}'. These are commands that LaTeX requires you to use in any case, so nothing special needs to be done to identify the header.
The commands (tex-buffer
) and (tex-region
) do all of their
work in a temporary directory, and do not have available any of the auxiliary
files needed by TeX for cross-references; these commands are generally
not suitable for running the final copy in which all of the cross-references
need to be correct.
When you want the auxiliary files for cross references, use C-c
C-f (tex-file
) which runs TeX on the current buffer's file,
in that file's directory. Before running TeX, it offers to save any
modified buffers. Generally, you need to use (tex-file
) twice to
get the cross-references right.
The value of the variable tex-start-options-string
specifies
options for the TeX run. The default value causes TeX to run in
nonstopmode. To run TeX interactively, set the variable to ""
.
Large TeX documents are often split into several files--one main
file, plus subfiles. Running TeX on a subfile typically does not
work; you have to run it on the main file. In order to make
tex-file
useful when you are editing a subfile, you can set the
variable tex-main-file
to the name of the main file. Then
tex-file
runs TeX on that file.
The most convenient way to use tex-main-file
is to specify it
in a local variable list in each of the subfiles. See section Local Variables in Files.
For LaTeX files, you can use BibTeX to process the auxiliary
file for the current buffer's file. BibTeX looks up bibliographic
citations in a data base and prepares the cited references for the
bibliography section. The command C-c TAB
(tex-bibtex-file
) runs the shell command
(tex-bibtex-command
) to produce a `.bbl' file for the
current buffer's file. Generally, you need to do C-c C-f
(tex-file
) once to generate the `.aux' file, then do
C-c TAB (tex-bibtex-file
), and then repeat C-c C-f
(tex-file
) twice more to get the cross-references correct.
Entering any kind of TeX mode runs the hooks text-mode-hook
and tex-mode-hook
. Then it runs either
plain-tex-mode-hook
or latex-mode-hook
, whichever is
appropriate. For SliTeX files, it calls slitex-mode-hook
.
Starting the TeX shell runs the hook tex-shell-hook
.
See section Hooks.
Go to the first, previous, next, last section, table of contents.