Blame doc/quickstart.texi

Packit f2bd10
@include macros.texi
Packit f2bd10
Packit f2bd10
@node Quick Start
Packit f2bd10
@chapter Quick Start
Packit f2bd10
Packit f2bd10
@AUCTeX{} is a powerful program offering many features and configuration
Packit f2bd10
options.  If you are new to @AUCTeX{} this might be deterrent.
Packit f2bd10
Fortunately you do not have to learn everything at once.  This Quick
Packit f2bd10
Start Guide will give you the knowledge of the most important commands
Packit f2bd10
and enable you to prepare your first @LaTeX{} document with @AUCTeX{}
Packit f2bd10
after only a few minutes of reading.
Packit f2bd10
Packit f2bd10
In this introduction, we assume that @AUCTeX{} is already installed on
Packit f2bd10
your system.  If this is not the case, you should read the file
Packit f2bd10
@file{INSTALL} in the base directory of the unpacked distribution
Packit f2bd10
tarball.  These installation instructions are available in this manual
Packit f2bd10
as well, @ref{Installation}.  We also assume that you are familiar with
Packit f2bd10
the way keystrokes are written in Emacs manuals.  If not, have a look at
Packit f2bd10
the Emacs Tutorial in the Help menu.
Packit f2bd10
Packit f2bd10
If @AUCTeX{} is installed in any other way than from the Emacs package
Packit f2bd10
manager (@acronym{ELPA}), you might still need to activate it, by
Packit f2bd10
inserting
Packit f2bd10
Packit f2bd10
@lisp
Packit f2bd10
(load "auctex.el" nil t t)
Packit f2bd10
@end lisp
Packit f2bd10
Packit f2bd10
in your user init file.@footnote{This usually is a file in your home
Packit f2bd10
directory called @file{.emacs}, or @file{.emacs.d/init.el}.}
Packit f2bd10
Packit f2bd10
If @AUCTeX{} is installed from @acronym{ELPA}, the installation
Packit f2bd10
procedure already cares about loading @AUCTeX{} correctly and you
Packit f2bd10
@strong{must not} have the line above in your init file.  Note that this
Packit f2bd10
also applies if you have the following line in your init file
Packit f2bd10
Packit f2bd10
@lisp
Packit f2bd10
(package-initialize)
Packit f2bd10
@end lisp
Packit f2bd10
Packit f2bd10
In order to get support for many of the @LaTeX{} packages you will use
Packit f2bd10
in your documents, you should enable document parsing as well, which can
Packit f2bd10
be achieved by putting
Packit f2bd10
Packit f2bd10
@lisp
Packit f2bd10
(setq TeX-auto-save t)
Packit f2bd10
(setq TeX-parse-self t)
Packit f2bd10
@end lisp
Packit f2bd10
Packit f2bd10
into your init file.  Finally, if you often use @code{\include} or
Packit f2bd10
@code{\input}, you should make @AUCTeX{} aware of the multi-file
Packit f2bd10
document structure.  You can do this by inserting
Packit f2bd10
Packit f2bd10
@lisp
Packit f2bd10
(setq-default TeX-master nil)
Packit f2bd10
@end lisp
Packit f2bd10
Packit f2bd10
into your init file.  Each time you open a new file, @AUCTeX{} will then
Packit f2bd10
ask you for a master file.
Packit f2bd10
Packit f2bd10
@menu
Packit f2bd10
* Editing Facilities::          Functions for editing TeX files
Packit f2bd10
* Processing Facilities::       Creating and viewing output, debugging
Packit f2bd10
@end menu
Packit f2bd10
Packit f2bd10
@iftex
Packit f2bd10
This Quick Start Guide covers two main topics: First we explain how
Packit f2bd10
@AUCTeX{} helps you in editing your input file for @TeX{}, @LaTeX{}, and
Packit f2bd10
some other formats.  Then we describe the functions that @AUCTeX{}
Packit f2bd10
provides for processing the input files with @LaTeX{}, Bib@TeX{}, etc.,
Packit f2bd10
and for viewing and debugging.
Packit f2bd10
@end iftex
Packit f2bd10
Packit f2bd10
@node Editing Facilities
Packit f2bd10
@section Functions for editing TeX files
Packit f2bd10
Packit f2bd10
@subsection Making your @TeX{} code more readable
Packit f2bd10
Packit f2bd10
@AUCTeX{} can do syntax highlighting of your source code, that means
Packit f2bd10
commands will get special colors or fonts.  You can enable it locally by
Packit f2bd10
typing @kbd{M-x font-lock-mode RET}.  If you want to have font locking
Packit f2bd10
activated generally, enable @code{global-font-lock-mode}, e.g. with
Packit f2bd10
@kbd{M-x customize-variable RET global-font-lock-mode RET}.
Packit f2bd10
Packit f2bd10
@AUCTeX{} will indent new lines to indicate their syntactical
Packit f2bd10
relationship to the surrounding text.  For example, the text of a
Packit f2bd10
@code{\footnote} or text inside of an environment will be indented
Packit f2bd10
relative to the text around it.  If the indenting has gotten wrong after
Packit f2bd10
adding or deleting some characters, use @key{TAB} to reindent the line,
Packit f2bd10
@kbd{M-q} for the whole paragraph, or @kbd{M-x LaTeX-fill-buffer RET}
Packit f2bd10
for the whole buffer.
Packit f2bd10
Packit f2bd10
@subsection Entering sectioning commands
Packit f2bd10
@cindex Sectioning
Packit f2bd10
@cindex Sections
Packit f2bd10
@cindex Chapters
Packit f2bd10
@cindex @code{\chapter}
Packit f2bd10
@cindex @code{\section}
Packit f2bd10
@cindex @code{\subsection}
Packit f2bd10
@cindex @code{\label}
Packit f2bd10
Packit f2bd10
Insertion of sectioning macros, that is @samp{\chapter},
Packit f2bd10
@samp{\section}, @samp{\subsection}, etc. and accompanying @samp{\label}
Packit f2bd10
commands may be eased by using @kbd{C-c C-s}.  You will be asked for the
Packit f2bd10
section level.  As nearly everywhere in @AUCTeX{}, you can use the
Packit f2bd10
@key{TAB} or @key{SPC} key to get a list of available level names, and
Packit f2bd10
to auto-complete what you started typing.  Next, you will be asked for
Packit f2bd10
the printed title of the section, and last you will be asked for a label
Packit f2bd10
to be associated with the section.
Packit f2bd10
Packit f2bd10
@subsection Inserting environments
Packit f2bd10
Packit f2bd10
Similarly, you can insert environments, that is
Packit f2bd10
@samp{\begin@{@}}--@samp{\end@{@}} pairs: Type @kbd{C-c C-e}, and select
Packit f2bd10
an environment type.  Again, you can use @key{TAB} or @key{SPC} to get a
Packit f2bd10
list, and to complete what you type.  Actually, the list will not only
Packit f2bd10
provide standard @LaTeX{} environments, but also take your
Packit f2bd10
@samp{\documentclass} and @samp{\usepackage} commands into account if
Packit f2bd10
you have parsing enabled by setting @code{TeX-parse-self} to @code{t}.
Packit f2bd10
If you use a couple of environments frequently, you can use the up and
Packit f2bd10
down arrow keys (or @kbd{M-p} and @kbd{M-n}) in the minibuffer to get
Packit f2bd10
back to the previously inserted commands.
Packit f2bd10
Packit f2bd10
Some environments need additional arguments.  Often, @AUCTeX{} knows about
Packit f2bd10
this and asks you to enter a value. 
Packit f2bd10
Packit f2bd10
@subsection Inserting macros
Packit f2bd10
Packit f2bd10
@kbd{C-c C-m}, or simply @kbd{C-c RET} will give you a prompt that asks
Packit f2bd10
you for a @LaTeX{} macro.  You can use @key{TAB} for completion, or the
Packit f2bd10
up/down arrow keys (or @kbd{M-p} and @kbd{M-n}) to browse the command
Packit f2bd10
history.  In many cases, @AUCTeX{} knows which arguments a macro needs
Packit f2bd10
and will ask you for that.  It even can differentiate between mandatory
Packit f2bd10
and optional arguments---for details, see @ref{Completion}.
Packit f2bd10
Packit f2bd10
An additional help for inserting macros is provided by the possibility
Packit f2bd10
to complete macros right in the buffer.  With point at the end of a
Packit f2bd10
partially written macro, you can complete it by typing @kbd{M-TAB}.
Packit f2bd10
Packit f2bd10
@subsection Changing the font 
Packit f2bd10
Packit f2bd10
@AUCTeX{} provides convenient keyboard shortcuts for inserting macros
Packit f2bd10
which specify the font to be used for typesetting certain parts of the
Packit f2bd10
text.  They start with @kbd{C-c C-f}, and the last @kbd{C-} combination
Packit f2bd10
tells @AUCTeX{} which font you want:
Packit f2bd10
Packit f2bd10
@table @kbd
Packit f2bd10
@item C-c C-f C-b
Packit f2bd10
@kindex C-c C-f C-b
Packit f2bd10
@cindex @code{\textbf}
Packit f2bd10
Insert @b{bold face} @samp{\textbf@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-i
Packit f2bd10
@kindex C-c C-f C-i
Packit f2bd10
@cindex @code{\textit}
Packit f2bd10
Insert @i{italics} @samp{\textit@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-e
Packit f2bd10
@kindex C-c C-f C-e
Packit f2bd10
@cindex @code{\emph}
Packit f2bd10
Insert @i{emphasized} @samp{\emph@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-s
Packit f2bd10
@kindex C-c C-f C-s
Packit f2bd10
@cindex @code{\textsl}
Packit f2bd10
Insert @i{slanted} @samp{\textsl@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-r
Packit f2bd10
@kindex C-c C-f C-r
Packit f2bd10
@cindex @code{\textrm}
Packit f2bd10
Insert roman @r{\textrm@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-f
Packit f2bd10
@kindex C-c C-f C-f
Packit f2bd10
@cindex @code{\textsf}
Packit f2bd10
Insert  @sansserif{sans serif} @samp{\textsf@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-t
Packit f2bd10
@kindex C-c C-f C-t
Packit f2bd10
@cindex @code{\texttt}
Packit f2bd10
Insert @t{typewriter} @samp{\texttt@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-c
Packit f2bd10
@kindex C-c C-f C-c
Packit f2bd10
@cindex @code{\textsc}
Packit f2bd10
Insert @sc{small caps} @samp{\textsc@{@point{}@}} text.
Packit f2bd10
Packit f2bd10
@item C-c C-f C-d
Packit f2bd10
@kindex C-c C-f C-c
Packit f2bd10
@cindex Deleting fonts
Packit f2bd10
Delete the innermost font specification containing point.
Packit f2bd10
Packit f2bd10
@end table
Packit f2bd10
Packit f2bd10
If you want to change font attributes of existing text, mark it as an
Packit f2bd10
active region, and then invoke the commands.  If no region is selected,
Packit f2bd10
the command will be inserted with empty braces, and you can start typing
Packit f2bd10
the changed text.
Packit f2bd10
Packit f2bd10
Most of those commands will also work in math mode, but then macros like
Packit f2bd10
@code{\mathbf} will be inserted.
Packit f2bd10
Packit f2bd10
Packit f2bd10
@subsection Other useful features
Packit f2bd10
Packit f2bd10
@AUCTeX{} also tries to help you when inserting the right ``quote''
Packit f2bd10
signs for your language, dollar signs to typeset math, or pairs of
Packit f2bd10
braces.  It offers shortcuts for commenting out text (@kbd{C-c ;} for
Packit f2bd10
the current region or @kbd{C-c %} for the paragraph you are in).  The
Packit f2bd10
same keystrokes will remove the % signs, if the region or paragraph is
Packit f2bd10
commented out yet.  With @code{TeX-fold-mode}, you can hide certain
Packit f2bd10
parts (like footnotes, references etc.) that you do not edit currently.
Packit f2bd10
Support for Emacs' outline mode is provided as well.  And there's more,
Packit f2bd10
but this is beyond the scope of this Quick Start Guide.
Packit f2bd10
Packit f2bd10
Packit f2bd10
Packit f2bd10
@node Processing Facilities
Packit f2bd10
@section Creating and viewing output, debugging
Packit f2bd10
Packit f2bd10
@subsection One Command for @LaTeX{}, helpers, viewers, and printing
Packit f2bd10
Packit f2bd10
If you have typed some text and want to run @LaTeX{} (or @TeX{}, or
Packit f2bd10
other programs---see below) on it, type @kbd{C-c C-c}.  If applicable,
Packit f2bd10
you will be asked whether you want to save changes, and which program
Packit f2bd10
you want to invoke.  In many cases, the choice that @AUCTeX{} suggests
Packit f2bd10
will be just what you want: first @command{latex}, then a viewer.  If a
Packit f2bd10
@command{latex} run produces or changes input files for
Packit f2bd10
@command{makeindex}, the next suggestion will be to run that program,
Packit f2bd10
and @AUCTeX{} knows that you need to run @command{latex} again
Packit f2bd10
afterwards---the same holds for Bib@TeX{}.
Packit f2bd10
Packit f2bd10
When no processor invocation is necessary anymore, @AUCTeX{} will
Packit f2bd10
suggest to run a viewer, or you can chose to create a PostScript file
Packit f2bd10
using @command{dvips}, or to directly print it.
Packit f2bd10
Packit f2bd10
Actually, there is another command which comes in handy to compile
Packit f2bd10
documents: type @kbd{C-c C-a} (@code{TeX-command-run-all}) and @AUCTeX{}
Packit f2bd10
will compile the document for you until it is ready and then run the
Packit f2bd10
viewer.  This is the same as issuing repeatedly @kbd{C-c C-c} and
Packit f2bd10
letting @AUCTeX{} guess the next command to run.
Packit f2bd10
Packit f2bd10
At this place, a warning needs to be given: First, although @AUCTeX{} is
Packit f2bd10
really good in detecting the standard situations when an additional
Packit f2bd10
@command{latex} run is necessary, it cannot detect it always.  Second,
Packit f2bd10
the creation of PostScript files or direct printing currently only works
Packit f2bd10
when your output file is a @acronym{DVI} file, not a @acronym{PDF} file.
Packit f2bd10
Packit f2bd10
Ah, you didn't know you can do both?  That brings us to the next topic.
Packit f2bd10
Packit f2bd10
@subsection Choosing an output format
Packit f2bd10
Packit f2bd10
From a @LaTeX{} file, you can produce @acronym{DVI} output, or a
Packit f2bd10
@acronym{PDF} file directly @i{via} @command{pdflatex}.  You can switch
Packit f2bd10
on source specials for easier navigation in the output file, or tell
Packit f2bd10
@command{latex} to stop after an error (usually @code{\noninteractive}
Packit f2bd10
is used, to allow you to detect all errors in a single run).
Packit f2bd10
Packit f2bd10
These options are controlled by toggles, the keystrokes should be easy
Packit f2bd10
to memorize:
Packit f2bd10
Packit f2bd10
@table @kbd
Packit f2bd10
@item @kbd{C-c C-t C-p}
Packit f2bd10
This command toggles between @acronym{DVI} and @acronym{PDF} output
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-t C-i}
Packit f2bd10
toggles interactive mode
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-t C-s}
Packit f2bd10
toggles source specials support
Packit f2bd10
Packit f2bd10
@item @kbd{C-c C-t C-o}
Packit f2bd10
toggles usage of Omega/lambda.
Packit f2bd10
Packit f2bd10
@end table
Packit f2bd10
Packit f2bd10
There is also another possibility: compile the document with
Packit f2bd10
@command{tex} (or @command{latex}) and then convert the resulting
Packit f2bd10
@acronym{DVI} file to @acronym{PDF} using
Packit f2bd10
@command{dvips}--@command{ps2pdf} sequence.  If you want to go by this
Packit f2bd10
route, when @code{TeX-PDF-via-dvips-ps2pdf} variable is non-nil,
Packit f2bd10
@AUCTeX{} will suggest you to run the appropriate command when you type
Packit f2bd10
@kbd{C-C C-c}.  For details, see @ref{Processor Options}.
Packit f2bd10
Packit f2bd10
@subsection Debugging @LaTeX{}
Packit f2bd10
Packit f2bd10
When @AUCTeX{} runs a program, it creates an output buffer in which it
Packit f2bd10
displays the output of the command.  If there is a syntactical error in
Packit f2bd10
your file, @command{latex} will not complete successfully. @AUCTeX{}
Packit f2bd10
will tell you that, and you can get to the place where the first error
Packit f2bd10
occured by pressing @kbd{C-c `} (the last character is a backtick).  The
Packit f2bd10
view will be split in two windows, the output will be displayed in the
Packit f2bd10
lower buffer, and both buffers will be centered around the place where
Packit f2bd10
the error ocurred.  You can then try to fix it in the document buffer,
Packit f2bd10
and use the same keystrokes to get to the next error.  This procedure
Packit f2bd10
may be repeated until all errors have been dealt with.  By pressing
Packit f2bd10
@kbd{C-c C-w} (@code{TeX-toggle-debug-boxes}) you can toggle whether
Packit f2bd10
@AUCTeX{} should notify you of overfull and underfull boxes in addition
Packit f2bd10
to regular errors.
Packit f2bd10
Packit f2bd10
Issue @kbd{M-x TeX-error-overview RET} to see a nicely formatted list of
Packit f2bd10
all errors and warnings reported by the compiler.
Packit f2bd10
Packit f2bd10
If a command got stuck in a seemingly infinite loop, or you want to stop
Packit f2bd10
execution for other reasons, you can use @kbd{C-c C-k} (for ``kill'').
Packit f2bd10
Similar to @kbd{C-l}, which centers the buffer you are in around your
Packit f2bd10
current position, @kbd{C-c C-l} centers the output buffer so that the
Packit f2bd10
last lines added at the bottom become visible.
Packit f2bd10
Packit f2bd10
@subsection Running @LaTeX{} on parts of your document
Packit f2bd10
Packit f2bd10
If you want to check how some part of your text looks like, and do not
Packit f2bd10
want to wait until the whole document has been typeset, then mark it as
Packit f2bd10
a region and use @kbd{C-c C-r}.  It behaves just like @kbd{C-c C-c}, but
Packit f2bd10
it only uses the document preamble and the region you marked.
Packit f2bd10
Packit f2bd10
If you are using @code{\include} or @code{\input} to structure your
Packit f2bd10
document, try @kbd{C-c C-b} while you are editing one of the included
Packit f2bd10
files.  It will run @command{latex} only on the current buffer, using the
Packit f2bd10
preamble from the master file.
Packit f2bd10
@c does this also work with input? why not?
Packit f2bd10
Packit f2bd10
@c Local Variables: 
Packit f2bd10
@c mode: texinfo
Packit f2bd10
@c TeX-master: "auctex"
Packit f2bd10
@c End: