]> code.delx.au - gnu-emacs-elpa/blob - packages/auctex/doc/quickstart.texi
Don't provide the features auto-loads and preview-latex included in tex-site.
[gnu-emacs-elpa] / packages / auctex / doc / quickstart.texi
1 @include macros.texi
2
3 @node Quick Start
4 @chapter Quick Start
5
6 @AUCTeX{} is a powerful program offering many features and configuration
7 options. If you are new to @AUCTeX{} this might be deterrent.
8 Fortunately you do not have to learn everything at once. This Quick
9 Start Guide will give you the knowledge of the most important commands
10 and enable you to prepare your first @LaTeX{} document with @AUCTeX{}
11 after only a few minutes of reading.
12
13 In this introduction, we assume that @AUCTeX{} is already installed on
14 your system. If this is not the case, you should read the file
15 @file{INSTALL} in the base directory of the unpacked distribution
16 tarball. These installation instructions are available in this manual
17 as well, @ref{Installation}. We also assume that you are familiar with
18 the way keystrokes are written in Emacs manuals. If not, have a look at
19 the Emacs Tutorial in the Help menu.
20
21 If @AUCTeX{} is installed, you might still need to activate it, by
22 inserting
23
24 @lisp
25 (load "auctex.el" nil t t)
26 @end lisp
27
28 in your user init file.@footnote{This usually is a file in your home
29 directory called @file{.emacs} if you are utilizing GNU Emacs or
30 @file{.xemacs/init.el} if you are using XEmacs.} If you've installed
31 @AUCTeX{} from the Emacs package manager (ELPA), you must not have this
32 line in your user init file. The installation procedure already cares
33 about loading @AUCTeX{} correctly.
34
35 In order to get support for many of the @LaTeX{} packages you will use
36 in your documents, you should enable document parsing as well, which can
37 be achieved by putting
38
39 @lisp
40 (setq TeX-auto-save t)
41 (setq TeX-parse-self t)
42 @end lisp
43
44 into your init file. Finally, if you often use @code{\include} or
45 @code{\input}, you should make @AUCTeX{} aware of the multi-file
46 document structure. You can do this by inserting
47
48 @lisp
49 (setq-default TeX-master nil)
50 @end lisp
51
52 into your init file. Each time you open a new file, @AUCTeX{} will then
53 ask you for a master file.
54
55 @menu
56 * Editing Facilities:: Functions for editing TeX files
57 * Processing Facilities:: Creating and viewing output, debugging
58 @end menu
59
60 @iftex
61 This Quick Start Guide covers two main topics: First we explain how
62 @AUCTeX{} helps you in editing your input file for @TeX{}, @LaTeX{}, and
63 some other formats. Then we describe the functions that @AUCTeX{}
64 provides for processing the input files with @LaTeX{}, Bib@TeX{}, etc.,
65 and for viewing and debugging.
66 @end iftex
67
68 @node Editing Facilities
69 @section Functions for editing TeX files
70
71 @subsection Making your @TeX{} code more readable
72
73 @AUCTeX{} can do syntax highlighting of your source code, that means
74 commands will get special colors or fonts. You can enable it locally by
75 typing @kbd{M-x font-lock-mode RET}. If you want to have font locking
76 activated generally, enable @code{global-font-lock-mode}, e.g. with
77 @kbd{M-x customize-variable RET global-font-lock-mode RET}.
78
79 @AUCTeX{} will indent new lines to indicate their syntactical
80 relationship to the surrounding text. For example, the text of a
81 @code{\footnote} or text inside of an environment will be indented
82 relative to the text around it. If the indenting has gotten wrong after
83 adding or deleting some characters, use @key{TAB} to reindent the line,
84 @kbd{M-q} for the whole paragraph, or @kbd{M-x LaTeX-fill-buffer RET}
85 for the whole buffer.
86
87 @subsection Entering sectioning commands
88 @cindex Sectioning
89 @cindex Sections
90 @cindex Chapters
91 @cindex @code{\chapter}
92 @cindex @code{\section}
93 @cindex @code{\subsection}
94 @cindex @code{\label}
95
96 Insertion of sectioning macros, that is @samp{\chapter},
97 @samp{\section}, @samp{\subsection}, etc. and accompanying @samp{\label}
98 commands may be eased by using @kbd{C-c C-s}. You will be asked for the
99 section level. As nearly everywhere in @AUCTeX{}, you can use the
100 @key{TAB} or @key{SPC} key to get a list of available level names, and
101 to auto-complete what you started typing. Next, you will be asked for
102 the printed title of the section, and last you will be asked for a label
103 to be associated with the section.
104
105 @subsection Inserting environments
106
107 Similarly, you can insert environments, that is
108 @samp{\begin@{@}}--@samp{\end@{@}} pairs: Type @kbd{C-c C-e}, and select
109 an environment type. Again, you can use @key{TAB} or @key{SPC} to get a
110 list, and to complete what you type. Actually, the list will not only
111 provide standard @LaTeX{} environments, but also take your
112 @samp{\documentclass} and @samp{\usepackage} commands into account if
113 you have parsing enabled by setting @code{TeX-parse-self} to @code{t}.
114 If you use a couple of environments frequently, you can use the up and
115 down arrow keys (or @kbd{M-p} and @kbd{M-n}) in the minibuffer to get
116 back to the previously inserted commands.
117
118 Some environments need additional arguments. Often, @AUCTeX{} knows about
119 this and asks you to enter a value.
120
121 @subsection Inserting macros
122
123 @kbd{C-c C-m}, or simply @kbd{C-c RET} will give you a prompt that asks
124 you for a @LaTeX{} macro. You can use @key{TAB} for completion, or the
125 up/down arrow keys (or @kbd{M-p} and @kbd{M-n}) to browse the command
126 history. In many cases, @AUCTeX{} knows which arguments a macro needs
127 and will ask you for that. It even can differentiate between mandatory
128 and optional arguments---for details, see @ref{Completion}.
129
130 An additional help for inserting macros is provided by the possibility
131 to complete macros right in the buffer. With point at the end of a
132 partially written macro, you can complete it by typing @kbd{M-TAB}.
133
134 @subsection Changing the font
135
136 @AUCTeX{} provides convenient keyboard shortcuts for inserting macros
137 which specify the font to be used for typesetting certain parts of the
138 text. They start with @kbd{C-c C-f}, and the last @kbd{C-} combination
139 tells @AUCTeX{} which font you want:
140
141 @table @kbd
142 @item C-c C-f C-b
143 @kindex C-c C-f C-b
144 @cindex @code{\textbf}
145 Insert @b{bold face} @samp{\textbf@{@point{}@}} text.
146
147 @item C-c C-f C-i
148 @kindex C-c C-f C-i
149 @cindex @code{\textit}
150 Insert @i{italics} @samp{\textit@{@point{}@}} text.
151
152 @item C-c C-f C-e
153 @kindex C-c C-f C-e
154 @cindex @code{\emph}
155 Insert @i{emphasized} @samp{\emph@{@point{}@}} text.
156
157 @item C-c C-f C-s
158 @kindex C-c C-f C-s
159 @cindex @code{\textsl}
160 Insert @i{slanted} @samp{\textsl@{@point{}@}} text.
161
162 @item C-c C-f C-r
163 @kindex C-c C-f C-r
164 @cindex @code{\textrm}
165 Insert roman @r{\textrm@{@point{}@}} text.
166
167 @item C-c C-f C-f
168 @kindex C-c C-f C-f
169 @cindex @code{\textsf}
170 Insert @sansserif{sans serif} @samp{\textsf@{@point{}@}} text.
171
172 @item C-c C-f C-t
173 @kindex C-c C-f C-t
174 @cindex @code{\texttt}
175 Insert @t{typewriter} @samp{\texttt@{@point{}@}} text.
176
177 @item C-c C-f C-c
178 @kindex C-c C-f C-c
179 @cindex @code{\textsc}
180 Insert @sc{small caps} @samp{\textsc@{@point{}@}} text.
181
182 @item C-c C-f C-d
183 @kindex C-c C-f C-c
184 @cindex Deleting fonts
185 Delete the innermost font specification containing point.
186
187 @end table
188
189 If you want to change font attributes of existing text, mark it as a
190 region, and then invoke the commands. If no region is selected, the
191 command will be inserted with empty braces, and you can start typing the
192 changed text.
193
194 Most of those commands will also work in math mode, but then macros like
195 @code{\mathbf} will be inserted.
196
197
198 @subsection Other useful features
199
200 @AUCTeX{} also tries to help you when inserting the right ``quote''
201 signs for your language, dollar signs to typeset math, or pairs of
202 braces. It offers shortcuts for commenting out text (@kbd{C-c ;} for
203 the current region or @kbd{C-c %} for the paragraph you are in). The
204 same keystrokes will remove the % signs, if the region or paragraph is
205 commented out yet. With @code{TeX-fold-mode}, you can hide certain
206 parts (like footnotes, references etc.) that you do not edit currently.
207 Support for Emacs' outline mode is provided as well. And there's more,
208 but this is beyond the scope of this Quick Start Guide.
209
210
211
212 @node Processing Facilities
213 @section Creating and viewing output, debugging
214
215 @subsection One Command for @LaTeX{}, helpers, viewers, and printing
216
217 If you have typed some text and want to run @LaTeX{} (or @TeX{}, or
218 other programs---see below) on it, type @kbd{C-c C-c}. If applicable,
219 you will be asked whether you want to save changes, and which program
220 you want to invoke. In many cases, the choice that @AUCTeX{} suggests
221 will be just what you want: first @command{latex}, then a viewer. If a
222 @command{latex} run produces or changes input files for
223 @command{makeindex}, the next suggestion will be to run that program,
224 and @AUCTeX{} knows that you need to run @command{latex} again
225 afterwards---the same holds for Bib@TeX{}.
226
227 When no processor invocation is necessary anymore, @AUCTeX{} will
228 suggest to run a viewer, or you can chose to create a PostScript file
229 using @command{dvips}, or to directly print it.
230
231 At this place, a warning needs to be given: First, although @AUCTeX{} is
232 really good in detecting the standard situations when an additional
233 @command{latex} run is necessary, it cannot detect it always. Second,
234 the creation of PostScript files or direct printing currently only works
235 when your output file is a @acronym{DVI} file, not a @acronym{PDF} file.
236
237 Ah, you didn't know you can do both? That brings us to the next topic.
238
239 @subsection Choosing an output format
240
241 From a @LaTeX{} file, you can produce @acronym{DVI} output, or a
242 @acronym{PDF} file directly @i{via} @command{pdflatex}. You can switch
243 on source specials for easier navigation in the output file, or tell
244 @command{latex} to stop after an error (usually @code{\noninteractive}
245 is used, to allow you to detect all errors in a single run).
246
247 These options are controlled by toggles, the keystrokes should be easy
248 to memorize:
249
250 @table @kbd
251 @item @kbd{C-c C-t C-p}
252 This command toggles between @acronym{DVI} and @acronym{PDF} output
253
254 @item @kbd{C-c C-t C-i}
255 toggles interactive mode
256
257 @item @kbd{C-c C-t C-s}
258 toggles source specials support
259
260 @item @kbd{C-c C-t C-o}
261 toggles usage of Omega/lambda.
262
263 @end table
264
265 @subsection Debugging @LaTeX{}
266
267 When @AUCTeX{} runs a program, it creates an output buffer in which it
268 displays the output of the command. If there is a syntactical error in
269 your file, @command{latex} will not complete successfully. @AUCTeX{}
270 will tell you that, and you can get to the place where the first error
271 occured by pressing @kbd{C-c `} (the last character is a backtick). The
272 view will be split in two windows, the output will be displayed in the
273 lower buffer, and both buffers will be centered around the place where
274 the error ocurred. You can then try to fix it in the document buffer,
275 and use the same keystrokes to get to the next error. This procedure
276 may be repeated until all errors have been dealt with. By pressing
277 @kbd{C-c C-w} (@code{TeX-toggle-debug-boxes}) you can toggle whether
278 @AUCTeX{} should notify you of overfull and underfull boxes in addition
279 to regular errors.
280
281 If a command got stuck in a seemingly infinite loop, or you want to stop
282 execution for other reasons, you can use @kbd{C-c C-k} (for ``kill'').
283 Similar to @kbd{C-l}, which centers the buffer you are in around your
284 current position, @kbd{C-c C-l} centers the output buffer so that the
285 last lines added at the bottom become visible.
286
287 @subsection Running @LaTeX{} on parts of your document
288
289 If you want to check how some part of your text looks like, and do not
290 want to wait until the whole document has been typeset, then mark it as
291 a region and use @kbd{C-c C-r}. It behaves just like @kbd{C-c C-c}, but
292 it only uses the document preamble and the region you marked.
293
294 If you are using @code{\include} or @code{\input} to structure your
295 document, try @kbd{C-c C-b} while you are editing one of the included
296 files. It will run @command{latex} only on the current buffer, using the
297 preamble from the master file.
298 @c does this also work with input? why not?
299
300 @c Local Variables:
301 @c mode: texinfo
302 @c TeX-master: "auctex"
303 @c End: