1\input texinfo 2@comment %**start of header 3@setfilename auctex.info 4@include version.texi 5@settitle AUCTeX @value{VERSION} 6@c footnotestyle separate 7@c paragraphindent 2 8@comment %**end of header 9@include macros.texi 10@copying 11This manual is for @AUCTeX{} 12(version @value{VERSION} from @value{UPDATED}), 13a sophisticated TeX environment for Emacs. 14 15Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2019 16Free Software Foundation, Inc. 17 18@quotation 19Permission is granted to copy, distribute and/or modify this document 20under the terms of the GNU Free Documentation License, Version 1.3 or 21any later version published by the Free Software Foundation; with no 22Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. A 23copy of the license is included in the section entitled ``GNU Free 24Documentation License.'' 25@end quotation 26@end copying 27 28@dircategory Emacs 29@direntry 30* AUCTeX: (auctex). A sophisticated TeX environment for Emacs. 31@end direntry 32@dircategory TeX 33@direntry 34* AUCTeX: (auctex). A sophisticated TeX environment for Emacs. 35@end direntry 36 37@iftex 38@tolerance 10000 @emergencystretch 3em 39@end iftex 40 41@finalout 42@titlepage 43@title @AUCTeX{} 44@subtitle A sophisticated @TeX{} environment for Emacs 45@subtitle Version @value{VERSION}, @value{UPDATED} 46@author Kresten Krab Thorup 47@author Per Abrahamsen 48@author David Kastrup and others 49@page 50@vskip 0pt plus 1filll 51@insertcopying 52@end titlepage 53 54@c Use @ifinfo _and_ @ifhtml here because Texinfo 3 cannot cope with 55@c @ifnottex around a top node. 56@ifinfo 57@node top 58@top @AUCTeX{} 59 60This manual may be copied under the conditions spelled out in 61@ref{Copying this Manual}. 62 63@end ifinfo 64@ifhtml 65@node top 66@top @AUCTeX{} 67@insertcopying 68@end ifhtml 69 70@contents 71 72@iftex 73@unnumbered Executive Summary 74@end iftex 75 76@AUCTeX{} is an integrated environment for editing @LaTeX{}, @ConTeXt{}, 77doc@TeX{}, Texinfo, and @TeX{} files. 78 79Although @AUCTeX{} contains a large number of features, there are no 80reasons to despair. You can continue to write @TeX{} and @LaTeX{} 81documents the way you are used to, and only start using the multiple 82features in small steps. @AUCTeX{} is not monolithic, each feature 83described in this manual is useful by itself, but together they provide 84an environment where you will make very few @LaTeX{} errors, and makes 85it easy to find the errors that may slip through anyway. 86 87It is a good idea to make a printout of @AUCTeX{}'s reference card 88@file{tex-ref.tex} or one of its typeset versions. 89 90If you want to make @AUCTeX{} aware of style files and multi-file 91documents right away, insert the following in your @file{.emacs} file. 92 93@lisp 94(setq TeX-auto-save t) 95(setq TeX-parse-self t) 96(setq-default TeX-master nil) 97@end lisp 98 99Another thing you should enable is Ref@TeX{}, a comprehensive solution 100for managing cross references, bibliographies, indices, document 101navigation and a few other things. (@pxref{Installation,,,reftex,The 102Ref@TeX{} manual}) 103 104For detailed information about the @previewlatex{} subsystem of 105@AUCTeX{}, see @ref{Top,,Introduction,preview-latex,The @previewlatex{} 106Manual}. 107 108There is a mailing list for general discussion about @AUCTeX{}: write a 109mail with ``subscribe'' in the subject to 110@email{auctex-request@@gnu.org} to join it. Send contributions to 111@email{auctex@@gnu.org}. 112 113Bug reports should go to @email{bug-auctex@@gnu.org}, suggestions for 114new features, and pleas for help should go to either 115@email{auctex-devel@@gnu.org} (the @AUCTeX{} developers), or to 116@email{auctex@@gnu.org} if they might have general interest. Please use 117the command @kbd{M-x TeX-submit-bug-report RET} to report bugs if 118possible. You can subscribe to a low-volume announcement list by 119sending ``subscribe'' in the subject of a mail to 120@email{info-auctex-request@@gnu.org}. 121 122@menu 123* Copying:: Copying 124* Introduction:: Introduction to @AUCTeX{} 125* Editing:: Editing the Document Source 126* Display:: Controlling Screen Display 127* Processing:: Starting Processors, Viewers and Other Programs 128* Customization:: Customization and Extension 129* Appendices:: Copying, Changes, Development, FAQ, Texinfo mode 130* Indices:: Indices 131 132@detailmenu 133 --- The Detailed Node Listing --- 134 135Introduction 136 137* Summary:: Overview of @AUCTeX{} 138* Installation:: Installing @AUCTeX{} 139* Quick Start:: Quick Start 140 141Editing the Document Source 142 143* Quotes:: Inserting double quotes 144* Font Specifiers:: Inserting Font Specifiers 145* Sectioning:: Inserting chapters, sections, etc. 146* Environments:: Inserting Environment Templates 147* Mathematics:: Entering Mathematics 148* Completion:: Completion of macros 149* Commenting:: Commenting text 150* Indenting:: Reflecting syntactic constructs with whitespace 151* Filling:: Automatic and manual line breaking 152 153Inserting Environment Templates 154 155* Equations:: Equations 156* Floats:: Floats 157* Itemize-like:: Itemize-like Environments 158* Tabular-like:: Tabular-like Environments 159* Customizing Environments:: Customizing Environments 160 161Controlling Screen Display 162 163* Font Locking:: Font Locking 164* Folding:: Folding Macros and Environments 165* Outline:: Outlining the Document 166* Narrowing:: Restricting display and editing to a portion of the buffer 167* Prettifying:: Displaying Greek and math macros as Unicode characters 168 169Font Locking 170 171* Fontification of macros:: Fontification of macros 172* Fontification of quotes:: Fontification of quotes 173* Fontification of math:: Fontification of math constructs 174* Verbatim content:: Verbatim macros and environments 175* Faces:: Faces used by font-latex 176 177Starting Processors, Viewers and Other Programs 178 179* Commands:: Invoking external commands. 180* Viewing:: Invoking external viewers. 181* Debugging:: Debugging @TeX{} and @LaTeX{} output. 182* Checking:: Checking the document. 183* Control:: Controlling the processes. 184* Cleaning:: Cleaning intermediate and output files. 185* Documentation:: Documentation about macros and packages. 186 187Viewing the Formatted Output 188 189* Starting Viewers:: Starting viewers 190* I/O Correlation:: Forward and inverse search 191 192Catching the errors 193 194* Ignoring warnings:: Controlling warnings to be reported 195* Error overview:: List of all errors and warnings 196 197Customization and Extension 198 199* Multifile:: Multifile Documents 200* Parsing Files:: Automatic Parsing of @TeX{} Files 201* Internationalization:: Language Support 202* Automatic:: Automatic Customization 203* Style Files:: Writing Your Own Style Support 204 205Language Support 206 207* European:: Using @AUCTeX{} with European Languages 208* Japanese:: Using @AUCTeX{} with Japanese 209 210Automatic Customization 211 212* Automatic Global:: Automatic Customization for the Site 213* Automatic Private:: Automatic Customization for a User 214* Automatic Local:: Automatic Customization for a Directory 215 216Writing Your Own Style Support 217 218* Simple Style:: A Simple Style File 219* Adding Macros:: Adding Support for Macros 220* Adding Environments:: Adding Support for Environments 221* Adding Other:: Adding Other Information 222* Hacking the Parser:: Automatic Extraction of New Things 223 224Copying, Changes, Development, FAQ 225 226* Copying this Manual:: 227* Changes:: 228* Development:: 229* FAQ:: 230* Texinfo mode:: 231 232Copying this Manual 233 234* GNU Free Documentation License:: License for copying this manual. 235 236Indices 237 238* Key Index:: 239* Function Index:: 240* Variable Index:: 241* Concept Index:: 242 243@end detailmenu 244@end menu 245 246@node Copying 247@unnumbered Copying 248@cindex Copying 249@cindex Copyright 250@cindex GPL 251@cindex General Public License 252@cindex License 253@cindex Free 254@cindex Free software 255@cindex Distribution 256@cindex Right 257@cindex Warranty 258 259@c This text adapted from the Texinfo 2.16 distribution. 260 261@AUCTeX{} primarily consists of Lisp files for Emacs, but 262there are also installation scripts and files and @TeX{} support files. 263All of those are @dfn{free}; this means that everyone is free to use 264them and free to redistribute them on a free basis. The files of 265@AUCTeX{} are not in the public domain; they are copyrighted and there 266are restrictions on their distribution, but these restrictions are 267designed to permit everything that a good cooperating citizen would want 268to do. What is not allowed is to try to prevent others from further 269sharing any version of these programs that they might get from you. 270 271Specifically, we want to make sure that you have the right to give away 272copies of the files that constitute @AUCTeX{}, that you receive source 273code or else can get it if you want it, that you can change these files 274or use pieces of them in new free programs, and that you know you can do 275these things. 276 277To make sure that everyone has such rights, we have to forbid you to 278deprive anyone else of these rights. For example, if you distribute 279copies of parts of @AUCTeX{}, you must give the recipients all the 280rights that you have. You must make sure that they, too, receive or can 281get the source code. And you must tell them their rights. 282 283Also, for our own protection, we must make certain that everyone finds 284out that there is no warranty for @AUCTeX{}. If any parts are modified 285by someone else and passed on, we want their recipients to know that 286what they have is not what we distributed, so that any problems 287introduced by others will not reflect on our reputation. 288 289The precise conditions of the licenses for the files currently being 290distributed as part of @AUCTeX{} are found in the General Public 291Licenses that accompany them. This manual specifically is covered by 292the GNU Free Documentation License (@pxref{Copying this Manual}). 293 294@node Introduction 295@chapter Introduction 296 297@menu 298* Summary:: Overview of @AUCTeX{} 299* Installation:: Installing @AUCTeX{} 300* Quick Start:: Quick Start 301@end menu 302 303@lowersections 304@include intro.texi 305 306@include install.texi 307 308@include quickstart.texi 309@raisesections 310 311@node Editing 312@chapter Editing the Document Source 313 314The most commonly used commands/macros of @AUCTeX{} are those which 315simply insert templates for often used @TeX{}, @LaTeX{}, or @ConTeXt{} 316constructs, like font changes, handling of environments, etc. These 317features are very simple, and easy to learn, and help you avoid mistakes 318like mismatched braces, or @samp{\begin@{@}}-@samp{\end@{@}} pairs. 319 320Apart from that this chapter contains a description of some features for 321entering more specialized sorts of text, for formatting the source by 322indenting and filling and for navigating through the document. 323 324@menu 325* Quotes:: Inserting quotes, dollars, and braces 326* Font Specifiers:: Inserting Font Specifiers 327* Sectioning:: Inserting chapters, sections, etc. 328* Environments:: Inserting Environment Templates 329* Mathematics:: Entering Mathematics 330* Completion:: Completion of macros 331* Marking:: Marking Environments, Sections, or Texinfo Nodes 332* Commenting:: Commenting text 333* Indenting:: Reflecting syntactic constructs with whitespace 334* Filling:: Automatic and manual line breaking 335@end menu 336 337@node Quotes 338@section Insertion of Quotes, Dollars, and Braces 339 340@cindex Quotes 341@cindex Double quotes 342@cindex Braces 343@cindex Brackets 344@cindex Dollars 345@cindex Math mode delimiters 346@cindex Matching dollar signs 347@cindex Display math mode 348 349@subheading Quotation Marks 350 351In @TeX{}, literal double quotes @samp{"like this"} are seldom used, 352instead two single quotes are used @samp{``like this''}. To help you 353insert these efficiently, @AUCTeX{} allows you to continue to press 354@kbd{"} to insert two single quotes. To get a literal double quote, 355press @kbd{"} twice. 356 357@deffn Command TeX-insert-quote @var{count} 358@kindex " 359(@kbd{"}) Insert the appropriate quote marks for @TeX{}. 360 361Inserts the value of @code{TeX-open-quote} (normally @samp{``}) or 362@code{TeX-close-quote} (normally @samp{''}) depending on the context. 363With prefix argument, always inserts @samp{"} characters. 364@end deffn 365 366@defopt TeX-open-quote 367String inserted by typing @kbd{"} to open a quotation. 368(@xref{European}, for language-specific quotation mark insertion.) 369@end defopt 370 371@defopt TeX-close-quote 372String inserted by typing @kbd{"} to close a quotation. 373(@xref{European}, for language-specific quotation mark insertion.) 374@end defopt 375 376@defopt TeX-quote-after-quote 377Determines the behavior of @kbd{"}. If it is non-nil, typing @kbd{"} 378will insert a literal double quote. The respective values of 379@code{TeX-open-quote} and @code{TeX-close-quote} will be inserted 380after typing @kbd{"} once again. 381@end defopt 382 383The @samp{babel} package provides special support for the requirements 384of typesetting quotation marks in many different languages. If you use 385this package, either directly or by loading a language-specific style 386file, you should also use the special commands for quote insertion 387instead of the standard quotes shown above. @AUCTeX{} is able to 388recognize several of these languages and will change quote insertion 389accordingly. @xref{European}, for details about this feature and how to 390control it. 391 392@vindex LaTeX-csquotes-open-quote 393@vindex LaTeX-csquotes-close-quote 394@vindex LaTeX-csquotes-quote-after-quote 395In case you are using the @samp{csquotes} package, you should customize 396@code{LaTeX-csquotes-open-quote}, @code{LaTeX-csquotes-close-quote} and 397@code{LaTeX-csquotes-quote-after-quote}. The quotation characters will 398only be used if both variables---@code{LaTeX-csquotes-open-quote} and 399@code{LaTeX-csquotes-close-quote}---are non-empty strings. But then the 400@samp{csquotes}-related values will take precedence over the 401language-specific ones. 402 403@subheading Dollar Signs 404 405In @AUCTeX{}, dollar signs should match like they do in @TeX{}. This 406has been partially implemented, we assume dollar signs always match 407within a paragraph. By default, the first @samp{$} you insert in a 408paragraph will do nothing special. The second @samp{$} will match the 409first. This will be indicated by moving the cursor temporarily over the 410first dollar sign. 411 412@deffn Command TeX-insert-dollar @var{arg} 413@kindex $ 414(@kbd{$}) Insert dollar sign. 415 416Show matching dollar sign if this dollar sign end the @TeX{} math mode. 417 418With optional @var{arg}, insert that many dollar signs. 419@end deffn 420 421@TeX{} and @LaTeX{} users often look for a way to insert inline 422equations like @samp{$...$} or @samp{\(...\)} simply typing @kbd{$}. 423@AUCTeX{} helps them through the customizable variable 424@code{TeX-electric-math}. 425 426@defopt TeX-electric-math 427If the variable is non-nil and you type @kbd{$} outside math mode, 428@AUCTeX{} will automatically insert the opening and closing symbols for 429an inline equation and put the point between them. The opening symbol 430will blink when @code{blink-matching-paren} is non-nil. If 431@code{TeX-electric-math} is nil, typing @kbd{$} simply inserts @samp{$} 432at point, this is the default. 433 434Besides @code{nil}, possible values for this variable are @code{(cons 435"$" "$")} for @TeX{} inline equations @samp{$...$}, and @code{(cons 436"\\(" "\\)")} for @LaTeX{} inline equations @samp{\(...\)}. 437 438If the variable is non-nil and point is inside math mode right between a 439couple of single dollars, pressing @kbd{$} will insert another pair of 440dollar signs and leave the point between them. Thus, if 441@code{TeX-electric-math} is set to @code{(cons "$" "$")} you can easily 442obtain a @TeX{} display equation @samp{$$...$$} by pressing @kbd{$} 443twice in a row. (Note that you should not use double dollar signs in 444@LaTeX{} because this practice can lead to wrong spacing in typeset 445documents.) 446 447In addition, when the variable is non-nil and there is an active region 448outside math mode, typing @kbd{$} will put around the active region 449symbols for opening and closing inline equation and keep the region 450active, leaving point after the closing symbol. By pressing repeatedly 451@kbd{$} while the region is active you can toggle between an inline 452equation, a display equation, and no equation. To be precise, 453@samp{$...$} is replaced by @samp{$$...$$}, whereas @samp{\(...\)} is 454replaced by @samp{\[...\]}. 455@end defopt 456 457If you want to automatically insert @samp{$...$} in plain @TeX{} files, 458and @samp{\(...\)} in @LaTeX{} files by pressing @kbd{$}, add the 459following to your init file 460@lisp 461(add-hook 'plain-TeX-mode-hook 462 (lambda () (set (make-local-variable 'TeX-electric-math) 463 (cons "$" "$")))) 464(add-hook 'LaTeX-mode-hook 465 (lambda () (set (make-local-variable 'TeX-electric-math) 466 (cons "\\(" "\\)")))) 467@end lisp 468 469@subheading Braces 470 471To avoid unbalanced braces, it is useful to insert them pairwise. You 472can do this by typing @kbd{C-c @{}. 473 474@deffn Command TeX-insert-braces 475@kindex C-c @{ 476(@kbd{C-c @{}) Make a pair of braces and position the cursor 477to type inside of them. If there is an active region, put braces around 478it and leave point after the closing brace. 479@end deffn 480 481When writing complex math formulas in @LaTeX{} documents, you 482sometimes need to adjust the size of braces with pairs of macros like 483@samp{\left}-@samp{\right}, @samp{\bigl}-@samp{\bigr} and so on. You 484can avoid unbalanced pairs with the help of @code{TeX-insert-macro}, 485bound to @kbd{C-c C-m} or @kbd{C-c @key{RET}} (@pxref{Completion}). 486If you insert left size adjusting macros such as @samp{\left}, 487@samp{\bigl} etc. with @code{TeX-insert-macro}, it asks for left brace 488to use and supplies automatically right size adjusting macros such as 489@samp{\right}, @samp{\bigr} etc. and corresponding right brace in 490addtion to the intended left macro and left brace. 491 492The completion by @code{TeX-insert-macro} also applies when entering 493macros such as @samp{\langle}, @samp{\lfloor} and @samp{\lceil}, which 494produce the left part of the paired braces. For example, inserting 495@samp{\lfloor} by @kbd{C-c C-m} is immediately followed by the 496insertion of @samp{\rfloor}. In addition, if the point was located 497just after @samp{\left} or its friends, the corresponding 498@samp{\right} etc. will be inserted in front of @samp{\rfloor}. 499In both cases, active region is honored. 500 501As a side effect, when @code{LaTeX-math-mode} (@pxref{Mathematics}) is 502on, just typing @kbd{`(} inserts not only @samp{\langle}, but also 503@samp{\rangle}. 504 505If you do not like such auto completion at all, it can be disabled by a 506user option. 507 508@defopt TeX-arg-right-insert-p 509If this option is turned off, the automatic supply of the right macros 510and braces is suppressed. 511@end defopt 512 513When you edit @LaTeX{} documents, you can enable automatic brace 514pairing when typing @kbd{(}, @kbd{@{} and @kbd{[}. 515 516@defopt LaTeX-electric-left-right-brace 517If this option is on, just typing @kbd{(}, @kbd{@{} or @kbd{[} 518immediately adds the corresponding right brace @samp{)}, @samp{@}} or 519@samp{]}. The point is left after the opening brace. If there is an 520active region, braces are put around it. 521 522They recognize the preceding backslash or size adjusting macros such 523as @samp{\left}, @samp{\bigl} etc., so the following completions will 524occur: 525@itemize @bullet 526 527@item 528(when typing single left brace) 529@itemize @minus 530 531@item 532@samp{(} -> @samp{()} 533 534@item 535@samp{@{} -> @samp{@{@}} 536 537@item 538@samp{[} -> @samp{[]} 539@end itemize 540 541@item 542(when typing left brace just after a backslash) 543@itemize @minus 544 545@item 546@samp{\(} -> @samp{\(\)} 547 548@item 549@samp{\@{} -> @samp{\@{\@}} 550 551@item 552@samp{\[} -> @samp{\[\]} 553@end itemize 554 555@item 556(when typing just after @samp{\left} or @samp{\bigl}) 557@itemize @minus 558 559@item 560@samp{\left(} -> @samp{\left(\right)} 561 562@item 563@samp{\bigl[} -> @samp{\bigl[\bigr]} 564@end itemize 565 566@item 567(when typing just after @samp{\Bigl\}) 568@itemize @minus 569 570@item 571@samp{\Bigl\@{} -> @samp{\Bigl\@{\Bigr\@}} 572 573@end itemize 574 575@end itemize 576 577This auto completion feature may be a bit annoying when editing an 578already existing @LaTeX{} document. In that case, use @kbd{C-u 1} or 579@kbd{C-q} before typing @kbd{(}, @kbd{@{} or @kbd{[}. Then no 580completion is done and just a single left brace is inserted. In fact, 581with optional prefix @var{arg}, just that many open braces are 582inserted without any completion. 583@end defopt 584 585@node Font Specifiers 586@section Inserting Font Specifiers 587 588@cindex Fonts 589@cindex Font macros 590@cindex Changing font 591@cindex Specifying a font 592 593Perhaps the most used keyboard commands of @AUCTeX{} are the short-cuts 594available for easy insertion of font changing macros. 595 596If you give an argument (that is, type @kbd{C-u}) to the font command, 597the innermost font will be replaced, i.e. the font in the @TeX{} group 598around point will be changed. The following table shows the available 599commands, with @code{@point{}} indicating the position where the text 600will be inserted. 601 602@table @kbd 603@item C-c C-f C-b 604@kindex C-c C-f C-b 605@cindex @code{\textbf} 606Insert @b{bold face} @samp{\textbf@{@point{}@}} text. 607 608@item C-c C-f C-i 609@kindex C-c C-f C-i 610@cindex @code{\textit} 611Insert @i{italics} @samp{\textit@{@point{}@}} text. 612 613@item C-c C-f C-e 614@kindex C-c C-f C-e 615@cindex @code{\emph} 616Insert @i{emphasized} @samp{\emph@{@point{}@}} text. 617 618@item C-c C-f C-s 619@kindex C-c C-f C-s 620@cindex @code{\textsl} 621Insert @i{slanted} @samp{\textsl@{@point{}@}} text. 622 623@item C-c C-f C-r 624@kindex C-c C-f C-r 625@cindex @code{\textrm} 626Insert roman @r{\textrm@{@point{}@}} text. 627 628@item C-c C-f C-f 629@kindex C-c C-f C-f 630@cindex @code{\textsf} 631Insert @sansserif{sans serif} @samp{\textsf@{@point{}@}} text. 632 633@item C-c C-f C-t 634@kindex C-c C-f C-t 635@cindex @code{\texttt} 636Insert @t{typewriter} @samp{\texttt@{@point{}@}} text. 637 638@item C-c C-f C-c 639@kindex C-c C-f C-c 640@cindex @code{\textsc} 641Insert @sc{small caps} @samp{\textsc@{@point{}@}} text. 642 643@item C-c C-f C-d 644@kindex C-c C-f C-c 645@cindex Deleting fonts 646Delete the innermost font specification containing point. 647 648@end table 649 650@deffn Command TeX-font replace what 651@kindex C-c C-f 652(@kbd{C-c C-f}) Insert template for font change command. 653 654If @var{replace} is not nil, replace current font. @var{what} 655determines the font to use, as specified by @code{TeX-font-list}. 656@end deffn 657 658@defopt TeX-font-list 659List of fonts used by @code{TeX-font}. 660 661Each entry is a list with three elements. The first element is the 662key to activate the font. The second element is the string to insert 663before point, and the third element is the string to insert after 664point. An optional fourth element means always replace if not nil. 665@end defopt 666 667@defopt LaTeX-font-list 668List of fonts used by @code{TeX-font} in LaTeX mode. It has the same 669structure as @code{TeX-font-list}. 670@end defopt 671 672@node Sectioning 673@section Inserting chapters, sections, etc. 674@cindex Sectioning 675@cindex Sections 676@cindex Chapters 677@cindex @code{\chapter} 678@cindex @code{\section} 679@cindex @code{\subsection} 680@cindex @code{\label} 681 682Insertion of sectioning macros, that is @samp{\chapter}, 683@samp{\section}, @samp{\subsection}, etc. and accompanying 684@samp{\label}'s may be eased by using @kbd{C-c C-s}. This command is 685highly customizable, the following describes the default behavior. 686 687When invoking you will be asked for a section macro to insert. An 688appropriate default is automatically selected by @AUCTeX{}, that is 689either: at the top of the document; the top level sectioning for that 690document style, and any other place: The same as the last occurring 691sectioning command. 692 693Next, you will be asked for the actual name of that section, and last 694you will be asked for a label to be associated with that section. The 695label will be prefixed by the value specified in 696@code{LaTeX-section-hook}. 697 698@deffn Command LaTeX-section @var{arg} 699@kindex C-c C-s 700(@kbd{C-c C-s}) Insert a sectioning command. 701 702Determine the type of section to be inserted, by the argument 703@var{arg}. 704 705@itemize @bullet 706@item 707If @var{arg} is nil or missing, use the current level. 708@item 709If @var{arg} is a list (selected by C-u), go downward one level. 710@item 711If @var{arg} is negative, go up that many levels. 712@item 713If @var{arg} is positive or zero, use absolute level: 714@itemize + 715@item 7160 : part 717@item 7181 : chapter 719@item 7202 : section 721@item 7223 : subsection 723@item 7244 : subsubsection 725@item 7265 : paragraph 727@item 7286 : subparagraph 729@end itemize 730@end itemize 731 732The following variables can be set to customize the function. 733 734@vtable @code 735@item LaTeX-section-hook 736Hooks to be run when inserting a section. 737@item LaTeX-section-label 738Prefix to all section references. 739@end vtable 740 741@end deffn 742 743The precise behavior of @code{LaTeX-section} is defined by the contents 744of @code{LaTeX-section-hook}. 745 746@defopt LaTeX-section-hook 747List of hooks to run when a new section is inserted. 748 749The following variables are set before the hooks are run 750 751@table @var 752@item level 753Numeric section level, default set by prefix arg to 754@code{LaTeX-section}. 755@item name 756Name of the sectioning command, derived from @var{level}. 757@item title 758The title of the section, default to an empty string. 759@item toc 760Entry for the table of contents list, default nil. 761@item done-mark 762Position of point afterwards, default nil meaning after the inserted 763text. 764@end table 765 766A number of hooks are already defined. Most likely, you will be able to 767get the desired functionality by choosing from these hooks. 768 769@ftable @code 770@item LaTeX-section-heading 771Query the user about the name of the sectioning command. Modifies 772@var{level} and @var{name}. 773@item LaTeX-section-title 774Query the user about the title of the section. Modifies @var{title}. 775@item LaTeX-section-toc 776Query the user for the toc entry. Modifies @var{toc}. 777@item LaTeX-section-section 778Insert @LaTeX{} section command according to @var{name}, @var{title}, 779and @var{toc}. If @var{toc} is nil, no toc entry is inserted. If 780@var{toc} or @var{title} are empty strings, @var{done-mark} will be 781placed at the point they should be inserted. 782@item LaTeX-section-label 783Insert a label after the section command. Controlled by the variable 784@code{LaTeX-section-label}. 785@end ftable 786 787To get a full featured @code{LaTeX-section} command, insert 788 789@lisp 790(setq LaTeX-section-hook 791 '(LaTeX-section-heading 792 LaTeX-section-title 793 LaTeX-section-toc 794 LaTeX-section-section 795 LaTeX-section-label)) 796@end lisp 797 798in your @file{.emacs} file. 799@end defopt 800 801The behavior of @code{LaTeX-section-label} is determined by the 802variable @code{LaTeX-section-label}. 803 804@defopt LaTeX-section-label 805Default prefix when asking for a label. 806 807If it is a string, it is used unchanged for all kinds of sections. 808If it is nil, no label is inserted. 809If it is a list, the list is searched for a member whose car is equal 810to the name of the sectioning command being inserted. The cdr is then 811used as the prefix. If the name is not found, or if the cdr is nil, 812no label is inserted. 813 814@cindex Prefix for labels 815@cindex Label prefix 816@cindex Labels 817By default, chapters have a prefix of @samp{cha:} while sections and 818subsections have a prefix of @samp{sec:}. Labels are not automatically 819inserted for other types of sections. 820@end defopt 821 822@node Environments 823@section Inserting Environment Templates 824@cindex Environments 825@cindex @samp{\begin} 826@cindex @samp{\end} 827 828A large apparatus is available that supports insertions of environments, 829that is @samp{\begin@{@}} --- @samp{\end@{@}} pairs. 830 831@AUCTeX{} is aware of most of the actual environments available in a 832specific document. This is achieved by examining your 833@samp{\documentclass} command, and consulting a precompiled list of 834environments available in a large number of styles. 835 836Most of these are described further in the following sections, and you 837may easily specify more. @xref{Customizing Environments}. 838 839You insert an environment with @kbd{C-c C-e}, and select an environment 840type. Depending on the environment, @AUCTeX{} may ask more questions 841about the optional parts of the selected environment type. With 842@kbd{C-u C-c C-e} you will change the current environment. 843 844@deffn Command LaTeX-environment @var{arg} 845@kindex C-c C-e 846(@kbd{C-c C-e}) @AUCTeX{} will prompt you for an environment 847to insert. At this prompt, you may press @key{TAB} or @key{SPC} to 848complete a partially written name, and/or to get a list of available 849environments. After selection of a specific environment @AUCTeX{} may 850prompt you for further specifications. 851 852If the optional argument @var{arg} is not-nil (i.e. you have given a 853prefix argument), the current environment is modified and no new 854environment is inserted. 855@end deffn 856 857@AUCTeX{} helps you adding labels to environments which use them, such 858as @samp{equation}, @samp{figure}, @samp{table}, etc@dots{} When you 859insert one of the supported environments with @kbd{C-c C-e}, you will be 860automatically prompted for a label. You can select the prefix to be 861used for such environments with the @code{LaTeX-label-alist} variable. 862@defopt LaTeX-label-alist 863List the prefixes to be used for the label of each supported 864environment. 865 866This is an alist whose car is the environment name, and the cdr either 867the prefix or a symbol referring to one. 868 869If the name is not found, or if the cdr is nil, no label is 870automatically inserted for that environment. 871 872If you want to automatically insert a label for a environment but with 873an empty prefix, use the empty string @code{""} as the cdr of the 874corresponding entry. 875@end defopt 876 877As a default selection, @AUCTeX{} will suggest the environment last 878inserted or, as the first choice the value of the variable 879@code{LaTeX-default-environment}. 880 881@defopt LaTeX-default-environment 882Default environment to insert when invoking @samp{LaTeX-environment} 883first time. When the current environment is @samp{document}, it is 884overriden by @code{LaTeX-default-document-environment}. 885@end defopt 886 887@defvar LaTeX-default-document-environment 888Default environment when invoking @samp{LaTeX-environment} and the 889current environment is @samp{document}. It is intended to be used in 890@LaTeX{} class style files. For example, in @file{beamer.el} it is set 891to @code{frame}, in @file{letter.el} to @code{letter}, and in 892@file{slides.el} to @code{slide}. 893@end defvar 894 895If the document is empty, or the cursor is placed at the top of the 896document, @AUCTeX{} will default to insert a @samp{document} environment 897prompting also for the insertion of @samp{\documentclass} and 898@samp{\usepackage} macros. You will be prompted for a new package until 899you enter nothing. If you do not want to insert any @samp{\usepackage} 900at all, just press @key{RET} at the first @samp{Packages} prompt. 901 902@AUCTeX{} distinguishes normal and expert environments. By default, it 903will offer completion only for normal environments. This behavior is 904controlled by the user option @code{TeX-complete-expert-commands}. 905 906@defopt TeX-complete-expert-commands 907Complete macros and environments marked as expert commands. 908 909Possible values are nil, t, or a list of style names. 910 911@table @asis 912@item nil 913Don't complete expert commands (default). 914@item t 915Always complete expert commands. 916@item (STYLES @dots{}) 917Only complete expert commands of STYLES. 918@end table 919@end defopt 920 921 922@menu 923* Equations:: Equations 924* Floats:: Floats 925* Itemize-like:: Itemize-like Environments 926* Tabular-like:: Tabular-like Environments 927* Customizing Environments:: Customizing Environments 928@end menu 929 930You can close the current environment with @kbd{C-c ]}, but we suggest 931that you use @kbd{C-c C-e} to insert complete environments instead. 932 933@deffn Command LaTeX-close-environment 934@kindex C-c ] 935(@kbd{C-c ]}) Insert an @samp{\end} that matches the current environment. 936@end deffn 937 938@AUCTeX{} offers keyboard shortcuts for moving point to the beginning 939and to the end of the current environment. 940@deffn Command LaTeX-find-matching-begin 941@kindex C-M-a 942(@kbd{C-M-a}) Move point to the @samp{\begin} of the current 943environment. 944 945If this command is called inside a comment and 946@code{LaTeX-syntactic-comments} is enabled, try to find the environment 947in commented regions with the same comment prefix. 948@end deffn 949 950@deffn Command LaTeX-find-matching-end 951@kindex C-M-e 952(@kbd{C-M-e}) Move point to the @samp{\end} of the current environment. 953 954If this command is called inside a comment and 955@code{LaTeX-syntactic-comments} is enabled, try to find the environment 956in commented regions with the same comment prefix. 957@end deffn 958 959@node Equations 960@subsection Equations 961@cindex Equations 962@cindex Equation 963@cindex Eqnarray 964@cindex amsmath 965 966When inserting equation-like environments, the @samp{\label} will have a 967default prefix, which is controlled by the following variables: 968 969@defopt LaTeX-equation-label 970Prefix to use for `equation' labels. 971@end defopt 972 973@defopt LaTeX-eqnarray-label 974Prefix to use for `eqnarray' labels. 975@end defopt 976 977@defopt LaTeX-amsmath-label 978Prefix to use for amsmath equation labels. Amsmath equations include 979@samp{align}, @samp{alignat}, @samp{xalignat}, @samp{aligned}, 980@samp{flalign} and @samp{gather}. 981@end defopt 982 983@node Floats 984@subsection Floats 985@cindex Floats 986@cindex Figures 987@cindex Figure environment 988@cindex Tables 989@cindex Table environment 990 991Figures and tables (i.e., floats) may also be inserted using @AUCTeX{}. 992After choosing either `figure' or `table' in the environment list 993described above, you will be prompted for a number of additional things. 994 995@table @var 996@item float position 997This is the optional argument of float environments that controls how 998they are placed in the final document. In @LaTeX{} this is a sequence 999of the letters @samp{htbp} as described in the @LaTeX{} manual. The 1000value will default to the value of @code{LaTeX-float}. 1001@vindex LaTeX-float 1002 1003@item caption 1004This is the caption of the float. The default is to insert the caption 1005at the bottom of the float. You can specify floats where the caption 1006should be placed at the top with @code{LaTeX-top-caption-list}. 1007@vindex LaTeX-top-caption-list 1008 1009@item short caption 1010If the specified caption is greater than a specific length, then a short 1011caption is prompted for and it is inserted as an optional argument to 1012the @samp{\caption} macro. The length that a caption needs to be before 1013prompting for a short version is controlled by 1014@code{LaTeX-short-caption-prompt-length}. 1015@vindex LaTeX-short-caption-prompt-length 1016 1017@item label 1018The label of this float. The label will have a default prefix, which is 1019controlled by the variables @code{LaTeX-figure-label} and 1020@code{LaTeX-table-label}. 1021@vindex LaTeX-figure-label 1022@vindex LaTeX-table-label 1023@cindex Prefix for labels 1024@cindex Label prefix 1025@cindex Labels 1026@end table 1027 1028Moreover, you will be asked if you want the contents of the float 1029environment to be horizontally centered. Upon a positive answer a 1030@samp{\centering} macro will be inserted at the beginning of the float 1031environment. 1032 1033@defopt LaTeX-float 1034Default placement for floats. 1035@end defopt 1036 1037@defopt LaTeX-figure-label 1038Prefix to use for figure labels. 1039@end defopt 1040 1041@defopt LaTeX-table-label 1042Prefix to use for table labels. 1043@end defopt 1044 1045@defopt LaTeX-top-caption-list 1046List of float environments with top caption. 1047@end defopt 1048 1049@defopt LaTeX-short-caption-prompt-length 1050Number of chars a caption should be before prompting for a short 1051caption. 1052@end defopt 1053 1054@node Itemize-like 1055@subsection Itemize-like Environments 1056@cindex Itemize 1057@cindex Enumerates 1058@cindex Descriptions 1059@cindex Items 1060@cindex \item 1061 1062In an itemize-like environment, nodes (i.e., @samp{\item}s) may be 1063inserted using @kbd{C-c @key{LFD}}. 1064 1065@deffn Command LaTeX-insert-item 1066@kindex C-c @key{LFD} 1067(@kbd{C-c @key{LFD}}) Close the current item, move to the next line and 1068insert an appropriate @samp{\item} for the current environment. That is, 1069`itemize' and `enumerate' will have @samp{\item } inserted, while 1070`description' will have @samp{\item[]} inserted. 1071@end deffn 1072 1073@defopt TeX-arg-item-label-p 1074If non-nil, you will always be asked for optional label in items. 1075Otherwise, you will be asked only in description environments. 1076@end defopt 1077 1078@node Tabular-like 1079@subsection Tabular-like Environments 1080@cindex amsmath 1081 1082When inserting Tabular-like environments, that is, `tabular' `array' 1083etc., you will be prompted for a template for that environment. 1084Related variables: 1085 1086@defopt LaTeX-default-format 1087Default format string for array and tabular environments. 1088@end defopt 1089 1090@defopt LaTeX-default-width 1091Default width for minipage and tabular* environments. 1092@end defopt 1093 1094@defopt LaTeX-default-position 1095Default position string for array and tabular environments. If nil, 1096act like the empty string is given, but don't prompt for a position. 1097@end defopt 1098 1099@AUCTeX{} calculates the number of columns from the format string and 1100inserts the suitable number of ampersands. 1101 1102You can use @kbd{C-c @key{LFD}} (@code{LaTeX-insert-item}) to terminate 1103rows in these environments. It supplies line break macro @samp{\\} and 1104inserts the suitable number of ampersands on the next line. @AUCTeX{} 1105also supports the @samp{*@{num@}@{cols@}} notation (which may contain 1106another @samp{*}-expression) in the format string when calculating the 1107number of ampersands. Please note that @samp{num} and @samp{cols} must 1108be enclosed in braces; expressions like @samp{*2l} are not recognized 1109correctly by the algorithm. 1110 1111@deffn Command LaTeX-insert-item 1112@kindex C-c @key{LFD} 1113(@kbd{C-c @key{LFD}}) Close the current row with @samp{\\}, move to the 1114next line and insert an appropriate number of ampersands for the current 1115environment. 1116@end deffn 1117 1118Similar supports are provided for various amsmath environments such as 1119@samp{align}, @samp{gather}, @samp{alignat}, @samp{matrix} etc. Try 1120typing @kbd{C-c @key{LFD}} in these environments. It recognizes the 1121current environment and does the appropriate job depending on the 1122context. 1123 1124@node Customizing Environments 1125@subsection Customizing Environments 1126 1127@xref{Adding Environments}, for how to customize the list of known 1128environments. 1129 1130@node Mathematics 1131@section Entering Mathematics 1132@cindex Mathematics 1133@cindex Symbols 1134@cindex Abbreviations 1135 1136@TeX{} is written by a mathematician, and has always contained good 1137support for formatting mathematical text. @AUCTeX{} supports this 1138tradition, by offering a special minor mode for entering text with many 1139mathematical symbols. You can enter this mode by typing @kbd{C-c 1140~}. 1141 1142@deffn Command LaTeX-math-mode 1143@kindex C-c ~ 1144(@kbd{C-c ~}) Toggle LaTeX Math mode. This is a minor mode rebinding 1145the key @code{LaTeX-math-abbrev-prefix} to allow easy typing of 1146mathematical symbols. @kbd{`} will read a character from the keyboard, 1147and insert the symbol as specified in @code{LaTeX-math-default} and 1148@code{LaTeX-math-list}. If given a prefix argument, the symbol will be 1149surrounded by dollar signs. 1150@end deffn 1151 1152You can use another prefix key (instead of @kbd{`}) by setting the 1153variable @code{LaTeX-math-abbrev-prefix}. 1154 1155To enable LaTeX Math mode by default, add the following in your 1156@file{.emacs} file: 1157@lisp 1158(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode) 1159@end lisp 1160 1161@defopt LaTeX-math-abbrev-prefix 1162A string containing the prefix of @code{LaTeX-math-mode} commands; This 1163value defaults to @kbd{`}. 1164 1165The string has to be a key or key sequence in a format understood by the 1166@code{kbd} macro. This corresponds to the syntax usually used in the 1167manuals for Emacs Emacs Lisp. 1168@end defopt 1169 1170The variable @code{LaTeX-math-list} allows you to add your own mappings. 1171 1172@defopt LaTeX-math-list 1173A list containing user-defined keys and commands to be used in LaTeX 1174Math mode. Each entry should be a list of two to four elements. 1175 1176First, the key to be used after @code{LaTeX-math-abbrev-prefix} for 1177macro insertion. If it is nil, the symbol has no associated 1178keystroke (it is available in the menu, though). 1179 1180Second, a string representing the name of the macro (without a leading 1181backslash.) 1182 1183Third, a string representing the name of a submenu the command should be 1184added to. Use a list of strings in case of nested menus. 1185 1186Fourth, the position of a Unicode character to be displayed in the menu 1187alongside the macro name. This is an integer value. 1188@end defopt 1189 1190@defopt LaTeX-math-menu-unicode 1191Whether the LaTeX menu should try using Unicode for effect. Your Emacs 1192built must be able to display include Unicode characters in menus for 1193this feature. 1194@end defopt 1195 1196@AUCTeX{}'s reference card @file{tex-ref.tex} includes a list of all 1197math mode commands. 1198 1199@AUCTeX{} can help you write subscripts and superscripts in math 1200constructs by automatically inserting a pair of braces after typing 1201@key{_} or @key{^} respectively and putting point between the braces. 1202In order to enable this feature, set the variable 1203@code{TeX-electric-sub-and-superscript} to a non-nil value. 1204 1205@defopt TeX-electric-sub-and-superscript 1206If non-nil, insert braces after typing @key{^} and @key{_} in math mode. 1207@end defopt 1208 1209You can automatically turn off input methods, used to input non-ascii 1210characters, when you begin to enter math constructs. 1211 1212@defopt TeX-math-input-method-off-regexp 1213Input method matching this regular expression is turned off when @kbd{$} 1214is typed to begin math mode or a math environment is inserted by 1215@kbd{C-c C-e} (@code{LaTeX-environment}). 1216@end defopt 1217 1218@node Completion 1219@section Completion 1220@cindex Completion 1221@cindex Expansion 1222@cindex Macro expansion 1223@cindex Macro completion 1224@cindex Macro arguments 1225@cindex Arguments to @TeX{} macros 1226 1227Emacs lisp programmers probably know the @code{lisp-complete-symbol} 1228command which was bound to @kbd{M-@key{TAB}} until completion-at-point 1229became the new standard completion facility (see below). Users of the 1230wonderful ispell mode know and love the @code{ispell-complete-word} 1231command from that package. Similarly, @AUCTeX{} has a 1232@code{TeX-complete-symbol} command, by default bound to 1233@kbd{M-@key{TAB}} which is equivalent to @kbd{M-C-i}. Using 1234@code{TeX-complete-symbol} makes it easier to type and remember the 1235names of long @LaTeX{} macros. 1236 1237In order to use @code{TeX-complete-symbol}, you should write a backslash 1238and the start of the macro. Typing @kbd{M-@key{TAB}} will now complete 1239as much of the macro, as it unambiguously can. For example, if you type 1240`@samp{\renewc}' and then @kbd{M-@key{TAB}}, it will expand to 1241`@samp{\renewcommand}'. But there's more: if point is just after 1242@samp{\begin@{}, then @code{TeX-complete-symbol} will complete @LaTeX{} 1243environments, etc. This is controlled by @code{TeX-complete-list}. 1244 1245@deffn Command TeX-complete-symbol 1246@kindex M-@key{TAB} 1247(@kbd{M-@key{TAB}}) Complete @TeX{} symbol before point. 1248@end deffn 1249 1250@defvar TeX-complete-list 1251List of ways to complete the preceding text. 1252 1253Each entry is a list with the following elements: 1254 1255@enumerate 1256@item 1257Regexp matching the preceding text or a predicate of arity 0 which 1258returns non-nil and sets `match-data' appropriately if it is applicable. 1259@item 1260A number indicating the subgroup in the regexp containing the text. 1261@item 1262A function returning an alist of possible completions. 1263@item 1264Text to append after a succesful completion. 1265@end enumerate 1266 1267Or alternatively: 1268 1269@enumerate 1270@item 1271Regexp matching the preceding text. 1272@item 1273Function to do the actual completion. 1274@end enumerate 1275@end defvar 1276 1277More recent Emacs versions have a new completion mechanism. Modes may 1278define and register custom completion-at-point functions and when the 1279user invokes @code{completion-at-point} (usually bound to 1280@kbd{M-@key{TAB}}), all such registered functions are consulted for 1281checking for possible completions. Modern completion UIs like 1282@i{company-mode} support this completion-at-point facility. 1283 1284@defun TeX--completion-at-point 1285@AUCTeX{}'s completion-at-point function which is automatically added to 1286@code{completion-at-point-functions} in @TeX{} and @LaTeX{} buffers. 1287 1288It offers the same completion candidates as would 1289@code{TeX-complete-symbol} (and is also controlled by 1290@code{TeX-complete-list}) except that it doesn't fall back on 1291@code{ispell-complete-word} which would be awkward with completion UIs 1292like @i{company-mode}. 1293@end defun 1294 1295A more direct way to insert a macro is with @code{TeX-insert-macro}, 1296bound to @kbd{C-c C-m} which is equivalent to @kbd{C-c @key{RET}}. It 1297has the advantage over completion that it knows about the argument of 1298most standard @LaTeX{} macros, and will prompt for them. It also knows 1299about the type of the arguments, so it will for example give completion 1300for the argument to @samp{\include}. Some examples are listed below. 1301 1302@deffn Command TeX-insert-macro 1303@kindex C-c C-m 1304(@kbd{C-c C-m} or @kbd{C-c @key{RET}}) Prompt (with completion) for the 1305name of a @TeX{} macro, and if @AUCTeX{} knows the macro, prompt for 1306each argument. 1307@end deffn 1308 1309As a default selection, @AUCTeX{} will suggest the macro last inserted 1310or, as the first choice the value of the variable 1311@code{TeX-default-macro}. 1312 1313@defopt TeX-insert-macro-default-style 1314Specifies whether @code{TeX-insert-macro} will ask for all optional 1315arguments. 1316 1317If set to the symbol @code{show-optional-args}, @code{TeX-insert-macro} 1318asks for optional arguments of @TeX{} marcos, unless the previous 1319optional argument has been rejected. If set to 1320@code{show-all-optional-args}, @code{TeX-insert-macro} asks for all 1321optional arguments. @code{mandatory-args-only}, @code{TeX-insert-macro} 1322asks only for mandatory arguments. When @code{TeX-insert-macro} is 1323called with prefix argument (@kbd{C-u}), it's the other way round. 1324 1325Note that for some macros, there are special mechanisms, e.g. 1326@code{LaTeX-includegraphics-options-alist} and 1327@code{TeX-arg-cite-note-p}. 1328@end defopt 1329 1330 1331@defopt TeX-default-macro 1332Default macro to insert when invoking @code{TeX-insert-macro} first time. 1333@end defopt 1334 1335A faster alternative is to enable the option 1336@code{TeX-electric-escape}. 1337 1338@defopt TeX-electric-escape 1339If this is non-nil, typing the @TeX{} escape character @kbd{\} will 1340invoke the command @code{TeX-electric-macro}. 1341 1342In Texinfo mode, the command is invoked by @kbd{@@} instead. 1343@end defopt 1344 1345The difference between @code{TeX-insert-macro} and 1346@code{TeX-electric-macro} is that space will complete and exit from the 1347minibuffer in @code{TeX-electric-macro}. Use @key{TAB} if you merely 1348want to complete. 1349 1350@deffn Command TeX-electric-macro 1351Prompt (with completion) for the name of a @TeX{} macro, 1352and if @AUCTeX{} knows the macro, prompt for each argument. 1353Space will complete and exit. 1354@end deffn 1355 1356By default @AUCTeX{} will put an empty set braces @samp{@{@}} after a 1357macro with no arguments to stop it from eating the next whitespace. 1358This is suppressed inside math mode and can be disabled totally by 1359setting @code{TeX-insert-braces} to nil. 1360 1361@defopt TeX-insert-braces 1362If non-nil, append a empty pair of braces after inserting a macro with 1363no arguments. 1364@end defopt 1365 1366@defopt TeX-insert-braces-alist 1367Control the insertion of a pair of braces after a macro on a per macro 1368basis. 1369 1370This variable is an alist. Each element is a cons cell, whose car is 1371the macro name, and the cdr is non-nil or nil, depending on whether a 1372pair of braces should be, respectively, appended or not to the macro. 1373 1374If a macro has an element in this variable, @code{TeX-parse-macro} will 1375use its value to decide what to do, whatever the value of the variable 1376@code{TeX-insert-braces}. 1377@end defopt 1378 1379Completions work because @AUCTeX{} can analyze @TeX{} files, and store 1380symbols in Emacs Lisp files for later retrieval. @xref{Automatic}, for 1381more information. 1382 1383@AUCTeX{} distinguishes normal and expert macros. By default, it will 1384offer completion only for normal commands. This behavior can be 1385controlled using the user option @code{TeX-complete-expert-commands}. 1386 1387@defopt TeX-complete-expert-commands 1388Complete macros and environments marked as expert commands. 1389 1390Possible values are nil, t, or a list of style names. 1391 1392@table @asis 1393@item nil 1394Don't complete expert commands (default). 1395@item t 1396Always complete expert commands. 1397@item (STYLES @dots{}) 1398Only complete expert commands of STYLES. 1399@end table 1400@end defopt 1401 1402 1403@cindex \cite, completion of 1404@cindex Bib@TeX{}, completion 1405@cindex cite, completion of 1406@cindex bibliography, completion 1407@cindex citations, completion of 1408@cindex \label, completion 1409@cindex \ref, completion 1410@cindex labels, completion of 1411@AUCTeX{} will also make completion for many macro arguments, for 1412example existing labels when you enter a @samp{\ref} macro with 1413@code{TeX-insert-macro} or @code{TeX-electric-macro}, and Bib@TeX{} 1414entries when you enter a @samp{\cite} macro. For this kind of 1415completion to work, parsing must be enabled as described in 1416@pxref{Parsing Files}. For @samp{\cite} you must also make sure that 1417the Bib@TeX{} files have been saved at least once after you enabled 1418automatic parsing on save, and that the basename of the Bib@TeX{} file 1419does not conflict with the basename of one of @TeX{} files. 1420 1421@node Marking 1422@section Marking Environments, Sections, or Texinfo Nodes 1423 1424You can mark the current environment by typing @kbd{C-c .}, or the 1425current section by typing @kbd{C-c *}. 1426 1427In Texinfo documents you can type @kbd{M-C-h} to mark the current node. 1428 1429When the region is set, the point is moved to its beginning and the mark 1430to its end. 1431 1432@menu 1433* Marking (LaTeX):: LaTeX Commands for Marking Environments and Sections 1434* Marking (Texinfo):: Texinfo Commands for Marking Environments, Sections, and Nodes 1435@end menu 1436 1437@node Marking (LaTeX) 1438@subsection LaTeX Commands for Marking Environments and Sections 1439 1440@deffn Command LaTeX-mark-section 1441@kindex C-c * 1442(@kbd{C-c *}) Set mark at end of current logical section, and point at 1443top. 1444 1445With a non-nil prefix argument, mark only the region from the current 1446section start to the next sectioning command. Thereby subsections are 1447not being marked. Otherwise, any included subsections are also marked 1448along with current section. 1449@end deffn 1450 1451@deffn Command LaTeX-mark-environment 1452@kindex C-c . 1453(@kbd{C-c .}) Set mark to the end of the current environment and point 1454to the matching beginning. 1455 1456If a prefix argument is given, mark the respective number of enclosing 1457environments. The command will not work properly if there are 1458unbalanced begin-end pairs in comments and verbatim environments. 1459@end deffn 1460 1461@node Marking (Texinfo) 1462@subsection Texinfo Commands for Marking Environments and Sections 1463 1464@deffn Command Texinfo-mark-section 1465@kindex C-c * 1466(@kbd{C-c *}) Mark the current section, with inclusion of any containing 1467node. 1468 1469The current section is detected as starting by any of the structuring 1470commands matched by the regular expression in the variable 1471@code{outline-regexp} which in turn is a regular expression matching any 1472element of the variable @code{texinfo-section-list}. 1473 1474With a non-nil prefix argument, mark only the region from the current 1475section start to the next sectioning command. Thereby subsections are 1476not being marked. Otherwise, any included subsections are also marked 1477 1478Note that when the current section is starting immediately after a node 1479command, then the node command is also marked as part of the section. 1480@end deffn 1481 1482@deffn Command Texinfo-mark-environment 1483@kindex C-c . 1484(@kbd{C-c .}) Set mark to the end of the current environment and point 1485to the matching beginning. 1486 1487If a prefix argument is given, mark the respective number of enclosing 1488environments. The command will not work properly if there are 1489unbalanced begin-end pairs in comments and verbatim environments. 1490@end deffn 1491 1492@deffn Command Texinfo-mark-node 1493@kindex M-C-h 1494(@kbd{M-C-h}) Mark the current node. This is the node in which point is 1495located. It is starting at the previous occurrence of the keyword 1496@code{@@node} and ending at next occurrence of the keywords 1497@code{@@node} or @code{@@bye}. 1498@end deffn 1499 1500@node Commenting 1501@section Commenting 1502 1503It is often necessary to comment out temporarily a region of @TeX{} or 1504@LaTeX{} code. This can be done with the commands @kbd{C-c ;} and 1505@kbd{C-c %}. @kbd{C-c ;} will comment out all lines in the current 1506region, while @kbd{C-c %} will comment out the current paragraph. 1507Type @kbd{C-c ;} again to uncomment all lines of a commented region, 1508or @kbd{C-c %} again to uncomment all comment lines around point. 1509These commands will insert or remove a single @samp{%} respectively. 1510 1511@deffn Command TeX-comment-or-uncomment-region 1512@kindex C-c ; 1513(@kbd{C-c ;}) Add or remove @samp{%} from the beginning of each line 1514in the current region. Uncommenting works only if the region encloses 1515solely commented lines. If @AUCTeX{} should not try to guess if the 1516region should be commented or uncommented the commands 1517@code{TeX-comment-region} and @code{TeX-uncomment-region} can be used 1518to explicitly comment or uncomment the region in concern. 1519@end deffn 1520 1521@deffn Command TeX-comment-or-uncomment-paragraph 1522@kindex C-c % 1523(@kbd{C-c %}) Add or remove @samp{%} from the beginning of each line 1524in the current paragraph. When removing @samp{%} characters the 1525paragraph is considered to consist of all preceding and succeeding 1526lines starting with a @samp{%}, until the first non-comment line. 1527@end deffn 1528 1529@node Indenting 1530@section Indenting 1531@cindex Formatting 1532@cindex Indenting 1533@cindex Indentation 1534@cindex Reformatting 1535@cindex Reindenting 1536 1537Indentation means the addition of whitespace at the beginning of lines 1538to reflect special syntactical constructs. This makes it easier to see 1539the structure of the document, and to catch errors such as a missing 1540closing brace. Thus, the indentation is done for precisely the same 1541reasons that you would indent ordinary computer programs. 1542 1543Indentation is done by @LaTeX{} environments and by @TeX{} groups, that 1544is the body of an environment is indented by the value of 1545@code{LaTeX-indent-level} (default 2). Also, items of an `itemize-like' 1546environment are indented by the value of @code{LaTeX-item-indent}, 1547default @minus{}2. (Items are identified with the help of 1548@code{LaTeX-item-regexp}.) If more environments are nested, they are 1549indented `accumulated' just like most programming languages usually are 1550seen indented in nested constructs. 1551@vindex LaTeX-indent-level 1552@vindex LaTeX-item-indent 1553@vindex LaTeX-item-regexp 1554 1555You can explicitely indent single lines, usually by pressing @key{TAB}, 1556or marked regions by calling @code{indent-region} on it. If you have 1557@code{auto-fill-mode} enabled and a line is broken while you type it, 1558Emacs automatically cares about the indentation in the following line. 1559If you want to have a similar behavior upon typing @key{RET}, you can 1560customize the variable @code{TeX-newline-function} and change the 1561default of @code{newline} which does no indentation to 1562@code{newline-and-indent} which indents the new line or 1563@code{reindent-then-newline-and-indent} which indents both the current 1564and the new line. 1565@vindex TeX-newline-function 1566 1567There are certain @LaTeX{} environments which should be indented in a 1568special way, like @samp{tabular} or @samp{verbatim}. Those environments 1569may be specified in the variable @code{LaTeX-indent-environment-list} 1570together with their special indentation functions. Taking the 1571@samp{verbatim} environment as an example you can see that 1572@code{current-indentation} is used as the indentation function. This 1573will stop @AUCTeX{} from doing any indentation in the environment if you 1574hit @key{TAB} for example. 1575@vindex LaTeX-indent-environment-list 1576 1577There are environments in @code{LaTeX-indent-environment-list} which do 1578not bring a special indentation function with them. This is due to the 1579fact that first the respective functions are not implemented yet and 1580second that filling will be disabled for the specified environments. 1581This shall prevent the source code from being messed up by accidently 1582filling those environments with the standard filling routine. If you 1583think that providing special filling routines for such environments 1584would be an appropriate and challenging task for you, you are invited to 1585contribute. (@xref{Filling}, for further information about the filling 1586functionality) 1587@vindex LaTeX-indent-environment-list 1588 1589The check for the indentation function may be enabled or disabled by 1590customizing the variable @code{LaTeX-indent-environment-check}. 1591@vindex LaTeX-indent-environment-check 1592 1593As a side note with regard to formatting special environments: Newer 1594Emacsen include @file{align.el} and therefore provide some support for 1595formatting @samp{tabular} and @samp{tabbing} environments with the 1596function @code{align-current} which will nicely align columns in the 1597source code. 1598 1599@AUCTeX{} is able to format commented parts of your code just as any 1600other part. This means @LaTeX{} environments and @TeX{} groups in 1601comments will be indented syntactically correct if the variable 1602@code{LaTeX-syntactic-comments} is set to t. If you disable it, 1603comments will be filled like normal text and no syntactic indentation 1604will be done. 1605@vindex LaTeX-syntactic-comments 1606 1607Following you will find a list of most commands and variables related 1608to indenting with a small summary in each case: 1609 1610@table @kbd 1611@item @key{TAB} 1612@kindex @key{TAB} 1613@findex LaTeX-indent-line 1614@code{LaTeX-indent-line} will indent the current line. 1615 1616@item @key{LFD} 1617@kindex @key{LFD} 1618@code{newline-and-indent} inserts a new line (much like @key{RET}) and 1619moves the cursor to an appropriate position by the left margin. 1620 1621Most keyboards nowadays lack a linefeed key and @kbd{C-j} may be tedious 1622to type. Therefore you can customize @AUCTeX{} to perform indentation 1623upon typing @key{RET} as well. The respective option is called 1624@code{TeX-newline-function}. 1625 1626@item C-j 1627@kindex C-j 1628Alias for @key{LFD} 1629@end table 1630 1631@defopt LaTeX-indent-environment-list 1632List of environments with special indentation. The second element in 1633each entry is the function to calculate the indentation level in 1634columns. 1635 1636The filling code currently cannot handle tabular-like environments 1637which will be completely messed-up if you try to format them. This is 1638why most of these environments are included in this customization 1639option without a special indentation function. This will prevent that 1640they get filled. 1641@end defopt 1642 1643@defopt LaTeX-indent-level 1644Number of spaces to add to the indentation for each @samp{\begin} not 1645matched by a @samp{\end}. 1646@end defopt 1647 1648@defopt LaTeX-item-indent 1649Number of spaces to add to the indentation for @samp{\item}'s in list 1650environments. 1651@end defopt 1652 1653@defopt TeX-brace-indent-level 1654Number of spaces to add to the indentation for each @samp{@{} not 1655matched by a @samp{@}}. 1656@end defopt 1657 1658@defopt LaTeX-syntactic-comments 1659If non-nil comments will be filled and indented according to @LaTeX{} 1660syntax. Otherwise they will be filled like normal text. 1661@end defopt 1662 1663@defopt TeX-newline-function 1664Used to specify the function which is called when @key{RET} is pressed. 1665This will normally be @code{newline} which simply inserts a new line. 1666In case you want to have @AUCTeX{} do indentation as well when you press 1667@key{RET}, use the built-in functions @code{newline-and-indent} or 1668@code{reindent-then-newline-and-indent}. The former inserts a new line 1669and indents the following line, i.e. it moves the cursor to the right 1670position and therefore acts as if you pressed @key{LFD}. The latter 1671function additionally indents the current line. If you choose 1672@samp{Other}, you can specify your own fancy function to be called when 1673@key{RET} is pressed. 1674@end defopt 1675 1676@AUCTeX{} treats by default @samp{\[...\]} math mode as a regular 1677environment and indents it accordingly. If you do not like such 1678behavior you only need to remove @code{\|\[} and @code{\|\]} from 1679@code{LaTeX-begin-regexp} and @code{LaTeX-end-regexp} variables 1680respectively. 1681 1682@node Filling 1683@section Filling 1684@cindex Filling 1685@cindex Formatting 1686@cindex Reformatting 1687@cindex Refilling 1688 1689Filling deals with the insertion of line breaks to prevent lines from 1690becoming wider than what is specified in @code{fill-column}. The 1691linebreaks will be inserted automatically if @code{auto-fill-mode} is 1692enabled. In this case the source is not only filled but also indented 1693automatically as you write it. 1694 1695@code{auto-fill-mode} can be enabled for @AUCTeX{} by calling 1696@code{turn-on-auto-fill} in one of the hooks @AUCTeX{} is running. 1697@xref{Modes and Hooks}. As an example, if you want to enable 1698@code{auto-fill-mode} in @code{LaTeX-mode}, put the following into your 1699init file: 1700 1701@lisp 1702(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill) 1703@end lisp 1704 1705You can manually fill explicitely marked regions, paragraphs, 1706environments, complete sections, or the whole buffer. (Note that manual 1707filling in @AUCTeX{} will indent the start of the region to be filled in 1708contrast to many other Emacs modes.) 1709 1710There are some syntactical constructs which are handled specially with 1711regard to filling. These are so-called code comments and paragraph 1712commands. 1713 1714Code comments are comments preceded by code or text in the same line. 1715Upon filling a region, code comments themselves will not get filled. 1716Filling is done from the start of the region to the line with the code 1717comment and continues after it. In order to prevent overfull lines in 1718the source code, a linebreak will be inserted before the last 1719non-comment word by default. This can be changed by customizing 1720@code{LaTeX-fill-break-before-code-comments}. If you have overfull 1721lines with code comments you can fill those explicitely by calling 1722@code{LaTeX-fill-paragraph} or pressing @kbd{M-q} with the cursor 1723positioned on them. This will add linebreaks in the comment and indent 1724subsequent comment lines to the column of the comment in the first line 1725of the code comment. In this special case @kbd{M-q} only acts on the 1726current line and not on the whole paragraph. 1727 1728Lines with @samp{\par} are treated similarly to code comments, 1729i.e. @samp{\par} will be treated as paragraph boundary which should not 1730be followed by other code or text. But it is not treated as a real 1731paragraph boundary like an empty line where filling a paragraph would 1732stop. 1733 1734Paragraph commands like @samp{\section} or @samp{\noindent} (the list of 1735commands is defined by @code{LaTeX-paragraph-commands}) are often to be 1736placed in their own line(s). This means they should not be consecuted 1737with any preceding or following adjacent lines of text. @AUCTeX{} will 1738prevent this from happening if you do not put any text except another 1739macro after the end of the last brace of the respective macro. If 1740there is other text after the macro, @AUCTeX{} regards this as a sign 1741that the macro is part of the following paragraph. 1742@vindex LaTeX-paragraph-commands 1743 1744Here are some examples: 1745 1746@example 1747\begin@{quote@} 1748 text text text text 1749@end example 1750 1751@example 1752\begin@{quote@}\label@{foo@} 1753 text text text text 1754@end example 1755 1756If you press @kbd{M-q} on the first line in both examples, nothing will 1757change. But if you write 1758 1759@example 1760\begin@{quote@} text 1761 text text text text 1762@end example 1763 1764and press @kbd{M-q}, you will get 1765 1766@example 1767\begin@{quote@} text text text text text 1768@end example 1769 1770Besides code comments and paragraph commands, another speciality of 1771filling in @AUCTeX{} involves commented lines. You should be aware that 1772these comments are treated as islands in the rest of the @LaTeX{} code 1773if syntactic filling is enabled. This means, for example, if you try to 1774fill an environment with @code{LaTeX-fill-environment} and have the 1775cursor placed on a commented line which does not have a surrounding 1776environment inside the comment, @AUCTeX{} will report an error. 1777@findex LaTeX-fill-environment 1778 1779The relevant commands and variables with regard to filling are: 1780 1781@table @kbd 1782@item C-c C-q C-p 1783@kindex C-c C-q C-p 1784@findex LaTeX-fill-paragraph 1785@code{LaTeX-fill-paragraph} will fill and indent the current paragraph. 1786 1787@item M-q 1788@kindex M-q 1789Alias for @kbd{C-c C-q C-p} 1790 1791@item C-c C-q C-e 1792@kindex C-c C-q C-e 1793@findex LaTeX-fill-environment 1794@code{LaTeX-fill-environment} will fill and indent the current 1795environment. This may e.g. be the `document' environment, in which case 1796the entire document will be formatted. 1797 1798@item C-c C-q C-s 1799@kindex C-c C-q C-s 1800@findex LaTeX-fill-section 1801@code{LaTeX-fill-section} will fill and indent the current logical 1802sectional unit. 1803 1804@item C-c C-q C-r 1805@kindex C-c C-q C-r 1806@findex LaTeX-fill-region 1807@code{LaTeX-fill-region} will fill and indent the current region. 1808@end table 1809 1810@defopt LaTeX-fill-break-at-separators 1811List of separators before or after which respectively linebreaks will 1812be inserted if they do not fit into one line. The separators can be 1813curly braces, brackets, switches for inline math (@samp{$}, @samp{\(}, 1814@samp{\)}) and switches for display math (@samp{\[}, @samp{\]}). Such 1815formatting can be useful to make macros and math more visible or to 1816prevent overfull lines in the @LaTeX{} source in case a package for 1817displaying formatted @TeX{} output inside the Emacs buffer, like 1818preview-latex, is used. 1819@end defopt 1820 1821@defopt LaTeX-fill-break-before-code-comments 1822Code comments are comments preceded by some other text in the same line. 1823When a paragraph containing such a comment is to be filled, the comment 1824start will be seen as a border after which no line breaks will be 1825inserted in the same line. If the option 1826@code{LaTeX-fill-break-before-code-comments} is enabled (which is the 1827default) and the comment does not fit into the line, a line break will 1828be inserted before the last non-comment word to minimize the chance that 1829the line becomes overfull. 1830@end defopt 1831 1832@defopt LaTeX-fill-excluded-macros 1833A list of macro names (without leading backslash) for whose arguments 1834filling should be disabled. Typically, you will want to add macros here 1835which have long, multi-line arguments. An example is 1836@code{\pgfplotstabletypeset} from the pgfplotstable package which is 1837used as shown in the following listing: 1838 1839@verbatim 1840\pgfplotstabletypeset[skip first n=4]{% 1841 XYZ Format, 1842 Version 1.234 1843 Date 2010-09-01 1844 @author Mustermann 1845 A B C 1846 1 2 3 1847 4 5 6 1848} 1849@end verbatim 1850@end defopt 1851 1852@node Display 1853@chapter Controlling Screen Display 1854 1855It is often desirable to get visual help of what markup code in a text 1856actually does without having to decipher it explicitly. For this 1857purpose Emacs and @AUCTeX{} provide font locking (also known as syntax 1858highlighting) which visually sets off markup code like macros or 1859environments by using different colors or fonts. For example text to be 1860typeset in italics can be displayed with an italic font in the editor as 1861well, or labels and references get their own distinct color. 1862 1863While font locking helps you grasp the purpose of markup code and 1864separate markup from content, the markup code can still be distracting. 1865@AUCTeX{} lets you hide those parts and show them again at request with 1866its built-in support for hiding macros and environments which we call 1867folding here. 1868 1869Besides folding of macros and environments, @AUCTeX{} provides support 1870for Emacs' outline mode which lets you narrow the buffer content to 1871certain sections of your text by hiding the parts not belonging to these 1872sections. 1873 1874Moreover, you can focus in a specific portion of the code by narrowing 1875the buffer to the desired region. @AUCTeX{} provides also functions to 1876narrow the buffer to the current group and to @LaTeX{} environments. 1877 1878@AUCTeX{} also provides some WYSIWYG features. 1879 1880First, you can customize @code{font-latex-fontify-script} to enable 1881special formatting of @code{^} superscripts and @code{_} subscripts 1882(@pxref{Font Locking}). 1883 1884Secondly, @AUCTeX{} with GNU Emacs 25 or later can display certain math 1885macros using Unicode characters, e.g., @code{\alpha} as α. This is 1886called prettification and is lightweight and reasonable robust 1887(@pxref{Prettifying}). 1888 1889A more accurate approach is provided by @previewlatex{}, a subsystem of 1890@AUCTeX{}, see @ref{Top,,Introduction,preview-latex,The @previewlatex{} 1891Manual}. This system uses @LaTeX{} to generate images that are then 1892displayed in your buffer. It is extremely accurate but can be fragile 1893with some packages (like older pgf versions). 1894 1895Please note that you can use prettification and @previewlatex{} together. 1896 1897@menu 1898* Font Locking:: Font Locking 1899* Folding:: Folding Macros and Environments 1900* Outline:: Outlining the Document 1901* Narrowing:: Restricting display and editing to a portion of the buffer 1902* Prettifying:: Displaying Greek and math macros as Unicode characters 1903@end menu 1904 1905@node Font Locking 1906@section Font Locking 1907@cindex Font Locking 1908@cindex Syntax Highlighting 1909@cindex font-latex 1910 1911Font locking is supposed to improve readability of the source code by 1912highlighting certain keywords with different colors or fonts. It 1913thereby lets you recognize the function of markup code to a certain 1914extent without having to read the markup command. For general 1915information on controlling font locking with Emacs' Font Lock mode, see 1916@ref{Font Lock, , Font Lock Mode, emacs, GNU Emacs Manual}. 1917 1918@defopt TeX-install-font-lock 1919Once font locking is enabled globally or for the major modes provided by 1920@AUCTeX{}, the font locking patterns and functionality of @fontlatex{} 1921are activated by default. You can switch to a different font locking 1922scheme or disable font locking in @AUCTeX{} by customizing the variable 1923@code{TeX-install-font-lock}. 1924 1925Besides @fontlatex{} @AUCTeX{} ships with a scheme which is derived 1926from Emacs' default @LaTeX{} mode and activated by choosing 1927@code{tex-font-setup}. Be aware that this scheme is not coupled with 1928@AUCTeX{}'s style system and not the focus of development. Therefore 1929and due to @fontlatex{} being much more feature-rich the following 1930explanations will only cover @fontlatex{}. 1931 1932In case you want to hook in your own fontification scheme, you can 1933choose @code{other} and insert the name of the function which sets up 1934your font locking patterns. If you want to disable fontification in 1935@AUCTeX{} completely, choose @code{ignore}. 1936@end defopt 1937 1938@fontlatex{} provides many options for customization which are 1939accessible with @kbd{M-x customize-group RET font-latex RET}. For this 1940description the various options are explained in conceptional groups. 1941 1942@menu 1943* Fontification of macros:: Fontification of macros 1944* Fontification of quotes:: Fontification of quotes 1945* Fontification of math:: Fontification of math constructs 1946* Verbatim content:: Verbatim macros and environments 1947* Faces:: Faces used by font-latex 1948* Known problems:: Known fontification problems 1949@end menu 1950 1951@node Fontification of macros 1952@subsection Fontification of macros 1953 1954Highlighting of macros can be customized by adapting keyword lists which 1955can be found in the customization group @code{font-latex-keywords}. 1956 1957Three types of macros can be handled differently with respect to 1958fontification: 1959 1960@enumerate 1961@item 1962Commands of the form @samp{\foo[bar]@{baz@}} which consist of the macro 1963itself, optional arguments in square brackets and mandatory arguments in 1964curly braces. For the command itself the face 1965@code{font-lock-keyword-face} will be used and for the optional 1966arguments the face @code{font-lock-variable-name-face}. The face 1967applied to the mandatory argument depends on the macro class represented 1968by the respective built-in variables. 1969@item 1970Declaration macros of the form @samp{@{\foo text@}} which consist of the 1971macro which may be enclosed in a @TeX{} group together with text to be 1972affected by the macro. In case a @TeX{} group is present, the macro 1973will get the face @code{font-lock-keyword-face} and the text will get 1974the face configured for the respective macro class. If no @TeX{} group 1975is present, the latter face will be applied to the macro itself. 1976@item 1977Simple macros of the form @samp{\foo} which do not have any arguments or 1978groupings. The respective face will be applied to the macro itself. 1979@end enumerate 1980 1981Customization variables for @samp{\foo[bar]@{baz@}} type macros allow 1982both the macro name and the sequence of arguments to be specified. The 1983latter is done with a string which can contain the characters 1984@table @samp 1985@item * 1986indicating the existence of a starred variant for the macro, 1987@item [ 1988for optional arguments in brackets, 1989@item @{ 1990for mandatory arguments in braces, 1991@item \ 1992for mandatory arguments consisting of a single macro and 1993@item | 1994as a prefix indicating that two alternatives are following. 1995@end table 1996For example the specifier for @samp{\documentclass} would be @samp{[@{} 1997because the macro has one optional followed by one mandatory argument. 1998The specifier for @samp{\newcommand} would be @samp{*|@{\[[@{} because 1999there is a starred variant, the mandatory argument following the macro 2000name can be a macro or a @TeX{} group which can be followed by two 2001optional arguments and the last token is a mandatory argument in braces. 2002 2003Customization variables for the @samp{@{\foo text@}} and @samp{\foo} 2004types are simple lists of strings where each entry is a macro name 2005(without the leading backslash). 2006 2007@subheading General macro classes 2008 2009@fontlatex{} provides keyword lists for different macro classes which 2010are described in the following table: 2011 2012@vindex font-latex-match-function-keywords 2013@vindex font-latex-match-reference-keywords 2014@vindex font-latex-match-textual-keywords 2015@vindex font-latex-match-variable-keywords 2016@vindex font-latex-match-warning-keywords 2017@table @code 2018@item font-latex-match-function-keywords 2019Keywords for macros defining or related to functions, like 2020@samp{\newcommand}.@* 2021Type: @samp{\macro[...]@{...@}}@* 2022Face: @code{font-lock-function-name-face} 2023 2024@item font-latex-match-reference-keywords 2025Keywords for macros defining or related to references, like 2026@samp{\ref}.@* 2027Type: @samp{\macro[...]@{...@}}@* 2028Face: @code{font-lock-constant-face} 2029 2030@item font-latex-match-textual-keywords 2031Keywords for macros specifying textual content, like @samp{\caption}.@* 2032Type: @samp{\macro[...]@{...@}}@* 2033Face: @code{font-lock-type-face} 2034 2035@item font-latex-match-variable-keywords 2036Keywords for macros defining or related to variables, like 2037@samp{\setlength}.@* 2038Type: @samp{\macro[...]@{...@}}@* 2039Face: @code{font-lock-variable-name-face} 2040 2041@item font-latex-match-warning-keywords 2042Keywords for important macros, e.g. affecting line or page break, like 2043@samp{\clearpage}.@* 2044Type: @samp{\macro}@* 2045Face: @code{font-latex-warning-face} 2046@end table 2047 2048@subheading Sectioning commands 2049@cindex Sectioning commands, fontification of 2050 2051Sectioning commands are macros like @samp{\chapter} or @samp{\section}. 2052For these commands there are two fontification schemes which may be 2053selected by customizing the variable @code{font-latex-fontify-sectioning}. 2054 2055@defopt font-latex-fontify-sectioning 2056@c Is @vindex correct? 2057@vindex font-latex-sectioning-0-face 2058@vindex font-latex-sectioning-1-face 2059@vindex font-latex-sectioning-2-face 2060@vindex font-latex-sectioning-3-face 2061@vindex font-latex-sectioning-4-face 2062@vindex font-latex-sectioning-5-face 2063Per default sectioning commands will be shown in a larger, proportional 2064font, which corresponds to a number for this variable. The font size 2065varies with the sectioning level, e.g. @samp{\part} 2066(@code{font-latex-sectioning-0-face}) has a larger font than 2067@samp{\paragraph} (@code{font-latex-sectioning-5-face}). Typically, 2068values from 1.05 to 1.3 for @code{font-latex-fontify-sectioning} give 2069best results, depending on your font setup. If you rather like to use 2070the base font and a different color, set the variable to the symbol 2071@samp{color}. In this case the face @code{font-lock-type-face} will be 2072used to fontify the argument of the sectioning commands. 2073@end defopt 2074 2075@vindex font-latex-match-sectioning-0-keywords 2076@vindex font-latex-match-sectioning-1-keywords 2077@vindex font-latex-match-sectioning-2-keywords 2078@vindex font-latex-match-sectioning-3-keywords 2079@vindex font-latex-match-sectioning-4-keywords 2080@vindex font-latex-match-sectioning-5-keywords 2081You can make @fontlatex{} aware of your own sectioning commands be 2082adding them to the keyword lists: 2083@code{font-latex-match-sectioning-0-keywords} 2084(@code{font-latex-sectioning-0-face}) @dots{} 2085@code{font-latex-match-sectioning-5-keywords} 2086(@code{font-latex-sectioning-5-face}). 2087 2088@vindex font-latex-slide-title-face 2089@vindex font-latex-match-slide-title-keywords 2090Related to sectioning there is special support for slide titles which 2091may be fontified with the face @code{font-latex-slide-title-face}. You 2092can add macros which should appear in this face by customizing the 2093variable @code{font-latex-match-slide-title-keywords}. 2094 2095@subheading Commands for changing fonts 2096 2097@LaTeX{} provides various macros for changing fonts or font attributes. 2098For example, you can select an italic font with @samp{\textit@{...@}} or 2099bold with @samp{\textbf@{...@}}. An alternative way to specify these 2100fonts is to use special macros in @TeX{} groups, like @samp{@{\itshape 2101...@}} for italics and @samp{@{\bfseries ...@}} for bold. As mentioned 2102above, we call the former variants commands and the latter 2103declarations. 2104 2105Besides the macros for changing fonts provided by @LaTeX{} there is an 2106infinite number of other macros---either defined by yourself for logical 2107markup or defined by macro packages---which affect the font in the 2108typeset text. While @LaTeX{}'s built-in macros and macros of packages 2109known by @AUCTeX{} are already handled by @fontlatex{}, different 2110keyword lists per type style and macro type are provided for entering 2111your own macros which are listed in the table below. 2112 2113@vindex font-latex-match-bold-command-keywords 2114@vindex font-latex-match-italic-command-keywords 2115@vindex font-latex-match-math-command-keywords 2116@vindex font-latex-match-type-command-keywords 2117@vindex font-latex-match-bold-declaration-keywords 2118@vindex font-latex-match-italic-declaration-keywords 2119@vindex font-latex-match-type-declaration-keywords 2120@table @code 2121@item font-latex-match-bold-command-keywords 2122Keywords for commands specifying a bold type style.@* 2123Face: @code{font-latex-bold-face} 2124@item font-latex-match-italic-command-keywords 2125Keywords for commands specifying an italic font.@* 2126Face: @code{font-latex-italic-face} 2127@item font-latex-match-math-command-keywords 2128Keywords for commands specifying a math font.@* 2129Face: @code{font-latex-math-face} 2130@item font-latex-match-type-command-keywords 2131Keywords for commands specifying a typewriter font.@* 2132Face: @code{font-lock-type-face} 2133@item font-latex-match-bold-declaration-keywords 2134Keywords for declarations specifying a bold type style.@* 2135Face: @code{font-latex-bold-face} 2136@item font-latex-match-italic-declaration-keywords 2137Keywords for declarations specifying an italic font.@* 2138Face: @code{font-latex-italic-face} 2139@item font-latex-match-type-declaration-keywords 2140Keywords for declarations specifying a typewriter font.@* 2141Face: @code{font-latex-type-face} 2142@end table 2143 2144@subheading Deactivating defaults of built-in keyword classes 2145 2146@vindex font-latex-deactivated-keyword-classes 2147@fontlatex{} ships with predefined lists of keywords for the classes 2148described above. You can disable these defaults per class by 2149customizing the variable @code{font-latex-deactivated-keyword-classes}. 2150This is a list of strings for keyword classes to be deactivated. Valid 2151entries are "warning", "variable", "biblatexnoarg", "biblatex", 2152"reference", "function" , "sectioning-0", "sectioning-1", 2153"sectioning-2", "sectioning-3", "sectioning-4", "sectioning-5", 2154"slide-title", "textual", "bold-command", "italic-command", 2155"math-command", "type-command", "bold-declaration", 2156"italic-declaration", "type-declaration". 2157 2158You can also get rid of certain keywords only. For example if you want 2159to remove highlighting of footnotes as references you can put the 2160following stanza into your init file: 2161 2162@lisp 2163(eval-after-load "font-latex" 2164 '(setq-default 2165 font-latex-match-reference-keywords-local 2166 (remove (assoc-string "footnote" 2167 font-latex-match-reference-keywords-local) 2168 font-latex-match-reference-keywords-local))) 2169@end lisp 2170 2171But note that this means fiddling with @fontlatex{}'s internals and is 2172not guaranteed to work in future versions of @fontlatex{}. 2173 2174@subheading User-defined keyword classes 2175 2176In case the customization options explained above do not suffice for 2177your needs, you can specify your own keyword classes by customizing the 2178variable @code{font-latex-user-keyword-classes}. 2179 2180@defopt font-latex-user-keyword-classes 2181Every keyword class consists of four parts, a name, a list of keywords, 2182a face and a specifier for the type of macros to be highlighted. 2183 2184When adding new entries, you have to use unique values for the class 2185names, i.e. they must not clash with names of the built-in keyword 2186classes or other names given by you. Additionally the names must not 2187contain spaces. 2188 2189The list of keywords defines which commands and declarations should be 2190covered by the keyword class. A keyword can either be a simple command 2191name omitting the leading backslash or a list consisting of the command 2192name and a string specifying the sequence of arguments for the command. 2193 2194The face argument can either be an existing face or face attributes 2195made by you. 2196 2197There are three alternatives for the type of keywords---``Command with 2198arguments'', ``Declaration inside @TeX{} group'' and ``Command without 2199arguments''---which correspond with the macro types explained above. 2200@end defopt 2201 2202@node Fontification of quotes 2203@subsection Fontification of quotes 2204@cindex Quotes, fontification of 2205 2206Text in quotation marks is displayed with the face 2207@code{font-latex-string-face}. Besides the various forms of opening and 2208closing double and single quotation marks, so-called guillemets (<<, >>) 2209can be used for quoting. Because there are two styles of using 2210them---French style: << text >>; German style: >>text<<---you can 2211customize the variable @code{font-latex-quotes} to tell @fontlatex{} 2212which type you are using if the correct value cannot be derived from 2213document properties. 2214 2215@defopt font-latex-quotes 2216The default value of @code{font-latex-quotes} is @samp{auto} which means 2217that @fontlatex{} will try to derive the correct type of quotation mark 2218matching from document properties like the language option supplied to 2219the babel @LaTeX{} package. 2220 2221If the automatic detection fails for you and you mostly use one specific 2222style you can set it to a specific language-dependent value as well. 2223Set the value to @samp{german} if you are using >>German quotes<< and to 2224@samp{french} if you are using << French quotes >>. @fontlatex{} will 2225recognize the different ways these quotes can be given in your source 2226code, i.e. (@samp{"<}, @samp{">}), (@samp{<<}, @samp{>>}) and the 2227respective 8-bit variants. 2228 2229If you set @code{font-latex-quotes} to nil, quoted content will not be 2230fontified. 2231@end defopt 2232 2233 2234@node Fontification of math 2235@subsection Fontification of mathematical constructs 2236@cindex Math, fontification of 2237@cindex Subscript, fontification of 2238@cindex Superscript, fontification of 2239 2240@vindex font-latex-match-math-command-keywords 2241@vindex font-latex-math-environments 2242In @LaTeX{} mathematics can be indicated by a variety of different 2243methods: toggles (like dollar signs), macros and environments. Math 2244constructs known by @fontlatex{} are displayed with the face 2245@code{font-latex-math-face}. Support for dollar signs and shorthands 2246like @samp{\(...\)} or @samp{\[...\]} is built-in and not customizable. 2247Support for other math macros and environments can be adapted by 2248customizing the variables @code{font-latex-match-math-command-keywords} 2249and @code{font-latex-math-environments} respectively. 2250 2251In order to make math constructs more readable, @fontlatex{} displays 2252subscript and superscript parts in a smaller font and raised or lowered 2253respectively. This fontification feature can be controlled with the 2254variables @code{font-latex-fontify-script} and 2255@code{font-latex-script-display}. 2256 2257@defopt font-latex-fontify-script 2258If non-nil, fontify subscript and superscript strings. Concretely, this 2259means that the scripts are raised or lowered. 2260 2261Another possiblity is setting this variable to the symbol 2262@code{multi-level}. In this case, in a formula @i{x^@{y^z@}}, @i{y} is 2263raised above and smaller than @i{x}, and @i{z} is raised above and 2264smaller than @i{y}. With many script levels, the text might become too 2265small to be readable. (See @code{font-latex-fontify-script-max-level} 2266below.) 2267 2268Lastly, you can set this variable to @code{invisible} whose behavior is 2269like @code{multi-level}, and in addition the super-/subscript characters 2270@i{^} and @i{_} are not displayed. 2271@end defopt 2272 2273 2274@defopt font-latex-fontify-script-max-level 2275Maximum scriptification level for which script faces are applied. 2276 2277The faces @code{font-latex-superscript-face} and 2278@code{font-latex-subscript-face} define custom @code{:height} values < 22791.0. Therefore, scripts are displayed with a slightly smaller font than 2280normal math text. If @code{font-latex-fontify-script} is 2281@code{multi-level} or @code{invisible}, the font size becomes too small 2282to be readable after a few levels. This option allows to specify the 2283maximum level after which the size of the script text won’t be shrunken 2284anymore. 2285 2286For example, in the expression @i{x^@{y^@{z^a_b@}@}}, @i{x} has 2287scriptification level 0, @i{y} has level 1, @i{z} has level 2, and both 2288@i{a} and @i{b} have scriptification level 3. 2289 2290If @code{font-latex-fontify-script-max-level} was 2, then @i{z}, @i{a}, 2291and @i{b} would have the same font size. If it was 3 or more, then 2292@i{a} and @i{b} were smaller than @i{z} just in the same way as @i{z} is 2293smaller than @i{y} and @i{y} is smaller than @i{x}. 2294@end defopt 2295 2296The script characters @samp{^} and @samp{_} themselves are also 2297fontified with an own face named @code{font-latex-script-char-face}. 2298 2299@defopt font-latex-script-display 2300Display specification for subscript and superscript content. The car is 2301used for subscript, the cdr is used for superscript. The feature is 2302implemented using so-called display properties. For information on what 2303exactly to specify for the values, see @ref{Other Display Specs, , Other 2304Display Specifications, elisp, GNU Emacs Lisp Reference Manual}. 2305@end defopt 2306 2307@node Verbatim content 2308@subsection Verbatim macros and environments 2309@cindex Verbatim, fontification of 2310 2311Usually it is not desirable to have content to be typeset verbatim 2312highlighted according to @LaTeX{} syntax. Therefore this content will 2313be fontified uniformly with the face @code{font-latex-verbatim-face}. 2314 2315@vindex LaTeX-verbatim-macros-with-delims 2316@vindex LaTeX-verbatim-macros-with-braces 2317@vindex LaTeX-verbatim-environments 2318@fontlatex{} differentiates three different types of verbatim 2319constructs for fontification. Macros with special characters like | as 2320delimiters, macros with braces, and environments. Which macros and 2321environments are recognized is controlled by the variables 2322@code{LaTeX-verbatim-macros-with-delims}, 2323@code{LaTeX-verbatim-macros-with-braces}, and 2324@code{LaTeX-verbatim-environments} respectively. 2325 2326@node Faces 2327@subsection Faces used by @fontlatex{} 2328@cindex Faces 2329 2330In case you want to change the colors and fonts used by @fontlatex{} 2331please refer to the faces mentioned in the explanations above and use 2332@kbd{M-x customize-face RET <face> RET}. All faces defined by 2333@fontlatex{} are accessible through a customization group by typing 2334@kbd{M-x customize-group RET font-latex-highlighting-faces RET}. 2335 2336@node Known problems 2337@subsection Known fontification problems 2338@cindex Dollar signs, color bleed with 2339@cindex Math, fontification problems with 2340 2341In certain cases the fontification machinery fails to interpret buffer 2342contents correctly. This can lead to color bleed, i.e. large parts of a 2343buffer get fontified with an inappropriate face. A typical situation 2344for this to happen is the use of a dollar sign (@samp{$}) in a verbatim 2345macro or environment. If @fontlatex{} is not aware of the verbatim 2346construct, it assumes the dollar sign to be a toggle for mathematics and 2347fontifies the following buffer content with the respective face until it 2348finds a closing dollar sign or till the end of the buffer. 2349 2350As a remedy you can make the verbatim construct known to @fontlatex{}, 2351@pxref{Verbatim content}. If this is not possible, you can insert a 2352commented dollar sign (@samp{%$}) at the next suitable end of line as a 2353quick workaround. 2354@c As a last resort one can set `font-lock-keywords-only', but we should 2355@c probably not advise users to do this. 2356 2357 2358@node Folding 2359@section Folding Macros and Environments 2360@cindex Outlining 2361@cindex Folding 2362@cindex Reveal 2363@cindex Auto-Reveal 2364@cindex Hide Macros 2365 2366A popular complaint about markup languages like @TeX{} and @LaTeX{} is 2367that there is too much clutter in the source text and that one cannot 2368focus well on the content. There are macros where you are only 2369interested in the content they are enclosing, like font specifiers where 2370the content might already be fontified in a special way by font locking. 2371Or macros the content of which you only want to see when actually 2372editing it, like footnotes or citations. Similarly you might find 2373certain environments or comments distracting when trying to concentrate 2374on the body of your document. 2375 2376With @AUCTeX{}'s folding functionality you can collapse those items and 2377replace them by a fixed string, the content of one of their arguments, 2378or a mixture of both. If you want to make the original text visible 2379again in order to view or edit it, move point sideways onto the 2380placeholder (also called display string) or left-click with the mouse 2381pointer on it. (The latter is currently only supported on Emacs.) The 2382macro or environment will unfold automatically, stay open as long as 2383point is inside of it and collapse again once you move point out of it. 2384(Note that folding of environments currently does not work in every 2385@AUCTeX{} mode.) 2386 2387In order to use this feature, you have to activate @code{TeX-fold-mode} 2388which will activate the auto-reveal feature and the necessary commands 2389to hide and show macros and environments. You can activate the mode in 2390a certain buffer by typing the command @kbd{M-x TeX-fold-mode RET} or 2391using the keyboard shortcut @kbd{C-c C-o C-f}. If you want to use it 2392every time you edit a @LaTeX{} document, add it to a hook: 2393@findex TeX-fold-mode 2394@kindex C-c C-o C-f 2395 2396@lisp 2397(add-hook 'LaTeX-mode-hook (lambda () 2398 (TeX-fold-mode 1))) 2399@end lisp 2400 2401If it should be activated in all @AUCTeX{} modes, use 2402@code{TeX-mode-hook} instead of @code{LaTeX-mode-hook}. 2403 2404Once the mode is active there are several commands available to hide 2405and show macros, environments and comments: 2406 2407@deffn Command TeX-fold-buffer 2408@kindex C-c C-o C-b 2409(@kbd{C-c C-o C-b}) Hide all foldable items in the current buffer 2410according to the setting of @code{TeX-fold-type-list}. 2411 2412If you want to have this done automatically every time you open a file, 2413add it to a hook and make sure the function is called after font locking 2414is set up for the buffer. The following code should accomplish this: 2415 2416@lisp 2417(add-hook 'find-file-hook 'TeX-fold-buffer t) 2418@end lisp 2419 2420The command can be used any time to refresh the whole buffer and fold 2421any new macros and environments which were inserted after the last 2422invocation of the command. 2423@end deffn 2424 2425@defopt TeX-fold-type-list 2426List of symbols determining the item classes to consider for folding. 2427This can be macros, environments and comments. Per default only macros 2428and environments are folded. 2429@end defopt 2430 2431@defopt TeX-fold-force-fontify 2432In order for all folded content to get the right faces, the whole buffer 2433has to be fontified before folding is carried out. 2434@code{TeX-fold-buffer} therefore will force fontification of unfontified 2435regions. As this will prolong the time folding takes, you can prevent 2436forced fontification by customizing the variable 2437@code{TeX-fold-force-fontify}. 2438@end defopt 2439 2440@defopt TeX-fold-auto 2441By default, a macro inserted with @code{TeX-insert-macro} (@kbd{C-c 2442C-m}) will not be folded. Set this variable to a non-nil value to 2443aumatically fold macros as soon as they are inserted. 2444@end defopt 2445 2446@defopt TeX-fold-preserve-comments 2447By default items found in comments will be folded. If your comments 2448often contain unfinished code this might lead to problems. Give this 2449variable a non-nil value and foldable items in your comments will be 2450left alone. 2451@end defopt 2452 2453@defopt TeX-fold-unfold-around-mark 2454When this variable is non-nil and there is an active regione, text 2455around the mark will be kept unfolded. 2456@end defopt 2457 2458@deffn Command TeX-fold-region 2459@kindex C-c C-o C-r 2460(@kbd{C-c C-o C-r}) Hide all configured macros in the marked region. 2461@end deffn 2462 2463@deffn Command TeX-fold-paragraph 2464@kindex C-c C-o C-p 2465(@kbd{C-c C-o C-p}) Hide all configured macros in the paragraph 2466containing point. 2467@end deffn 2468 2469@deffn Command TeX-fold-macro 2470@kindex C-c C-o C-m 2471(@kbd{C-c C-o C-m}) Hide the macro on which point currently is located. 2472If the name of the macro is found in @code{TeX-fold-macro-spec-list}, 2473the respective display string will be shown instead. If it is not 2474found, the name of the macro in sqare brackets or the default string for 2475unspecified macros (@code{TeX-fold-unspec-macro-display-string}) will be 2476shown, depending on the value of the variable 2477@code{TeX-fold-unspec-use-name}. 2478@end deffn 2479 2480@deffn Command TeX-fold-env 2481@kindex C-c C-o C-e 2482(@kbd{C-c C-o C-e}) Hide the environment on which point currently is 2483located. The behavior regarding the display string is analogous to 2484@code{TeX-fold-macro} and determined by the variables 2485@code{TeX-fold-env-spec-list} and 2486@code{TeX-fold-unspec-env-display-string} respectively. 2487@end deffn 2488 2489@deffn Command TeX-fold-math 2490Hide the math macro on which point currently is located. If the name of 2491the macro is found in @code{TeX-fold-math-spec-list}, the respective 2492display string will be shown instead. If it is not found, the name of 2493the macro in sqare brackets or the default string for unspecified macros 2494(@code{TeX-fold-unspec-macro-display-string}) will be shown, depending 2495on the value of the variable @code{TeX-fold-unspec-use-name}. 2496@end deffn 2497 2498@deffn Command TeX-fold-comment 2499@kindex C-c C-o C-c 2500(@kbd{C-c C-o C-c}) Hide the comment point is located on. 2501@end deffn 2502 2503@deffn Command TeX-fold-clearout-buffer 2504@kindex C-c C-o b 2505(@kbd{C-c C-o b}) Permanently unfold all macros and environments in the 2506current buffer. 2507@end deffn 2508 2509@deffn Command TeX-fold-clearout-region 2510@kindex C-c C-o r 2511(@kbd{C-c C-o r}) Permanently unfold all macros and environments in the 2512marked region. 2513@end deffn 2514 2515@deffn Command TeX-fold-clearout-paragraph 2516@kindex C-c C-o p 2517(@kbd{C-c C-o p}) Permanently unfold all macros and environments in the 2518paragraph containing point. 2519@end deffn 2520 2521@deffn Command TeX-fold-clearout-item 2522@kindex C-c C-o i 2523(@kbd{C-c C-o i}) Permanently show the macro or environment on which 2524point currently is located. In contrast to temporarily opening the 2525macro when point is moved sideways onto it, the macro will be 2526permanently unfolded and will not collapse again once point is leaving 2527it. 2528@end deffn 2529 2530@deffn Command TeX-fold-dwim 2531@kindex C-c C-o C-o 2532(@kbd{C-c C-o C-o}) Hide or show items according to the current context. 2533If there is folded content, unfold it. If there is a marked region, 2534fold all configured content in this region. If there is no folded 2535content but a macro or environment, fold it. 2536@end deffn 2537 2538@vindex TeX-fold-command-prefix 2539In case you want to use a different prefix than @kbd{C-c C-o} for these 2540commands you can customize the variable @code{TeX-fold-command-prefix}. 2541(Note that this will not change the key binding for activating the 2542mode.) 2543 2544The commands above will only take macros or environments into 2545consideration which are specified in the variables 2546@code{TeX-fold-macro-spec-list} or @code{TeX-fold-env-spec-list} 2547respectively. 2548 2549@defopt TeX-fold-macro-spec-list 2550List of replacement specifiers and macros to fold. The specifier can be 2551a string, an integer or a function symbol. 2552 2553If you specify a string, it will be used as a display replacement for 2554the whole macro. Numbers in braces, brackets, parens or angle brackets 2555will be replaced by the respective macro argument. For example 2556@samp{@{1@}} will be replaced by the first mandatory argument of the 2557macro. One can also define alternatives within the specifier which are 2558used if an argument is not found. Alternatives are separated by 2559@samp{||}. They are most useful with optional arguments. As an 2560example, the default specifier for @samp{\item} is @samp{[1]:||*} which 2561means that if there is an optional argument, its value is shown followed 2562by a colon. If there is no optional argument, only an asterisk is used 2563as the display string. 2564 2565If you specify a number as the first element, the content of the 2566respective mandatory argument of a @LaTeX{} macro will be used as the 2567placeholder. 2568 2569If the first element is a function symbol, the function will be called 2570with all mandatory arguments of the macro and the result of the function 2571call will be used as a replacement for the macro. 2572 2573The placeholder is made by copying the text from the buffer together with 2574its properties, i.e. its face as well. If fontification has not 2575happened when this is done (e.g. because of lazy font locking) the 2576intended fontification will not show up. As a workaround you can leave 2577Emacs idle a few seconds and wait for stealth font locking to finish 2578before you fold the buffer. Or you just re-fold the buffer with 2579@code{TeX-fold-buffer} when you notice a wrong fontification. 2580@end defopt 2581 2582@defopt TeX-fold-env-spec-list 2583List of display strings or argument numbers and environments to fold. 2584Argument numbers refer to the @samp{\begin} statement. That means if 2585you have e.g. @samp{\begin@{tabularx@}@{\linewidth@}@{XXX@} ... 2586\end@{tabularx@}} and specify 3 as the argument number, the resulting 2587display string will be ``XXX''. 2588@end defopt 2589 2590@defopt TeX-fold-math-spec-list 2591List of display strings and math macros to fold. 2592@end defopt 2593 2594@vindex LaTeX-fold-macro-spec-list 2595@vindex LaTeX-fold-env-spec-list 2596@vindex LaTeX-fold-math-spec-list 2597The variables @code{TeX-fold-macro-spec-list}, 2598@code{TeX-fold-env-spec-list}, and @code{TeX-fold-math-spec-list} apply 2599to any @AUCTeX{} mode. If you want to make settings which are only 2600applied to @LaTeX{} mode, you can use the mode-specific variables 2601@code{LaTeX-fold-macro-spec-list}, @code{LaTeX-fold-env-spec-list}, and 2602@code{LaTeX-fold-math-spec-list} 2603 2604@defopt TeX-fold-unspec-macro-display-string 2605Default display string for macros which are not specified in 2606@code{TeX-fold-macro-spec-list}. 2607@end defopt 2608 2609@defopt TeX-fold-unspec-env-display-string 2610Default display string for environments which are not specified in 2611@code{TeX-fold-env-spec-list}. 2612@end defopt 2613 2614@defopt TeX-fold-unspec-use-name 2615If non-nil the name of the macro or environment surrounded by square 2616brackets is used as display string, otherwise the defaults specified in 2617@code{TeX-fold-unspec-macro-display-string} or 2618@code{TeX-fold-unspec-env-display-string} respectively. 2619@end defopt 2620 2621When you hover with the mouse pointer over folded content, its original 2622text will be shown in a tooltip or the echo area depending on Tooltip 2623mode being activate. In order to avoid exorbitantly big tooltips and to 2624cater for the limited space in the echo area the content will be cropped 2625after a certain amount of characters defined by the variable 2626@code{TeX-fold-help-echo-max-length}. 2627 2628@defopt TeX-fold-help-echo-max-length 2629Maximum length of original text displayed in a tooltip or the echo area 2630for folded content. Set it to zero in order to disable this feature. 2631@end defopt 2632 2633 2634@node Outline 2635@section Outlining the Document 2636@cindex Outlining 2637@cindex Headers 2638@cindex Sections 2639@cindex Overview 2640@cindex Folding 2641 2642@AUCTeX{} supports the standard outline minor mode using 2643@LaTeX{}/@ConTeXt{} sectioning commands as header lines. @xref{Outline 2644Mode, , Outline Mode, emacs, GNU Emacs Manual}. 2645 2646You can add your own headings by setting the variable 2647@code{TeX-outline-extra}. 2648 2649@defvar TeX-outline-extra 2650List of extra @TeX{} outline levels. 2651 2652Each element is a list with two entries. The first entry is the regular 2653expression matching a header, and the second is the level of the header. 2654A @samp{^} is automatically prepended to the regular expressions in the 2655list, so they must match text at the beginning of the line. 2656 2657See @code{LaTeX-section-list} or @code{ConTeXt-INTERFACE-section-list} 2658for existing header levels. 2659@end defvar 2660 2661The following example add @samp{\item} and @samp{\bibliography} headers, 2662with @samp{\bibliography} at the same outline level as @samp{\section}, 2663and @samp{\item} being below @samp{\subparagraph}. 2664 2665@lisp 2666(setq TeX-outline-extra 2667 '(("[ \t]*\\\\\\(bib\\)?item\\b" 7) 2668 ("\\\\bibliography\\b" 2))) 2669@end lisp 2670 2671You may want to check out the unbundled @file{out-xtra} package for even 2672better outline support. It is available from your favorite emacs lisp 2673archive. 2674 2675@node Narrowing 2676@section Narrowing 2677 2678Sometimes you want to focus your attention to a limited region of the 2679code. You can do that by restricting the text addressable by editing 2680commands and hiding the rest of the buffer with the narrowing functions, 2681@pxref{Narrowing,,,emacs,GNU Emacs Manual}. In addition, AUCTeX 2682provides a couple of other commands to narrow the buffer to a group, 2683i.e. a region enclosed in a pair of curly braces, and to @LaTeX{} 2684environments. 2685 2686@deffn Command TeX-narrow-to-group 2687@kindex C-x n g 2688(@kbd{C-x n g}) Make text outside current group invisible. 2689@end deffn 2690 2691@deffn Command LaTeX-narrow-to-environment @var{count} 2692@kindex C-x n e 2693(@kbd{C-x n e}) Make text outside current environment invisible. With 2694optional argument @var{count} keep visible that number of enclosing 2695environmens. 2696@end deffn 2697 2698Like other standard narrowing functions, the above commands are 2699disabled. Attempting to use them asks for confirmation and gives you 2700the option of enabling them; if you enable the commands, confirmation 2701will no longer be required for them. 2702 2703@node Prettifying 2704@section Prettifying 2705 2706Emacs 25 is able to prettify symbols in programming language buffers, 2707@pxref{Misc for Programs,,,emacs,GNU Emacs Manual}. The canonical 2708example is to display @code{(lambda () ...)} as @code{(λ () ...)} in 2709Lisp buffers. 2710 2711@AUCTeX{} can use this feature in order to display certain math macros 2712and greek letters using their Unicode representation, too. For example, 2713the @TeX{} code @code{\alpha \times \beta} will be displayed as @code{α 2714× β}. When point is on one of the characters, it'll be unprettified 2715automatically, meaning you see the verbatim text again. For this 2716behaviour however you need to set 2717@code{prettify-symbols-unprettify-at-point} to t or @code{right-edge} 2718which will unprettify the symbol when point moves into or near it. 2719 2720To enable prettification in @AUCTeX{}, simply add 2721@code{prettify-symbols-mode} to @code{TeX-mode-hook}. If you enabled 2722prettification globally with @code{global-prettify-symbols-mode}, then 2723it's automatically enabled in @AUCTeX{}, too. 2724 2725You can also add custom symbol unicode-character pairs for 2726prettification by adding to @code{tex--prettify-symbols-alist}. Note 2727that this variable is part of Emacs' stock @code{tex-mode.el} and used 2728by that and @AUCTeX{}. 2729 2730@node Processing 2731@chapter Starting Processors, Viewers and Other Programs 2732 2733The most powerful features of @AUCTeX{} may be those allowing you to run 2734@TeX{}, @LaTeX{}, @ConTeXt{} and other external commands like Bib@TeX{} 2735and @code{makeindex} from within Emacs, viewing and printing the 2736results, and moreover allowing you to @emph{debug} your documents. 2737 2738@cindex tool bar, toolbar 2739@vindex LaTeX-enable-toolbar 2740@vindex plain-TeX-enable-toolbar 2741@AUCTeX{} comes with a special tool bar for @TeX{} and @LaTeX{} which 2742provides buttons for the most important commands. You can enable or 2743disable it by customizing the options @code{plain-TeX-enable-toolbar} 2744and @code{LaTeX-enable-toolbar} in the @code{TeX-tool-bar} customization 2745group. 2746 2747@menu 2748* Commands:: Invoking external commands. 2749* Viewing:: Invoking external viewers. 2750* Debugging:: Debugging @TeX{} and @LaTeX{} output. 2751* Checking:: Checking the document. 2752* Control:: Controlling the processes. 2753* Cleaning:: Cleaning intermediate and output files. 2754* Documentation:: Documentation about macros and packages. 2755@end menu 2756 2757@node Commands 2758@section Executing Commands 2759@cindex Formatting 2760@cindex Running @LaTeX{} 2761@cindex Running @TeX{} 2762@cindex @LaTeX{} 2763@cindex @TeX{} 2764@cindex Running commands 2765@cindex Default command 2766@cindex Header 2767@cindex Trailer 2768@cindex Setting the header 2769@cindex Setting the trailer 2770@cindex Region 2771@cindex Region file 2772@cindex Setting the default command 2773@cindex Commands 2774@cindex External Commands 2775@cindex Indexing 2776@cindex Making an index 2777@cindex Running @code{makeindex} 2778@cindex @code{makeindex} 2779@cindex Bib@TeX{} 2780@cindex Bibliography 2781@cindex Literature 2782@cindex Running Bib@TeX{} 2783@cindex Making a bibliography 2784@cindex Printing 2785@cindex Writing to a printer 2786 2787Formatting the document with @TeX{}, @LaTeX{} or @ConTeXt{}, viewing 2788with a previewer, printing the document, running Bib@TeX{}, making an 2789index, or checking the document with @command{lacheck} or 2790@command{chktex} all require running an external command. 2791 2792@menu 2793* Starting a Command:: Starting a Command on a Document or Region 2794* Selecting a Command:: Selecting and Executing a Command 2795* Processor Options:: Options for @TeX{} Processors 2796@end menu 2797 2798@node Starting a Command 2799@subsection Starting a Command on a Document or Region 2800 2801There are two ways to run an external command, you can either run it on 2802the current document with @code{TeX-command-master}, or on the current 2803region with @code{TeX-command-region}. A special case of running @TeX{} 2804on a region is @code{TeX-command-buffer} which differs from 2805@code{TeX-command-master} if the current buffer is not its own master 2806file. 2807 2808@deffn Command TeX-command-master 2809@kindex C-c C-c 2810(@kbd{C-c C-c}) Query the user for a command, and run it on the master 2811file associated with the current buffer. The name of the master file is 2812controlled by the variable @code{TeX-master}. The available commands are 2813controlled by the variable @code{TeX-command-list}. 2814@vindex TeX-master 2815@vindex TeX-command-list 2816@end deffn 2817 2818@deffn Command TeX-command-region 2819@kindex C-c C-r 2820(@kbd{C-c C-r}) Query the user for a command, and run it on the contents 2821of the selected region. The region contents are written into the region 2822file, after extracting the header and trailer from the master file. If 2823mark is inactive (which can happen with Transient Mark mode), use the 2824old region. See also the command @code{TeX-pin-region} about how to fix 2825a region. 2826 2827The name of the region file is controlled by the variable 2828@code{TeX-region}. The name of the master file is controlled by the 2829variable @code{TeX-master}. The header is all text up to the line 2830matching the regular expression @code{TeX-header-end}. The trailer is 2831all text from the line matching the regular expression 2832@code{TeX-trailer-start}. The available commands are controlled by the 2833variable @code{TeX-command-list}. 2834@vindex TeX-region 2835@vindex TeX-header-end 2836@vindex TeX-trailer-start 2837@vindex TeX-master 2838@vindex TeX-command-list 2839@end deffn 2840 2841@deffn Command TeX-command-buffer 2842@kindex C-c C-b 2843(@kbd{C-c C-b}) Query the user for a command, and apply it to the 2844contents of the current buffer. The buffer contents are written into 2845the region file, after extracting the header and trailer from the master 2846file. The command is then actually run on the region file. See above 2847for details. 2848@end deffn 2849 2850@deffn Command LaTeX-command-section 2851@kindex C-c C-z 2852(@kbd{C-c C-z}) Query the user for a command, and apply it to the 2853current section (or part, chapter, subsection, paragraph, or 2854subparagraph). What makes the current section is determined by 2855@code{LaTeX-command-section-level} which can be enlarged/shrunken using 2856@code{LaTeX-command-section-change-level} (@kbd{C-c M-z}). The given 2857numeric prefix arg is added to the current value of 2858@code{LaTeX-command-section-level}. By default, 2859@code{LaTeX-command-section-level} is initialized with the current 2860document's @code{LaTeX-largest-level}. The buffer contents are written 2861into the region file, after extracting the header and trailer from the 2862master file. The command is then actually run on the region file. See 2863@code{TeX-command-region} for details. 2864@end deffn 2865 2866It is also possible to compile automatically the whole document until it 2867is ready with a single command: @code{TeX-command-run-all}. 2868 2869@deffn Command TeX-command-run-all 2870@kindex C-c C-a 2871(@kbd{C-c C-a}) Compile the current document until an error occurs or it 2872is finished. If compilation finishes successfully, run the viewer at 2873the end. 2874@end deffn 2875 2876Here are some relevant variables. 2877 2878@defopt TeX-region 2879The name of the file for temporarily storing the text when formatting 2880the current region. 2881@end defopt 2882 2883@defopt TeX-header-end 2884A regular expression matching the end of the header. By default, this 2885is @samp{\begin@{document@}} in @LaTeX{} mode and @samp{%**end of 2886header} in @TeX{} mode. 2887@end defopt 2888 2889@defopt TeX-trailer-start 2890A regular expression matching the start of the trailer. By default, 2891this is @samp{\end@{document@}} in @LaTeX{} mode and @samp{\bye} in 2892@TeX{} mode. 2893@end defopt 2894 2895If you want to change the values of @code{TeX-header-end} and 2896@code{TeX-trailer-start} you can do this for all files by setting the 2897variables in a mode hook or per file by specifying them as file 2898variables (@pxref{File Variables,,,emacs,The Emacs Editor}). 2899 2900@deffn Command TeX-pin-region 2901@kindex C-c C-t C-r 2902(@kbd{C-c C-t C-r}) If you don't have a mode like Transient Mark mode 2903active, where marks get disabled automatically, the region would need to 2904get properly set before each call to @code{TeX-command-region}. If you 2905fix the current region with @kbd{C-c C-t C-r}, then it will get used for 2906more commands even though mark and point may change. An explicitly 2907activated mark, however, will always define a new region when calling 2908@code{TeX-command-region}. 2909@end deffn 2910 2911@AUCTeX{} will allow one process for each document, plus one process 2912for the region file to be active at the same time. Thus, if you are 2913editing @var{n} different documents, you can have @var{n} plus one 2914processes running at the same time. If the last process you started was 2915on the region, the commands described in @ref{Debugging} and 2916@ref{Control} will work on that process, otherwise they will work on the 2917process associated with the current document. 2918 2919@node Selecting a Command 2920@subsection Selecting and Executing a Command 2921 2922Once you started the command selection with @kbd{C-c C-c}, @kbd{C-c C-r} 2923or @kbd{C-c C-b} you will be prompted for the type of command. 2924@AUCTeX{} will try to guess which command is appropriate in the given 2925situation and propose it as default. Usually this is a processor like 2926@samp{TeX} or @samp{LaTeX} if the document was changed or a viewer if 2927the document was just typeset. Other commands can be selected in the 2928minibuffer with completion support by typing @key{TAB}. 2929 2930@vindex TeX-command-list 2931@vindex TeX-expand-list 2932The available commands are defined by the variable 2933@code{TeX-command-list}. Per default it includes commands for 2934typesetting the document (e.g. @samp{LaTeX}), for viewing the output 2935(@samp{View}), for printing (@samp{Print}), for generating an index 2936(@samp{Index}) or for spell checking (@samp{Spell}) to name but a few. 2937You can also add your own commands by adding entries to 2938@code{TeX-command-list}. Refer to its doc string for information about 2939its syntax. You might also want to look at @code{TeX-expand-list} to 2940learn about the expanders you can use in @code{TeX-command-list}. 2941 2942Note that the default of the variable occasionally changes. Therefore 2943it is advisable to add to the list rather than overwriting it. You can 2944do this with a call to @code{add-to-list} in your init file. For 2945example, if you wanted to add a command for running a program called 2946@samp{foo} on the master or region file, you could do this with the 2947following form. 2948 2949@lisp 2950(eval-after-load "tex" 2951 '(add-to-list 'TeX-command-list 2952 '("Foo" "foo %s" TeX-run-command t t :help "Run foo") t)) 2953@end lisp 2954 2955As mentioned before, @AUCTeX{} will try to guess what command you want 2956to invoke. If you want to use another command than @samp{TeX}, 2957@samp{LaTeX} or whatever processor @AUCTeX{} thinks is appropriate for 2958the current mode, set the variable @code{TeX-command-default}. You can 2959do this for all files by setting it in a mode hook or per file by 2960specifying it as a file variable (@pxref{File Variables,,,emacs,The 2961Emacs Editor}). 2962 2963@defopt TeX-command-default 2964The default command to run in this buffer. Must be an entry in 2965@code{TeX-command-list}. 2966@end defopt 2967 2968@cindex Biber 2969@cindex biblatex 2970In case you use biblatex in a document, when automatic parsing is 2971enabled @AUCTeX{} checks the value of @samp{backend} option given to 2972biblatex at load time to decide whether to use Bib@TeX{} or Biber for 2973bibliography processing. Should @AUCTeX{} fail to detect the right 2974backend, you can use the file local @code{LaTeX-biblatex-use-Biber} 2975variable. 2976@defvr Variable LaTeX-biblatex-use-Biber 2977If this boolean variable is set as file local, it tells to @AUCTeX{} 2978whether to use Biber with biblatex. In this case, the autodetection of 2979the biblatex backend will be overridden. You may want to set locally 2980this variable if automatic parsing is not enabled. 2981@end defvr 2982 2983After confirming a command to execute, @AUCTeX{} will try to save any 2984buffers related to the document, and check if the document needs to be 2985reformatted. If the variable @code{TeX-save-query} is non-nil, 2986@AUCTeX{} will query before saving each file. By default @AUCTeX{} will 2987check emacs buffers associated with files in the current directory, in 2988one of the @code{TeX-macro-private} directories, and in the 2989@code{TeX-macro-global} directories. You can change this by setting the 2990variable @code{TeX-check-path}. 2991 2992@defopt TeX-check-path 2993Directory path to search for dependencies. 2994 2995If nil, just check the current file. 2996Used when checking if any files have changed. 2997@end defopt 2998 2999@cindex ispell 3000When performing spell checking on a document or a region (invoked 3001through @AUCTeX{}'s @samp{Spell} command or @kbd{M-x ispell RET}), you 3002want the spell checking program to skip certain macro arguments and 3003environments, most notably the arguments of referencing macros and the 3004contents of verbatim environments. The skipped parts are controlled by 3005variable @code{ispell-tex-skip-alists} provided by @file{ispell.el}. 3006@AUCTeX{} has a library which can be added to this variable depending on 3007the value of @code{TeX-ispell-extend-skip-list} which is set to @code{t} 3008by default. 3009 3010@defopt TeX-ispell-extend-skip-list 3011This boolean option controls whether @AUCTeX{} activates its extension 3012for skipping certain macro arguments and environments when spell 3013checking. 3014 3015When non-@code{nil}, @AUCTeX{} loads the file @file{tex-ispell.el} and 3016adds its content to @code{ispell-tex-skip-alists}. This library can and 3017will never be complete, but the interface can be used to add selected 3018and private macro names within your init file or on a file local basis. 3019 3020@code{ispell-tex-skip-alists} has the following structure: 3021@lisp 3022(defvar ispell-tex-skip-alists 3023 '((;; First list 3024 ("\\\\addcontentsline" ispell-tex-arg-end 2) 3025 ("\\\\\\([aA]lph\\|arabic\\)" ispell-tex-arg-end) 3026 ("\\\\makebox" ispell-tex-arg-end 0) 3027 ("\\\\documentclass" . "\\\\begin@{document@}")) 3028 (;; Second list 3029 ("\\(figure\\|table\\)\\*?" ispell-tex-arg-end 0) 3030 ("list" ispell-tex-arg-end 2) 3031 ("verbatim\\*?" . "\\\\end@{verbatim\\*?@}"))) 3032 "*Lists of regions to be skipped in TeX mode. 3033First list is used raw. 3034Second list has key placed inside \\begin@{@}.") 3035@end lisp 3036Each item is an alist and the structure of it is described in 3037@code{ispell-skip-region-alist}: 3038@lisp 3039(defvar ispell-skip-region-alist 3040 '((...)) 3041 "Alist expressing beginning and end of regions not to spell check. 3042The alist key must be a regular expression. 3043Valid forms include: 3044 (KEY) - just skip the key. 3045 (KEY . REGEXP) - skip to the end of REGEXP. 3046 REGEXP may be string or symbol. 3047 (KEY REGEXP) - skip to end of REGEXP. REGEXP must be a string. 3048 (KEY FUNCTION ARGS) - FUNCTION called with ARGS 3049 returns end of region.") 3050@end lisp 3051 3052Let's go through the first list of @code{ispell-tex-skip-alists} line by 3053line: 3054@lisp 3055("\\\\addcontentsline" ispell-tex-arg-end 2) 3056@end lisp 3057@code{KEY} is the string @code{"\\\\addcontentsline"}, @code{FUNCTION} 3058is @code{ispell-tex-arg-end} called with @code{ARGS}, here @code{2}. 3059@code{ispell-tex-arg-end} is a function provided by @file{ispell.el} 3060which skips as many subsequent optional arguments in square brackets as 3061it sees and then skips @code{ARGS} number of mandatory arguments in 3062braces. Omitting @code{ARGS} means skip @code{1} mandatory argument. 3063In practice, when you have something like this in your document: 3064@example 3065\addcontentsline@{toc@}@{chapter@}@{Some text@} 3066@end example 3067The first two arguments are left out and @samp{Some text} will be spell 3068checked. For the next line 3069@lisp 3070("\\\\\\([aA]lph\\|arabic\\)" ispell-tex-arg-end) 3071@end lisp 3072the name of the counter as argument is skipped. Next line is 3073@lisp 3074("\\\\makebox" ispell-tex-arg-end 0) 3075@end lisp 3076where only optional arguments are skipped, the first mandatory argument 3077is checked, e.g. 3078@example 3079\makebox[0pt][l]@{Some text@} 3080@end example 3081Finally, the next line 3082@lisp 3083("\\\\documentclass" . "\\\\begin@{document@}")) 3084@end lisp 3085ensures that the entire preamble of a document is discarded. Second 3086list works the same; it is more convenient for environments since 3087@code{KEY} is wrapped inside @code{\begin@{@}}. 3088 3089@AUCTeX{} provides two functions to add items to car and cdr of 3090@code{ispell-tex-arg-end}, namely @code{TeX-ispell-skip-setcar} and 3091@code{TeX-ispell-skip-setcdr}. The argument of these functions is 3092exactly as in @code{ispell-tex-skip-alists}. Additions can be done via 3093init file, e.g.: 3094@lisp 3095(eval-after-load "tex-ispell" 3096 '(progn 3097 (TeX-ispell-skip-setcar 3098 '(("\\\\mymacro" ispell-tex-arg-end))) 3099 (TeX-ispell-skip-setcdr 3100 '(("myverbatim" . "\\\\end@{myverbatim@}"))))) 3101@end lisp 3102Another possibility is to use file local additions at the end of your 3103@TeX{} file, e.g.: 3104@example 3105%%% Local Variables: 3106%%% mode: latex 3107%%% TeX-master: t 3108%%% eval: (TeX-ispell-skip-setcar '(("\\\\mymacro" . "@{[-0-9]+@}"))) 3109%%% End: 3110@end example 3111 3112@findex TeX-ispell-tex-arg-end 3113Finally, @AUCTeX{} provides a function called 3114@code{TeX-ispell-tex-arg-end} which sees more arguments than 3115@code{ispell-tex-arg-end}. Refer to its doc string for more 3116information. 3117@end defopt 3118 3119@AUCTeX{} also provides a facility to skip the argument of in-line 3120verbatim macros like @samp{\Verb} from @file{fancyvrb.sty} or 3121@samp{\mintinline} from @file{minted.sty}. Characters delimiting the 3122verbatim text are stored in @code{TeX-ispell-verb-delimiters}. 3123 3124@defopt TeX-ispell-verb-delimiters 3125String with delimiters recognized for in-line verbatim macros. This 3126variable is initialized to @samp{!|#~\"*/+^-}. Since this string is 3127used to build a character alternative inside a regular expression, 3128special characters @samp{^} and @samp{-} should come last. Other 3129characters like opening brace @samp{@{}, asterisk @samp{*} or at sign 3130@samp{@@} should be avoided as they are not recognized by 3131@file{font-latex.el}. 3132@end defopt 3133 3134@node Processor Options 3135@subsection Options for @TeX{} Processors 3136 3137There are some options you can customize affecting which processors are 3138invoked or the way this is done and which output they produce as a 3139result. These options control if @acronym{DVI} or @acronym{PDF} output 3140should be produced, if @TeX{} should be started in interactive or 3141nonstop mode, if source specials or a Sync@TeX{} file should be produced 3142for making inverse and forward search possible or which @TeX{} engine 3143should be used instead of regular @TeX{}, like PDF@TeX{}, Omega or 3144Xe@TeX{}, and the style error messages are printed with. 3145 3146@deffn Command TeX-PDF-mode 3147@kindex C-c C-t C-p 3148@vindex TeX-PDF-mode 3149@cindex PDF mode 3150(@kbd{C-c C-t C-p}) 3151This command toggles the @acronym{PDF} mode of @AUCTeX{}, a buffer-local 3152minor mode which is enabled by default. You can customize 3153@code{TeX-PDF-mode} to give it a different default or set it as a file 3154local variable on a per-document basis. This option usually results in 3155calling either PDF@TeX{} or ordinary @TeX{}. 3156@end deffn 3157 3158@defopt TeX-DVI-via-PDFTeX 3159If this is set, @acronym{DVI} will also be produced by calling 3160PDF@TeX{}, setting @code{\pdfoutput=0}. This makes it possible to use 3161PDF@TeX{} features like character protrusion even when producing 3162@acronym{DVI} files. Contemporary @TeX{} distributions do this anyway, 3163so that you need not enable the option within @AUCTeX{}. 3164@end defopt 3165 3166@deffn Command TeX-interactive-mode 3167@kindex C-c C-t C-i 3168@vindex TeX-interactive-mode 3169(@kbd{C-c C-t C-i}) This command toggles the interactive mode of 3170@AUCTeX{}, a global minor mode. You can customize 3171@code{TeX-interactive-mode} to give it a different default. In 3172interactive mode, @TeX{} will pause with an error prompt when errors are 3173encountered and wait for the user to type something. 3174@end deffn 3175 3176@cindex I/O correlation 3177@cindex SyncTeX 3178@cindex Source specials 3179@cindex PDFSync 3180@deffn Command TeX-source-correlate-mode 3181@kindex C-c C-t C-s 3182@vindex TeX-source-correlate-mode 3183(@kbd{C-c C-t C-s}) Toggles support for forward and inverse search. 3184Forward search refers to jumping to the place in the previewed document 3185corresponding to where point is located in the document source and 3186inverse search to the other way round. @xref{I/O Correlation}. 3187 3188You can permanently activate @code{TeX-source-correlate-mode} by 3189customizing the variable @code{TeX-source-correlate-mode}. There is a 3190bunch of customization options for the mode, use @kbd{M-x 3191customize-group @key{RET} TeX-view @key{RET}} to find out more. 3192 3193@vindex TeX-source-correlate-method 3194@AUCTeX{} is aware of three different means to do I/O correlation: 3195source specials (only DVI output), the pdfsync @LaTeX{} package (only 3196PDF output) and Sync@TeX{}. The choice between source specials and 3197Sync@TeX{} can be controlled with the variable 3198@code{TeX-source-correlate-method}. 3199 3200Should you use source specials it has to be stressed @emph{very} 3201strongly however, that source specials can cause differences in page 3202breaks and spacing, can seriously interfere with various packages and 3203should thus @emph{never} be used for the final version of a document. 3204In particular, fine-tuning the page breaks should be done with source 3205specials switched off. 3206@end deffn 3207 3208Sometimes you are requested, by journal rules or packages, to compile 3209the document into @acronym{DVI} output. Thus, if you want a 3210@acronym{PDF} document in the end you can either use Xe@TeX{} engine, 3211see below for information about how to set engines, or compile the 3212document with @command{tex} and then convert to @acronym{PDF} with 3213@command{dvips}--@command{ps2pdf} before viewing it. In addition, 3214current Japanese @TeX{} engines cannot generate @acronym{PDF} directly 3215so they rely on @acronym{DVI}-to-@acronym{PDF} converters. Usually 3216@command{dvipdfmx} command is used for this purpose. You can use the 3217@code{TeX-PDF-from-DVI} variable to let @AUCTeX{} know you want to 3218generate the final @acronym{PDF} by converting a @acronym{DVI} file. 3219 3220@defopt TeX-PDF-from-DVI 3221This option controls if and how to produce a @acronym{PDF} file by 3222converting a @acronym{DVI} file. 3223 3224When @code{TeX-PDF-mode} is non-nil, if @code{TeX-PDF-from-DVI} is 3225non-nil too the document is compiled to @acronym{DVI} instead of 3226@acronym{PDF}. When the document is ready, @kbd{C-c C-c} will suggest 3227to run the converter to @acronym{PDF} or an intermediate format. 3228 3229If non-nil, @code{TeX-PDF-from-DVI} should be the name of the command, 3230as a string, used to convert the @acronym{DVI} file to @acronym{PDF} or 3231to an intermediate format. Values currently supported are: 3232@itemize 3233@item 3234@code{"Dvips"}: the @acronym{DVI} file is converted to @acronym{PS} with 3235@command{dvips}. After successfully running it, @command{ps2pdf} will 3236be the default command to convert the @acronym{PS} file to 3237@acronym{PDF}. 3238@item 3239@code{"Dvipdfmx"}: the @acronym{DVI} file is converted to @acronym{PDF} 3240with @command{dvipdfmx}. 3241@end itemize 3242(case is significant; note the uppercase ``D'' in both strings) 3243When the @acronym{PDF} file is finally ready, the next suggested command 3244will be to open the viewer. 3245 3246This option can also be set as a file local variable, in order to use 3247this conversion on a per-document basis. 3248 3249Recall the whole sequence of @kbd{C-c C-c} commands can be replace by 3250the single @kbd{C-c C-a}. 3251@end defopt 3252 3253@AUCTeX{} also allows you to easily select different @TeX{} engines for 3254processing, either by using the entries in the @samp{TeXing Options} 3255submenu below the @samp{Command} menu or by calling the function 3256@code{TeX-engine-set}. These eventually set the variable 3257@code{TeX-engine} which you can also modify directly. 3258 3259@defopt TeX-engine 3260This variable allows you to choose which @TeX{} engine should be used 3261for typesetting the document, i.e. the executables which will be used 3262when you invoke the @samp{TeX} or @samp{LaTeX} commands. The value 3263should be one of the symbols defined in @code{TeX-engine-alist-builtin} 3264or @code{TeX-engine-alist}. The symbols @samp{default}, @samp{xetex}, 3265@samp{luatex} and @samp{omega} are available from the built-in list. 3266@end defopt 3267 3268Note that @code{TeX-engine} is buffer-local, so setting the variable 3269directly or via the above mentioned menu or function will not take 3270effect in other buffers. If you want to activate an engine for all 3271@AUCTeX{} modes, set @code{TeX-engine} in your init file, e.g. by using 3272@kbd{M-x customize-variable <RET>}. If you want to activate it for a 3273certain @AUCTeX{} mode only, set the variable in the respective mode 3274hook. If you want to activate it for certain files, set it through file 3275variables (@pxref{File Variables,,,emacs,The Emacs Editor}). 3276 3277@vindex TeX-command 3278@vindex LaTeX-command 3279@vindex TeX-Omega-command 3280@vindex LaTeX-Omega-command 3281@vindex ConTeXt-engine 3282@vindex ConTeXt-Omega-engine 3283@vindex TeX-engine-alist 3284@vindex TeX-engine-alist-builtin 3285Should you need to change the executable names related to the different 3286engine settings, there are some variables you can tweak. Those are 3287@code{TeX-command}, @code{LaTeX-command}, @code{TeX-Omega-command}, 3288@code{LaTeX-Omega-command}, @code{ConTeXt-engine} and 3289@code{ConTeXt-Omega-engine}. The rest of the executables is defined 3290directly in @code{TeX-engine-alist-builtin}. If you want to override an 3291entry from that, add an entry to @code{TeX-engine-alist} that starts 3292with the same symbol as that the entry in the built-in list and specify 3293the executables you want to use instead. You can also add entries to 3294@code{TeX-engine-alist} in order to add support for engines not covered 3295per default. 3296 3297@defopt TeX-engine-alist 3298Alist of TeX engines and associated commands. Each entry is a list with 3299a maximum of five elements. The first element is a symbol used to 3300identify the engine. The second is a string describing the engine. The 3301third is the command to be used for plain TeX. The fourth is the 3302command to be used for LaTeX. The fifth is the command to be used for 3303the @samp{--engine} parameter of ConTeXt's @samp{texexec} program. Each 3304command can either be a variable or a string. An empty string or nil 3305means there is no command available. 3306@end defopt 3307 3308In some systems, Emacs cannot inherit the PATH environment variable from 3309the shell and thus @AUCTeX{} may not be able to run @TeX{} commands. 3310Before running them, @AUCTeX{} checks if it able to find those commands 3311and will warn you in case it fails. You can skip this test by changing 3312the option @code{TeX-check-TeX}. 3313 3314@defopt TeX-check-TeX 3315@vindex TeX-command 3316@vindex TeX-check-TeX-command-not-found 3317If non-nil, @AUCTeX{} will check if it is able to find a working @TeX{} 3318distribution before running @TeX{}, @LaTeX{}, @ConTeXt{}, etc. It 3319actually checks if can run @code{TeX-command} command or the shell 3320returns a command not found error. The error code returned by the shell 3321in this case can be set in @code{TeX-check-TeX-command-not-found} 3322option. 3323@end defopt 3324 3325Some @LaTeX{} packages requires the document to be compiled with a 3326specific engine. Notable examples are fontspec and polyglossia 3327packages, which require Lua@TeX{} and Xe@TeX{} engines. If you try to 3328compile a document which loads one of such packages and the set engine 3329is not one of those allowed you will be asked to select a different 3330engine before running the @LaTeX{} command. If you do not want to be 3331warned by @AUCTeX{} in these cases, customize the option 3332@code{TeX-check-engine}. 3333 3334@defopt TeX-check-engine 3335This boolean option controls whether @AUCTeX{} should check the correct 3336engine has been set before running @LaTeX{} commands. 3337@end defopt 3338 3339As shown above, @AUCTeX{} handles in a special way most of the main 3340options that can be given to the @TeX{} processors. When you need to 3341pass to the @TeX{} processor arbitrary options not handled by @AUCTeX{}, 3342you can use the file local variable @code{TeX-command-extra-options}. 3343@defopt TeX-command-extra-options 3344String with the extra options to be given to the TeX processor. For 3345example, if you need to enable the shell escape feature to compile a 3346document, add the following line to the list of local variables of the 3347source file: 3348@example 3349%%% TeX-command-extra-options: "-shell-escape" 3350@end example 3351By default this option is not safe as a file-local variable because a 3352specially crafted document compiled with shell escape enabled can be 3353used for malicious purposes. 3354@end defopt 3355 3356You can customize @AUCTeX{} to show the processor output as it is 3357produced. 3358 3359@defopt TeX-show-compilation 3360If non-nil, the output of @TeX{} compilation is shown in another window. 3361@end defopt 3362 3363You can instruct @TeX{} to print error messages in the form 3364file:line:error which is similar to the way many compilers format them. 3365 3366@defopt TeX-file-line-error 3367If non-nil, @TeX{} will produce file:line:error style error messages. 3368@end defopt 3369 3370@ConTeXt{} users can choose between Mark II and Mark IV versions. This 3371is controlled by @code{ConTeXt-Mark-version} option. 3372 3373@defopt ConTeXt-Mark-version 3374This variables specifies which version of Mark should be used. Values 3375currently supported are @code{"II"}, the default, and @code{"IV"}. It 3376can be set globally using customization interface or on a per-file 3377basis, by specifying it as a file variable. 3378@end defopt 3379 3380@node Viewing 3381@section Viewing the Formatted Output 3382@cindex Viewing 3383@cindex Previewing 3384@cindex Starting a previewer 3385 3386@AUCTeX{} allows you to start external programs for previewing the 3387formatted output of your document. 3388 3389@menu 3390* Starting Viewers:: Starting viewers 3391* I/O Correlation:: Forward and inverse search 3392@end menu 3393 3394@node Starting Viewers 3395@subsection Starting Viewers 3396 3397Viewers are normally invoked by pressing @kbd{C-c C-c} once the document 3398is formatted, which will propose the View command, or by activating the 3399respective entry in the Command menu. Alternatively you can type 3400@kbd{C-c C-v} which calls the function @code{TeX-view}. 3401 3402@deffn Command TeX-view 3403@kindex C-c C-v 3404(@kbd{C-c C-v}) Start a viewer without confirmation. The viewer is 3405started either on a region or the master file, depending on the last 3406command issued. This is especially useful for jumping to the location 3407corresponding to point in the viewer when using 3408@code{TeX-source-correlate-mode}. 3409@end deffn 3410 3411@AUCTeX{} will try to guess which type of viewer (@acronym{DVI}, 3412PostScript or @acronym{PDF}) has to be used and what options are to be 3413passed over to it. This decision is based on the output files present 3414in the working directory as well as the class and style options used in 3415the document. For example, if there is a @acronym{DVI} file in your 3416working directory, a @acronym{DVI} viewer will be invoked. In case of a 3417@acronym{PDF} file it will be a @acronym{PDF} viewer. If you specified 3418a special paper format like @samp{a5paper} or use the @samp{landscape} 3419option, this will be passed to the viewer by the appropriate options. 3420Especially some @acronym{DVI} viewers depend on this kind of information 3421in order to display your document correctly. In case you are using 3422@samp{pstricks} or @samp{psfrag} in your document, a @acronym{DVI} 3423viewer cannot display the contents correctly and a PostScript viewer 3424will be invoked instead. 3425 3426The association between the tests for the conditions mentioned above and 3427the viewers is made in the variable @code{TeX-view-program-selection}. 3428Therefore this variable is the starting point for customization if you 3429want to use other viewers than the ones suggested by default. 3430 3431@defopt TeX-view-program-selection 3432This is a list of predicates and viewers which is evaluated from front 3433to back in order to find out which viewer to call under the given 3434conditions. In the first element of each list item you can reference 3435one or more predicates defined in @code{TeX-view-predicate-list} or 3436@code{TeX-view-predicate-list-builtin}. In the second element you can 3437reference a viewer defined in @code{TeX-view-program-list} or 3438@code{TeX-view-program-list-builtin}. The viewer of the first item with 3439a positively evaluated predicate is selected. 3440@end defopt 3441 3442So @code{TeX-view-program-selection} only contains references to the 3443actual implementations of predicates and viewer commands respectively 3444which can be found elsewhere. @AUCTeX{} comes with a set of 3445preconfigured predicates and viewer commands which are stored in the 3446variables @code{TeX-view-predicate-list-builtin} and 3447@code{TeX-view-program-list-builtin} respectively. If you are not 3448satisfied with those and want to overwrite one of them or add your own 3449definitions, you can do so via the variables 3450@code{TeX-view-predicate-list} and @code{TeX-view-program-list}. 3451 3452@defopt TeX-view-predicate-list 3453This is a list of predicates for viewer selection and invocation. The 3454first element of each list item is a symbol and the second element a 3455Lisp form to be evaluated. The form should return nil if the predicate 3456is not fulfilled. 3457 3458A built-in predicate from @code{TeX-view-predicate-list-builtin} can be 3459overwritten by defining a new predicate with the same symbol. 3460@end defopt 3461 3462@defopt TeX-view-program-list 3463This is a list of viewer specifications each consisting of a symbolic 3464name and either a command line or a function to be invoked when the 3465viewer is called. If a command line is used, parts of it can be 3466conditionalized by prefixing them with predicates from 3467@code{TeX-view-predicate-list} or 3468@code{TeX-view-predicate-list-builtin}. (See the doc string for the 3469exact format to use.) The command line can also contain placeholders as 3470defined in @code{TeX-expand-list} and @code{TeX-expand-list-builtin} 3471which are expanded before the viewer is called. 3472 3473The third element of each item is a string, or a list of strings, with 3474the name of the executable, or executables, needed to open the output 3475file in the viewer. Placeholders defined in @code{TeX-expand-list} and 3476@code{TeX-expand-list-builtin} can be used here. This element is 3477optional and is used to check whether the viewer is actually available 3478on the system. 3479 3480A built-in viewer spec from @code{TeX-view-program-list-builtin} can be 3481overwritten by defining a new viewer spec with the same name. 3482@end defopt 3483 3484After the viewer is called via either the View command or the key stroke 3485@kbd{C-c C-v}, the window system focus goes and stays on the viewer. If 3486you prefer that the focus is pulled back to Emacs immediately after that 3487and you are using evince-compatible viewer, customize the option 3488@code{TeX-view-enince-keep-focus}. 3489 3490@defopt TeX-view-evince-keep-focus 3491When this option is non-nil and the viewer is compatible with evince, 3492the focus is pulled back to Emacs immediately after the viewer is 3493invoked or refreshed from within @AUCTeX{}. 3494@end defopt 3495 3496Note that the viewer selection and invocation as described above will 3497only work if certain default settings in @AUCTeX{} are intact. For one, 3498the whole viewer selection machinery will only be triggered if there is 3499no @samp{%V} expander in @code{TeX-expand-list}. So if you have trouble 3500with the viewer invocation you might check if there is an older 3501customization of the variable in place. In addition, the use of a 3502function in @code{TeX-view-program-list} only works if the View command 3503in @code{TeX-command-list} makes use of the hook 3504@code{TeX-run-discard-or-function}. 3505 3506Note also that the implementation described above replaces an older one 3507which was less flexible. This old implementation works with the 3508variables @code{TeX-output-view-style} and @code{TeX-view-style} which 3509are used to associate file types and style options with viewers. If 3510desired you can reactivate it by using the placeholder @samp{%vv} for 3511the View command in @code{TeX-command-list}. Note however, that it is 3512bound to be removed from @AUCTeX{} once the new implementation proved to 3513be satisfactory. For the time being, find a short description of the 3514mentioned customization options below. 3515 3516@defopt TeX-output-view-style 3517List of output file extensions, style options and view options. Each 3518item of the list consists of three elements. If the first element (a 3519regular expression) matches the output file extension, and the second 3520element (a regular expression) matches the name of one of the style 3521options, any occurrence of the string @code{%V} in a command in 3522@code{TeX-command-list} will be replaced with the third element. 3523@end defopt 3524 3525@defopt TeX-view-style 3526List of style options and view options. This is the predecessor of 3527@code{TeX-output-view-style} which does not provide the possibility to 3528specify output file extensions. It is used as a fallback in case none 3529of the alternatives specified in @code{TeX-output-view-style} match. In 3530case none of the entries in @code{TeX-view-style} match either, no 3531suggestion for a viewer is made. 3532@end defopt 3533 3534@node I/O Correlation 3535@subsection Forward and Inverse Search 3536@cindex Inverse search 3537@cindex Forward search 3538@cindex I/O correlation 3539@cindex Source specials 3540@cindex SyncTeX 3541@cindex PDFSync 3542 3543Forward and inverse search refer to the correlation between the document 3544source in the editor and the typeset document in the viewer. Forward 3545search allows you to jump to the place in the previewed document 3546corresponding to a certain line in the document source and inverse 3547search vice versa. 3548 3549@findex TeX-source-correlate-mode 3550@AUCTeX{} supports three methods for forward and inverse search: source 3551specials (only DVI output), the pdfsync @LaTeX{} package (only PDF 3552output) and Sync@TeX{} (any type of output). If you want to make use of 3553forward and inverse searching with source specials or Sync@TeX{}, switch 3554on @code{TeX-source-correlate-mode}. @xref{Processor Options}, on how 3555to do that. The use of the pdfsync package is detected automatically if 3556document parsing is enabled. Customize the variable 3557@code{TeX-source-correlate-method} to select the method to use. 3558 3559@defopt TeX-source-correlate-method 3560Method to use for enabling forward and inverse search. This can be 3561@samp{source-specials} if source specials should be used, @samp{synctex} 3562if SyncTeX should be used, or @samp{auto} if @AUCTeX{} should decide. 3563 3564When the variable is set to @samp{auto}, @AUCTeX{} will always use 3565SyncTeX if your @code{latex} processor supports it, source specials 3566otherwise. You must make sure your viewer supports the same method. 3567 3568It is also possible to specify a different method depending on the 3569output, either DVI or PDF, by setting the variable to an alist of the 3570kind 3571@lisp 3572((dvi . <source-specials or synctex>) 3573 (pdf . <source-specials or synctex>)) 3574@end lisp 3575in which the CDR of each entry is a symbol specifying the method to be 3576used in the corresponding mode. The default value of the variable is 3577@lisp 3578((dvi . source-specials) 3579 (pdf . synctex)) 3580@end lisp 3581which is compatible with the majority of viewers. 3582@end defopt 3583 3584@findex TeX-view 3585Forward search happens automatically upon calling the viewer, e.g. by 3586typing @kbd{C-c C-v} (@code{TeX-view}). This will open the viewer or 3587bring it to front and display the output page corresponding to the 3588position of point in the source file. @AUCTeX{} will automatically pass 3589the necessary command line options to the viewer for this to happen. 3590 3591@vindex TeX-source-correlate-start-server 3592Upon opening the viewer you will be asked if you want to start a server 3593process (Gnuserv or Emacs server) which is necessary for inverse search. 3594This happens only if there is no server running already. You can 3595customize the variable @code{TeX-source-correlate-start-server} to 3596inhibit the question and always or never start the server respectively. 3597 3598@defopt TeX-source-correlate-start-server 3599If @code{TeX-source-correlate-mode} is active and a viewer is invoked, 3600the default behavior is to ask if a server process should be started. 3601Set this variable to @code{t} if the question should be inhibited and 3602the server should always be started. Set it to @code{nil} if the server 3603should never be started. Inverse search will not be available in the 3604latter case. 3605@end defopt 3606 3607Inverse search, i.e. jumping to the part of your document source in 3608Emacs corresponding to a certain position in the viewer, is triggered 3609from the viewer, typically by a mouse click. Refer to the documentation 3610of your viewer to find out how it has to be configured and what you have 3611to do exactly. In xdvi you normally have to use @kbd{C-down-mouse-1}. 3612 3613@vindex TeX-source-correlate-start-server 3614Note that inverse search with the Evince PDF viewer or its MATE fork 3615Atril might fail in raising the Emacs frame after updating point in your 3616document's buffer. There is simply no way to raise the Emacs frame 3617reliably accross different operating systems and different window 3618managers with their different focus stealing policies. If the Emacs 3619frame is not raised after performing an inverse search from Evince or 3620Atril, you can customize the following option. 3621 3622@defopt TeX-raise-frame-function 3623A function that will be called after performing an inverse search from 3624Evince or Atril in order to raise the current Emacs frame. 3625 3626If your Emacs frame is already raised in that situation, just 3627leave this variable set to its default value 3628@code{raise-frame}. Otherwise, here are some alternative 3629settings that work for some users. 3630 3631@lisp 3632;; Alternative 1: For some users, `x-focus-frame' works. 3633(setq TeX-raise-frame-function #'x-focus-frame) 3634 3635;; Alternative 2: Under GNOME 3.20 (and probably others), it 3636;; seems some focus stealing prevention policy prohibits that 3637;; some window gets the focus immediately after the user has 3638;; clicked in some other window. Here waiting a bit before 3639;; issuing the request seems to work. 3640(setq TeX-raise-frame-function 3641 (lambda () 3642 (run-at-time 0.5 nil #'x-focus-frame))) 3643 3644;; Alternative 3: Use the external wmctrl tool in order to 3645;; force Emacs into the focus. 3646(setq TeX-raise-frame-function 3647 (lambda () 3648 (call-process 3649 "wmctrl" nil nil nil "-i" "-R" 3650 (frame-parameter (selected-frame) 'outer-window-id)))) 3651@end lisp 3652@end defopt 3653 3654 3655@node Debugging 3656@section Catching the errors 3657@cindex Debugging 3658@cindex Errors 3659@cindex Parsing errors 3660@cindex Parsing TeX output 3661@cindex Next error 3662@cindex Parsing @LaTeX{} errors 3663@cindex Overfull boxes 3664@cindex Bad boxes 3665@cindex Underfull boxes 3666 3667Once you've formatted your document you may `debug' it, i.e. browse 3668through the errors (La)@TeX{} reported. You may also have a look at a 3669nicely formatted list of all errors and warnings reported by the 3670compiler. 3671 3672@deffn Command TeX-next-error @var{arg} @var{reparse} 3673@kindex C-c ` 3674(@kbd{C-c `}) Go to the next error reported by @TeX{}. The view will 3675be split in two, with the cursor placed as close as possible to the 3676error in the top view. In the bottom view, the error message will be 3677displayed along with some explanatory text. 3678 3679An optional numeric @var{arg}, positive or negative, specifies how many 3680error messages to move. A negative @var{arg} means to move back to 3681previous error messages, see also @code{TeX-previous-error}. 3682 3683The optional @var{reparse} argument makes @AUCTeX{} reparse the error 3684message buffer and start the debugging from the first error. This can 3685also be achieved by calling the function with a prefix argument 3686(@kbd{C-u}). 3687@end deffn 3688 3689@deffn Command TeX-previous-error @var{arg} 3690@kindex M-g p 3691(@kbd{M-g p}) Go to the previous error reported by @TeX{}. An optional 3692numeric @var{arg} specifies how many error messages to move backward. 3693This is like calling @code{TeX-next-error} with a negative argument. 3694@end deffn 3695 3696The command @code{TeX-previous-error} works only if @AUCTeX{} can parse 3697the whole @TeX{} log buffer. This is controlled by the 3698@code{TeX-parse-all-errors} variable. 3699 3700@defopt TeX-parse-all-errors 3701If t, @AUCTeX{} automatically parses the whole output log buffer right 3702after running a @TeX{} command, in order to collect all warnings and 3703errors. This makes it possible to navigate back and forth between the 3704error messages using @code{TeX-next-error} and 3705@code{TeX-previous-error}. This is the default. If nil, @AUCTeX{} does 3706not parse the whole output log buffer and @code{TeX-previous-error} 3707cannot be used. 3708@end defopt 3709 3710As default, @AUCTeX{} will display a special help buffer containing the 3711error reported by @TeX{} along with the documentation. There is however 3712an `expert' option, which allows you to display the real @TeX{} output. 3713 3714@defopt TeX-display-help 3715If t @AUCTeX{} will automatically display a help text whenever an error 3716is encountered using @code{TeX-next-error} (@kbd{C-c `}). If nil a 3717terse information about the error is displayed in the echo area. If 3718@code{expert} @AUCTeX{} will display the output buffer with the raw 3719@TeX{} output. 3720@end defopt 3721 3722@menu 3723* Ignoring warnings:: Controlling warnings to be reported 3724* Error overview:: List of all errors and warnings 3725@end menu 3726 3727@node Ignoring warnings 3728@subsection Controlling warnings to be reported 3729 3730Normally @AUCTeX{} will only report real errors, but you may as well 3731ask it to report `bad boxes' and warnings as well. 3732 3733@deffn Command TeX-toggle-debug-bad-boxes 3734@kindex C-c C-t C-b 3735@vindex TeX-debug-bad-boxes 3736(@kbd{C-c C-t C-b}) Toggle whether @AUCTeX{} should stop at bad boxes 3737(i.e. overfull and underfull boxes) as well as normal errors. The 3738boolean option @code{TeX-debug-bad-boxes} is set accordingly. 3739@end deffn 3740 3741@deffn Command TeX-toggle-debug-warnings 3742@kindex C-c C-t C-w 3743@vindex TeX-debug-warnings 3744(@kbd{C-c C-t C-w}) Toggle whether @AUCTeX{} should stop at warnings as 3745well as normal errors. The boolean option @code{TeX-debug-warnings} is 3746set accordingly. 3747@end deffn 3748 3749While many users desire to have warnings reported after compilation, 3750there are certain warnings that are considered unimportant and users 3751want to ignore them. For a more fine-grained control of what kinds of 3752warnings should be shown after compilation, @AUCTeX{} provides other 3753options. 3754 3755@defopt TeX-ignore-warnings 3756Controls which warnings are to be ignored. 3757 3758It can be a regexp matching the message of the warnings to be ignored. 3759 3760More advanced users can set also this option to a symbol with the name 3761of a custom function taking as arguments all the information of the 3762warning listed in @code{TeX-error-list} variable, except the last one 3763about whether to ignore the warning. See the code of @code{TeX-warning} 3764function and the documentation of @code{TeX-error-list} for more 3765details. 3766@end defopt 3767 3768@deffn Command TeX-toggle-suppress-ignored-warnings 3769@kindex C-c C-t C-x 3770@vindex TeX-suppress-ignored-warnings 3771(@kbd{C-c C-t C-x}) Toggle whether @AUCTeX{} should actually hide the 3772ignored warnings specified with @code{TeX-ignore-warnings}. The boolean 3773option @code{TeX-suppress-ignored-warnings} is set accordingly. If this 3774is nil, all warnings are shown, even those matched by 3775@code{TeX-ignore-warnings}, otherwise these are hidden. 3776 3777Note that @code{TeX-debug-warnings} takes the precedence: if it is nil, 3778all warnings are hidden in any case. 3779@end deffn 3780 3781@node Error overview 3782@subsection List of all errors and warnings 3783 3784When the option @code{TeX-parse-all-errors} is non-nil, you will be also 3785able to open an overview of all errors and warnings reported by the TeX 3786compiler. 3787 3788@deffn Command TeX-error-overview 3789Show an overview of the errors and warnings occurred in the last TeX 3790run. 3791 3792In this window you can visit the error on which point is on by pressing 3793@key{RET}, and visit the next or previous issue by pressing @key{n} or 3794@key{p} respectively. A prefix argument to these keys specifies how 3795many errors to move forward or backward. You can visit an error also by 3796clicking on its message. Jump to error point in the source code with 3797@key{j}, and use @key{l} see the error in the log buffer. In addition, 3798you can toggle visibility of bad boxes, generic warnings, and ignored 3799warnings with @key{b}, @key{w}, and @key{x}, respectively (see 3800@ref{Ignoring warnings} for details). Press @key{q} to quit the 3801overview. 3802@end deffn 3803 3804@defopt TeX-error-overview-open-after-TeX-run 3805When this boolean variable is non-nil, the error overview will be 3806automatically opened after running TeX if there are errors or warnings 3807to show. 3808@end defopt 3809 3810The error overview is opened in a new window of the current frame by 3811default, but you can change this behavior by customizing the option 3812@code{TeX-error-overview-setup}. 3813 3814@defopt TeX-error-overview-setup 3815Controls the frame setup of the error overview. The possible value is: 3816@code{separate-frame}; with a nil value the current frame is used 3817instead. 3818 3819The parameters of the separate frame can be set with the 3820@code{TeX-error-overview-frame-parameters} option. 3821 3822If the display does not support multi frame, the current frame 3823will be used regardless of the value of this variable. 3824@vindex TeX-error-overview-frame-parameters 3825@end defopt 3826 3827@node Checking 3828@section Checking for problems 3829@cindex Checking 3830@cindex @code{lacheck} 3831@cindex @code{chktex} 3832@cindex Finding errors 3833@cindex Running @code{lacheck} 3834@cindex Running @code{chktex} 3835@cindex Style 3836@cindex Problems 3837@cindex Flymake 3838@cindex Running Flymake 3839 3840Running @TeX{} or @LaTeX{} will only find regular errors in the 3841document, not examples of bad style. Furthermore, description of the 3842errors may often be confusing. The utilities @code{lacheck} and 3843@code{chktex} can be used to find style errors, such as forgetting to 3844escape the space after an abbreviation or using @samp{...} instead of 3845@samp{\ldots} and other similar problems. You start @code{lacheck} with 3846@kbd{C-c C-c Check @key{RET}} and @code{chktex} with @kbd{C-c C-c ChkTeX 3847@key{RET}}. The result will be a list of errors in the 3848@samp{*compilation*} buffer. You can go through the errors with 3849@kbd{C-x `} (@code{next-error}, @pxref{Compilation,,,emacs,The Emacs 3850Editor}), which will move point to the location of the next error. 3851 3852Alternatively, you may want in-buffer notation. @AUCTeX{} provides 3853support for this using the Flymake package in Emacs 26 or newer 3854(@xref{Using Flymake,,,Flymake,GNU Flymake} for details). To enable, 3855call @kbd{M-x flymake-mode RET} in the buffer or enable it in all 3856buffers by adding this to your init file: 3857@lisp 3858(add-hook 'LaTeX-mode-hook #'flymake-mode) 3859@end lisp 3860Note that @AUCTeX{} currently only provides support for using 3861@code{chktex} as the flymake backend. 3862 3863Each of the two utilities @code{lacheck} and @code{chktex} will find 3864some errors the other doesn't, but @code{chktex} is more configurable, 3865allowing you to create your own errors. You may need to install the 3866programs before using them. You can get @code{lacheck} from 3867@file{<URL:https://www.ctan.org/pkg/lacheck>} and 3868@code{chktex} from 3869@file{<URL:https://www.ctan.org/pkg/chktex>}. 3870 3871@node Control 3872@section Controlling the output 3873@cindex Controlling the output 3874@cindex Output 3875@cindex Redisplay output 3876@cindex Processes 3877@cindex Killing a process 3878@cindex Finding the master file 3879@cindex Master file 3880@cindex Stopping a process 3881@cindex Current file 3882@cindex Finding the current file 3883 3884A number of commands are available for controlling the output of an 3885application running under @AUCTeX{} 3886 3887@deffn Command TeX-kill-job 3888@kindex C-c C-k 3889(@kbd{C-c C-k}) Kill currently running external application. 3890This may be either of @TeX{}, @LaTeX{}, previewer, Bib@TeX{}, etc. 3891@end deffn 3892 3893@deffn Command TeX-recenter-output-buffer 3894@kindex C-c C-l 3895(@kbd{C-c C-l}) Recenter the output buffer so that the bottom line is 3896visible. 3897@end deffn 3898 3899@deffn Command TeX-home-buffer 3900@kindex C-c ^ 3901(@kbd{C-c ^}) Go to the `master' file in the document associated with 3902the current buffer, or if already there, to the file where the current 3903process was started. 3904@end deffn 3905 3906@node Cleaning 3907@section Cleaning intermediate and output files 3908@cindex Cleaning 3909 3910@deffn Command TeX-clean 3911@vindex plain-TeX-clean-intermediate-suffixes 3912@vindex plain-TeX-clean-output-suffixes 3913@vindex LaTeX-clean-intermediate-suffixes 3914@vindex LaTeX-clean-output-suffixes 3915@vindex docTeX-clean-intermediate-suffixes 3916@vindex docTeX-clean-output-suffixes 3917@vindex Texinfo-clean-intermediate-suffixes 3918@vindex Texinfo-clean-output-suffixes 3919@vindex ConTeXt-clean-intermediate-suffixes 3920@vindex ConTeXt-clean-output-suffixes 3921@vindex AmSTeX-clean-intermediate-suffixes 3922@vindex AmSTeX-clean-output-suffixes 3923Remove generated intermediate files. In case a prefix argument is 3924given, remove output files as well. 3925 3926Canonical access to the function is provided by the @samp{Clean} and 3927@samp{Clean All} entries in @code{TeX-command-list}, invokable with 3928@kbd{C-c C-c} or the Command menu. 3929 3930The patterns governing which files to remove can be adapted separately 3931for each @AUCTeX{} mode by means of the variables 3932@code{plain-TeX-clean-intermediate-suffixes}, 3933@code{plain-TeX-clean-output-suffixes}, 3934@code{LaTeX-clean-intermediate-suffixes}, 3935@code{LaTeX-clean-output-suffixes}, 3936@code{docTeX-clean-intermediate-suffixes}, 3937@code{docTeX-clean-output-suffixes}, 3938@code{Texinfo-clean-intermediate-suffixes}, 3939@code{Texinfo-clean-output-suffixes}, 3940@code{ConTeXt-clean-intermediate-suffixes}, 3941@code{ConTeXt-clean-output-suffixes}, 3942@code{AmSTeX-clean-intermediate-suffixes} and 3943@code{AmSTeX-clean-output-suffixes}. 3944@end deffn 3945 3946@defopt TeX-clean-confirm 3947Control if deletion of intermediate and output files has to be confirmed 3948before it is actually done. If non-nil, ask before deleting files. 3949@end defopt 3950 3951@node Documentation 3952@section Documentation about macros and packages 3953@cindex Documentation 3954 3955@deffn Command TeX-documentation-texdoc 3956@kindex C-c ? 3957(@kbd{C-c ?}) Get documentation about the packages installed on your 3958system, using @samp{texdoc} to find the manuals. The function will 3959prompt for the name of packages. If point is on a word, this will be 3960suggested as default. 3961 3962If the command is called with a prefix argument, you will be shown a 3963list of manuals of the given package among to choose. 3964 3965The command can be invoked by the key binding mentioned above as well as 3966the @samp{Find Documentation...} entry in the mode menu. 3967@end deffn 3968 3969@node Customization 3970@chapter Customization and Extension 3971 3972@menu 3973* Modes and Hooks:: Modes and Hooks 3974* Multifile:: Multifile Documents 3975* Parsing Files:: Automatic Parsing of @TeX{} Files 3976* Internationalization:: Language Support 3977* Automatic:: Automatic Customization 3978* Style Files:: Writing Your Own Style Support 3979@end menu 3980 3981@node Modes and Hooks 3982@section Modes and Hooks 3983 3984@AUCTeX{} supports a wide variety of derivatives and extensions of 3985@TeX{}. Besides plain @TeX{} those are @LaTeX{}, AMS-@TeX{}, 3986@ConTeXt{}, Texinfo and doc@TeX{}. For each of them there is a separate 3987major mode in @AUCTeX{} and each major mode runs @code{text-mode-hook}, 3988@code{TeX-mode-hook} as well as a hook special to the mode in this 3989order. The following table provides an overview of the respective mode 3990functions and hooks. 3991 3992@multitable {Plain @TeX{}} {@code{plain-TeX-mode}} {@code{plain-TeX-mode-hook}} 3993@headitem Type @tab Mode function @tab Hook 3994@item Plain @TeX{} @tab @code{plain-TeX-mode} @tab @code{plain-TeX-mode-hook} 3995@item @LaTeX{} @tab @code{LaTeX-mode} @tab @code{LaTeX-mode-hook} 3996@item AMS-@TeX{} @tab @code{ams-tex-mode} @tab @code{AmS-TeX-mode-hook} 3997@item @ConTeXt{} @tab @code{ConTeXt-mode} @tab @code{ConTeXt-mode-hook} 3998@item Texinfo @tab @code{Texinfo-mode} @tab @code{Texinfo-mode-hook} 3999@item Doc@TeX{} @tab @code{docTeX-mode} @tab @code{docTeX-mode-hook} 4000@end multitable 4001@findex plain-TeX-mode 4002@vindex plain-TeX-mode-hook 4003@findex LaTeX-mode 4004@vindex LaTeX-mode-hook 4005@findex AmS-TeX-mode 4006@vindex AmS-TeX-mode-hook 4007@findex ConTeXt-mode 4008@vindex ConTeXt-mode-hook 4009@findex Texinfo-mode 4010@vindex Texinfo-mode-hook 4011@findex docTeX-mode 4012@vindex docTeX-mode-hook 4013 4014If you need to make a customization via a hook which is only relevant 4015for one of the modes listed above, put it into the respective mode hook, 4016if it is relevant for any @AUCTeX{} mode, add it to @code{TeX-mode-hook} 4017and if it is relevant for all text modes, append it to 4018@code{text-mode-hook}. 4019 4020Other useful hooks are listed below. 4021 4022@defvr Variable TeX-after-compilation-finished-hook 4023Hook which is run after the @TeX{}/@LaTeX{} processor has successfully 4024finished compiling your document. (@xref{Processing}, for finding out 4025how to compile your document). Each function in the hook is run with 4026the compiled output document as its argument. 4027 4028This is useful for automatically refreshing the viewer after 4029re-compilation especially when using Emacs viewers such as DocView or 4030PDF Tools. The function @code{TeX-revert-document-buffer} can be added 4031to the hook for this purpose. 4032@end defvr 4033@vindex TeX-after-compilation-finished-hook 4034@findex TeX-revert-document-buffer 4035 4036@node Multifile 4037@section Multifile Documents 4038@cindex Multifile Documents 4039@cindex Documents 4040@cindex Documents with multiple files 4041@cindex Multiple Files 4042@cindex Many Files 4043@cindex Including 4044@cindex \include 4045@cindex Inputing 4046@cindex \input 4047@cindex Master file 4048 4049You may wish to spread a document over many files (as you are likely to do if 4050there are multiple authors, or if you have not yet discovered the power 4051of the outline commands (@pxref{Outline})). This can be done by having a 4052``master'' file in which you include the various files with the @TeX{} 4053macro @samp{\input} or the @LaTeX{} macro @samp{\include}. These 4054files may also include other files themselves. However, to format the 4055document you must run the commands on the top level master file. 4056 4057When you, for example, ask @AUCTeX{} to run a command on the master file, 4058it has no way of knowing the name of the master file. By default, 4059it will assume that the current file is the master file. If you insert 4060the following in your @file{.emacs} file @AUCTeX{} will use a more 4061advanced algorithm. 4062 4063@lisp 4064(setq-default TeX-master nil) ; Query for master file. 4065@end lisp 4066 4067If @AUCTeX{} finds the line indicating the end of the header in a master 4068file (@code{TeX-header-end}), it can figure out for itself that this is 4069a master file. Otherwise, it will ask for the name of the master file 4070associated with the buffer. To avoid asking you again, @AUCTeX{} will 4071automatically insert the name of the master file as a file variable 4072(@pxref{File Variables,,,emacs,The Emacs Editor}). You can also insert 4073the file variable yourself, by putting the following text at the end of 4074your files. 4075@findex TeX-header-end 4076 4077@example 4078%%% Local Variables: 4079%%% TeX-master: "master" 4080%%% End: 4081@end example 4082 4083You should always set this variable to the name of the top level document. If 4084you always use the same name for your top level documents, you can set 4085@code{TeX-master} in your @file{.emacs} file. 4086 4087@lisp 4088(setq-default TeX-master "master") ; All master files called "master". 4089@end lisp 4090 4091@defopt TeX-master 4092The master file associated with the current buffer. If the file being 4093edited is actually included from another file, then you can tell @AUCTeX{} 4094the name of the master file by setting this variable. If there are 4095multiple levels of nesting, specify the top level file. 4096 4097If this variable is @code{nil}, @AUCTeX{} will query you for the 4098name. 4099 4100If the variable is @code{t}, then @AUCTeX{} will assume the file is a master 4101file itself. 4102 4103If the variable is @code{shared}, then @AUCTeX{} will query for the name, 4104but will not change the file. 4105 4106If the variable is @code{dwim}, @AUCTeX{} will try to avoid querying by 4107attempting to ``do what I mean''; and then change the file. 4108@end defopt 4109 4110@defopt TeX-one-master 4111Regular expression matching ordinary @TeX{} files. 4112 4113You should set this variable to match the name of all files, for which 4114it is a good idea to append a @code{TeX-master} file variable entry 4115automatically. When @AUCTeX{} adds the name of the master file as a 4116file variable, it does not need to ask next time you edit the file. 4117 4118If you dislike @AUCTeX{} automatically modifying your files, you can 4119set this variable to @samp{"<none>"}. By default, @AUCTeX{} will modify 4120any file with an extension of @samp{.tex}. 4121@end defopt 4122 4123@deffn Command TeX-master-file-ask 4124@kindex C-c _ 4125(@kbd{C-c _}) Query for the name of a master file and add the respective 4126File Variables (@pxref{File Variables,,,emacs,The Emacs Editor}) to the 4127file for setting this variable permanently. 4128 4129@AUCTeX{} will not ask for a master file when it encounters existing 4130files. This function shall give you the possibility to insert the 4131variable manually. 4132@end deffn 4133 4134@AUCTeX{} keeps track of macros, environments, labels, and style 4135files that are used in a given document. For this to work with 4136multifile documents, @AUCTeX{} has to have a place to put the 4137information about the files in the document. This is done by having an 4138@file{auto} subdirectory placed in the directory where your document is 4139located. Each time you save a file, @AUCTeX{} will write information 4140about the file into the @file{auto} directory. When you load a file, 4141@AUCTeX{} will read the information in the @file{auto} directory 4142about the file you loaded @emph{and the master file specified by 4143@code{TeX-master}}. Since the master file (perhaps indirectly) includes 4144all other files in the document, @AUCTeX{} will get information from 4145all files in the document. This means that you will get from each file, 4146for example, completion for all labels defined anywhere in the document. 4147 4148@AUCTeX{} will create the @file{auto} directory automatically if 4149@code{TeX-auto-save} is non-nil. Without it, the files in the document 4150will not know anything about each other, except for the name of the 4151master file. @xref{Automatic Local}. 4152 4153@deffn Command TeX-save-document 4154@kindex C-c C-d 4155(@kbd{C-c C-d}) Save all buffers known to belong to the current document. 4156@end deffn 4157 4158@defopt TeX-save-query 4159If non-nil, then query the user before saving each file with 4160@code{TeX-save-document}. 4161@end defopt 4162 4163 4164@node Parsing Files 4165@section Automatic Parsing of @TeX{} Files 4166@cindex Parsing @TeX{} 4167@cindex Automatic Parsing 4168@cindex Tabs 4169@cindex Tabify 4170@cindex Untabify 4171 4172@AUCTeX{} depends heavily on being able to extract information from the 4173buffers by parsing them. Since parsing the buffer can be somewhat slow, 4174the parsing is initially disabled. You are encouraged to enable them by 4175adding the following lines to your @file{.emacs} file. 4176 4177@lisp 4178(setq TeX-parse-self t) ; Enable parse on load. 4179(setq TeX-auto-save t) ; Enable parse on save. 4180@end lisp 4181 4182The latter command will make @AUCTeX{} store the parsed information in 4183an @file{auto} subdirectory in the directory each time the @TeX{} files 4184are stored, @pxref{Automatic Local}. If @AUCTeX{} finds the pre-parsed 4185information when loading a file, it will not need to reparse the buffer. 4186The information in the @file{auto} directory is also useful for 4187multifile documents, @pxref{Multifile}, since it allows each file to 4188access the parsed information from all the other files in the document. 4189This is done by first reading the information from the master file, and 4190then recursively the information from each file stored in the master 4191file. 4192 4193The variables can also be done on a per file basis, by changing the file 4194local variables. 4195 4196@example 4197%%% Local Variables: 4198%%% TeX-parse-self: t 4199%%% TeX-auto-save: t 4200%%% End: 4201@end example 4202 4203Even when you have disabled the automatic parsing, you can force the 4204generation of style information by pressing @kbd{C-c C-n}. This is 4205often the best choice, as you will be able to decide when it is 4206necessary to reparse the file. 4207 4208@defopt TeX-parse-self 4209Parse file after loading it if no style hook is found for it. 4210@end defopt 4211 4212@defopt TeX-auto-save 4213Automatically save style information when saving the buffer. 4214@end defopt 4215 4216@deffn Command TeX-normal-mode @var{arg} 4217@kindex C-c C-n 4218(@kbd{C-c C-n}) Remove all information about this buffer, and apply the 4219style hooks again. Save buffer first including style information. With 4220optional argument, also reload the style hooks. 4221@end deffn 4222 4223When @AUCTeX{} saves your buffer, it can optionally convert all tabs in 4224your buffer into spaces. 4225Tabs confuse @AUCTeX{}'s error message parsing and so should generally be 4226avoided. However, tabs are significant in some environments, and so by 4227default @AUCTeX{} does not remove them. 4228To convert tabs to spaces when saving a buffer, insert the 4229following in your @file{.emacs} file: 4230 4231@lisp 4232(setq TeX-auto-untabify t) 4233@end lisp 4234 4235@defopt TeX-auto-untabify 4236Automatically remove all tabs from a file before saving it. 4237@end defopt 4238 4239Instead of disabling the parsing entirely, you can also speed it 4240significantly up by limiting the information it will search for (and 4241store) when parsing the buffer. You can do this by setting the default 4242values for the buffer local variables @code{TeX-auto-regexp-list} and 4243@code{TeX-auto-parse-length} in your @file{.emacs} file. 4244 4245@lisp 4246;; Only parse LaTeX class and package information. 4247(setq-default TeX-auto-regexp-list 'LaTeX-auto-minimal-regexp-list) 4248;; The class and package information is usually near the beginning. 4249(setq-default TeX-auto-parse-length 2000) 4250@end lisp 4251 4252This example will speed the parsing up significantly, but @AUCTeX{} 4253will no longer be able to provide completion for labels, macros, 4254environments, or bibitems specified in the document, nor will it know 4255what files belong to the document. 4256 4257These variables can also be specified on a per file basis, by changing 4258the file local variables. 4259 4260@example 4261%%% Local Variables: 4262%%% TeX-auto-regexp-list: TeX-auto-full-regexp-list 4263%%% TeX-auto-parse-length: 999999 4264%%% End: 4265@end example 4266 4267@defopt TeX-auto-regexp-list 4268List of regular expressions used for parsing the current file. 4269@end defopt 4270 4271@defopt TeX-auto-parse-length 4272Maximal length of @TeX{} file that will be parsed. 4273@end defopt 4274 4275The pre-specified lists of regexps are defined below. You can use these 4276before loading @AUCTeX{} by quoting them, as in the example above. 4277 4278@defvr Constant TeX-auto-empty-regexp-list 4279Parse nothing 4280@end defvr 4281 4282@defvr Constant LaTeX-auto-minimal-regexp-list 4283Only parse @LaTeX{} class and packages. 4284@end defvr 4285 4286@defvr Constant LaTeX-auto-label-regexp-list 4287Only parse @LaTeX{} labels. 4288@end defvr 4289 4290@defvr Constant LaTeX-auto-index-regexp-list 4291Only parse @LaTeX{} index and glossary entries. 4292@end defvr 4293 4294@defvr Constant LaTeX-auto-class-regexp-list 4295Only parse macros in @LaTeX{} classes and packages. 4296@end defvr 4297 4298@defvr Constant LaTeX-auto-pagestyle-regexp-list 4299Only parse @LaTeX{} pagestyles. 4300@end defvr 4301 4302@defvr Constant LaTeX-auto-counter-regexp-list 4303Only parse @LaTeX{} counters. 4304@end defvr 4305 4306@defvr Constant LaTeX-auto-length-regexp-list 4307Only parse @LaTeX{} lengths. 4308@end defvr 4309 4310@defvr Constant LaTeX-auto-savebox-regexp-list 4311Only parse @LaTeX{} saveboxes. 4312@end defvr 4313 4314@defvr Constant LaTeX-auto-regexp-list 4315Parse common @LaTeX{} commands. 4316@end defvr 4317 4318@defvr Constant plain-TeX-auto-regexp-list 4319Parse common plain @TeX{} commands. 4320@end defvr 4321 4322@defvr Constant TeX-auto-full-regexp-list 4323Parse all @TeX{} and @LaTeX{} commands that @AUCTeX{} can use. 4324@end defvr 4325 4326@node Internationalization 4327@section Language Support 4328@cindex Internationalization 4329@cindex Language Support 4330@cindex Character set 4331@cindex National letters 4332@cindex CJK language 4333@cindex MULE 4334@cindex C@TeX{} 4335@cindex China@TeX{} 4336@cindex p@TeX{} 4337@cindex ASCII p@TeX{} 4338@cindex j@TeX{} 4339@cindex NTT j@TeX{} 4340@cindex k@TeX{} 4341@cindex H@LaTeX{} 4342@cindex CJK-@LaTeX{} 4343@cindex UNICODE 4344@cindex MULE-UCS 4345 4346@TeX{} and Emacs are usable for European (Latin, Cyrillic, Greek) based 4347languages. Some @LaTeX{} and EmacsLisp packages are available for easy 4348typesetting and editing documents in European languages. 4349 4350@c Some Texinfo macros are not used because they require quite recent 4351@c texinfo versions (2005-03-05): 4352@c Second arg of @acronym is available with 4.7, @comma is available in 4353@c 4.7, @abbr is available in 4.8. 4354@c -> @abbr{MULE, MULtilingual Enhancement to GNU Emacs} 4355@c -> @acronym{CJK, Chinese@comma{} Japanese@comma{} and Korean} 4356 4357All Emacs versions supported by current @AUCTeX{} can handle 4358@acronym{CJK} languages by default. 4359 4360In most cases, special versions of @TeX{} engines are needed for 4361high-quality typesetting of @acronym{CJK} languages: C@TeX{} and 4362China@TeX{} for Chinese, ASCII p@TeX{}, up@TeX{} and NTT j@TeX{} for 4363Japanese, H@LaTeX{} and k@TeX{} for Korean. They are necessary as well 4364when you want to typeset documents saved in their domestic encodings 4365such as @acronym{Shift-JIS}. Currently, @AUCTeX{} offers native support 4366for p@TeX{}, up@TeX{} and j@TeX{} only. 4367 4368@c FIXME: We need more information for CTeX, ChinaTeX, KTeX, and HLaTeX. 4369 4370If you don't need fine tuning in the result with respect to the 4371typesetting rules of their respective national standards, most unicode 4372based @TeX{} engines e.g. Lua@TeX{} and Xe@TeX{} can handle 4373@acronym{CJK} languages by default if they are encoded in 4374@acronym{UTF-8}. The @acronym{CJK}-@LaTeX{} package is provided for 4375supporting @acronym{CJK} scripts in a standard @LaTeX{} document. 4376 4377@menu 4378* European:: Using @AUCTeX{} with European Languages 4379* Japanese:: Using @AUCTeX{} with Japanese 4380@end menu 4381 4382@node European 4383@subsection Using @AUCTeX{} with European Languages 4384@cindex Europe 4385@cindex European Characters 4386@cindex ISO 8859 Latin 1 4387@cindex Latin 1 4388@cindex ISO 8859 Latin 2 4389@cindex Latin 2 4390@cindex ANSI 4391 4392@subsubsection Typing and Displaying Non-ASCII Characters 4393 4394First you will need a way to write non-ASCII characters. You can either 4395use macros, or teach @TeX{} about the ISO character sets. I prefer the 4396latter, it has the advantage that the usual standard emacs word 4397movement and case change commands will work. 4398 4399With @LaTeX{}2e, just add @samp{\usepackage[latin1]@{inputenc@}}. Other 4400languages than Western European ones will probably have other encoding 4401needs. 4402 4403To be able to display non-ASCII characters you will need an appropriate 4404font and a version of GNU Emacs capable of displaying 8-bit characters. 4405The manner in which this is supported differs between Emacsen, so you 4406need to take a look at your respective documentation. 4407 4408A compromise is to use an European character set when editing the file, 4409and convert to @TeX{} macros when reading and writing the files. 4410 4411@table @file 4412@item iso-cvt.el 4413@cindex @file{iso-cvt.el} 4414Much like @file{iso-tex.el} but is bundled with Emacs 19.23 and later. 4415 4416@item X-Symbol 4417@cindex X-Symbol 4418a much more complete package for Emacs that can also handle a lot of 4419mathematical characters and input methods. 4420@end table 4421 4422@subsubsection Style Files for Different Languages 4423 4424@cindex ispell 4425@AUCTeX{} supports style files for several languages. Each style file 4426may modify @AUCTeX{} to better support the language, and will run 4427a language specific hook that will allow you to for example change 4428ispell dictionary, or run code to change the keyboard remapping. The 4429following will for example choose a Danish dictionary for documents 4430including @samp{\usepackage[danish]@{babel@}}. 4431This requires parsing to be enabled, @pxref{Parsing Files}. 4432 4433@lisp 4434(add-hook 'TeX-language-dk-hook 4435 (lambda () (ispell-change-dictionary "danish"))) 4436@end lisp 4437 4438The following style files are recognized: 4439 4440@c In alphabetic order of the hooks: 4441@vindex TeX-language-bg-hook 4442@vindex TeX-language-cz-hook 4443@vindex TeX-language-dk-hook 4444@vindex TeX-language-en-hook 4445@vindex TeX-language-nl-hook 4446@vindex TeX-language-de-hook 4447@vindex TeX-language-it-hook 4448@vindex TeX-language-is-hook 4449@vindex TeX-language-pl-hook 4450@vindex TeX-language-sk-hook 4451@vindex TeX-language-sv-hook 4452@cindex Bulgarian 4453@cindex Czech 4454@cindex Italian 4455@cindex Danish 4456@cindex Dutch 4457@cindex English 4458@cindex German 4459@cindex Polish 4460@cindex Slovak 4461@cindex Swedish 4462@table @file 4463@item bulgarian 4464Runs style hook @code{TeX-language-bg-hook}. Gives @samp{"} word 4465syntax, makes the @key{"} key insert a literal @samp{"}. Typing @key{"} 4466twice will insert insert @samp{"`} or @samp{"'} depending on context. 4467Typing @key{-} twice will insert @samp{"=}, three times @samp{--}. 4468 4469@item czech 4470Runs style hook @code{TeX-language-cz-hook}. Pressing @key{"} will 4471insert @samp{\uv@{} and @samp{@}} depending on context. 4472 4473@c Is the difference between dk and danish really intented? 4474@item danish 4475Runs style hook @code{TeX-language-dk-hook}. Pressing @key{"} will 4476insert @samp{"`} and @samp{"'} depending on context. Typing @key{-} 4477twice will insert @samp{"=}, i.e. a hyphen string allowing hyphenation 4478in the composing words. 4479@c dk.sty seems to be obsolete, so we don't want to encourage using it. 4480@c @item dk 4481@c Runs style hook @code{TeX-language-dk-hook}. 4482 4483@item dutch 4484Runs style hook @code{TeX-language-nl-hook}. 4485 4486@item english 4487@itemx australian 4488@itemx canadian 4489@itemx newzealand 4490Runs style hook @code{TeX-language-en-hook}. 4491 4492@item frenchb 4493@itemx francais 4494Runs style hook @code{TeX-language-fr-hook}. Pressing @key{"} will 4495insert @samp{\\og} and @samp{\\fg} depending on context. Note that the 4496language name for customizing @code{TeX-quote-language-alist} is 4497@samp{french}. 4498 4499@item german 4500@itemx ngerman 4501Runs style hook @code{TeX-language-de-hook}. Gives @samp{"} word 4502syntax, makes the @key{"} key insert a literal @samp{"}. Pressing the 4503key twice will give you opening or closing German quotes (@samp{"`} or 4504@samp{"'}). Typing @key{-} twice will insert @samp{"=}, three times 4505@samp{--}. 4506 4507@item icelandic 4508Runs style hook @code{TeX-language-is-hook}. Gives @samp{"} word 4509syntax, makes the @key{"} key insert a literal @samp{"}. Typing @key{"} 4510twice will insert insert @samp{"`} or @samp{"'} depending on context. 4511Typing @key{-} twice will insert @samp{"=}, three times @samp{--}. 4512 4513@item italian 4514Runs style hook @code{TeX-language-it-hook}. Pressing @key{"} will 4515insert @samp{"<} and @samp{">} depending on context. 4516 4517@item polish 4518Runs style hook @code{TeX-language-pl-hook}. Gives @samp{"} word syntax 4519and makes the @key{"} key insert a literal @samp{"}. Pressing @key{"} 4520twice will insert @samp{"`} or @samp{"'} depending on context. 4521 4522@item polski 4523Runs style hook @code{TeX-language-pl-hook}. Makes the @key{"} key 4524insert a literal @samp{"}. Pressing @key{"} twice will insert @samp{,,} 4525or @samp{''} depending on context. 4526 4527@item slovak 4528Runs style hook @code{TeX-language-sk-hook}. Pressing @key{"} will 4529insert @samp{\uv@{} and @samp{@}} depending on context. 4530 4531@item swedish 4532Runs style hook @code{TeX-language-sv-hook}. Pressing @key{"} will 4533insert @samp{''}. Typing @key{-} twice will insert @samp{"=}, three 4534times @samp{--}. 4535@end table 4536 4537Replacement of language-specific hyphen strings like @samp{"=} with 4538dashes does not require to type @key{-} three times in a row. You can 4539put point after the hypen string anytime and trigger the replacement by 4540typing @key{-}. 4541 4542In case you are not satisfied with the suggested behavior of quote and 4543hyphen insertion you can change it by customizing the variables 4544@code{TeX-quote-language-alist} and 4545@code{LaTeX-babel-hyphen-language-alist} respectively. 4546 4547@defopt TeX-quote-language-alist 4548Used for overriding the default language-specific quote insertion 4549behavior. This is an alist where each element is a list consisting of 4550four items. The first item is the name of the language in concern as a 4551string. See the list of supported languages above. The second item is 4552the opening quotation mark. The third item is the closing quotation 4553mark. Opening and closing quotation marks can be specified directly as 4554strings or as functions returning a string. The fourth item is a 4555boolean controlling quote insertion. It should be non-nil if if the 4556special quotes should only be used after inserting a literal @samp{"} 4557character first, i.e. on second key press. 4558@end defopt 4559 4560@defopt LaTeX-babel-hyphen-language-alist 4561Used for overriding the behavior of hyphen insertion for specific 4562languages. Every element in this alist is a list of three items. The 4563first item should specify the affected language as a string. The second 4564item denotes the hyphen string to be used as a string. The third item, 4565a boolean, controls the behavior of hyphen insertion and should be 4566non-nil if the special hyphen should be inserted after inserting a 4567literal @samp{-} character, i.e. on second key press. 4568@end defopt 4569 4570The defaults of hyphen insertion are defined by the variables 4571@code{LaTeX-babel-hyphen} and @code{LaTeX-babel-hyphen-after-hyphen} 4572respectively. 4573 4574@defopt LaTeX-babel-hyphen 4575String to be used when typing @key{-}. This usually is a hyphen 4576alternative or hyphenation aid provided by @samp{babel} and the related 4577language style files, like @samp{"=}, @samp{"~} or @samp{"-}. 4578 4579Set it to an empty string or nil in order to disable language-specific 4580hyphen insertion. 4581@end defopt 4582 4583@defopt LaTeX-babel-hyphen-after-hyphen 4584Control insertion of hyphen strings. If non-nil insert normal hyphen on 4585first key press and swap it with the language-specific hyphen string 4586specified in the variable @code{LaTeX-babel-hyphen} on second key press. 4587If nil do it the other way round. 4588@end defopt 4589 4590@node Japanese 4591@subsection Using @AUCTeX{} with Japanese @TeX{} 4592@cindex Japan 4593@cindex Japanese 4594@cindex Nippon 4595@cindex MULE 4596@cindex NTT j@TeX{} 4597@cindex j@TeX{} 4598@cindex j@LaTeX{} 4599@cindex ASCII p@TeX{} 4600@cindex p@TeX{} 4601@cindex p@LaTeX{} 4602@cindex up@TeX{} 4603@cindex up@LaTeX{} 4604@cindex @file{tex-jp.el} 4605@vindex TeX-default-mode 4606@vindex TeX-parse-self 4607@vindex TeX-engine 4608@vindex TeX-engine-alist 4609@vindex japanese-TeX-engine-default 4610@vindex japanese-LaTeX-default-style 4611@vindex japanese-TeX-use-kanji-opt-flag 4612@vindex TeX-japanese-process-input-coding-system 4613@vindex TeX-japanese-process-output-coding-system 4614 4615To write Japanese text with @AUCTeX{}, you need the versions of 4616@TeX{} and Emacs that support Japanese. @AUCTeX{} supports three 4617Japanese @TeX{} engines by default: NTT j@TeX{}, ASCII p@TeX{} and 4618up@TeX{}. 4619 4620To use the Japanese @TeX{} engines, activate 4621@code{japanese-plain-tex-mode} or @code{japanese-latex-mode}. If it 4622doesn't work, send mail to Masayuki Ataka 4623@samp{<masayuki.ataka@@gmail.com>} or Ikumi Keita 4624@samp{<ikumikeita@@jcom.home.ne.jp>}, who currently concern with 4625stuff related to Japanese in @AUCTeX{}. None of the primary @AUCTeX{} 4626maintainers understand Japanese, so they cannot help you. 4627 4628It is recommended to enable @code{TeX-parse-self} for typical Japanese 4629@LaTeX{} users. When enabled, @code{japanese-latex-mode} selects the 4630suitable Japanese @TeX{} engine automatically based on the class file 4631name (such as @code{jbook}, @code{jsarticle} and @code{tjreport}) and 4632its option. @pxref{Parsing Files}. 4633 4634It is important to select the suitable Japanese @TeX{} engine because 4635the selected engine determines the command name such as @samp{platex} 4636and @samp{uptex} to typeset the document. If you find that wrong 4637command is used, check the value of @code{TeX-engine} on that buffer. 4638If the value does not suit the current document, change the value by the 4639@samp{TeXing Options} submenu below the @samp{Command} menu. 4640@pxref{Processor Options}. 4641 4642To make the selected engine to persist across Emacs sessions, there are 4643two ways from which you can choose one according to your needs: 4644 4645@enumerate 4646@item 4647If you use a specific engine (almost) exclusively, customize the option 4648@code{japanese-TeX-engine-default}. 4649 4650@defopt japanese-TeX-engine-default 4651The default TeX engine in Japanese @TeX{} mode. 4652 4653The default value is @samp{ptex}. 4654@end defopt 4655@item 4656If you want to set the engine on a per file basis, use the file local 4657variables to set @code{TeX-engine}. 4658 4659Here is a sample code to set @code{TeX-engine} to @samp{uptex}: 4660 4661@example 4662%%% Local Variables: 4663%%% mode: japanese-latex 4664%%% TeX-engine: uptex 4665%%% End: 4666@end example 4667@end enumerate 4668 4669In the both cases above, the valid value is one of @samp{ptex}, 4670@samp{jtex} and @samp{uptex}. 4671 4672You can override the command names associated with the above three 4673engines or define your own engine by customizing 4674@code{TeX-engine-alist}. @xref{Processor Options}. 4675 4676It is sometimes necessary to use an engine which differs from the one 4677@AUCTeX{} selects automatically. For example, even when you want to use 4678@code{j-article} document class deliberately with ASCII p@LaTeX{}, 4679@AUCTeX{} selects NTT j@LaTeX{} command if @code{TeX-parse-self} is 4680enabled, because @code{j-article} originally belongs to NTT j@LaTeX{}. 4681In such cases, use the file local variable method above to select the 4682engine you intend to use. 4683 4684If you usually use @AUCTeX{} in Japanese, setting the following 4685variables is useful. 4686 4687@defopt TeX-default-mode 4688Mode to enter for a new file when it cannot be determined whether the 4689file is plain @TeX{} or @LaTeX{} or what. 4690 4691If you want to enter Japanese @LaTeX{} mode whenever this may happen, 4692set the variable like this: 4693@lisp 4694(setq TeX-default-mode 'japanese-latex-mode) 4695@end lisp 4696@end defopt 4697 4698@defopt japanese-LaTeX-default-style 4699The default style/class when creating a new Japanese @LaTeX{} document. 4700 4701The default value is @samp{"jarticle"}. 4702@end defopt 4703 4704It is recommended also for Japanese users to customize the option 4705@code{TeX-PDF-from-DVI} to @code{"Dvipdfmx"}. @xref{Processor Options} 4706 4707There are three customize options with regard to the encoding of 4708Japanese text. 4709 4710@defopt japanese-TeX-use-kanji-opt-flag 4711If non-nil, @AUCTeX{} adds @code{-kanji} option to the typesetting 4712command when @code{TeX-engine} is @samp{ptex}. 4713@end defopt 4714 4715Usually @AUCTeX{} guesses the right coding systems for input to and 4716output from the Japanese @TeX{} process, but you can override them by 4717the following two customize options. 4718 4719@defopt TeX-japanese-process-input-coding-system 4720If non-nil, used for encoding input to Japanese @TeX{} process. 4721When @code{nil}, @AUCTeX{} tries to choose suitable coding system. 4722@end defopt 4723 4724@defopt TeX-japanese-process-output-coding-system 4725If non-nil, used for decoding output from Japanese @TeX{} process. 4726When @code{nil}, @AUCTeX{} tries to choose suitable coding system. 4727@end defopt 4728 4729The former customize options @code{japanese-TeX-command-default}, 4730@code{japanese-LaTeX-command-default} and 4731@code{japanese-TeX-command-list} are removed from @AUCTeX{}. Use 4732@code{japanese-TeX-engine-default} instead. If you need to customize 4733the executable file name such as @samp{"latex"}, the options for them, 4734or both, customize @code{TeX-engine-alist}. 4735 4736The following two additional font commands are available in 4737@LaTeX{} mode buffer. 4738 4739@table @kbd 4740@item C-c C-f g 4741@kindex C-c C-f g 4742@cindex @code{\textgt} 4743@cindex @code{\mathgt} 4744Insert @b{gothic face} font command @samp{\textgt@{@point{}@}} or 4745@samp{\mathgt@{@point{}@}} depending on the context. 4746 4747@item C-c C-f m 4748@kindex C-c C-f m 4749@cindex @code{\textmc} 4750@cindex @code{\mathmc} 4751Insert mincho font command @samp{\textmc@{@point{}@}} or 4752@samp{\mathmc@{@point{}@}} depending on the context. 4753 4754@end table 4755 4756Although they are meaningful only with @samp{ptex} and @samp{uptex} 4757engines, it won't matter in buffers with other engines. 4758 4759See @file{tex-jp.el} for more information. 4760 4761@node Automatic 4762@section Automatic Customization 4763@cindex Automatic Customization 4764@cindex Extracting @TeX{} symbols 4765@cindex Automatic 4766@cindex @file{auto} directories. 4767@cindex Parsing @TeX{} 4768@cindex @TeX{} parsing 4769@cindex Generating symbols 4770 4771Since @AUCTeX{} is so highly customizable, it makes sense that it is able 4772to customize itself. The automatic customization consists of scanning 4773@TeX{} files and extracting symbols, environments, and things like that. 4774 4775The automatic customization is done on three different levels. The 4776global level is the level shared by all users at your site, and consists 4777of scanning the standard @TeX{} style files, and any extra styles added 4778locally for all users on the site. The private level deals with those 4779style files you have written for your own use, and use in different 4780documents. You may have a @file{~/lib/TeX/} directory where you store 4781useful style files for your own use. The local level is for a specific 4782directory, and deals with writing customization for the files for your 4783normal @TeX{} documents. 4784 4785If compared with the environment variable @code{TEXINPUTS}, the 4786global level corresponds to the directories built into @TeX{}. The 4787private level corresponds to the directories you add yourself, except for 4788@file{.}, which is the local level. 4789 4790@menu 4791* Automatic Global:: Automatic Customization for the Site 4792* Automatic Private:: Automatic Customization for a User 4793* Automatic Local:: Automatic Customization for a Directory 4794@end menu 4795 4796By default @AUCTeX{} will search for customization files in all the 4797global, private, and local style directories, but you can also set the 4798path directly. This is useful if you for example want to add another 4799person's style hooks to your path. Please note that all matching files 4800found in @code{TeX-style-path} are loaded, and all hooks defined in the 4801files will be executed. 4802 4803@defopt TeX-style-path 4804List of directories to search for @AUCTeX{} style files. 4805@end defopt 4806 4807By default, when @AUCTeX{} searches a directory for files, it will 4808recursively search through subdirectories. 4809 4810@defopt TeX-file-recurse 4811Whether to search @TeX{} directories recursively: nil means do not 4812recurse, a positive integer means go that far deep in the directory 4813hierarchy, t means recurse indefinitely. 4814@end defopt 4815 4816By default, @AUCTeX{} will ignore files named @file{.}, @file{..}, 4817@file{SCCS}, @file{RCS}, and @file{CVS}. 4818 4819@defopt TeX-ignore-file 4820Regular expression matching file names to ignore. 4821 4822These files or directories will not be considered when searching for 4823@TeX{} files in a directory. 4824@end defopt 4825 4826@node Automatic Global 4827@subsection Automatic Customization for the Site 4828@cindex Global style hook directory 4829@cindex Global macro directory 4830@cindex Site macro directory 4831@cindex Global @TeX{} macro directory 4832@cindex Site @TeX{} macro directory 4833@cindex Global directories 4834@cindex Site information 4835 4836Assuming that the automatic customization at the global level was done 4837when @AUCTeX{} was installed, your choice is now: will you use it? If 4838you use it, you will benefit by having access to all the symbols and 4839environments available for completion purposes. The drawback is slower 4840load time when you edit a new file and perhaps too many confusing 4841symbols when you try to do a completion. 4842 4843You can disable the automatic generated global style hooks by setting 4844the variable @code{TeX-auto-global} to nil. 4845 4846@defopt TeX-macro-global 4847Directories containing the site's @TeX{} style files. 4848@end defopt 4849 4850@defopt TeX-style-global 4851Directory containing hand generated @TeX{} information. 4852 4853These correspond to @TeX{} macros shared by all users of a site. 4854@end defopt 4855 4856@defopt TeX-auto-global 4857Directory containing automatically generated information. 4858 4859For storing automatic extracted information about the @TeX{} macros 4860shared by all users of a site. 4861@end defopt 4862 4863@node Automatic Private 4864@subsection Automatic Customization for a User 4865@cindex Private style hook directory 4866@cindex Private macro directory 4867@cindex Personal macro directory 4868@cindex Private @TeX{} macro directory 4869@cindex Personal @TeX{} macro directory 4870@cindex Private directories 4871@cindex Personal information 4872 4873You should specify where you store your private @TeX{} macros, so 4874@AUCTeX{} can extract their information. The extracted information will 4875go to the directories listed in @code{TeX-auto-private} 4876 4877Use @kbd{M-x TeX-auto-generate @key{RET}} to extract the information. 4878 4879@defopt TeX-macro-private 4880Directories where you store your personal @TeX{} macros. The value 4881defaults to the directories listed in the @samp{TEXINPUTS} and 4882@samp{BIBINPUTS} environment variables or to the respective directories 4883in @code{$TEXMFHOME} if no results can be obtained from the environment 4884variables. 4885@end defopt 4886 4887@defopt TeX-auto-private 4888List of directories containing automatically generated @AUCTeX{} style 4889files. These correspond to the personal @TeX{} macros. 4890@end defopt 4891 4892@deffn Command TeX-auto-generate @var{TEX} @var{AUTO} 4893(@kbd{M-x TeX-auto-generate @key{RET}}) Generate style hook for 4894@var{TEX} and store it in @var{AUTO}. If @var{TEX} is a directory, 4895generate style hooks for all files in the directory. 4896@end deffn 4897 4898@defopt TeX-style-private 4899List of directories containing hand generated @AUCTeX{} style files. 4900These correspond to the personal @TeX{} macros. 4901@end defopt 4902 4903@node Automatic Local 4904@subsection Automatic Customization for a Directory 4905@cindex Local style hooks 4906@cindex Updating style hooks 4907@cindex Automatic updating style hooks 4908@cindex Local style hooks 4909@cindex Local style directory 4910 4911@AUCTeX{} can update the style information about a file each time you 4912save it, and it will do this if the directory @code{TeX-auto-local} 4913exists. @code{TeX-auto-local} is by default set to @samp{"auto"}, so 4914simply creating an @file{auto} directory will enable automatic saving of 4915style information. 4916 4917The advantage of doing this is that macros, labels, etc. defined in any 4918file in a multifile document will be known in all the files in the 4919document. The disadvantage is that saving will be slower. To disable, 4920set @code{TeX-auto-local} to nil. 4921 4922@defopt TeX-style-local 4923Directory containing hand generated @TeX{} information. 4924 4925These correspond to @TeX{} macros found in the current directory. 4926@end defopt 4927 4928@defopt TeX-auto-local 4929Directory containing automatically generated @TeX{} information. 4930 4931These correspond to @TeX{} macros found in the current directory. 4932@end defopt 4933 4934@node Style Files 4935@section Writing Your Own Style Support 4936@cindex Style files 4937@cindex Style hooks 4938@cindex @file{style} 4939 4940@xref{Automatic}, for a discussion about automatically generated global, 4941private, and local style files. The hand generated style files are 4942equivalent, except that they by default are found in @file{style} 4943directories instead of @file{auto} directories. 4944 4945@menu 4946* Simple Style:: A Simple Style File 4947* Adding Macros:: Adding Support for Macros 4948* Adding Environments:: Adding Support for Environments 4949* Adding Other:: Adding Other Information 4950* Hacking the Parser:: Automatic Extraction of New Things 4951@end menu 4952 4953If you write some useful support for a public @TeX{} style file, please 4954send it to us. 4955 4956@node Simple Style 4957@subsection A Simple Style File 4958@cindex @file{book.el} 4959@cindex Sample style file 4960@cindex Style file 4961@cindex Example of a style file. 4962@cindex Style hook 4963@cindex Adding a style hook 4964 4965Here is a simple example of a style file. 4966 4967@lisp 4968;;; book.el - Special code for book style. 4969 4970(TeX-add-style-hook 4971 "book" 4972 (lambda () 4973 (LaTeX-largest-level-set "chapter")) 4974 LaTeX-dialect) 4975@end lisp 4976 4977The example is from the @AUCTeX{} sources and is loaded for any @LaTeX{} 4978document using the book document class (or style before @LaTeX{}2e). 4979The file specifies that the largest kind of section in such a document 4980is chapter. The interesting thing to notice is that the style file 4981defines an (anonymous) function, and adds it to the list of loaded style 4982hooks by calling @code{TeX-add-style-hook}. 4983 4984The first time the user indirectly tries to access some style-specific 4985information, such as the largest sectioning command available, the style 4986hooks for all files directly or indirectly read by the current document 4987are executed. The actual files will only be evaluated once, but the 4988hooks will be called for each buffer using the style file. 4989 4990Note that the basename of the style file and the name of the style hook 4991should usually be identical. 4992 4993@defun TeX-add-style-hook @var{style} @var{hook} &optional @var{dialect-expr} 4994Add @var{hook} to the list of functions to run when we use the @TeX{} 4995file @var{style} and the current dialect is one in the set derived from 4996@var{dialect-expr}. When @var{dialect-expr} is omitted, then @var{hook} 4997is allowed to be run whatever the current dialect is. 4998 4999@var{dialect-expr} may be one of: 5000 5001@itemize 5002@item 5003A symbol indicating a singleton containing one basic @TeX{} dialect, 5004this symbol shall be selected among: 5005@table @code 5006@item :latex 5007For all files in @LaTeX{} mode, or any mode derived thereof. 5008@item :bibtex 5009For all files in Bib@TeX{} mode, or any mode derived thereof. 5010@item :texinfo 5011For all files in @acronym{Texinfo} mode. 5012@item :plain-tex 5013For all files in plain-@TeX{} mode, or any mode derived thereof. 5014@item :context 5015For all files in @ConTeXt{} mode. 5016@item :classopt 5017For class options of @LaTeX{} document. This is provided as 5018pseudo-dialect for style hooks associated with class options. 5019@end table 5020@item 5021A logical expression like: 5022@table @code 5023@item (or @var{dialect-expression1} @dots{} @var{dialect-expression_@var{n}}) 5024For union of the sets of dialects corresponding to @var{dialect-expression1} 5025through @var{dialect-expression_@var{n}} 5026@item (and @var{dialect-expression1} @dots{} @var{dialect-expression_@var{n}}) 5027For intersection of the sets of dialects corresponding to 5028@var{dialect-expression1} through @var{dialect-expression_@var{n}} 5029@item (nor @var{dialect-expression1} @dots{} @var{dialect-expression_@var{n}}) 5030For complement of the union sets of dialects corresponding to 5031@var{dialect-expression1} through @var{dialect-expression_@var{n}} 5032relatively to the set of all supported dialects 5033@item (not @var{dialect-expr}) 5034For complement set of dialect corresponding to @var{dialect-expr} 5035relatively to the set of all supported dialects 5036@end table 5037@end itemize 5038 5039@end defun 5040 5041In case of adding a style hook for @LaTeX{}, when calling function 5042@code{TeX-add-style-hook} it is thought more futureproof for argument 5043@var{dialect-expr} to pass constant @code{LaTeX-dialect} currently 5044defined to @code{:latex}, rather than passing @code{:latex} directly. 5045 5046@defvr Constant LaTeX-dialect 5047Default dialect for use with function @code{TeX-add-style-hook} for 5048argument @var{dialect-expr} when the hook is to be run only on LaTeX 5049file, or any mode derived thereof. 5050@end defvr 5051 5052 5053@node Adding Macros 5054@subsection Adding Support for Macros 5055@cindex Adding macros 5056@cindex Macros, adding 5057@cindex Defining macros in style hooks 5058 5059The most common thing to define in a style hook is new symbols (@TeX{} 5060macros). Most likely along with a description of the arguments to the 5061function, since the symbol itself can be defined automatically. 5062 5063Here are a few examples from @file{latex.el}. 5064 5065@lisp 5066(TeX-add-style-hook 5067 "latex" 5068 (lambda () 5069 (TeX-add-symbols 5070 '("arabic" TeX-arg-counter) 5071 '("label" TeX-arg-define-label) 5072 '("ref" TeX-arg-ref) 5073 '("newcommand" TeX-arg-define-macro [ "Number of arguments" ] t) 5074 '("newtheorem" TeX-arg-define-environment 5075 [ TeX-arg-environment "Numbered like" ] 5076 t [ TeX-arg-counter "Within counter" ])))) 5077@end lisp 5078 5079@defun TeX-add-symbols @var{symbol} @dots{} 5080Add each @var{symbol} to the list of known symbols. 5081@end defun 5082 5083Each argument to @code{TeX-add-symbols} is a list describing one symbol. 5084The head of the list is the name of the symbol, the remaining elements 5085describe each argument. 5086 5087If there are no additional elements, the symbol will be inserted with 5088point inside braces. Otherwise, each argument of this function should 5089match an argument of the @TeX{} macro. What is done depends on the argument 5090type. 5091 5092If a macro is defined multiple times, @AUCTeX{} will choose the one with 5093the longest definition (i.e. the one with the most arguments). 5094 5095Thus, to overwrite 5096@example 5097 '("tref" 1) ; one argument 5098@end example 5099you can specify 5100@example 5101 '("tref" TeX-arg-ref ignore) ; two arguments 5102@end example 5103 5104@code{ignore} is a function that does not do anything, so when you 5105insert a @samp{tref} you will be prompted for a label and no more. 5106 5107You can use the following types of specifiers for arguments: 5108 5109@table @code 5110@item string 5111Use the string as a prompt to prompt for the argument. 5112 5113@item number 5114Insert that many braces, leave point inside the first. 0 and -1 are 5115special. 0 means that no braces are inserted. -1 means that braces are 5116inserted around the macro and an active region (e.g. @samp{@{\tiny 5117foo@}}). If there is no active region, no braces are inserted. 5118 5119@item nil 5120Insert empty braces. 5121 5122@item t 5123Insert empty braces, leave point between the braces. 5124 5125@item other symbols 5126Call the symbol as a function. You can define your 5127own hook, or use one of the predefined argument hooks. 5128 5129@item list 5130If the car is a string, insert it as a prompt and the next 5131element as initial input. Otherwise, call the car of the list with 5132the remaining elements as arguments. 5133 5134@item vector 5135Optional argument. If it has more than one element, parse it 5136as a list, otherwise parse the only element as above. Use square 5137brackets instead of curly braces, and is not inserted on empty user 5138input. 5139@end table 5140 5141A lot of argument hooks have already been defined. The first argument to 5142all hooks is a flag indicating if it is an optional argument. It is up 5143to the hook to determine what to do with the remaining arguments, if 5144any. Typically the next argument is used to overwrite the default 5145prompt. 5146 5147@ftable @code 5148@item TeX-arg-conditional 5149Implements if EXPR THEN ELSE. If EXPR evaluates to true, parse THEN as an 5150argument list, else parse ELSE as an argument list. 5151 5152@item TeX-arg-literal 5153Insert its arguments into the buffer. Used for specifying extra syntax 5154for a macro. 5155 5156@item TeX-arg-free 5157Parse its arguments but use no braces when they are inserted. 5158 5159@item TeX-arg-eval 5160Evaluate arguments and insert the result in the buffer. 5161 5162@item TeX-arg-label 5163Prompt for a label completing with known labels. If Ref@TeX{} is 5164active, prompt for the reference format. 5165 5166@item TeX-arg-ref 5167Prompt for a label completing with known labels. If Ref@TeX{} is 5168active, do not prompt for the reference format. Usually, reference 5169macros should use this function instead of @code{TeX-arg-label}. 5170 5171@item TeX-arg-index-tag 5172Prompt for an index tag. This is the name of an index, not the entry. 5173 5174@item TeX-arg-index 5175Prompt for an index entry completing with known entries. 5176 5177@item TeX-arg-length 5178Prompt for a @LaTeX{} length completing with known lengths. 5179 5180@item TeX-arg-macro 5181Prompt for a @TeX{} macro with completion. 5182 5183@item TeX-arg-date 5184@vindex TeX-date-format 5185Prompt for a date, defaulting to the current date. The format of the 5186date is specified by the @code{TeX-date-format} option. If you want to 5187change the format when the @samp{babel} package is loaded with a 5188specific language, set @code{TeX-date-format} inside the appropriate 5189language hook, for details @pxref{European}. 5190 5191@item TeX-arg-version 5192Prompt for the version of a file, using as initial input the current 5193date. 5194 5195@item TeX-arg-environment 5196Prompt for a @LaTeX{} environment with completion. 5197 5198@item TeX-arg-cite 5199@vindex TeX-arg-cite-note-p 5200Prompt for a Bib@TeX{} citation. If the variable 5201@code{TeX-arg-cite-note-p} is non-nil, ask also for optional note in citations. 5202 5203@item TeX-arg-counter 5204Prompt for a @LaTeX{} counter completing with known counters. 5205 5206@item TeX-arg-savebox 5207Prompt for a @LaTeX{} savebox completing with known saveboxes. 5208 5209@item TeX-arg-file 5210Prompt for a filename in the current directory, and use it with the 5211extension. 5212 5213@item TeX-arg-file-name 5214Prompt for a filename and use as initial input the name of the file 5215being visited in the current buffer, with extension. 5216 5217@item TeX-arg-file-name-sans-extension 5218Prompt for a filename and use as initial input the name of the file 5219being visited in the current buffer, without extension. 5220 5221@item TeX-arg-input-file 5222@vindex TeX-arg-input-file-search 5223Prompt for the name of an input file in @TeX{}'s search path, and use it 5224without the extension. Run the style hooks for the file. (Note that 5225the behavior (type of prompt and inserted file name) of the function can 5226be controlled by the variable @code{TeX-arg-input-file-search}.) 5227 5228@item TeX-arg-define-label 5229Prompt for a label completing with known labels. Add label to list of 5230defined labels. 5231 5232@item TeX-arg-define-length 5233Prompt for a @LaTeX{} length completing with known lengths. Add length 5234to list of defined lengths. 5235 5236@item TeX-arg-define-macro 5237Prompt for a @TeX{} macro with completion. Add macro to list of defined 5238macros. 5239 5240@item TeX-arg-define-environment 5241Prompt for a @LaTeX{} environment with completion. Add environment to 5242list of defined environments. 5243 5244@item TeX-arg-define-cite 5245Prompt for a Bib@TeX{} citation. 5246 5247@item TeX-arg-define-counter 5248Prompt for a @LaTeX{} counter. 5249 5250@item TeX-arg-define-savebox 5251Prompt for a @LaTeX{} savebox. 5252 5253@item TeX-arg-document 5254@vindex LaTeX-default-style 5255@vindex LaTeX-default-options 5256@vindex TeX-arg-input-file-search 5257@vindex LaTeX-style-list 5258Prompt for a @LaTeX{} document class, using @code{LaTeX-default-style} 5259as default value and @code{LaTeX-default-options} as default list of 5260options. If the variable @code{TeX-arg-input-file-search} is t, you 5261will be able to complete with all @LaTeX{} classes available on your 5262system, otherwise classes listed in the variable @code{LaTeX-style-list} 5263will be used for completion. It is also provided completion for options 5264of many common classes. 5265 5266@item LaTeX-arg-usepackage 5267@vindex TeX-arg-input-file-search 5268Prompt for @LaTeX{} packages. If the variable 5269@code{TeX-arg-input-file-search} is t, you will be able to complete with 5270all @LaTeX{} packages available on your system. It is also provided 5271completion for options of many common packages. 5272 5273@item TeX-arg-bibstyle 5274Prompt for a Bib@TeX{} style file completing with all style available on 5275your system. 5276 5277@item TeX-arg-bibliography 5278Prompt for BibTeX database files completing with all databases available 5279on your system. 5280 5281@item TeX-arg-corner 5282Prompt for a @LaTeX{} side or corner position with completion. 5283 5284@item TeX-arg-lr 5285Prompt for a @LaTeX{} side with completion. 5286 5287@item TeX-arg-tb 5288Prompt for a @LaTeX{} side with completion. 5289 5290@item TeX-arg-pagestyle 5291Prompt for a @LaTeX{} pagestyle with completion. 5292 5293@item TeX-arg-verb 5294Prompt for delimiter and text. 5295 5296@item TeX-arg-verb-delim-or-brace 5297Prompt for delimiter and text. This function is similar to 5298@code{TeX-arg-verb}, but is intended for macros which take their 5299argument enclosed in delimiters or in braces. 5300 5301@item TeX-arg-pair 5302Insert a pair of numbers, use arguments for prompt. The numbers are 5303surrounded by parentheses and separated with a comma. 5304 5305@item TeX-arg-size 5306Insert width and height as a pair. No arguments. 5307 5308@item TeX-arg-coordinate 5309Insert x and y coordinates as a pair. No arguments. 5310 5311@item LaTeX-arg-author 5312@vindex LaTeX-default-author 5313Prompt for document author, using @code{LaTeX-default-author} as initial 5314input. 5315 5316@item TeX-read-key-val 5317Prompt for a key=value list of options and return them. 5318 5319@item TeX-arg-key-val 5320Prompt for a key=value list of options and insert it as a @TeX{} macro 5321argument. 5322@end ftable 5323 5324If you add new hooks, you can assume that point is placed directly after 5325the previous argument, or after the macro name if this is the first 5326argument. Please leave point located after the argument you are 5327inserting. If you want point to be located somewhere else after all 5328hooks have been processed, set the value of @code{exit-mark}. It will 5329point nowhere, until the argument hook sets it. 5330 5331Some packages provide macros that are rarely useful to non-expert users. 5332Those should be marked as expert macros using 5333@code{TeX-declare-expert-macros}. 5334 5335@defun TeX-declare-expert-macros @var{style} @var{macros}... 5336Declare MACROS as expert macros of STYLE. 5337 5338Expert macros are completed depending on `TeX-complete-expert-commands'. 5339@end defun 5340 5341 5342@node Adding Environments 5343@subsection Adding Support for Environments 5344@cindex Adding environments 5345@cindex Environments, adding 5346@cindex Defining environments in style hooks 5347 5348Adding support for environments is very much like adding support for 5349@TeX{} macros, except that each environment normally only takes one 5350argument, an environment hook. The example is again a short version of 5351@file{latex.el}. 5352 5353@lisp 5354(TeX-add-style-hook 5355 "latex" 5356 (lambda () 5357 (LaTeX-add-environments 5358 '("document" LaTeX-env-document) 5359 '("enumerate" LaTeX-env-item) 5360 '("itemize" LaTeX-env-item) 5361 '("list" LaTeX-env-list)))) 5362@end lisp 5363 5364It is completely up to the environment hook to insert the environment, 5365but the function @code{LaTeX-insert-environment} may be of some help. 5366The hook will be called with the name of the environment as its first 5367argument, and extra arguments can be provided by adding them to a list 5368after the hook. 5369 5370For simple environments with arguments, for example defined with 5371@samp{\newenvironment}, you can make @AUCTeX{} prompt for the arguments 5372by giving the prompt strings in the call to 5373@code{LaTeX-add-environments}. The fact that an argument is optional 5374can be indicated by wrapping the prompt string in a vector. 5375 5376For example, if you have defined a @code{loop} environment with the 5377three arguments @var{from}, @var{to}, and @var{step}, you can add 5378support for them in a style file. 5379 5380@example 5381%% loop.sty 5382 5383\newenvironment@{loop@}[3]@{...@}@{...@} 5384@end example 5385 5386@lisp 5387;; loop.el 5388 5389(TeX-add-style-hook 5390 "loop" 5391 (lambda () 5392 (LaTeX-add-environments 5393 '("loop" "From" "To" "Step")))) 5394@end lisp 5395 5396If an environment is defined multiple times, @AUCTeX{} will choose the 5397one with the longest definition. Thus, if you have an enumerate style 5398file, and want it to replace the standard @LaTeX{} enumerate hook above, 5399you could define an @file{enumerate.el} file as follows, and place it in 5400the appropriate style directory. 5401 5402@lisp 5403(TeX-add-style-hook 5404 "latex" 5405 (lambda () 5406 (LaTeX-add-environments 5407 '("enumerate" LaTeX-env-enumerate foo)))) 5408 5409(defun LaTeX-env-enumerate (environment &optional ignore) ...) 5410@end lisp 5411 5412The symbol @code{foo} will be passed to @code{LaTeX-env-enumerate} as 5413the second argument, but since we only added it to overwrite the 5414definition in @file{latex.el} it is just ignored. 5415 5416@defun LaTeX-add-environments @var{env} @dots{} 5417Add each @var{env} to list of loaded environments. 5418@end defun 5419 5420@defun LaTeX-insert-environment @var{env} [ @var{extra} ] 5421Insert environment of type @var{env}, with optional argument @var{extra}. 5422@end defun 5423 5424Following is a list of available hooks for 5425@code{LaTeX-add-environments}: 5426 5427@ftable @code 5428@item LaTeX-env-item 5429Insert the given environment and the first item. 5430 5431@item LaTeX-env-figure 5432Insert the given figure-like environment with a caption and a label. 5433 5434@item LaTeX-env-array 5435Insert the given array-like environment with position and column 5436specifications. 5437 5438@item LaTeX-env-label 5439Insert the given environment with a label. 5440 5441@item LaTeX-env-list 5442Insert the given list-like environment, a specifier for the label and 5443the first item. 5444 5445@item LaTeX-env-minipage 5446Insert the given minipage-like environment with position and width 5447specifications. 5448 5449@item LaTeX-env-tabular* 5450Insert the given tabular*-like environment with width, position and 5451column specifications. 5452 5453@item LaTeX-env-picture 5454Insert the given environment with width and height specifications. 5455 5456@item LaTeX-env-bib 5457Insert the given environment with a label for a bibitem. 5458 5459@item LaTeX-env-contents 5460Insert the given environment with a filename as its argument. 5461 5462@item LaTeX-env-args 5463Insert the given environment with arguments. You can use this as a hook 5464in case you want to specify multiple complex arguments just like in 5465elements of @code{TeX-add-symbols}. This is most useful if the 5466specification of arguments to be prompted for with strings and strings 5467wrapped in a vector as described above is too limited. 5468 5469Here is an example from @file{listings.el} which calls a function with 5470one argument in order to prompt for a key=value list to be inserted as 5471an optional argument of the @samp{lstlisting} environment: 5472 5473@lisp 5474(LaTeX-add-environments 5475 '("lstlisting" LaTeX-env-args 5476 [TeX-arg-key-val LaTeX-listings-key-val-options])) 5477@end lisp 5478@end ftable 5479 5480Some packages provide environments that are rarely useful to non-expert 5481users. Those should be marked as expert environments using 5482@code{LaTeX-declare-expert-environments}. 5483 5484@defun LaTeX-declare-expert-environments @var{style} @var{ENVIRONMENTS}... 5485Declare ENVIRONMENTS as expert environments of STYLE. 5486 5487Expert environments are completed depending on `TeX-complete-expert-commands'. 5488@end defun 5489 5490 5491@node Adding Other 5492@subsection Adding Other Information 5493@cindex Adding bibliographies 5494@cindex Bibliographies, adding 5495@cindex Defining bibliographies in style hooks 5496@cindex Adding labels 5497@cindex Labels, adding 5498@cindex Defining labels in style hooks 5499@cindex Adding other information 5500@cindex Other information, adding 5501@cindex Defining other information in style hooks 5502 5503You can also specify bibliographical databases and labels in the style 5504file. This is probably of little use, since this information will 5505usually be automatically generated from the @TeX{} file anyway. 5506 5507@defun LaTeX-add-bibliographies @var{bibliography} @dots{} 5508Add each @var{bibliography} to list of loaded bibliographies. 5509@end defun 5510 5511@defun LaTeX-add-labels @var{label} @dots{} 5512Add each @var{label} to the list of known labels. 5513@end defun 5514 5515@node Hacking the Parser 5516@subsection Automatic Extraction of New Things 5517@cindex Parsing new macros 5518@cindex @file{macro.tex} 5519@cindex @file{macro.el} 5520@cindex Changing the parser 5521 5522The automatic @TeX{} information extractor works by searching for 5523regular expressions in the @TeX{} files, and storing the matched 5524information. You can add support for new constructs to the parser, 5525something that is needed when you add new commands to define symbols. 5526 5527For example, in the file @file{macro.tex} I define the following macro. 5528 5529@example 5530\newcommand@{\newmacro@}[5]@{% 5531\def#1@{#3\index@{#4@@#5~cite@{#4@}@}\nocite@{#4@}@}% 5532\def#2@{#5\index@{#4@@#5~cite@{#4@}@}\nocite@{#4@}@}% 5533@} 5534@end example 5535 5536@AUCTeX{} will automatically figure out that @samp{newmacro} is a macro 5537that takes five arguments. However, it is not smart enough to 5538automatically see that each time we use the macro, two new macros are 5539defined. We can specify this information in a style hook file. 5540 5541@lisp 5542;;; macro.el --- Special code for my own macro file. 5543 5544;;; Code: 5545 5546(defvar TeX-newmacro-regexp 5547 '("\\\\newmacro@{\\\\\\([a-zA-Z]+\\)@}@{\\\\\\([a-zA-Z]+\\)@}" 5548 (1 2) TeX-auto-multi) 5549 "Matches \newmacro definitions.") 5550 5551(defvar TeX-auto-multi nil 5552 "Temporary for parsing \\newmacro definitions.") 5553 5554(defun TeX-macro-cleanup () 5555 "Move symbols from `TeX-auto-multi' to `TeX-auto-symbol'." 5556 (mapcar (lambda (list) 5557 (mapcar (lambda (symbol) 5558 (setq TeX-auto-symbol 5559 (cons symbol TeX-auto-symbol))) 5560 list)) 5561 TeX-auto-multi)) 5562 5563(defun TeX-macro-prepare () 5564 "Clear `Tex-auto-multi' before use." 5565 (setq TeX-auto-multi nil)) 5566 5567(add-hook 'TeX-auto-prepare-hook 'TeX-macro-prepare) 5568(add-hook 'TeX-auto-cleanup-hook 'TeX-macro-cleanup) 5569 5570(TeX-add-style-hook 5571 "macro" 5572 (lambda () 5573 (TeX-auto-add-regexp TeX-newmacro-regexp) 5574 (TeX-add-symbols '("newmacro" 5575 TeX-arg-macro 5576 (TeX-arg-macro "Capitalized macro: \\") 5577 t 5578 "BibTeX entry: " 5579 nil)))) 5580 5581;;; macro.el ends here 5582@end lisp 5583 5584When this file is first loaded, it adds a new entry to 5585@code{TeX-newmacro-regexp}, and defines a function to be called before 5586the parsing starts, and one to be called after the parsing is done. It 5587also declares a variable to contain the data collected during parsing. 5588Finally, it adds a style hook which describes the @samp{newmacro} macro, 5589as we have seen it before. 5590 5591So the general strategy is: Add a new entry to @code{TeX-newmacro-regexp}. 5592Declare a variable to contain intermediate data during parsing. Add hook 5593to be called before and after parsing. In this case, the hook before 5594parsing just initializes the variable, and the hook after parsing 5595collects the data from the variable, and adds them to the list of symbols 5596found. 5597 5598@defvar TeX-auto-regexp-list 5599List of regular expressions matching @TeX{} macro definitions. 5600 5601The list has the following format ((REGEXP MATCH TABLE) @dots{}), that 5602is, each entry is a list with three elements. 5603 5604REGEXP. Regular expression matching the macro we want to parse. 5605 5606MATCH. A number or list of numbers, each representing one 5607parenthesized subexpression matched by REGEXP. 5608 5609TABLE. The symbol table to store the data. This can be a function, in 5610which case the function is called with the argument MATCH. Use 5611@code{TeX-match-buffer} to get match data. If it is not a function, it 5612is presumed to be the name of a variable containing a list of match 5613data. The matched data (a string if MATCH is a number, a list of 5614strings if MATCH is a list of numbers) is put in front of the table. 5615@end defvar 5616 5617@defvar TeX-auto-prepare-hook nil 5618List of functions to be called before parsing a @TeX{} file. 5619@end defvar 5620 5621@defvar TeX-auto-cleanup-hook nil 5622List of functions to be called after parsing a @TeX{} file. 5623@end defvar 5624 5625@node Appendices 5626@appendix Copying, Changes, Development, FAQ, Texinfo Mode 5627 5628@menu 5629* Copying this Manual:: 5630* Changes:: 5631* Development:: 5632* FAQ:: 5633* Texinfo mode:: 5634@end menu 5635 5636@node Copying this Manual 5637@appendixsec Copying this Manual 5638 5639@ifinfo 5640The copyright notice for this manual is: 5641 5642@insertcopying 5643@end ifinfo 5644 5645The full license text can be read here: 5646 5647@menu 5648* GNU Free Documentation License:: License for copying this manual. 5649@end menu 5650 5651@lowersections 5652@include fdl.texi 5653@raisesections 5654 5655@node Changes 5656@appendixsec Changes and New Features 5657 5658@lowersections 5659@include changes.texi 5660@raisesections 5661 5662@subheading Older versions 5663See the file @file{history.texi} for older changes. 5664 5665@node Development 5666@appendixsec Future Development 5667 5668@lowersections 5669@include todo.texi 5670@raisesections 5671 5672@node FAQ 5673@appendixsec Frequently Asked Questions 5674 5675@lowersections 5676@include faq.texi 5677@raisesections 5678 5679@node Texinfo mode 5680@appendixsec Features specific to @AUCTeX{}'s Texinfo major mode 5681 5682@AUCTeX{} includes a major mode for editting Texinfo files. This major 5683mode is not the same mode as the native Texinfo mode (@pxref{(texinfo) 5684Texinfo Mode}) of Emacs, although they have the same name. However, 5685@AUCTeX{} still relies on a number of functions from the native Texinfo 5686mode. 5687 5688The following text describes which functionality is offered by @AUCTeX{} 5689and which by the native Texinfo mode. This should enable you to decide 5690when to consult the @AUCTeX{} manual and when the manual of the native 5691mode. And in case you are a seasoned user of the native mode, the 5692information should help you to swiftly get to know the 5693@AUCTeX{}-specific commands. 5694 5695@menu 5696* Exploiting:: How @AUCTeX{} and the native mode work together 5697* Superseding:: Where the native mode is superseded 5698* Mapping:: Where key bindings are mapped to the native mode 5699* Unbinding:: Which native mode key bindings are missing 5700@end menu 5701 5702@node Exploiting 5703@appendixsubsec How @AUCTeX{} and the native mode work together 5704 5705In a nutshell the split between @AUCTeX{} Texinfo mode, and native 5706Texinfo mode is as follows: 5707 5708@itemize 5709@item 5710Most of the editing (environment creation, commenting, font command 5711insertions) and/or processing commands (e.g. compiling or printing) 5712which are available in other @AUCTeX{} modes are also handled by 5713@AUCTeX{} in Texinfo mode. 5714 5715@item 5716Texinfo-related features (e.g. info node linkage or menu creation) rely 5717on the commands provided by the native Texinfo mode. @AUCTeX{} provides 5718the key bindings to reach these functions, keeping the same keys as in 5719native Texinfo whenever possible, or similar ones otherwise. 5720@end itemize 5721 5722@node Superseding 5723@appendixsubsec Where the native mode is superseded 5724 5725This section is directed to users of the native Texinfo mode switching 5726to @AUCTeX{}. It follows the summary of the native mode 5727(@pxref{(texinfo) Texinfo Mode Summary}) and lists which of its commands 5728are no longer of use. 5729 5730@table @asis 5731@item Insert commands 5732In the native Texinfo mode, frequently used Texinfo commands can be 5733inserted with key bindings of the form @kbd{C-c C-c @var{k}} where 5734@var{k} differs for each Texinfo command; @kbd{c} inserts @@code, 5735@kbd{d} inserts @@dfn, @kbd{k} @@kbd, etc. 5736 5737In @AUCTeX{} commands are inserted with the key binding @kbd{C-c C-m} 5738instead which prompts for the macro to be inserted. For font selection 5739commands (like @@b, @@i, or @@emph) and a few related ones (like @@var, 5740@@key or @@code) there are bindings which insert the respective macros 5741directly. They have the form @code{C-c C-f @var{k}} or @code{C-c C-f 5742C-@var{k}} and call the function @code{TeX-font}. Type @kbd{C-c C-f 5743@key{RET}} to get a list of supported commands. 5744 5745Note that the prefix argument is not handled the same way by @AUCTeX{}. 5746Note also that the node insertion command from the native mode 5747(@code{texinfo-insert-@@node}) can still accessed from the Texinfo menu 5748in @AUCTeX{}. 5749 5750@item Insert braces 5751In @AUCTeX{} braces can be inserted with the same key binding as in the 5752native Texinfo mode: @kbd{C-c @{}. But @AUCTeX{} uses its own function 5753for the feature: @code{TeX-insert-braces}. 5754 5755@item Insert environments 5756The native Texinfo mode does not insert full environments. Instead, it 5757provides the function @code{texinfo-insert-@@end} (mapped to @kbd{C-c 5758C-c e}) for closing an open environment with a matching @@end statement. 5759 5760In @AUCTeX{} you can insert full environments, i.e. both the opening and 5761closing statements, with the function @code{Texinfo-environment} (mapped 5762to @kbd{C-c C-e}). 5763 5764@item Format info files with makeinfo and @TeX{} 5765In the native Texinfo mode there are various functions and bindings to 5766format a region or the whole buffer for info or to typeset the 5767respective text. For example, there is @code{makeinfo-buffer} (mapped 5768to @kbd{C-c C-m C-b}) which runs @samp{makeinfo} on the buffer or there 5769is @code{texinfo-tex-buffer} (mapped to @kbd{C-c C-t C-b}) which runs 5770@TeX{} on the buffer in order to produce a @acronym{DVI} file. 5771 5772In @AUCTeX{} different commands for formatting or typesetting can be 5773invoked through the function @code{TeX-command-master} (mapped to 5774@kbd{C-c C-c}). After typing @kbd{C-c C-c}, you can select the desired 5775command, e.g @samp{Makeinfo} or @samp{TeX}, through a prompt in the mini 5776buffer. Note that you can make, say @samp{Makeinfo}, the default by 5777adding this statement in your init file: 5778 5779@lisp 5780(add-hook 'Texinfo-mode-hook 5781 (lambda () (setq TeX-command-default "Makeinfo"))) 5782@end lisp 5783 5784Note also that @kbd{C-c C-c Makeinfo @key{RET}} is not completely 5785functionally equivalent to @code{makeinfo-buffer} as the latter will 5786display the resulting info file in Emacs, showing the node corresponding 5787to the position in the source file, just after a successful compilation. 5788This is why, while using @AUCTeX{}, invoking @code{makeinfo-buffer} 5789might still be more convenient. 5790 5791Note also that in the case of a multifile document, @kbd{C-c C-c} in 5792@AUCTeX{} will work on the whole document (provided that the file 5793variable @code{TeX-master} is set correctly), while 5794@code{makeinfo-buffer} in the native mode will process only the current 5795buffer, provided at the @code{@@setfilename} statement is provided. 5796 5797@item Produce indexes and print 5798The native Texinfo mode provides the binding @kbd{C-c C-t C-i} 5799(@code{texinfo-texindex}) for producing an index and the bindings 5800@kbd{C-c C-t C-p} (@code{texinfo-tex-print}) and @kbd{C-c C-t C-q} 5801(@code{tex-show-print-queue}) for printing and showing the printer 5802queue. These are superseded by the respective commands available 5803through @kbd{C-c C-c} (@code{TeX-command-master}) in @AUCTeX{}: Index, 5804Print, and Queue. 5805 5806@item Kill jobs 5807The command @kbd{C-c C-t C-k} (@code{tex-kill-job}) in the native mode 5808is superseded by @kbd{C-c C-k} (@code{TeX-kill-job}) in @AUCTeX{}. 5809@end table 5810 5811@node Mapping 5812@appendixsubsec Where key bindings are mapped to the native mode 5813 5814This node follows the native Texinfo mode summary (@pxref{(texinfo) 5815Texinfo Mode Summary}) and lists only those commands to which @AUCTeX{} 5816provides a keybinding. 5817 5818Basically all commands of the native mode related to producing menus and 5819interlinking nodes are mapped to same or similar keys in @AUCTeX{}, 5820while a few insertion commands are mapped to @AUCTeX{}-like keys. 5821 5822@table @asis 5823 5824@item @code{@@item} insertion 5825The binding @kbd{C-c C-c i} for the insertion of @code{@@item} in the 5826native mode is mapped to @kbd{M-@key{RET}} or @kbd{C-c C-j} in 5827@AUCTeX{}, similar to other @AUCTeX{} modes. 5828 5829@item @code{@@end} insertion 5830The binding @kbd{C-c C-c e} for closing a @code{@@@var{foo}} command by 5831a corresponding @code{@@end @var{foo}} statement in the native mode is 5832mapped to @kbd{C-c C-]} in @AUCTeX{}, similar to other @AUCTeX{} modes. 5833 5834@item Move out of balanced braces 5835The binding @kbd{C-@}} (@code{up-list}) is available both in the native 5836mode and in @AUCTeX{}. (This is because the command is not implemented 5837in either mode but a native Emacs command.) However, in @AUCTeX{}, you 5838cannot use @kbd{C-]} for this, as it is used for @code{@@end} insertion. 5839 5840@item Update pointers 5841The bindings @kbd{C-c C-u C-n} (@code{texinfo-update-node}) and @kbd{C-c 5842C-u C-e} (@code{texinfo-every-node-update}) from the native mode are 5843available in @AUCTeX{} as well. 5844 5845@item Update menus 5846The bindings @kbd{C-c C-u m} (@code{texinfo-master-menu}), @kbd{C-c C-u 5847C-m} (@code{texinfo-make-menu}), and @kbd{C-c C-u C-a} 5848(@code{texinfo-all-menus-update}) from the native mode are available in 5849@AUCTeX{} as well. The command @code{texinfo-start-menu-description}, 5850bound to @kbd{C-c C-c C-d} in the native mode, is bound to @kbd{C-c C-u 5851C-d} in @AUCTeX{} instead. 5852@end table 5853 5854@node Unbinding 5855@appendixsubsec Which native mode key bindings are missing 5856 5857The following commands from the native commands might still be useful 5858when working with @AUCTeX{}, however, they are not accessible with a 5859key binding any longer. 5860 5861@table @asis 5862@item @code{@@node} insertion 5863The node insertion command, mapped to @kbd{C-c C-c n} in the native 5864mode, is not mapped to any key in @AUCTeX{}. You can still access it 5865through the Texinfo menu, though. Another alternative is to use the 5866@kbd{C-c C-m} binding for macro insertion in @AUCTeX{}. 5867 5868@item Show the section structure 5869The command @code{texinfo-show-structure} (@kbd{C-c C-s}) from the 5870native mode does not have a key binding in @AUCTeX{}. The binding is 5871used by @AUCTeX{} for sectioning. 5872@end table 5873 5874@node Indices 5875@unnumbered Indices 5876 5877@menu 5878* Key Index:: 5879* Function Index:: 5880* Variable Index:: 5881* Concept Index:: 5882@end menu 5883 5884@node Key Index 5885@unnumberedsec Key Index 5886 5887@printindex ky 5888 5889@node Function Index 5890@unnumberedsec Function Index 5891 5892@printindex fn 5893 5894@node Variable Index 5895@unnumberedsec Variable Index 5896 5897@printindex vr 5898 5899@node Concept Index 5900@unnumberedsec Concept Index 5901 5902@printindex cp 5903 5904@bye 5905 5906@c Local Variables: 5907@c mode: texinfo 5908@c coding: utf-8 5909@c TeX-master: t 5910@c End: 5911