Minutes and Appendices (MAPS)
Total Page:16
File Type:pdf, Size:1020Kb
Bijlage S LATEX Editing Support 91 LATEX Editing Support Nelson H. F. Beebe Center for Scienti®c Computing Department of Mathematics South Physics Building University of Utah Salt Lake City, UT 84112 USA Tel: (801) 581-5254 FAX: (801) 581-4148 [email protected] Contents List of Figures A :: 1 Introduction 91 1 Online summary of LTEX mode. 94 2 More about LATEX mode. :: :::: 95 2Emacshistory 92 3 Online help for LaTeX-index. ::: 95 4 Local bindings in LATEX mode. ::: 96 3 Emacs editing model 92 5 More local bindings. : ::: :::: 96 6 .emacs ®le additions. ::: :::: 96 4 Emacs documentation 93 7 Letter template. ::: ::: :::: 107 5 Learning an Emacs editing mode 94 1 Introduction 6LATEX support 94 The structured markup of LATEX can be easy to read and 6.1 Preliminaries :: :::: ::: ::: 94 understand, but tedious to type. Its syntax of environ- 6.2 Creating a new LATEX®le::: ::: 97 ment groups bears a strong resemblance to the begin/ 6.3 LATEX macros :: :::: ::: ::: 98 end groups of the Algol family of computer program- 6.4 LATEX environments :: ::: ::: 99 ming languages, which can be described by rigorous 6.5 Common commands :: ::: ::: 99 grammars that in turn permit the automatic construc- 6.6 Math mode ::: :::: ::: ::: 100 tion of lexical analyzers and parsers, and structured 6.7 Dots, commas, and quotation marks 100 editors to support programming in those languages [4, 6.8 Font changes :: :::: ::: ::: 101 pp. 97±116, pp. 128±140, pp. 232-239]. This article de- 6.9 Comments ::: :::: ::: ::: 101 scribes a powerful facility for the preparation of LATEX 6.10 Mismatched delimiters : ::: ::: 102 documents using the Emacs text editor. 6.11 Mismatched environments :: ::: 102 The convention here is that material displayed in a 6.12 Word abbreviations ::: ::: ::: 103 typewriter font is computer output, a program 6.13 Bibliographies : :::: ::: ::: 103 name, or all or part of a ®le name. A sans serif font is 6.14 Indexing : ::: :::: ::: ::: 103 used for key names and Emacs functions, and a slanted 6.15 Cross-references :::: ::: ::: 104 font for Emacs variable names. 6.16 Miscellaneous functions ::: ::: 105 6.17 Miscellaneous variables ::: ::: 105 Emacs is very likely the world's most powerful text ed- 6.18 Customizing lists :::: ::: ::: 106 itor, because it is highly programmable and customiz- able. The popularity of the original Emacs on the DEC 7 SLITEX support 106 PDP-10 architecture in the 1970s led to several reimple- mentations on other operating systems, particularly on 8 Letter support 107 UNIX and VAX VMS. The wide availability of the ex- cellent implementation from the Free Software Found- 9 Bug reporting 107 ation, known as GNU Emacs, has made Emacs the ed- 10 Conclusion 108 itor of choice for many programmers on machines more powerful than personal computers. Smaller Emacs-like Index 110 editors have also been developed, including Jonathan Payne's jove (Jonathan's Own Version of Emacs) for UNIX, VAX VMS, IBM PC DOS, and the Apple Macintosh; microemacs and freemacs on IBM PC DOS; Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands Reprint MAPS#8 (92.1); May 1992 92 LATEX Editing Support Bijlage S the commercial editors epsilon from Lugaru Emacs' TECO was greatly extended beyond Dan Software, Ltd. (5843 Forbes Avenue, Pittsburgh, Murphy's original TECO developed on early DEC PDP PA 15217, USA), and brief from Solution Sys- machines at MIT in the 1960s. TECO remains available tems (541 Main St, Suite 410, South Weymouth, today on DEC PDP-11 and VAX VMS systems, though MA 02190, USA). it has largely fallen into disfavor because of its terse- ness, and because DEC's versions provide only limited Several years ago, I developed substantial editing sup- support for screen-based editing. port in the TOPS-20 Emacs text editor for the Fortran and SFTRAN3 languages, and also for LATEX. TOPS- The GNU Emacs reimplementation has a similar divi- 20 Emacs was programmed in a very terse language sion of architecture, but its kernel is written in the C called TECO, in which all 128 ASCII characters are language for portability, and high-level functions are assigned editing functions, and multi-character names written in Lisp for readability. The Emacs Lisp inter- provide thousands more. preter is provided by the C-language kernel, and the compiler is written in Lisp. The Lisp dialect is peculiar As we acquired VAX VMS and UNIX systems running to GNU Emacs, but is closely related to MIT's MAC- GNU Emacs, I reimplemented that editing support in Lisp. In particular, both use dynamic scoping, rather GNU Emacs Lisp, which although much more verbose than the lexical scoping of Common Lisp; if you don't than TECO, is much easier to read and write. know why that is signi®cant, read Stallman's article in The purpose of this article is to describe the capabilities [4]. of the LATEX editing support. Before we get into that, Emacs supports simultaneous editing of multiple ®les however, some background about Emacs must ®rst be in multiple buffers, with the screen divided horizont- presented. If you are already familiar with Emacs, you ally and/or vertically to provide windows into one or might want to skip ahead directly to the section LATEX more buffers. It also supports an extensive on-line help support beginning on page 94. system, with self-documenting commands, and the full text of many user manuals accessible inside the editor. 2 Emacs history All of this power requires a lot of code to support it, Emacs was developed by Richard M. Stallman starting and about a megabyte of central memory to run satis- about 1974 on a PDP-10 running MIT's ITS (Incom- factorily; that is why GNU Emacs has not been ported patible Timesharing System) operating system. The to personal computer environments. At version 18.55, kernel of the editor was written in PDP-10 assembly GNU Emacs consists of about 71400 lines of C code in language, which could be made to produce versions for 177 source ®les, 55300 lines of Lisp in 144 libraries, DEC's TOPS-10 and TOPS-20 systems and Stanford's 584 functions written in C, and 2643 functions written SAIL system as well, thanks to the availability of con- in Lisp. The LATEX support code described here con- ditional compilation facilities. SAIL was the home of sists of about 3900 lines of Lisp de®ning 82 functions the original TEX development. and 48 variables, together with an additional 900 lines Because PDP-10 machines formed the backbone of the and 30 functions of auxiliary support. original Arpanet, the precursor to today's Internet link- Some people argue that such a powerful editor `wastes ing millions of computers, and because Emacs' author machine resources'; I disagreeÐcomputers should believed fervently in the value of sharing of software, work for people, not the reverse. Emacs was soon in wide use throughout the Arpanet. Like Topsy in Uncle Tom's Cabin [15, p. 277], PDP-10 3 Emacs editing model Emacs just grew; the ®nal version from the mid 1980s Some vendor-provided text editors,such as edt in VAX had about 150 libraries and perhaps 2000 editing func- VMS and vi in UNIX, have two modes: command tions. What made this possible was the architectural mode, and text insertion mode. The meaning of a key division of the editor into two parts: depends on which mode you are in, and some users a modest kernel of low-level functions, like charac- ®nd themselves frequently making mistakes because ter insertion,deletion, and movement, string search- they type in the wrong mode. ing, and operating-system interface that have to be ef®ciently implemented for performance reasons, Emacs does not make a distinction between these two. and Instead, each character you type runs a function. The function attached to most printingcharacters just inserts a much larger collection of libraries written in a higher-level language, TECO (Text Editor and COr- them in the buffer, so entry of normal text works just like rector), that can be written,compiled, and debugged in other editors. However, certain keys invoke editing inside Emacs itself, thanks to the TECO interpreter functions that do other tasks. For example, pressing the and compiler included in the kernel. Libraries can DELete key results in a call to a function that deletes the be loaded on demand, or automatically when certain character on the screen immediately before the cursor. speci®ed conditions are met. Reprint MAPS#8 (92.1); May 1992 Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands Bijlage S LATEX Editing Support 93 The execution of editing functions in response to key- for editing. The connection between ®le extensions and strokes requires character-at-a-time input. Some older Emacs editing modes is of course user-customizable. mainframe operating systems do not support this, but Most Emacs functions can be given arguments when all newer ones do. they are invoked. In the simplest case, a numeric argu- Because most printing characters are needed for them- ment says to do the command n times. The function selves, and most ASCII control characters have no use- universal-argument is bound to C-u, so typing C-u ful printable representation, commonly-needed editing -31 produces an argument of -31. If no digits or minus functions are assigned to control characters, with mne- sign follow, an argument of 4 is provided, and if the monic signi®cance where possible. For example, the command is used more than once in succession, the character generated by holding down the control key argument is multiplied by four each time: C-u C-u while pressing the e key, represented by the compact C-u x will insert 64 x's into the buffer.