;;; latex.el --- major mode for editing LaTeX and SliTeX documents ;; Copyright (C) 1988--1998 Free Software Foundation, Inc. ;; Author: Nelson H. F. Beebe ;; Maintainer: Nelson H. F. Beebe ;; Created: 12 March 1988 ;; Version: 0.32 ;; Keywords: LaTeX, SliTeX ;; This file is part of GNU Emacs. ;;; Commentary: ;/u/sy/beebe/emacs/latex.el, Thu Jan 20 12:52:04 1994 ;Edit by Nelson H. F. Beebe ;;; ==================================================================== ;;; @Emacs-Lisp-file{ ;;; author = "Nelson H. F. Beebe", ;;; version = "0.41", ;;; date = "21 Nov 2000", ;;; time = "12:06:04 MST", ;;; filename = "latex.el", ;;; address = "Center for Scientific Computing ;;; University of Utah ;;; Department of Mathematics, 322 INSCC ;;; 155 S 1400 E RM 233 ;;; Salt Lake City, UT 84112-0090 ;;; USA", ;;; telephone = "+1 801 581 5254", ;;; FAX = "+1 801 585 1640, +1 801 581 4148", ;;; URL = "http://www.math.utah.edu/~beebe", ;;; checksum = "60713 5508 23948 205438", ;;; email = "beebe@math.utah.edu, beebe@acm.org, ;;; beebe@ieee.org (Internet)", ;;; URL = "http://www.math.utah.edu/~beebe/", ;;; codetable = "ISO/ASCII", ;;; keywords = "bibliography, index, LaTeX, SLiTeX", ;;; supported = "yes", ;;; docstring = "This file contains support for editing ;;; LaTeX documents in GNU Emacs. It is ;;; thoroughly documented in two separate ;;; files, ltxmode.ltx (a TUGboat article), and ;;; ltxinfo.ltx (a LaTeXinfo file). ;;; ;;; The checksum field above contains the ;;; standard UNIX wc (word count) utility ;;; output of lines, words, and characters; ;;; eventually, a better checksum scheme should ;;; be developed.", ;;; } ;;; ==================================================================== ;;; Change log: ;;;===================================================================== ;;; [0.42] ;;; [01-Sep-2015] Move functions LaTeX-2.09-mode and LaTeX-2e-mode ;;; after LaTeX-mode to avoid apparent infinite loop ;;; in recent emacs-24.x releases. ;;; ;;; [0.41] ;;; [21-Nov-2000] Rename split-string to LaTeX-split-string to avoid ;;; conflict with function split-string defined in ;;; .../emacs/20.x/lisp/subr.el, and move it to its ;;; proper alphabetical place in this file. ;;; ;;; [0.40] ;;; [24-Apr-1999] Change initial value of LaTeX-2e from nil to t, making ;;; LaTeX-2e the default. It is now 5 years since 2e ;;; appeared, so all new documents should certainly be ;;; using it in preference to 2.09. ;;; ;;; Change this change log to use three initial ;;; semicolons, instead of just one, to conform to Emacs ;;; Lisp comment conventions. ;;; ;;; Revise LaTeX-comment and LaTeX-uncomment to invert the ;;; sense of its argument compared to old versions. I ;;; found that I use them far more often to comment out a ;;; region, and only rarely, a paragraph, so it makes ;;; sense for them to act on a region by default, and a ;;; paragraph only if given an argument. I only regret ;;; that I did not make this change several years ago, ;;; sigh... ;;; ;;; In LaTeX-begin-end-block, reduce indentation of list ;;; environments after an \item, because it looks better. ;;; This was another change I'd been intending to do for ;;; several years. ;;; ;;; Update author address, telephone, FAX, and URL in file ;;; header to reflect my move to new building (14 months ;;; ago). ;;; ;;; [0.39] ;;; [21-Apr-1998] Update LaTeX-gripe, make-LaTeX-document, and ;;; make-SLiTeX-document to use mail-host-address when ;;; available. ;;; ;;; [0.38] ;;; [17-Dec-1997] Fix minor error in documentation of LaTeX-brace-words. ;;; ;;; [0.37] ;;; [10-Nov-1997] Change eql to eq, since the alias eql is no longer ;;; available in emacs-20 and later. ;;; ;;; [0.36] ;;; [05-Sep-1996] Insert patch in renumber-figures, renumber-slides, and ;;; renumber-tables to deal with changed behavior of ;;; zap-to-char between emacs 18 and 19. ;;; ;;; Add exclamation mark to regexps in LaTeX-begin-figure ;;; and LaTeX-begin-table since it is a new LaTeX 2e ;;; feature. ;;; ;;; Add Prof. and Profs. to list of ;;; LaTeX-standard-tied-abbreviations. ;;; ;;; [0.35] ;;; [29-Aug-1996] Remove superfluous %s format item in an (error "...") ;;; call in check-LaTeX-labels. ;;; ;;; [0.34] ;;; [21-Aug-1995] Change some doubled quotes inside strings to backslash ;;; quotes (obsolete use: change required for emacs 19.29 ;;; or later) ;;; ;;; [0.33] ;;; [01-May-1995] Update for LaTeX-2e support, and remove "beta test" ;;; from version string, pending public release of code. ;;; New variables: ;;; LaTeX-2e ;;; LaTeX-2e-extra-classes ;;; LaTeX-2e-extra-fonts ;;; LaTeX-2e-extra-italic-fonts ;;; LaTeX-2e-extra-macros ;;; LaTeX-2e-extra-options ;;; LaTeX-2e-extra-packages ;;; LaTeX-2e-standard-classes ;;; LaTeX-2e-standard-fonts ;;; LaTeX-2e-standard-italic-fonts ;;; LaTeX-2e-standard-macros ;;; LaTeX-2e-standard-options ;;; LaTeX-2e-standard-packages ;;; ;;; New functions: ;;; LaTeX-2.09-mode () ;;; LaTeX-2e-mode () ;;; LaTeX-2e-package () ;;; convert-LaTeX-2.09-to-LaTeX-2e () ;;; internal-LaTeX-2e-convert-document-options () ;;; internal-LaTeX-2e-convert-documentstyle () ;;; internal-LaTeX-2e-convert-font (old new) ;;; internal-LaTeX-set-mode-name () ;;; ;;; [beta test 0.32] ;;; [20-Jan-1994] Move LaTeX-x-window-setup to end of file to avoid ;;; references to undefined symbols. ;;; ;;; [beta test 0.31] ;;; [14-Sep-1993] Add new variables occur-highlight-time, ;;; occur-match-beginning, and occur-match-end. Replace ;;; occur mode's occur-mode-goto-occurrence with private ;;; version, and add new functions ;;; occur-mode-extended-goto-occurrence and ;;; occur-mode-mouse-goto to support quick mouse-click ;;; gotos. These functions are duplicated from the ;;; author's clsc.el library, but included here so that ;;; the two can be independent of one another. Replace ;;; show-LaTeX-labels with new version that uses ;;; occur-mode and extended mouse goto. ;;; ;;; [beta test 0.30] ;;; [07-Sep-1993] Merge in separate experimental development code, with ;;; new variables LaTeX-begin-table, ;;; LaTeX-display-math-comment-separator, ;;; LaTeX-displaymath-indentation-column, ;;; LaTeX-math-comment-separator, ;;; LaTeX-math-indentation-column, ;;; LaTeX-prettyprint-paragraph-separate, ;;; LaTeX-begin-figure, and LaTeX-path-delimiter, and ;;; new functions LaTeX-brace-words, LaTeX-path, ;;; LaTeX-prettyprint-displaymath, LaTeX-prettyprint-math, ;;; internal-LaTeX-indent-math, renumber-figures, and ;;; renumber-tables. Extend LaTeX-dollar, LaTeX-ref, and ;;; LaTeX-ref-with-completion to handle an optional ;;; argument. ;;; Thanks to Rick Zaccone [27-Jun-1992] for the extension ;;; to LaTeX-dollar. ;;; Add LaTeX-x-window-setup and call it from LaTeX-mode ;;; so popup menus are automatically provided when they ;;; can be supported. ;;; ;;; [beta test 0.29] ;;; [05-Sep-1993] Augment LaTeX-standard-dotted-abbreviations table. ;;; Add support for mouse-directed indexing under Emacs ;;; 19. ;;; Temporarily turn off transient-mark-mode during ;;; delimiter balance checking so that marks can be set a ;;; unmatched delimiters. ;;; Add customization variables LaTeX-update-bibtags and ;;; LaTeX-update-labels; nil values suppress updating the ;;; lists of bibtags and labels when LaTeX-mode is ;;; invoked. ;;; Fix a bug in update-LaTeX-bibtags that resulted in ;;; the .bib files not being found when emacs' default ;;; directory differs from that of the .aux file. ;;; In LaTeX-mode, move point to beginning before calling ;;; hooks, instead of after \documentstyle. ;;; Update show-LaTeX-bibtags and show-LaTeX-labels to ;;; remove extraneous output produced by emacs version 19 ;;; completion support. ;;; Add (save-excursion ...) wrapper around (set-buffer ;;; ...) calls in internal-LaTeX-collect-bibtags, ;;; update-LaTeX-bibtags, and update-LaTeX-labels so that ;;; subsequent (goto-char ...) positioning in original ;;; buffer is correct. ;;; ;;; [beta test 0.28] ;;; [12-Jun-1993] Update code to match guidelines in Style Tips section ;;; of Emacs Lisp Manual version 2.0. All uses of princ ;;; have been changed to message, some uses of message ;;; have been changed to error, all uses of ding have been ;;; removed, and recursive edits have been replaced by ;;; error termination. Key binding has been generalized ;;; through the addition of LaTeX-command-key-prefix so ;;; that the old C-c prefix can be easily changed by those ;;; who wish to do so. Functions have been reformatted ;;; according to guidelines. ;;; ;;; [beta test 0.27] ;;; [05-Nov-1992] Add w.r.t. to LaTeX-standard-dotted-abbreviations. ;;; ;;; [29-Oct-1992] Change paragraph-start to recognize a bare formfeed, ;;; instead of a formfeed just at beginning of line; TeX ;;; treats formfeed anywhere as a paragraph break. ;;; ;;; [05-Aug-1992] Change update-LaTeX-bibtags to return quietly if ;;; no bibliography files are found. ;;; ;;; [beta test 0.26] ;;; [25-Jul-1992] Add variables LaTeX-BIBINPUTS and LaTeX-bibtags, and ;;; functions expand-file-name-in-path, ;;; LaTeX-bibtag-with-completion, ;;; internal-LaTeX-collect-bibtags, show-LaTeX-bibtags, ;;; split-string, and update-LaTeX-bibtags. ;;; ;;; Change insert-file calls to insert-file-contents to ;;; avoid "Mark set" messages. ;;; ;;; [beta test 0.25] (changes made since [09-Aug-1991]) ;;; ;;; [26-May-1992] Add (let ...) to bind free variables discovered by ;;; new byte-compile-file in make-LaTeX-document ;;; (LaTeX-option) and LaTeX-end (environment-name). ;;; ;;; [25-Apr-1992] Move ltugboat from option list to style list. ;;; ;;; [16-Dec-1991] Don't load x-mouse if running under Epoch instead of ;;; Emacs ;;; ;;; [11-Dec-1991] Replace ;;; internal-LaTeX-check-matching-character-balance with ;;; new version. ;;; Increase LaTeX-brace-interval to 4000 from 500. ;;; Increase LaTeX-dollar-interval to 2000 from 500. ;;; Add new variable LaTeX-default-options whose string ;;; value is always put in the \documentstyle[...]{...} ;;; option list. ;;; Change default LaTeX-verb-delimiter from | to = to ;;; avoid conflict with use of | by MakeIndex. ;;; Add LaTeX-standard-comment-delimited-environments and ;;; LaTeX-extra-comment-delimited-environments and modify ;;; LaTeX-begin-end-block to use them. ;;; ;;; [09-Dec-1991] Remove one level of braces from indexing macro ;;; definition. ;;; ;;; [25-Nov-1991] Change amstex abbrev to expand to \AmSTeX, and ;;; add lamstex abbrev ;;; ;;; Load x-mouse only if window-system is known, to avoid the load ;;; aborting when window-system-version is referenced in x-mouse.el. ;;; That way, the code will work in Emacs implementations that have ;;; not been built with window support, or are not running under X. ;;; ;;; Make LaTeX-subscript and LaTeX-superscript recognize a preceding ;;; backslash, and just do a simple insertion. ;;; ;;; Finally implement support for ignoring paragraph breaks ;;; in internal-LaTeX-check-matching-character-balance and ;;; functions that call it. ;;; ;;; Reduce "-insert-" to "-" in function names for consistency. ;;; ;;; Modify code references to LaTeX-xxx-start-with-newline to ;;; avoid newline insertion if already at beginning of line. ;;; ;;; Modify make-LaTeX-document and make-SLiTeX-document to permit ;;; non-interactive invocation. ;;; ;;; Change "non-NIL" to "non-nil" in doc strings. ;;; ;;; Correct handling of overlay environment (it was missing the empty ;;; braces), and fix format error in renumber-slides. ;;; ;;; Add function LaTeX-counter and supporting variables ;;; LaTeX-extra-counters and LaTeX-standard-counters. ;;; ;;; Add variables LaTeX-footnote-start-with-newline and ;;; LaTeX-footnote-end-with-newline, and update LaTeX-footnote to use ;;; them. ;;; ;;; Remove leading asterisk from doc strings of all defun and defconst ;;; values, so that they do not appear to be user-settable. ;;; ;;; Add optional list elements 2--4 to LaTeX-standard-environments and ;;; use them to simplify the code in LaTeX-begin-end-block, and permit ;;; greater user customization. ;;; ;;; Remove labelledequation environment (it was an obsolete remnant of ;;; TOPS-20 latex.emacs code). ;;; ;;; Add default filename completion to update-LaTeX-labels (idea ;;; borrowed from tags.el). ;;; ;;; Add LaTeX-extra-tied-abbreviations and ;;; LaTeX-standard-tied-abbreviations with support code in LaTeX-dot. ;;; ;;; In LaTeX-dot and LaTeX-comma, call expand-abbrev only if abbrev-mode ;;; is selected. ;;; ;;; Add missing terminal s to one instance of ;;; LaTeX-standard-unindented-environments. ;;; ;;; Correct internal-x-LaTeX-index-mark when LaTeX-index-macro is nil. ;;; ;;; Fine tune spacing in LaTeX-index. ;;; ;;; Make internal-LaTeX-wrap a no-op if the word-count argument is not ;;; > 0. ;;; ;;; Add internal-LaTeX-default function to clean up handling of ;;; optional arguments and their default values. This drastically ;;; reduces the number of complex references to current-prefix-arg ;;; and prefix-numeric-value. ;;; ;;; Remove deletion of horizontal space around \verb|| from C-c v for ;;; consistency with LaTeX-macro generation of same. ;;; ;;; Add suffix arg to internal-LaTeX-keyword for better space control, ;;; and tune space insertion in internal-LaTeX-delimiter-pair. ;;; ;;; Add LaTeX-set-indentation on C-c ,. ;;; ;;; Make LaTeX-item-count consistently be the number of \item or ;;; \bibitem lines generated. ;;; ;;; Make thebibliography environment always insert \bibitem[]{} ;;; instead of \bibitem{}. ;;; ;;; Make LaTeX-macro supply a newline after a macro with arguments only ;;; if it is being inserted in the middle of a line. Generation of ;;; superfluous blank lines is undesirable. ;;; ;;; Modify LaTeX-bibitem, LaTeX-cite, and LaTeX-item to generate [] when ;;; they are given an argument. ;;; ;;; Modify LaTeX-verb to make it consistent with output from ;;; (LaTeX-macro "verb"), obeying LaTeX-newline-after-opening-delimiter ;;; and LaTeX-newline-after-closing-delimiter. ;;; ;;; Modify LaTeX-begin-end-block to improve thebibliography formatting ;;; and make it consistent with other list environments. ;;; ;;; Set default comment-xxx variables in LaTeX-mode. ;;; ;;; Add LaTeX-subscript and LaTeX-superscript. ;;; ;;; Add LaTeX-label-definition and LaTeX-label-reference for user ;;; customization. ;;; ;;; Add file-name-sans-extension, internal-LaTeX-sort-alist, ;;; LaTeX-aux-file-label-tags, and update-LaTeX-labels to solve the ;;; problem of finding \label{} tags in multi-file documents. ;;; ;;; Augment documentation of many functions with their key/mouse ;;; bindings. ;;; ;;; Add variable LaTeX-space-after-begin-end, modify insertions of ;;; \begin or \end to use it, and change all regexps to allow ;;; optional space between begin/end keyword and opening brace. ;;; ;;; Rename all internal functions from "LaTeX-..." to ;;; "internal-LaTeX-..." to make it easier to verify that all ;;; user-visible functions are documented in reference manual. Remove ;;; (interactive) from all internal functions so as not to interfere ;;; with name completion. ;;; ;;; Move most top-level setq values to defvar initializations. ;;; ;;; Add missing asterisk to some defvar doc strings so the variables ;;; become user-settable (some are not, so the asterisk is omitted). ;;; ;;; Revise tex-mode.el to remove all definitions of LaTeX objects. It ;;; will still autoload LaTeX-mode if a \documentstyle command is found. ;;; ;;; TeX-insert-quote is copied and renamed LaTeX-quote. ;;; ;;; Change two x-LaTeX-index-* variables to LaTeX-index-*, with new code ;;; in LaTeX-index. ;;; ;;; Add LaTeX-label-start-with-newline and LaTeX-label-end-with-newline, ;;; with new code in LaTeX-label. ;;; ;;; Remove loading of tex-mode here, and create private keymap instead ;;; of using TeX-mode-map. With the new tex-mode.el* in place in the ;;; Emacs Lisp directory, and these autoload commands in loaddefs.el or ;;; site-init.el or personal .emacs files: ;;; ;;;>> (autoload 'latex-mode "latex" ;;;>> "\ ;;;>> Major mode for editing files of input for LaTeX. ;;;>> More information on this command is available after this mode is ;;;>> selected." ;;;>> t) ;;;>> ;;;>> (autoload 'LaTeX-mode "latex" ;;;>> "\ ;;;>> Major mode for editing files of input for LaTeX. ;;;>> More information on this command is available after this mode is ;;;>> selected." ;;;>> t) ;;; ;;; tex-mode and LaTeX-mode are now fully, and finally, independent. We ;;; preserve TeX-dollar here, since it does not exist in tex-mode.el. ;;; ;;; Move xxxslides from LaTeX-standard-options to LaTeX-standard-styles. ;;; ;;; Delete "Inside \begin{xxx}" message from LaTeX-item ;;; ;;; Change "'(lambda..." to "(function (lambda..." to allow more ;;; efficient byte compiling. ;;; ;;; Add LaTeX-standard-dotted-abbreviations and ;;; LaTeX-extra-dotted-abbreviations, and rewrite LaTeX-dot to use them. ;;; ;;; Add support function LaTeX-preceding-buffer-substring. ;;; ;;; Rename some xxx-LaTeX-yyy internal functions to LaTeX-xxx-yyy. ;;; ;;; Correct some alphabetization errors in the ordering of definitions ;;; of constants, variables and functions. ;;; ;;; Add SLiTeX note and overlay environment support in ;;; LaTeX-standard-environments, LaTeX-begin-end-block, and ;;; renumber-slides. ;;; ;;; Change LaTeX-unindented-environments to ;;; LaTeX-standard-unindented-environments and add ;;; LaTeX-extra-unindented-environments. ;;; ;;; Move x-latex.el back into this file, now that autoload problem has ;;; been solved. The load of x-menu has been deleted, and the load of ;;; x-mouse is a conditional that only on success causes mouse button ;;; bindings. ;;;===================================================================== ;;; [09-Aug-1991] ;;; Add LaTeX-maybe-remove-italic-correction, and add missing italic ;;; correction to LaTeX-font-sl. ;;; ;;; Change {cmd} to {\cmd} in macro comments to remind user to ;;; include backslash. ;;; ;;; Completely rewrite LaTeX-dollar to use LaTeX-begin-end-block and ;;; LaTeX-insert-delimiter-pair, and to support LaTeX-displaymath-option ;;; and LaTeX-math-option (LaTeX-use-math-dollar has been removed). ;;; ;;; Rewrite LaTeX-keyword to use LaTeX-insert-delimiter-pair ;;; ;;; For symmetry and consistency, change LaTeX-arg-on-empty-line to ;;; LaTeX-newline-after-opening-delimiter. ;;;===================================================================== ;;; [07-Aug-1991] ;;; Add (goto-char (point-min)) in LaTeX-gripe (thanks to Olaf ;;; Heimburger ) ;;;===================================================================== ;;; [beta test 0.24] [01-Aug-1991] ;;; Write TUGboat article describing all of LaTeX-mode. That effort ;;; suggested the additions and changes for this version. ;;; Add support for \verb*|...| in LaTeX-verb (an argument requests the ;;; starred form). ;;; Add LaTeX-angle-interval, LaTeX-angles, and ;;; LaTeX-check-angle-balance. ;;; Correct two comment errors in LaTeX-mode's documentation. ;;; Change two mailing addresses from science.utah.edu to math.utah.edu. ;;; Add LaTeX-protect. ;;; Add support for \@ in LaTeX-dot. ;;; Add x-LaTeX-* functions and variables for mouse-supported indexing ;;; in X windows; these are in x-latex.el, because they cannot be used ;;; unless Emacs has been compiled with xmenu.o. ;;; Add LaTeX-make-label-list, LaTeX-pageref-with-completion, and ;;; LaTeX-ref-with-completion, and put the latter two on C-c p and C-c ;;; r; because these might be slow (they must scan the whole buffer to ;;; create the label list), the old (and fast) LaTeX-pageref and ;;; LaTeX-ref functions are retained. ;;; Add LaTeX-uncomment, and change LaTeX-comment to use ;;; LaTeX-comment-prefix instead of hard-coded "% ". ;;; Add LaTeX-use-math-dollar variable and modify LaTeX-dollar; this ;;; gives access to the \( ... \) form instead of $ ... $. ;;; Correct error on show-LaTeX-labels comment. ;;; Add LaTeX-extra-environments, LaTeX-extra-fonts, ;;; LaTeX-extra-italic-fonts, LaTeX-extra-list-environments, ;;; LaTeX-extra-macros, LaTeX-extra-options, and LaTeX-extra-styles ;;; for easier user customization. ;;; Change last 3 args of all but one completing-read calls to nil nil ;;; nil, so that users can always override the offered completion list. ;;;===================================================================== ;;;/u/sy/beebe/emacs/latex.el, Wed May 8 18:35:06 1991 ;;;Edit by Nelson H.F. Beebe ;;;/u/sy/beebe/emacs/latex.el, Wed May 2 11:11:16 1990 ;;;Edit by Nelson H.F. Beebe ;;; [beta test 0.23] [08-May-1991] ;;; Fix incorrect help comments for framebox, makebox, minipage, parbox, ;;; and savebox. ;;;===================================================================== ;;;/u/sy/beebe/emacs/latex.el, Tue Dec 18 14:35:01 1990 ;;;Edit by Nelson H.F. Beebe ;;; [beta test 0.22] [18-Dec-1990] ;;; Add new functions for changing the font of one or more words. ;;; LaTeX-font-bf (on C-c C-c b) ;;; LaTeX-font-em (on C-c C-c e) ;;; LaTeX-font-it (on C-c C-c i) ;;; LaTeX-font-rm (on C-c C-c r) ;;; LaTeX-font-sc (on C-c C-c u) ;;; LaTeX-font-sf (on C-c C-c f) ;;; LaTeX-font-sl (on C-c C-c s) ;;; LaTeX-font-tt (on C-c C-c t) ;;;===================================================================== ;;;/u/sy/beebe/emacs/latex.el, Mon Jun 25 14:06:20 1990 ;;;Edit by Nelson H.F. Beebe ;;; [beta test 0.21] [25-Jun-1990] ;;; Add ltugboat style option. ;;;===================================================================== ;;; [beta test 0.20] [08-Jun-1990] ;;; Fix make-LaTeX-document to work if LaTeX-index-macro is not defined; ;;; thanks to Martin Jourdan . ;;;===================================================================== ;;; [beta test 0.19] [01-Jun-1990] ;;; Add expand-abbrev calls in LaTeX-comma and LaTeX-dot; thanks to ;;; Lucien Van Elsen for reporting this. ;;;===================================================================== ;;; [beta test 0.18] [02-May-1990] ;;; Fix LaTeX-begin-end-block to know about extra arguments for array ;;; and tabular* environments. ;;;===================================================================== ;;; [beta test 0.17] [30-Dec-1989] ;;; Rewrite LaTeX-comment to behave better. It will still hang in ;;; save-restriction if used on the last paragraph in the document; ;;; Ctl-G gets you out. ;;; Add LaTeX-equation on C-c = and LaTeX-displaymath on C-c C-c = ;;; Thanks for Fritz Zaucker for the ;;; bug report and ideas. ;;;===================================================================== ;;; [beta test 0.16] [31-Oct-1989] ;;; Add LaTeX-newline-after-closing-delimiter support; thanks to Stephen ;;; Adams for the idea. ;;;===================================================================== ;;; [beta test 0.15] [05-Sep-1989] ;;; Fixed bug in check-LaTeX-labels (bad regexp could match too much); ;;; thanks to Toby Ferguson ;;;===================================================================== ;;; [beta test 0.14] [27-Apr-1989] ;;; Added \special to LaTeX-standard-macros ;;;===================================================================== ;;; [beta test 0.13] [19-Apr-1989] ;;; Incorporated several suggestions and fixes from Ashwin Ram, with new ;;; versions of LaTeX-end, LaTeX-item, LaTeX-insert-item, moved ;;; keymap setting to load time instead of in LaTeX-mode, and changed ;;; calculate-latex-indent to calculate-LaTeX-indent for consistency. ;;; Removed ll abbreviation for Leslie Lamport (bad in text like I'll), ;;; and turned off abbrev mode by default (if you want it, turn it on in ;;; a mode hook). ;;; Alphabetized some out-of-order defuns. ;;;===================================================================== ;;; [beta test 0.12] [17-Apr-1989] ;;; Added abbrev-mode support ;;; Removed beta test note from mode line ;;; Added Ashwin Ram's change to LaTeX-insert-item ;;; Replaced LaTeX-indent-line by new code from George Hartzell (the old ;;; one is preserved as LaTeX-old-indent-line in case problems arise) ;;;===================================================================== ;;; [beta test 0.11] [27-Oct-88] ;;; Added tt to LaTeX-standard-fonts ;;;===================================================================== ;;; [beta test 0.10] [15-Sep-88] ;;; Change renumber-slides to use a variable SLiTeX-begin-slide for the ;;; matching regexp, and add binding to C-c 0 ;;; Fix call to completing-read in make-LaTeX-document so user can ;;; override standard styles. ;;; Replaced LaTeX-end by version that works correctly for things like ;;; \begin{tabular}{c}. ;;;===================================================================== ;;; [beta test 0.09] [30-Aug-88] ;;; Add LaTeX-comma (on ","). ;;; Add italic correction removal in LaTeX-dot. ;;; Add LaTeX-dollar (on "$"). ;;; Add TeX-dollar (no binding in LaTeX-mode, but may be useful in ;;; TeX-mode). ;;;===================================================================== ;;; [beta test 0.08] [05-May-88] ;;; Fix inserted comment in make-{La/SliTeX}-document ;;; Move setting of paragraph-separate and paragraph-start from preamble ;;; to LaTeX-mode ;;; Add LaTeX-news and bind to C-c C-n ;;;===================================================================== ;;; [beta test 0.07] ;;; Fixed LaTeX-begin-end-block to add [] in figure and table ;;; environments ;;; Add LaTeX-dot and bind to ".". ;;; Change paragraph-separate and paragraph-start to be more appropriate ;;; for LaTeX ;;; Fix LaTeX-end to work if \begin{foo} is at end-of-buffer, without ;;; preceding newline. ;;; Change {\(.*\)} patterns to {\([^{}]*\)} so as to match only one ;;; brace level. Otherwise \begin{thebibliography}{} will not match ;;; \end{thebibliography}, because the first pattern matches ;;; "thebibliography}{" instead of "thebibliography". ;;; Change LaTeX-add-word-to-index to index word at, or just before, ;;; point. ;;; Add LaTeX-comment (on C-c %) and LaTeX-tab (on C-c TAB) ;;; courtesy of Ashwin Ram ;;; Increase LaTeX-{brace,bracket,dollar,parenthesis}-interval to 500 ;;; from 200 ;;;===================================================================== ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Wed Mar 30 13:18:07 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; [beta test 0.06] ;;; Use LaTeX-arg-on-empty-line inside LaTeX-keyword too. ;;; Add LaTeX-indent-line and bind to indent-line-function in LaTeX-mode ;;; so C-j (linefeed) preserves indentation of previous line. ;;; LaTeX-insert-item no longer sets fill prefix, since C-j can be used ;;; instead to maintain the indentation. ;;; Change binding of LaTeX-item to C-c i and move LaTeX-index to C-c x ;;; Remove old binding of LaTeX-item to C-c t ;;; Put key bindings in TeX-mode-map instead of make-sparse-keymap ;;; so we preserve most TeX-mode bindings. Unbind TeX-close-LaTeX-block ;;; (C-C C-f) because it conflicts in functionality. ;;; Make LaTeX-end position on line following inserted \\end{...}, and ;;; print an error message as well as dinging if no unmatched ;;; \\begin{...} was found. ;;; If make-LaTeX-document-hook exists, run it to provide a ;;; user-customizable template for make-LaTeX-document instead of ;;; supplying a default template. If make-SLiTeX-document-hook exists, ;;; run it to provide a user-customizable template for ;;; make-SLiTeX-document instead of supplying a default template. ;;; Extend LaTeX-add-word-to-index to use verbose standard LaTeX ;;; indexing if LaTeX-index-macro is nil. ;;; Change M-X to M-x in documentation to conform to GNU Emacs practice. ;;;===================================================================== ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Fri Mar 18 10:33:18 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; [beta test 0.05] ;;; Modify LaTeX-macro to not follow macro with newline, except when ;;; there are arguments and LaTeX-arg-on-empty-line is non-nil. ;;; Add LaTeX-arg-on-empty-line variable. ;;; Add \\ to documentation strings so binding gets ;;; displayed in any mode. ;;; Add binding of make-SLiTeX-document (on C-C s). ;;; Add further comments to LaTeX-item, LaTeX-macro, and LaTeX-mode. ;;; Add LaTeX-verb-delimiter variable for use in LaTeX-verb. ;;; Add LaTeX-end (on C-C n) to supply matching \\end{...}. ;;;===================================================================== ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Thu Mar 17 21:09:12 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; [beta test 0.04] ;;; Call TeX-common-initialization in LaTeX-mode to setup comment and ;;; character ;;; syntax handling. ;;; Fix major-mode so describe-mode (C-H M) works. ;;; Add text-mode-hook and TeX-mode-hook to list of hooks run. ;;; Make LaTeX-macro print documentation string in minibuffer when no ;;; arg. ;;; Make LaTeX-item (and LaTeX-macro for item) display enclosing ;;; environment name. ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Mon Mar 14 10:26:49 1988 ;;;===================================================================== ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; [beta test 0.03] -- not distributed ;;; [beta test 0.02] -- not distributed ;;; [beta test 0.01] ;;; corrected a few macros after proofreading sorted list against LaTeX ;;; manual index ;;;===================================================================== ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Sat Mar 12 19:05:22 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; begin [beta test 0.00] ;;; fixed LaTeX-set-indentation to fail gracefully if \begin{}/\end{} ;;; not found ;;; added make-SLiTeX-document, renumber-slides, and slides environment ;;; support ;;; added LaTeX-gripe on C-C g for bug reports ;;; completed entry of all LaTeX macros in LaTeX-standard-macros ;;;===================================================================== ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Fri Mar 4 12:06:12 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; [alpha test 0.4] ;;; Resolved problem of unpleasant interaction between this library and ;;; tex-mode.el, which has a few identically named functions. ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Fri Feb 5 22:44:59 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Thu Feb 4 08:58:04 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Wed Feb 3 15:31:36 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;;/usr/csc-sun/u/sy/beebe/emacs/latex.el, Tue Feb 2 17:33:31 1988 ;;;Edit by Nelson H.F. Beebe (beebe at plot79.utah.edu) ;;; Experimental LaTeX mode based on my TOPS-20 LATEX.EMACS library in ;;; TECO. ;;; ;;; Most functions have been named identically to their TOPS-20 ;;; equivalents, except that in names, hyphens have replaced spaces, ^R ;;; and ... have been eliminated, and "LaTeX" has been inserted in a ;;; couple that were lacking it. Documentation has mostly been copied ;;; verbatim. ;;; ;;; New features include user-modifiable variables for standard ;;; environments, options, macros, styles, et al, and the LaTeX-macro ;;; and show-LaTeX-labels commands. The template generated by ;;; make-LaTeX-document is somewhat improved as well. ;;; ;;; Key bindings in the TOPS-20 version were usually on ;;; C-M- which can be typed (on TOPS-20) as ;;; C-Z-, and is distinct from ;;; C-Z- (and -C-, which means the ;;; upper-case variant). ;;; ;;; Unfortunately, C-Z is the BSD Unix suspend-process signal which is ;;; best left reserved for that purpose, so bindings to C-c- ;;; analogous to the TOPS-20 C-z- bindings are provided ;;; instead. This has the advantage that no existing standard ;;; bindings are usurped, and all the LaTeX-relevant bindings are on ;;; C-c-. ;;; ;;; Please keep the functions sorted ALPHABETICALLY (M-x sort-pages ;;; does the trick), with the SINGLE exception of tex-mode() ;;; immediately following. ;;; ;;; In order to avoid duplication of library source code, we load the ;;; tex-mode library, then rebind a stripped down version of the ;;; function tex-mode which will not attempt to run that library's ;;; latex-mode. Otherwise, we risk ending up in an infinite loop of ;;; confusion between the two libraries. All other functions in the ;;; tex-mode library are left intact, so that we have usurped nothing ;;; from a user who wishes to edit plain TeX files. ;;; (load "tex-mode" nil t nil) ;load it silently ;;; (defun tex-mode () ;;; "Major mode for editing files of input for plain TeX." ;;; (interactive) ;;; (plain-tex-mode)) ;;; Code: ;;; Although the defxxx macros permit the assignment of an initial ;;; value, they do this only if the name has not been previously ;;; defined. During interactive development while these values are ;;; changing, this is inconvenient, so all are assigned values by setq ;;; which can be executed directly to get updated values. (provide 'latex-mode) ;required by ltxmenu.el (defvar LaTeX-2e t) ;set to nil when in LaTeX-2.09 mode (defconst LaTeX-2e-extra-classes nil "*List of extra classes to augment those in LaTeX-2e-standard-classes for use by make-LaTeX-document.") (defconst LaTeX-2e-extra-fonts nil "*List of extra font change control sequences to augment those in LaTeX-2e-standard-fonts.") (defconst LaTeX-2e-extra-italic-fonts nil "*List of extra italic font change control sequences to augment those in LaTeX-2e-standard-italic-fonts.") (defconst LaTeX-2e-extra-macros nil "*List of extra macros to augment those in LaTeX-2e-standard-macros.") (defconst LaTeX-2e-extra-options nil "*List of extra options to augment those in LaTeX-2e-standard-options.") (defconst LaTeX-2e-extra-packages nil "*List of extra packages to augment those in LaTeX-2e-standard-packages.") (defvar LaTeX-angle-interval 500 "*Limit on number of characters between matching angle brackets for LaTeX-check-angle-balance (on \\\\[LaTeX-check-angle-balance]).") (defvar LaTeX-aux-file-label-tags nil "*List of \\label{} tags collected from an .aux file by update-LaTeX-labels. It is used by those functions that offer completion on label tags to augment the list of tags collected from the current buffer.") (defvar LaTeX-begin-end-indentation 2 "*Indentation given for each successive \\begin{}...\\end{} nesting level. Environments defined by LaTeX-standard-unindented-environments and LaTeX-extra-unindented-environments always have their indentation suppressed.") (defvar LaTeX-begin-figure "^[ \t]*\\\\begin *{figure}\\(\\[[a-z!]*\\]\\)?\\|^[ \t]*\\\\begin *{Figure}{[a-z!]*}" "*Regexp that matches the start of a figure. Used by renumber-figures to find a place to put the comment with the figure number. Text from the end of the match to end-of-line will be replaced by a comment with the figure number.") (defvar LaTeX-begin-table "^[ \t]*\\\\begin *{table}\\(\\[[a-z!]*\\]\\)?\\|^[ \t]*\\\\begin *{Table}{[a-z!]*}" "*Regexp that matches the start of a table. Used by renumber-tables to find a place to put the comment with the table number. Text from the end of the match to end-of-line will be replaced by a comment with the table number.") (defvar LaTeX-BIBINPUTS (concat ".:" (getenv "HOME") "/tex/bib:/usr/local/lib/tex/bibtex") "*Default BIBINPUTS search path for use in the event that the BIBINPUTS environment variable is not set. It is used by update-LaTeX-bibtags to locate .bib files referenced in \\bibdata{...} or \\bibliography{...} commands.") (defvar LaTeX-brace-interval 4000 "*Limit on number of characters between matching braces for LaTeX-check-brace-balance (on \\\\[LaTeX-check-brace-balance]).") (defvar LaTeX-bracket-interval 500 "*Limit on number of characters between matching brackets for LaTeX-check-bracket-balance (on \\\\[LaTeX-check-bracket-balance]).") (defvar LaTeX-bibtags nil "*List of BibTeX citation tags collected from the bibliography files listed in the \\bibliography{...} or \\bibdata{...} commands. Each list entry contains a citation tag, and the name of the file from which it was extracted. The list is used by LaTeX-bibtag-with-completion to offer completion on citation tags, and can be conveniently displayed by show-LaTeX-bibtags.") (defvar LaTeX-comma-after-dotted-abbreviation nil ;modern style: use \ "*When LaTeX-dot is invoked after dotted abbreviations, like ``e.g'' or ``i.e'', if this variable is nil, insert a \\ control sequence for a non-sentence ending period. If the variable is set non-nil, insert a comma instead. The choice between the two is a matter of style; traditional use inserts a comma, while modern tendency is to omit it.") (defvar LaTeX-command-key-prefix "\C-c" "*Prefix keystroke(s) to be applied to LaTeX mode key bindings. Emacs standards require that C-c be reserved for user-specific bindings, but LaTeX-mode has historically used C-c prefix key. You can set this variable to \"\\C-c\" for old-style binding, or to say, \"\\C-z\" or \"\\C-c\\C-c\" for standard-conforming binding.") (defvar LaTeX-comment-prefix "%%: " "*Comment prefix string for LaTeX-comment and LaTeX-uncomment. This is used in regular-expression matching by LaTeX-uncomment, so it should NOT contain any regular-expression pattern characters like . or *.") (defvar LaTeX-current-indentation 0 "*Indentation of current \\begin{} level (varies dynamically)") (defvar LaTeX-default-options nil "*This string value is always put in the \documentstyle[...]{...} option list by make-LaTeX-document and make-SLiTeX-document. Use it to customize environments where some styles are always used, e.g. \"a4,french\".") (defconst LaTeX-display-math-comment-separator "%%======================================================================\n" "*This variable defines a comment string that will be used by prettyprint-displaymath to set off display math from surrounding text. If nil or an empty string, no comment line is inserted.") (defconst LaTeX-displaymath-indentation-column 4 "*Number of columns to indent display math during prettyprinting.") (defvar LaTeX-displaymath-option 2 "*Select style of output by LaTeX-dollar. A value of 1 gives \\[ ... \\], 2 gives \\begin{displaymath} ... \\end{displaymath}, and anything else gives $$ ... $$.") (defvar LaTeX-dollar-interval 2000 "*Limit on number of characters between matching dollars for LaTeX-check-dollar-balance (on \\\\[LaTeX-check-dollar-balance]).") (defvar LaTeX-extra-comment-delimited-environments nil "*List of extra environments to set off by empty comment lines.") (defvar LaTeX-extra-counters nil "*List of extra counters to augment those in LaTeX-standard-counters (q.v.).") (defvar LaTeX-extra-dotted-abbreviations nil "*List of extra abbreviations to augment those in LaTeX-standard-dotted-abbreviations for which LaTeX-dot must provide special spacing, according to the value of LaTeX-comma-after-dotted-abbreviation.") (defvar LaTeX-extra-environments nil "*List of extra environments to augment those in LaTeX-standard-environments for use by LaTeX-begin-end-block.") (defvar LaTeX-extra-fonts nil "*List of extra fonts to augment those in LaTeX-standard-fonts for use by LaTeX-macro.") (defvar LaTeX-extra-italic-fonts nil "*List of extra fonts to augment those in LaTeX-standard-italic-fonts for use by LaTeX-macro.") (defvar LaTeX-extra-list-environments nil "*List of extra list environments to augment those in LaTeX-standard-list-environments for use by LaTeX-begin-end-block.") (defvar LaTeX-extra-macros nil "*List of extra macros to augment those in LaTeX-standard-macros for use by LaTeX-macro.") (defvar LaTeX-extra-options nil "*List of extra options to augment those in LaTeX-standard-options for use by make-LaTeX-document and make-SLiTeX-document.") (defvar LaTeX-extra-styles nil "*List of extra styles to augment those in LaTeX-standard-styles for use by make-LaTeX-document.") (defvar LaTeX-extra-tied-abbreviations nil "*List of extra abbreviations to augment those in LaTeX-standard-tied-abbreviations (q.v.).") (defvar LaTeX-extra-unindented-environments nil "*List of extra environments to augment those in LaTeX-standard-unindented-environments (q.v.).") (defvar LaTeX-footnote-end-with-newline nil "*Inserted footnote entries end with a newline if this is non-nil.") (defvar LaTeX-footnote-start-with-newline nil "*Non-nil means put footnotes on a new line.") (defvar LaTeX-index-end-with-newline nil "*Non-nil means that inserted index entries end with a newline.") (defvar LaTeX-index-macro "\\X" "*Private indexing macro that causes its argument to appear both in the document text, as well as in an index entry. If nil, then LaTeX-index (on \\\\[LaTeX-index]) will insert ..text..% \\index{..text..} instead of \\this-macro{..text..} ") (defvar LaTeX-index-start-with-newline nil "*Non-nil means that Inserted index entries start a newline at same indentation level.") (defvar LaTeX-item-count 4 "*Number of \\item or \\bibitem entries to generate in initial templates.") (defvar LaTeX-item-indentation 2 "*Indentation given to \\item's with respect to their enclosing \\begin{}...\\end{} group.") (defvar LaTeX-item-info-indent 6 "*The amount by which the text beneath an item gets indented." ) (defvar LaTeX-label-end-with-newline nil "*Non-nil means that inserted label entries end with a newline.") (defvar LaTeX-label-definition "\\\\label{\\([^{}]*\\)}" "*Regular expression which matches a label definition. It normally matches \\label{}, but may be extended if needed to include private macros that also contain label definitions.") (defvar LaTeX-label-reference "\\\\[page]*ref{\\([^{}]*\\)}" "*Regular expression which matches a label reference. It normally matches \\pageref{} and \\ref{}, but may be extended if needed to include private macros that also contain label references.") (defvar LaTeX-label-start-with-newline nil "*Non-nil means that inserted label entries start a newline at same indentation level.") (defvar LaTeX-labels-occur-pos-list () "List of label positions created by show-LaTeX-labels.") (defvar LaTeX-labels-occur-buffer nil "Name of buffer in which show-LaTeX-labels was last run.") (defconst LaTeX-math-comment-separator "%%----------------------------------------------------------------------\n" "*This variable defines a comment string that will be used by prettyprint-displaymath to set off display math from surrounding text. If nil or an empty string, no comment line is inserted.") (defconst LaTeX-math-indentation-column 4 "*Number of columns to indent math during prettyprinting.") (defvar LaTeX-math-option 0 "*Select style of output by LaTeX-dollar. A value of 1 gives \\( ... \\), 2 gives \\begin{math} ... \\end{math}, and anything else gives $ ... $.") (defvar LaTeX-mode-abbrev-table nil "Abbrev table in use in LaTeX-mode buffers.") (if LaTeX-mode-abbrev-table () (define-abbrev-table 'LaTeX-mode-abbrev-table ()) (let ((abbrevs-changed nil)) (define-abbrev LaTeX-mode-abbrev-table "amstex" "\\AmSTeX{}" nil) (define-abbrev LaTeX-mode-abbrev-table "bibtex" "\\BibTeX{}" nil) ;; (define-abbrev LaTeX-mode-abbrev-table "dd" "DVI driver" nil) ;; (define-abbrev LaTeX-mode-abbrev-table "dek" "Donald~E. Knuth" nil) (define-abbrev LaTeX-mode-abbrev-table "lamstex" "\\LamSTeX{}" nil) (define-abbrev LaTeX-mode-abbrev-table "latex" "\\LaTeX{}" nil) (define-abbrev LaTeX-mode-abbrev-table "lug" "\\LaTeX{} User's Guide and Reference Manual" nil) (define-abbrev LaTeX-mode-abbrev-table "mf" "\\MF{}" nil) ;; (define-abbrev LaTeX-mode-abbrev-table "ms" ;; "Michael~D. Spivak" nil) (define-abbrev LaTeX-mode-abbrev-table "slitex" "\\SLiTeX{}" nil) (define-abbrev LaTeX-mode-abbrev-table "tb" "\\TeX{}book" nil) (define-abbrev LaTeX-mode-abbrev-table "tex" "\\TeX{}" nil)) nil) (defvar LaTeX-mode-map nil "Keymap used in LaTeX mode.") (defvar occur-highlight-time 2 "*Number of seconds to highlight matches from *LaTeX Labels* selections when occur-mode-extended-goto-occurrence (on \\[occur-mode-extended-goto-occurrence]) is invoked. If you make it zero, highlighting is suppressed. If you make it large, highlighting will remain until you input something.") (defvar occur-match-beginning nil "*Byte position of beginning of occur match.") (defvar occur-match-end nil "*Byte position of end of occur match.") ; NB: this function must appear before references to it! (defun LaTeX-define-key (map suffix function) "Define a key binding in MAP, prefixing SUFFIX with LaTeX-command-key-prefix, and attach it to FUNCTION." (define-key map (concat LaTeX-command-key-prefix suffix) function)) (if LaTeX-mode-map () ;then do nothing if user-defined (let ((map (make-sparse-keymap))) ;else set standard map (define-key map "\"" 'LaTeX-quote) (LaTeX-define-key map "\C-b" 'LaTeX-bibitem) (LaTeX-define-key map "\C-i" 'LaTeX-tab) (LaTeX-define-key map "\C-n" 'LaTeX-news) (LaTeX-define-key map "\C-p" 'LaTeX-protect) (LaTeX-define-key map "<" 'LaTeX-angles) (LaTeX-define-key map ">" 'LaTeX-check-angle-balance) (LaTeX-define-key map "$" 'LaTeX-check-dollar-balance) (LaTeX-define-key map "%" 'LaTeX-comment) (LaTeX-define-key map "(" 'LaTeX-parentheses) (LaTeX-define-key map ")" 'LaTeX-check-parenthesis-balance) (LaTeX-define-key map "," 'LaTeX-set-indentation) (LaTeX-define-key map "." 'LaTeX-add-word-to-index) (LaTeX-define-key map "[" 'LaTeX-brackets) (LaTeX-define-key map "]" 'LaTeX-check-bracket-balance) (LaTeX-define-key map "0" 'renumber-slides) (LaTeX-define-key map "a" 'LaTeX-to-begin) (LaTeX-define-key map "b" 'LaTeX-begin-end-block) (LaTeX-define-key map "C" 'LaTeX-bibtag-with-completion) (LaTeX-define-key map "c" 'LaTeX-cite) (LaTeX-define-key map "d" 'make-LaTeX-document) (LaTeX-define-key map "e" 'LaTeX-to-end) (LaTeX-define-key map "f" 'LaTeX-footnote) (LaTeX-define-key map "g" 'LaTeX-gripe) (LaTeX-define-key map "i" 'LaTeX-item) (LaTeX-define-key map "k" 'LaTeX-counter) (LaTeX-define-key map "l" 'LaTeX-label) (LaTeX-define-key map "m" 'LaTeX-macro) (LaTeX-define-key map "n" 'LaTeX-end) (LaTeX-define-key map "p" 'LaTeX-pageref-with-completion) (LaTeX-define-key map "r" 'LaTeX-ref-with-completion) (LaTeX-define-key map "s" 'make-SLiTeX-document) (LaTeX-define-key map "u" 'LaTeX-uncomment) (LaTeX-define-key map "v" 'LaTeX-verb) (LaTeX-define-key map "x" 'LaTeX-index) (LaTeX-define-key map "{" 'LaTeX-braces) (LaTeX-define-key map "}" 'LaTeX-check-brace-balance) (LaTeX-define-key map "=" 'LaTeX-equation) (LaTeX-define-key map "\C-c=" 'LaTeX-displaymath) ;; The following bindings are similar to C-c C-f in mail-mode. ;; The second Ctl-C can be thought of as a mnemonic for `check' (LaTeX-define-key map "\C-c$" 'LaTeX-check-dollar-balance) (LaTeX-define-key map "\C-c)" 'LaTeX-check-parenthesis-balance) (LaTeX-define-key map "\C-c]" 'LaTeX-check-bracket-balance) (LaTeX-define-key map "\C-c}" 'LaTeX-check-brace-balance) ;; font wraps (need 3-char sequence, since we are running out ;; of two-character mnemonics) (LaTeX-define-key map "\C-cb" 'LaTeX-font-bf) (LaTeX-define-key map "\C-ce" 'LaTeX-font-em) (LaTeX-define-key map "\C-ci" 'LaTeX-font-it) (LaTeX-define-key map "\C-cr" 'LaTeX-font-rm) (LaTeX-define-key map "\C-cu" 'LaTeX-font-sc) (LaTeX-define-key map "\C-cf" 'LaTeX-font-sf) (LaTeX-define-key map "\C-cs" 'LaTeX-font-sl) (LaTeX-define-key map "\C-ct" 'LaTeX-font-tt) ;; miscellaneous bindings (LaTeX-define-key map "\C-c{" 'LaTeX-brace-words) (LaTeX-define-key map "\C-cp" 'LaTeX-path) (define-key map "\C-j" 'newline-and-indent) (define-key map "\M-(" 'backward-up-list) (define-key map "\M-)" 'forward-list) (define-key map "$" 'LaTeX-dollar) (define-key map "," 'LaTeX-comma) (define-key map "." 'LaTeX-dot) (define-key map "^" 'LaTeX-superscript) (define-key map "_" 'LaTeX-subscript) (setq LaTeX-mode-map map))) (defconst LaTeX-mode-version "0.42 [01-Sep-2015]" "Version number of current release of LaTeX-mode") (defvar LaTeX-newline-after-closing-delimiter nil "*Non-nil means that a newline is inserted after the closing brace following an inserted keyword (e.g. \cite{...}) or inserted delimiter pair.") (defvar LaTeX-newline-after-opening-delimiter t "*Non-nil means that macro arguments that appear in braces, brackets, or parenthesis are entered with the closing character on a new line, allowing typein to avoid having to push that character across the display. If nil, no empty line is created.") (defvar LaTeX-parenthesis-interval 500 "*Limit on number of characters between matching parentheses for\\ LaTeX-check-parenthesis-balance (on \\[LaTeX-check-parenthesis-balance]).") (defvar LaTeX-path-delimiter ?\= "*Delimiter character for LaTeX \\path macro.") (defconst LaTeX-prettyprint-paragraph-separate "^[ \t]*$\\| \\|^[ \t]*\\\\item\\|^[ \t]*\\\\bibitem\\|^[ \t]*%.*$" "*Regular expression for beginning of a line that separates paragraphs for the purposes of prettyprinting math mode.") (defvar LaTeX-space-after-begin-end nil "*Non-nil means that space is inserted before the braced environment name following a \\begin or \\end.") (defconst LaTeX-standard-comment-delimited-environments nil "*List of environments to always set off by empty comment lines.") (defconst LaTeX-standard-counters nil "List of standard counter names.") (setq LaTeX-standard-counters '( ("chapter") ("enumi") ("enumii") ("enumiii") ("enumiv") ("equation") ("figure") ("footnote") ("mpfootnote") ("page") ("paragraph") ("part") ("section") ("subparagraph") ("subsection") ("subsubsection") ("table") )) (defconst LaTeX-standard-dotted-abbreviations nil "List of abbreviations for which LaTeX-dot must provide special spacing, according to the value of LaTeX-comma-after-dotted-abbreviation.") (setq LaTeX-standard-dotted-abbreviations '( ("e.g.") ("ff.") ("i.e.") ("ibid.") ("loc cit.") ;both loc and loc. are in use ("loc. cit.") ("op. cit.") ("q.v.") ("viz.") ("w.r.t.") )) (defconst LaTeX-standard-environments nil "Standard environments known to LaTeX. Users may also define private ones in LaTeX-extra-environments. Each entry is itself a list, usually of only one string. A second optional list element is an additional string to be supplied after the \\begin{}. A third optional list element is a helpful comment string that is supplied on request. A fourth optional list element is a function to run after the \\begin{} \\end{} pair has been inserted, and point is between them; that function should position point to the place in the string defined by the second list element where something should be typed by the user.") (setq LaTeX-standard-environments '( ("abstract") ("alltt") ("array" "{}" (concat " % <- insert column justification letters (c,l,r)\n" " % Row entries: column-1 & column-2 & ... & column-n \\\\\n" " % Omit \\\\ on last row") (function (lambda () (search-backward "{}") (forward-char 1)))) ("bf") ("center") ("description") ("displaymath") ("document") ("em") ("enumerate") ("eqnarray") ("eqnarray*") ("equation") ("figure" "[]" " % <- insert location letters: h, b, t, p" (function (lambda () (search-backward "[]") (forward-char 1)))) ("figure*" "[]" " % <- insert location letters: h, b, t, p" (function (lambda () (search-backward "[]") (forward-char 1)))) ("flushleft") ("flushright") ("footnotesize") ("fussy") ("guess") ("huge") ("hunch") ("it") ("itemize") ("large") ("list") ("math") ("minipage" "[]{}" " % <- insert [position (b,t)]{width}" (function (lambda () (search-backward "[]{}") (forward-char 1)))) ("normalsize") ("note") ("overlay" "{}" " % <- insert {red,green,blue,etc.} color list" (function (lambda () (search-backward "{}") (forward-char 1)))) ("picture" "()()" " % <- insert (width,height)(lower-left-x,lower-left-y)" (function (lambda () (search-backward "()()") (forward-char 1)))) ("quotation") ("quote") ("scriptsize") ("setlength") ("sf") ("simple") ("sl") ("slide" "{}" " % <- insert {red,green,blue,etc.} color list" (function (lambda () (search-backward "{}") (forward-char 1)))) ("sloppy") ("sloppypar") ("small") ("tabbing") ("table" "[]" " % <- insert location letters: h, b, t, p" (function (lambda () (search-backward "[]") (forward-char 1)))) ("tabular" "{}" (concat " % <- insert column justification letters (c,l,r)\n" " % Row entries: column-1 & column-2 & ... & column-n \\\\\n" " % Omit \\\\ on last row") (function (lambda () (search-backward "{}") (forward-char 1)))) ("tabular*" "{}" (concat " % <- insert column justification letters (c,l,r)\n" " % Row entries: column-1 & column-2 & ... & column-n \\\\\n" " % Omit \\\\ on last row") (function (lambda () (search-backward "{}") (forward-char 1)))) ("thebibliography" "{}" " % <- insert widest label" (function (lambda () (search-forward "{thebibliography}") ;find \\end {thebibliography} (newline) ;and supply a newline (forward-line -2) (delete-blank-lines) (search-backward "{thebibliography}{}") (delete-blank-lines) (forward-char 18)))) ("theindex") ("theorem") ("tiny") ("titlepage") ("trivlist") ("tt") ("verbatim") ("verse") ("xguess") ("xiipt") ("xipt"))) (defconst LaTeX-standard-fonts nil "Standard LaTeX fonts which should be placed in a braced group.") (setq LaTeX-standard-fonts '( ;; size changes (from smallest to largest) ("tiny") ("scriptsize") ("footnotesize") ("small") ("normalsize") ("large") ("Large") ("LARGE") ("huge") ("Huge") ;; font style changes (alphabetically) ("bf") ("em") ("it") ("rm") ("sc") ("sf") ("sl") ("tt"))) (defconst LaTeX-2e-standard-fonts nil "Standard LaTeX 2e fonts which should be placed in a braced group.") (setq LaTeX-2e-standard-fonts '( ;; size changes (from smallest to largest) ("tiny") ("scriptsize") ("footnotesize") ("small") ("normalsize") ("large") ("Large") ("LARGE") ("huge") ("Huge") ;; font style changes (alphabetically) ;; These are excluded here, because they behave differently from ;; their 2.09 equivalents when inserted by LaTeX-macro. They ;; are included in LaTeX-2e-standard-macros. ;; ("emph") ;; ("textbf") ;; ("textit") ;; ("textmd") ;; ("textrm") ;; ("textsc") ;; ("textsf") ;; ("textsl") ;; ("textup") ;; ("texttt") )) (defconst LaTeX-standard-italic-fonts nil "Standard LaTeX italic fonts which usually take an italic correction.") (setq LaTeX-standard-italic-fonts '( ("em") ("it") ("sl"))) (defconst LaTeX-2e-standard-italic-fonts nil "Standard LaTeX 2e italic fonts. These do NOT require an italic correction, because the macros supply it automatically.") (setq LaTeX-2e-standard-italic-fonts '( ("emph") ("textit") ("textsl"))) (defconst LaTeX-standard-list-environments nil "Standard environments which expect \\item entries.") (setq LaTeX-standard-list-environments '( ("description") ("enumerate") ("itemize") ("list") ("trivlist"))) (defconst LaTeX-standard-macros nil "Standard LaTeX macros. These are stored in an associative list with elements of the form (\"name\" \"args\" \"short comment\"). If there are no arguments, then args is nil. For example, (\"framebox\" \"[][]{}\" \"[width][position (c,l,r)]{...}\") describes the macro \\framebox[width][position]{...}. The comment will be displayed by LaTeX-macro (on \[LaTeX-macro]) if name completion is requested.") ;;; Note that these are not globally sorted alphabetically, but instead ;;; are kept in order by their groupings in the LaTeX Reference Card, ;;; with blank lines separating the groups. The Reference Card does ;;; not cover the complete set of LaTeX commands, so we need to extend ;;; this some more yet. (setq LaTeX-standard-macros '( ;; miscellany ("date" "{}" "explicit date") ("footnotemark" "[]{}" "[number-or-symbol]{text} to footnote mark only") ("footnoterule" nil "command to draw line between text and footnotes") ("footnotesep" nil "height of vertical space between footnotes") ("footnotetext" "[]{}" "[number-or-symbol]{text} for footnote text only") ("special" "{}" "DVI-driver dependent text") ("today" nil "today's date like July 22, 1985") ;; type style ("bf" nil "bold text") ("boldmath" nil "use bold math symbols") ("cal" nil "upper-case calligraphic letters (math mode only)") ("em" nil "emphasized text") ("it" nil "italic text") ("mit" nil "math italics (math mode only)") ("rm" nil "roman text") ("sc" nil "small-caps text") ("sf" nil "sans-serif text") ("sl" nil "slanted text") ("tt" nil "typewriter text") ("unboldmath" nil "use normal math symbols") ;; math type styles ("displaystyle" nil "for normal symbols in displayed formula") ("scriptstyle" nil "for subscripts and superscripts") ("scriptscriptstyle" nil "for higher-level subscripts and superscripts") ("textstyle" nil "for normal symbols in in-text formula") ;; type size ("tiny" nil "tiny typesize") ("scriptsize" nil "subscript typesize") ("footnotesize" nil "footnote typesize") ("small" nil "small typesize") ("normalsize" nil "normal typesize") ("large" nil "large typesize") ("Large" nil "larger typesize") ("LARGE" nil "very large typesize") ("huge" nil "huge typesize") ("Huge" nil "Hugest typesize") ;; special symbols ("P" nil "pilcrow (paragraph mark)") ("S" nil "section mark") ("copyright" nil "copyright mark") ("dag" nil "single dagger") ("ddag" nil "double dagger") ("pounds" nil "sterling currency mark") ;; document sectioning ("tableofcontents" nil "generate table of contents in document") ("listoffigures" nil "generate list of figures in document") ("listoftables" nil "generate list of tables in document") ("part" "{}" "part in document") ("chapter" "{}" "chapter in document") ("section" "{}" "section in document") ("subsection" "{}" "subsection in document") ("subsubsection" "{}" "subsubsection in document") ("paragraph" "{}" "paragraph in document") ("subparagraph" "{}" "subparagraph in document") ("appendix" nil "appendix in document") ("part*" "{}" "unnumbered part in document") ("chapter*" "{}" "unnumbered chapter in document") ("section*" "{}" "unnumbered section in document") ("subsection*" "{}" "unnumbered subsection in document") ("subsubsection*" "{}" "unnumbered subsubsection in document") ("paragraph*" "{}" "unnumbered paragraph in document") ("subparagraph*" "{}" "unnumbered subparagraph in document") ;; math symbols ("frac" "{}{}" "{numerator}{denominator}") ("left" nil "left delimiter (follow by one of \".([{|\")") ("overbrace" "{}" "expression to overbrace") ("overline" "{}" "expression to overline") ("right" nil "right delimiter (follow by one of \".)]}|\")") ("sqrt" "[]{}" "[n-th root]{what of}") ("underbrace" "{}" "expression to underbrace") ("underline" "{}" "expression to underline") ;; document and page styles ("pagenumbering" "{}" "one of: arabic, roman, alph, Roman, Alph") ("pagestyle" "{}" "one of: plain, empty, headings, myheadings") ;; title page and abstract ("author" "{}" "author name(s)") ("and" nil "another author") ("maketitle" nil "generate title from \\title, \\author, \\date") ("title" "{}" "document title") ;; splitting the input ("include" "{}" "read {file} unless excluded by \\readonly") ("includeonly" "{}" "exclude any file not in {files}") ("input" "{}" "read {file}") ;; line breaking ("\\\\" "[]" "start new line leave [v] extra vertical space") ("\\\\*" "[]" "start new line leave [v] extra vertical space WITHOUT page break") ("linebreak" "[]" "force or encourage a line break ([n] in [0]..[4])") ("nolinebreak" "[]" "forbid or discourage a line break ([n] in [0]..[4])") ("sloppy" nil "allow loose lines (opposite of \\fussy)") ;; page breaking ("clearpage" nil "print all figures and tables and start a new page") ("cleardoublepage" nil "print all figures and tables and start a new right-hand (odd-numbered) page") ("newpage" nil "start a new page") ("nopagebreak" "[]" "forbid or discourage a page break ([n] in [0]..[4])") ("pagebreak" "[]" "force or encourage a page break ([n] in [0]..[4])") ("samepage" nil "forbid page breaking except between paragraphs") ;; boxes ("fbox" "{}" "frame {text} in box") ("framebox" "[][]{}" "make framed box of [width][position (l,r)]{...}") ("makebox" "[][]{}" "make box of [width][position (l,r)]{...}") ("mbox" "{}" "unbreakable text") ("newsavebox" "{}" "define {\\cmd} to be a bin for saving boxes") ("parbox" "[]{}{}" "paragraph box [position (b,t)]{width}{text}") ("savebox" "{}[][]{}" "{\\cmd}[width][position (l,r)]{text} save text in savebox {\\cmd}") ("sbox" "{}{}" "{\\cmd}{text} save text in savebox {\\cmd}") ("usebox" "{}" "print box saved in bin {\\cmd}") ;; length ("addtolength" "{}{}" "{\\cmd}{len} add len to length cmd") ("newlength" "{}" "define {\\cmd} to be a length") ("setlength" "{}{}" "{\\cmd}{len} set length cmd to len") ("settowidth" "{}{}" "{\\cmd}{text} set cmd to width of text") ;; space ("hspace" "{}" "make {length} horizontal space") ("hspace*" "{}" "make {length} horizontal space, even at beginning of line") ("vspace" "{}" "make {length} vertical space") ("vspace*" "{}" "make {length} vertical space, even at beginning of page") ;; pictures (NB: makebox, framebox, savebox have conflicting forms ;; here, and are omitted for now) ("circle" "{}" "circle of diameter {dia}") ("circle*" "{}" "filled disk of diameter {dia}") ("dashbox" "{}()[]{}" "{d}(x,y)[position (b,t,l,r)]{object} put frame of dashed line of length {d} around {object}") ("frame" "{}" "draw frame around {object}") ("line" "(){}" "line of slope (h,v) and horizontal extent {len} (length len if h = 0), h,v in 0..6") ("multiput" "()(){}{}" "(x,y)(dx,dy){n}{object} put object at (x,y), (x+dx, y+dy), ... n times") ("oval" "()[]" "[part (l,r,t,b)] of oval of size (width,height)") ("put" "(){}" "put at (x,y) some {object}") ("shortstack" "[]{}" "at [position (c,l,r)] stack {object} in box") ("thicklines" nil "thick picture lines") ("thinlines" nil "thin picture lines") ("vector" "(){}" "vector of slope (h,v) and horizontal extent {len} (length len if h = 0), h,v in 0..4") ;; figures and tables ("caption" "{}" "{caption} of figure or table") ;; tabbing environment ("=" nil "set tab stop") (">" nil "go to next tab stop") ("kill" nil "throw away sample line in tabbing environment") ;; array and tabular environments ("cline" "{}" "horizontal line across columns {i-j}") ("hline" nil "horizontal line between rows") ("multicolumn" "{}{}{}" "{n}{col}{text} span next n columns with col format") ("vline" nil "vertical line between columns") ;; definitions ("newcommand" "{}[]{}" "{\\cmd}[n]{def} define new command with n arguments") ("newcounter" "{}[]" "{new-counter}[within-counter]") ("newenvironment" "{}[]{}{}" "{env}[n]{beg}{end} define new environment with n arguments") ("newfont" "{}{}" "{command}{fontname} for new font") ("newtheorem" "{}{}" "{name}{caption} define new theorem environment") ;; numbering ("addtocounter" "{}{}" "{ctr}{n} add n to counter ctr") ("setcounter" "{}{}" "{ctr}{n} set counter ctr to n") ;; remainder not on reference card ;; bibliographies ("bibitem" "[]{}" "[label]{cite_key}") ("bibliography" "{}" "{bibliography-datebase-filename}") ("bibliographystyle" "{}" "{style-name}") ;; index and glossary ("glossary" "{}" "{glossary entry}") ("glossaryentry" "{}{}" "{string}{page} glossary entry") ("indexentry" "{}{}" "{string}{page} index entry") ("indexspace" nil "extra vertical space in index") ("makeglossary" nil "generate glossary (.glo) file (in preamble only)") ("makeindex" nil "generate index (.idx) file (in preamble only)") ;; terminal I/O ("typein" "[]{}" "[cmd]{message} -- (re)define cmd from terminal input") ("typeout" "{}" "{message}") ;; assorted others from Appendix C ("addvspace" "{}" "{len} extra vertical space") ("bigskip" nil "big skip") ("fussy" nil "restore fussy line breaking (opposite of \\sloppy)") ("hyphenation" "{}" "{hy-phen-ations sep-a-rated by spaces}") ("medskip" nil "medium skip") ("newline" nil "forced line break") ("raisebox" "{}[][]{}" "{raise_len}[height][depth]{text}") ("rule" "[]{}{}" "[raise_len]{width}{height}") ("smallskip" nil "small skip") ("stretch" "{}" "{dec_num} -- rubber length dec_num times the stretchability of \\fill") ("verb" "||" "|verbatim (typewriter) text| (use any identical delimiters in place of | |)") ("verb*" "||" "|verbatim (typewriter) text| with visible spaces (use any identical delimiters in place of | |)") ;; macros already bound to keys because of frequency of use, ;; but if user tries to generate them with LaTeX-macro, that ;; should be permitted too ("cite" "[]{}" "[remark text]{cite_key,key,...,key}") ("footnote" "{}" "{footnote text}") ("index" "{}" "{index text}") ("item" "[]" "[alternate item tag]") ("label" "{}" "{cross-reference key}") ("nocite" "{}" "{citation key,key,...,key}") ("pageref" "{}" "{cross-reference key}") ("ref" "{}" "{cross-reference key}") ;; foreign symbols ("AA{}" nil nil) ("AE{}" nil nil) ("L{}" nil nil) ("OE{}" nil nil) ("O{}" nil nil) ("aa{}" nil nil) ("ae{}" nil nil) ("l{}" nil nil) ("oe{}" nil nil) ("o{}" nil nil) ("ss{}" nil nil) ;; accents ("'" "{}" "acute over-accent") ("." "{}" "dot over-accent") ;;("=" "{}" "bar over-accent") ;;used in tabbing environment ("H" "{}" "hungarian umlaut over-accent") ("\"" "{}" "umlaut over-accent") ("^" "{}" "circumflex (hat) over-accent") ("`" "{}" "grave over-accent") ("b" "{}" "bar under-accent") ("c" "{}" "cedilla under-accent") ("d" "{}" "dot under-accent") ("t" "{}" "tie over-accent") ("u" "{}" "breve (cup) over-accent") ("v" "{}" "v (check) over-accent") ("~" "{}" "tilde over-accent") ;; math mode accents ("acute" "{}" "acute over-accent") ("bar" "{}" "bar over-accent") ("breve" "{}" "breve (cup) over-accent") ("check" "{}" "check over-accent") ("ddot" "{}" "double-dot over-accent") ("dot" "{}" "dot over-accent") ("grave" "{}" "grave over-accent") ("hat" "{}" "circumflex (hat) over-accent") ("tilde" "{}" "tilde over-accent") ("vec" "{}" "vector over-accent") ;; style parameters ("abovedisplayshortskip" nil "amount of extra space left above a short displayed formula (except in `fleqn' style option)") ("abovedisplayskip" nil "amount of extra space left above a long displayed formula (except in `fleqn' style option)") ("arraycolsep" nil "half width of default intercolumn space in `array' environment") ("arrayrulewidth" nil "width of rule from |, \\cline, \\hline, or \\vline") ("arraystretch" nil "multiplier of normal interrow spacing") ("belowdisplayshortskip" nil "amount of extra space left below a short displayed formula (except in `fleqn' style option)") ("belowdisplayskip" nil "amount of extra space left below a long displayed formula (except in `fleqn' style option)") ("bottomfraction" nil "maximum page fraction for bottom floats") ("dblfloatpagefraction" nil "minimum page fraction for floats in two-column style") ("dblfloatsep" nil "vertical space between top or bottom floats in two-column style") ("dbltextfloatsep" nil "vertical space between top or bottom floats and page text in two-column style") ("dbltopfraction" nil "maximum page fraction for top floats in two-column style") ("doublerulesep" nil "width of space between || or \\hline \\hline") ("evensidemargin" nil "one inch less than distance of left edge of paper to left margin of text on left-hand pages") ("extracolsep" "{}" "{width} extra space (for @-expression in `array' or `tabular' environment)") ("fboxrule" nil "width of lines in \\fbox and \\framebox") ("fboxsep" nil "amount of space between box edge and contents in \\fbox and \\framebox") ("floatpagefraction" nil "minimum page fraction for floats") ("floatsep" nil "vertical space between top or bottom floats") ("footheight" nil "height of a box containing the page foot") ("footskip" nil "distance from bottom of last line of body text to bottom of foot") ("headheight" nil "height of a box containing the head") ("headsep" nil "vertical space between head and body of page") ("intextsep" nil "vertical space above and below here-float") ("jot" nil "amount of extra vertical space between rows in `eqnarray' environment") ("marginpar" "[]{}" "[left-text]{right-text} of margin paragraph") ("marginparpush" nil "minimum vertical space between marginal notes") ("marginparsep" nil "horizontal space between outer margin and marginal note") ("marginparwidth" nil "width of marginal note parbox") ("mathindent" nil "indentation from left margin of displayed formulas in `fleqn' style") ("normalmarginpar" nil "place marginal notes in default margin") ("oddsidemargin" nil "one inch less than distance of left edge of paper to left margin of text on right-hand pages") ("reversemarginpar" nil "place marginal notes in opposite of default margin") ("tabcolsep" nil "half width of default intercolumn space in `tabular' environment") ("textfloatsep" nil "vertical space between top or bottom floats and page text") ("textfraction" nil "minimum page fraction for text") ("textheight" nil "normal height of page body") ("textwidth" nil "normal width of page body") ("topfraction" nil "maximum page fraction for top floats") ("topmargin" nil "one inch less than distance from top edge of paper to top of page head") ("topsep" nil "extra vertical space between list and surrounding text") ("topskip" nil "minimum distance from top of body to bottom of first line of text") ;; math mode ("bmod" nil "binary `mod' symbol") ("cdots" nil "dots ... at center of line") ("ddots" nil "diagonal dots") ("ldots" nil "dots ... at bottom of line") ("lefteqn" "{}" "print {formula} in zero-width display style in `eqnarray'") ("pmod" "{}" "produce `(mod {arg})'") ("vdots" nil "vertical dots") ;; Greek letters ("alpha" nil nil) ("beta" nil nil) ("gamma" nil nil) ("delta" nil nil) ("epsilon" nil nil) ("varepsilon" nil nil) ("zeta" nil nil) ("eta" nil nil) ("theta" nil nil) ("vartheta" nil nil) ("iota" nil nil) ("kappa" nil nil) ("lambda" nil nil) ("mu" nil nil) ("nu" nil nil) ("xi" nil nil) ("pi" nil nil) ("varpi" nil nil) ("rho" nil nil) ("varrho" nil nil) ("sigma" nil nil) ("varsigma" nil nil) ("tau" nil nil) ("upsilon" nil nil) ("phi" nil nil) ("varphi" nil nil) ("chi" nil nil) ("psi" nil nil) ("omega" nil nil) ("Gamma" nil nil) ("Delta" nil nil) ("Theta" nil nil) ("Lambda" nil nil) ("Xi" nil nil) ("Pi" nil nil) ("Sigma" nil nil) ("Upsilon" nil nil) ("Phi" nil nil) ("Psi" nil nil) ("Omega" nil nil) ;; delimiters ("langle" nil "left angle bracket") ("lceil" nil "left ceiling bracket") ("lfloor" nil "left floor bracket") ("rangle" nil "right angle bracket") ("rceil" nil "right ceiling bracket") ("rfloor" nil "right floor bracket") ;; binary operation symbols ("pm" nil "plus-minus") ("mp" nil "minus-plus") ("times" nil "multiply") ("div" nil "divide") ("ast" nil "asterisk") ("star" nil "star") ("circ" nil "hollow circle") ("bullet" nil "solid circle") ("cdot" nil "centered dot") ("cap" nil "intersection") ("cup" nil "union") ("uplus" nil "union plus") ("sqcap" nil "square cap") ("sqcup" nil "square cup") ("vee" nil "logical or") ("wedge" nil "logical and") ("setminus" nil "backslash") ("wr" nil "vertical squiggle") ("diamond" nil "hollow diamond") ("bigtriangleup" nil "up-pointing big triangle") ("bigtriangledown" nil "down-pointing big triangle") ("triangleleft" nil "left-pointing triangle") ("triangleright" nil "right-pointing triangle") ("lhd" nil "left arrowhead") ("rhd" nil "right arrowhead") ("unlhd" nil "underlined left arrowhead") ("unrhd" nil "underlined right arrowhead") ("oplus" nil "circled plus") ("ominus" nil "circled minus") ("otimes" nil "circled multiply") ("oslash" nil "circled divide") ("odot" nil "circled dot") ("bigcirc" nil "big hollow circle") ("dagger" nil "dagger") ("ddagger" nil "double dagger") ("amalg" nil "inverted Pi") ;; relation symbols ("not" nil "cross following math operator") ("leq" nil "less than or equal") ("prec" nil nil) ("preceq" nil nil) ("ll" nil "much less than") ("subset" nil "subset") ("subseteq" nil nil) ("sqsubset" nil "square subset") ("sqsubseteq" nil "square subseteq") ("in" nil "element of") ("vdash" nil nil) ("geq" nil "greater than or equal") ("succ" nil nil) ("succeq" nil nil) ("gg" nil "much greater than") ("supset" nil "superset") ("supseteq" nil nil) ("sqsupset" nil "square supset") ("sqsupseteq" nil "square supseteq") ("ni" nil "backwards \\in") ("dashv" nil nil) ("equiv" nil "equivalent") ("sim" nil nil) ("simeq" nil nil) ("asymp" nil nil) ("approx" nil "approximately equal") ("cong" nil nil) ("neq" nil "not equal to") ("doteq" nil "dotted equal") ("propto" nil "proportional to") ("models" nil nil) ("perp" nil "perpendicular to") ("mid" nil "vertical bar") ("parallel" nil "double vertical bar") ("bowtie" nil nil) ("Join" nil "small bowtie") ("smile" nil nil) ("frown" nil nil) ;; arrow symbols ("leftarrow" nil nil) ("Leftarrow" nil nil) ("rightarrow" nil nil) ("Rightarrow" nil nil) ("leftrightarrow" nil nil) ("Leftrightarrow" nil nil) ("mapsto" nil nil) ("hookleftarrow" nil nil) ("leftharpoonup" nil nil) ("leftharpoondown" nil nil) ("rightleftharpoons" nil nil) ("longleftarrow" nil nil) ("Longleftarrow" nil nil) ("longrightarrow" nil nil) ("Longrightarrow" nil nil) ("longleftrightarrow" nil nil) ("Longleftrightarrow" nil nil) ("longmapsto" nil nil) ("hookrightarrow" nil nil) ("rightharpoonup" nil nil) ("rightharpoondown" nil nil) ("leadsto" nil nil) ("uparrow" nil nil) ("Uparrow" nil nil) ("downarrow" nil nil) ("Downarrow" nil nil) ("updownarrow" nil nil) ("Updownarrow" nil nil) ("nearrow" nil nil) ("searrow" nil nil) ("swarrow" nil nil) ("nwarrow" nil nil) ;; miscellaneous symbols ("aleph" nil "first Hebrew letter") ("hbar" nil "Planck's constant/(2pi)") ("imath" nil "undotted italic i") ("jmath" nil "undotted italic j") ("ell" nil "script l") ("wp" nil nil) ("Re" nil "real part of") ("Im" nil "imaginary part of") ("mho" nil "reciprocal ohm") ("prime" nil nil) ("emptyset" nil "slashed 0") ("nabla" nil "inverted delta") ("surd" nil "root of") ("top" nil nil) ("bot" nil nil) ("|" nil "double vertical bars") ("angle" nil "angle between") ("forall" nil "inverted A") ("exists" nil "backwards E") ("neg" nil "negation") ("flat" nil "musical flat") ("natural" nil "musical natural") ("sharp" nil "musical sharp") ("backslash" nil nil) ("partial" nil "partial derivative") ("infty" nil "infinity") ("Box" nil "big hollow box") ("Diamond" nil "big hollow diamond") ("triangle" nil "hollow triangle") ("clubsuit" nil "playing card club suit") ("diamondsuit" nil "playing card diamond suit") ("heartsuit" nil "playing card heart suit") ("spadesuit" nil "playing card spade suit") ;; variable-sized symbols ("sum" nil "summation of") ("prod" nil "product of") ("coprod" nil nil) ("int" nil "integral of") ("oint" nil "contour integral of") ("bigcap" nil "big intersection of") ("bigcup" nil "big union of") ("bigsqcup" nil "big square union of") ("bigvee" nil "big logical or") ("bigwedge" nil "big logical and") ("bigodot" nil "big circled dot") ("bigotimes" nil "big circled multiply") ("bigoplus" nil "big circled plus") ("biguplus" nil "big union plus") ;; log-like functions ("arccos" nil nil) ("arcsin" nil nil) ("arctan" nil nil) ("arg" nil nil) ("cos" nil nil) ("cosh" nil nil) ("cot" nil nil) ("coth" nil nil) ("csc" nil nil) ("deg" nil nil) ("det" nil nil) ("dim" nil nil) ("exp" nil nil) ("gcd" nil nil) ("hom" nil nil) ("inf" nil nil) ("ker" nil nil) ("lg" nil nil) ("lim" nil nil) ("liminf" nil nil) ("limsup" nil nil) ("ln" nil nil) ("log" nil nil) ("max" nil nil) ("min" nil nil) ("Pr" nil nil) ("sec" nil nil) ("sin" nil nil) ("sinh" nil nil) ("sup" nil nil) ("tan" nil nil) ("tanh" nil nil) ;; letters ("address" "{}" "{line1\\\\line2\\\\...linen} of letter return address (in preamble)") ("cc" "{}" "{name1\\\\name2\\\\...namen} carbon copies of letter") ("closing" "{}" "{Best regards,} letter closing") ("makelabels" nil "make list of mailing labels") ("opening" "{}" "{Dear John,} letter opening") ("ps" nil "precedes text after letter \\closing (you type P.S.)") ("signature" "{}" "{name\\\\title} letter signature (in preamble)") ("encl" "{}" "{encl1\\\\encl2...\\\\encln} list of enclosures") ;; logos ("AMSTEX{}" nil "AMSTeX") ("BibTeX{}" nil "BibTeX") ("LaTeX{}" nil "LaTeX") ("METAFONT{}" nil "Metafont") ("MF{}" nil "Metafont") ("SLiTeX{}" nil "SLiTeX") ("TeX{}" nil "TeX") ;; remaining macros appearing in the index (alphabetically) ("Alph" "{}" "{counter} uppercase letters for counter") ("Roman" "{}" "{counter} uppercase roman numerals for counter") ("a'" "{}" "acute over-accent in tabbing environment") ("a=" "{}" "bar over-accent in tabbing environment") ("a`" "{}" "grave over-accent in tabbing environment") ("addcontentsline" "{}{}{}" "{file_ext}{sec_unit}{entry} -- add an entry to specified list or table") ("addtocontents" "{file_ext}{text}" "add text to .toc, .lof, or .lot file") ("alph" "{}" "{counter} lowercase letters for counter") ("arabic" "{}" "{counter} arabic numerals for counter") ("baselineskip" nil "minimum space between successive line bottoms") ("baselinestretch" nil "multiplier of \\baselineskip") ("batchmode" nil "non-stop LaTeX processing") ("begin" "{}" "{environment}") ("bibindent" nil "width of extra indentation in openbib block") ("bigskipamount" nil "vertical space for \\bigskip") ("blackandwhite" "{}" "{file} for black and white slides") ("centering" nil "centering text") ("colors" "{}" "{red,blue,green,etc.} slides") ("colorslides" "{}" "{file} for color slides") ("columnsep" nil "width of intercolumn space in twocolumn style") ("columnseprule" nil "width of intercolumn rule in twocolumn style") ("documentstyle" "[]{}" "[option,option,...]{style}") ("dotfill" nil "dotted fill") ("end" "{}" "{environment}") ("fill" nil "arbitrarily stretchable rubber length") ("flushbottom" nil "preamble declaration for flush page bottoms") ("fnsymbol" "{}" "{counter} one of 9 footnote symbols") ("frenchspacing" nil "suppress extra space after punctuation") ("hbox" "{}" "horizontal box") ("hfill" nil "horizontal stretchable space") ("hrulefill" nil "horizontal rule fill") ("indent" nil "horizontal space of size as paragraph indentation") ("invisible" nil "color declaration for invisible SliTeX text") ("itemindent" nil "extra indentation before item label") ("itemsep" nil "vertical space between list items") ("i{}" nil "undotted i") ("j{}" nil "undotted j") ("labelitemi" nil "macro to produce label item") ("labelitemii" nil "macro to produce label item") ("labelitemiii" nil "macro to produce label item") ("labelitemiv" nil "macro to produce label item") ("labelsep" nil "space between label box and item text") ("labelwidth" nil "width of label box") ("leftmargin" nil "horizontal distance from enclosing environment left margin and left margin of list") ("leftmargini" nil "horizontal distance from enclosing environment left margin and left margin of list") ("leftmarginii" nil "horizontal distance from enclosing environment left margin and left margin of list") ("leftmarginiii" nil "horizontal distance from enclosing environment left margin and left margin of list") ("leftmarginiv" nil "horizontal distance from enclosing environment left margin and left margin of list") ("linethickness" "{}" "{len} for picture environment lines") ("linewidth" nil "width of lines in current environment") ("listparindent" nil "extra indentation for first line of each paragraph except first one of item") ("load" "{}{}" "{size}{style} -- load size and style of font") ("makelabel" "{}" "{label} -- generate label for \\item command") ("markboth" "{}{}" "{left-head}{right-head} for page styles `headings' and `myheadings'") ("markright" "{}" "{right-head} for page styles `headings' and `myheadings'") ("medskipamount" nil "vertical space for \\medskip") ("nofiles" nil "suppress writing of .aux files") ("noindent" nil "suppress following paragraph indentation") ("nonfrenchspacing" nil "restore extra space after punctuation") ("nonumber" nil "suppress equation number in current row") ("numberline" "{}{}" "{sec_num}{heading} (for \\addcontentsline)") ("onecolumn" nil "start new page and revert to single column") ("onlynotes" "{}" "{1,3-5,7,23} -- produce subset of slide notes") ("onlyslides" "{}" "{1,3-5,7,23} -- produce subset of slides") ("par" nil "new paragraph") ("parindent" nil "paragraph indentation") ("parsep" nil "interparagraph separation in lists") ("parskip" nil "extra vertical space before paragraph") ("partopsep" nil "extra vertical space between list and surrounding text") ("poptabs" nil "restore pushed tab settings") ("protect" nil "protect following macro from immediate expansion") ("pushtabs" nil "push current tab settings (restore by \\poptabs)") ("raggedbottom" nil "preamble declaration for ragged page bottoms") ("raggedleft" nil "declaration for ragged left margins") ("raggedright" nil "declaration for ragged right margins") ("refstepcounter" "{}" "{counter} increment counter by 1 and declare \ref value") ("renewcommand" "{}[]{}" "{\\cmd}[n]{def} redefine old command with n arguments") ("renewenvironment" "{}[]{}{}" "{env}[n]{beg}{end} redefine old environment with n arguments") ("rightmargin" nil "horizontal distance from enclosing environment right margin and right margin of list") ("roman" "{}" "{counter} lowercase roman numerals for counter") ("smallskipamount" nil "vertical space for \\smallskip") ("space" nil "single space in argument of \\typeout{}") ("stackrel" "{}{}" "{top}{bottom} -- typeset top over bottom") ("stepcounter" "{}" "{counter} increment counter by 1") ("subitem" nil "subitem in document index") ("subsubitem" nil "subsubitem in document index") ("symbol" "{}" "typeset symbol {num} in current font") ("tabbingsep" nil "intercolumn tab stop separation") ("thanks" "{}" "{footnote} for titlepage -- put inside \\title{}, \\author{}, or \\date{}") ("the" nil "\\thectr is value of counter ctr") ("thepage" nil "current page number in current style") ("thispagestyle" "{}" "{style} of current page") ("twocolumn" "[]" "start new page in two column mode, setting two-column [optional-text] across top") ("unitlength" nil "size of unit length in picture mode") ("usecounter" "{}" "enable and zero {ctr} for numbering list items") ("value" "{}" "value of counter {ctr}") ("vbox" "{}" "vertical box") ("vfill" nil "vertical stretchable space") ("widehat" "{}" "{text} to be capped by wide hat") ("widetilde" "{}" "{text} to be capped by wide tilde") ;; miscellaneous additions ("printindex" nil "read and print index at this point") )) (defconst LaTeX-2e-standard-macros nil "Standard macros that are new with LaTeX 2e. They supplement the list in LaTeX-standard-macros.") (setq LaTeX-2e-standard-macros '( ;; These are given in the same order as they appear on the LaTeX ;; 2e reference card. Several additional ones are also provided. ;; type style ("emph" "{}" "emphasized text") ("textrm" "{}" "roman text") ("textit" "{}" "italic text") ("textbf" "{}" "bold text") ("textsl" "{}" "slanted text") ("textsc" "{}" "small-caps text") ("texttt" "{}" "typewriter text") ("textsf" "{}" "sans-serif text") ("textmd" "{}" "medium text") ; missing from reference card ("textup" "{}" "upright text") ; missing from reference card ("itshape" "{}" "italic shape") ; missing from reference card ("scshape" "{}" "small caps shape") ; missing from reference card ("slshape" "{}" "slanted shape") ; missing from reference card ("upshape" "{}" "upright shape") ; missing from reference card ("bfseries" "{}" "bold series") ; missing from reference card ("mdseries" "{}" "medium series") ; missing from reference card ("rmfamily" "{}" "roman family") ; missing from reference card ("sffamily" "{}" "sans serif family") ; missing from reference card ("ttfamily" "{}" "typewriter family") ; missing from reference card ("mathrm" "{}" "roman text") ("mathit" "{}" "italic text") ("mathbf" "{}" "bold text") ("mathtt" "{}" "typewriter text") ("mathsf" "{}" "sans-serif text") ("mathcal" "{}" "calligraphic text") ;; document class, packages, styles ("documentclass" "[]{}" "[option,option,...]{class}") ("usepackage" "[]{}" "[option,option,...]{subclass}") ;; page breaking ("enlargethispage" "{}" "squeeze extra {ht} of text onto this page") ("enlargethispage*" "{}" "squeeze extra {ht} of text onto this page") ;; graphics and color package ("scalebox" "{}{}" "{factor}{contents}: scale box by {factor}") ("resizebox" "{}{}{}" "{wd}{ht}{contents}: scale box to {wd} x {ht}") ("rotatebox" "{}{}" "{angle}{contents}: rotate box by {angle} degrees") ("includegraphics" "{}" "insert graphics from {file}") ("definecolor" "{}{}{}" "{color}{model}{value}: define color") ("textcolor" "{}{}" "{color}{text}: typeset colored text") ("colorbox""{}{}" "{color}{text}: typeset colored box") ("pagecolor" "{}" "set background {color} of page") )) (defconst LaTeX-standard-options nil "Standard \\documentstyle options. Users may also define private ones.") ;;; Note that is is not possible to just insert the names of all .sty ;;; files here, because a few are not for LaTeX (e.g. AMSTeX .sty ;;; files), and of the remainder, some are standalone styles (for ;;; LaTeX-standard-styles), and some (these) are modifying options. ;;; Some options, like 11pt, do not have a style file at all (which was ;;; probably a bad design choice, for otherwise, this list could be set ;;; dynamically from the file system). ;;; ;;; This list is chosen from the set of styles available at the author's ;;; site in Utah [last update 21 August 1991]. Some styles may not be ;;; available elsewhere, but that is fairly harmless. All of these ;;; styles may be freely distributed. Credits have been given; ;;; eventually, these comments may be added to the option list for ;;; additional documentation. (setq LaTeX-standard-options '( ("11pt") ;LaTeX 2.09 ("12pt") ;LaTeX 2.09 ("a4") ;John Pavel: A4 paper ("a4wide") ;Jean-Francois Lamy: wider text lines on A4 paper ("acm") ;LaTeX 2.09 ("acronym") ;Douglas Miller: acronyms ("agugrl") ;American Geophysical Union Geophysical Research Letters ("agujgr") ;American Geophysical Union Journal of Geophysical Research ("alltt") ;LaTeX 2.09 ("amsbsy") ;AMS-LaTeX ("amscd") ;AMS-LaTeX ("amsfonts") ;AMS-LaTeX ("amssymb") ;AMS-LaTeX ("amssymbols") ;Charles Karney: AMS symbol font support ("amstext") ;AMS-LaTeX ("apalike") ;BibTeX APA style citations ("archmemo") ;Utah ("array") ;F. Mittelbach array+tabular TUGboat 9(3)298 (1988), 10(1)103 (1989) ("bezier") ;LaTeX 2.09 ("biihead") ;Ted Shapin: underlined page headings ("boxedmini") ;Jerry Leichter: boxed minipage environment ("changebar") ;anonymous: changebar environment ("chapterbib") ;C. Niel Kempson: multiple bibliographies ("cite") ;Donald Arseneau: line breaks in long citations ("clsc") ;Utah ("clscmemo") ;Utah ("concrete") ;Concrete Roman fonts ("cropmark") ;Dominik Wujastyk: page crop marks (corner rules) ("ctagsplt") ;AMS-LaTeX ("cyrillic") ;Charles Karney: cyrillic fonts ("dblspace") ;same as doublespace ("doublespace") ;same as dblspace ("draft") ;Joe Baker: mark label, cite, ref, index, glossary ("drafthead") ;Stephen Page: DRAFT + timestamp in page header ("drop") ;David G. Cantor: dropped caps ("dvidoc") ;John Pavel: dvidoc fonts ("eqsecnum") ;aps (American Physical Society) ("espo") ;anonymous: Esperanto object names ("fleqn") ;LaTeX 2.09 ("format") ;Charles Karney: floating-point number formatting ("fullpage") ;Richard Furuta: extended text height ("geophysics") ;Stephen Gildea: Geophysics journal ("german") ;H. Partl: German object names et al ("gnuindex") ;Utah: GNU TeXindex indexing support ("ifthen") ;LaTeX 2.09 ("intlim") ;AMS-LaTeX ("ist21") ;anonymous: British Standards Institute IST21 docs ("leqno") ;LaTeX 2.09 ("listing") ;Utah: program listings ("longtab") ;David Carlisle: long tables ("makeidx") ;LaTeX 2.09 ("math") ;Utah ("merge") ;Johannes L. Braams: form letter merge ("mfr") ;Mark A. Roth: memo-for-record (usafmemo option) ("mitthesis") ;MIT thesis ("moretext") ;Jean-Francois Lamy: wider text lines ("natsci") ;Stephen Gildea: citations in NATSCI bib style. ("nl") ;Nederlands (Dutch) object names ("nonamelm") ;AMS-LaTeX ("nopageno") ;Richard Furuta: suppress page numbers ("nosumlim") ;AMS-LaTeX ("openbib") ;LaTeX 2.09 ("pandora") ;N. Billawala's Pandora fonts ("preprint") ;aps ("proc") ;LaTeX 2.09 ("psmavg") ;Kinch AP-TeX AvantGarde ("psmbkm") ;Kinch AP-TeX Bookman ("psmncs") ;Kinch AP-TeX NewCenturySchoolBook ("psmpal") ;Kinch AP-TeX Palatino ("psmtim") ;Kinch AP-TeX TimesRoman ("remark") ;anonymous: remark environment ("resume") ;Stephen Gildea: resume ("revtex") ;aps ("righttag") ;AMS-LaTeX ("sc21") ;British Standards Institute ISO/TC97/SC21 docs ("sc21-wg1") ;British Standards Institute ISO/TC97/SC21/WG1 ("sfwmac") ;anonymous: UNIX-style docs ("showidx") ;LaTeX 2.09 ("showlabels") ;Gil Neiger: show labels in line ("slem") ;Richard Furuta: \em -> \sl instead of \it ("spacecites") ;Richard Furuta: spaces in citation lists ("supertab") ;Theo Jurriens: supertabular environment ("suthesis") ;Joseph Pallas: Stanford University thesis ("tablisting") ;Utah: file listing ("tapeseal") ;Utah: tape seal label support ("texindex") ;FSF: TeXindex support ("texnames") ;Richard Furuta: TeXware names ("tgrind") ;anonymous: LaTeX prettyprinting ("theorem") ;AMS-LaTeX ("thp") ;AMS-LaTeX ("threepart") ;Lance Berc: threepart head and foot macros ("titlepage") ;LaTeX 2.09 ("trademark") ;anonymous: macros of trademarks ("troffman") ;Utah: troff man style ("troffms") ;Utah: troff ms style ("twocolumn") ;LaTeX 2.09 ("twoside") ;LaTeX 2.09 ("underline") ;anonymous: horizontal rule below page header ("uofutah") ;Utah: University of Utah letterhead ("vdm") ;M. Wolczko: VDM (== ???) ("verbatim") ;AMS-LaTeX )) ;;; The LaTeX 2e option set is much smaller than in LaTeX 2.09, because ;;; most of the latter have been transformed into packages. (defconst LaTeX-2e-standard-options nil "Standard \\documentclass options. Users may also define private ones.") (setq LaTeX-2e-standard-options '( ("11pt") ("12pt") ("a4paper") ("fleqn") ("leqno") ("titlepage") ("twocolumn") ("twoside") )) (defconst LaTeX-2e-standard-packages nil "Standard packages. Users may also define private ones.") ;;; This list of LaTeX 2e packages corresponds to the names ;;; /usr/local/lib/tex/latex2e/unpacked/*.sty in the LaTeX 2e ;;; 18-Dec-1994 release, plus files from the February 1995 AmSTeX ;;; release. However, it excludes all *.sty files for which a ;;; corresponding *.cls file exists, because use of those *.sty files ;;; generates a warning that a class file should be used instead. (setq LaTeX-2e-standard-packages '( ("afterpage") ("alltt") ("amsbsy") ("amscd") ("amsfonts") ("amsgen") ("amsintsm") ("amssymb") ("amstex") ("amstext") ("amsthm") ("amsxtra") ("array") ("avant") ("babel") ("bahasa") ("basker") ("bembo") ("bezier") ("bookman") ("catalan") ("chancery") ("charter") ("cmmib57") ("color") ("croatian") ("czech") ("danish") ("dcolumn") ("delarray") ("doc") ("dutch") ("english") ("enumerate") ("epsfig") ("esperant") ("eucal") ("eufrak") ("euscript") ("exscale") ("finnish") ("flafter") ("fontdoc") ("fontenc") ("fontinst") ("fontsmpl") ("francais") ("ftnright") ("galician") ("garamond") ("germanb") ("graphics") ("graphicx") ("graphpap") ("helvet") ("hhline") ("ifthen") ("indentfirst") ("inputenc") ("italian") ("keyval") ("latexsym") ("layout") ("longtable") ("lscape") ("lucbmath") ("lucbr") ("lucid") ("lucidbrb") ("lucidbry") ("lucmath") ("luctimes") ("magyar") ("makeidx") ("mathptm") ("mathtime") ("mtimes") ("multicol") ("newcent") ("newlfont") ("nimbus") ("norsk") ("oldgerm") ("oldlfont") ("ot1var") ("palatino") ("pandora") ("pict2e") ("pifont") ("polish") ("portuges") ("pstcol") ("rawfonts") ("romanian") ("romref") ("shortvrb") ("showidx") ("showkeys") ("slovak") ("slovene") ("somedefs") ("spanish") ("swedish") ("syntonly") ("t1enc") ("tabularx") ("thb") ("thc") ("thcb") ("theorem") ("thm") ("thmb") ("thp") ("times") ("tracefnt") ("trig") ("turkish") ("utopia") ("varioref") ("verbatim") ("xr") ("xspace") )) (defconst LaTeX-standard-styles nil "Standard document styles. Users may also define private ones.") (setq LaTeX-standard-styles '( ("aaai") ("amsart") ;AMS-LaTeX ("amsbook") ;AMS-LaTeX ("amstex") ;AMS-LaTeX ("aps") ;APS ("article") ;LaTeX 2.09 ("book") ;LaTeX 2.09 ("deproc") ;DECUS Proceedings ("letter") ;LaTeX 2.09 ("ltugboat") ;TeX User Group TUGboat journal ("ltugproc") ;TeX User Group Proceedings ("refman") ;H. Partl's Adobe-like reference manual ("report") ;LaTeX 2.09 ("siam") ;LaTeX 2.09 ("slides") ;LaTeX 2.09 ("tugboat") ;TeX User Group journal ("ucthesis") ;University of California thesis ("uoftoronto") ;University of Toronto thesis ("usafmemo") ;this is called `memo' at some sites ("uuthesis") ;University of Utah ("xxxslides") ;extended slides )) (defconst LaTeX-2e-standard-classes nil "Standard document classes. Users may also define private ones.") ;;; This list of LaTeX 2e packages corresponds to the names ;;; /usr/local/lib/tex/latex2e/unpacked/*.cls in the LaTeX 2e ;;; 18-Dec-1994 release, plus files from the February 1995 AmSTeX ;;; release. (setq LaTeX-2e-standard-classes '( ("amsart") ("amsbook") ("amsdtx") ("amsldoc") ("article") ;LaTeX 2.09 ("book") ;LaTeX 2.09 ("letter") ;LaTeX 2.09 ("ltnews") ("ltxdoc") ("ltxguide") ("proc") ("report") ;LaTeX 2.09 ("slides") ;LaTeX 2.09 )) (defconst LaTeX-standard-tied-abbreviations nil "List of abbreviations for which LaTeX-dot must suppy a tie following the dot. See the LaTeX User's Guide and Reference Manual, p. 18, and the TeXbook, pp. 73--74.") (setq LaTeX-standard-tied-abbreviations '( ("cf.") ("Dr.") ("Fig.") ("Fr.") ("Mr.") ("Mrs.") ("Ms.") ("Prof.") ("Profs.") ("resp.") ("Rev.") ("vs.") )) (defconst LaTeX-standard-unindented-environments nil "List of environments whose \\begin{} and \\end{} must not be indented") (setq LaTeX-standard-unindented-environments '( ("document") ("verbatim") )) (defvar LaTeX-update-labels t "Update list of LaTeX \\label{...} names when LaTeX-mode is selected.") (defvar LaTeX-update-bibtags t "Update list of LaTeX \\cite{...} bibliography tags when LaTeX-mode is selected.") (defvar LaTeX-verb-delimiter ?\= "*Delimiter character for LaTeX \\verb macro.") (defvar SLiTeX-begin-slide "\\\\begin *{slide}{[^{}]*}\\|\\\\begin *{overlay}{[^{}]*}\\|\\\\begin *{note}" "*Regexp that matches the start of a note, overlay, or slide. Used by renumber-slides to find a place to put the comment with the slide number.") ;;; We use this so the file can be harmlessly blank-trimmed (defmacro SPACE () "just an ordinary space" ?\ ) (defmacro NEWLINE () "just an ordinary newline" 10) ;;; set-auto-mode always downcases mode function name, so alias it (fset 'latex-mode 'LaTeX-mode) (defun expand-file-name-in-path (path filename) "Search a colon-separated directory PATH for an existing FILENAME, and return its full name. If the file cannot be found, return nil." (let ((filepath (LaTeX-split-string path ":"))) (while (and filepath (not (file-exists-p (concat (car filepath) "/" filename)))) (setq filepath (cdr filepath))) (if (null filepath) nil (concat (car filepath) "/" filename)))) (defun file-name-sans-extension (filename) "Return the base name (minus .extension) of FILENAME. If there is no extension, FILENAME is returned." (let (n) (setq n (1- (length filename))) (>= n 0) (while (and (>= n 0) (not (= (aref filename n) ?.))) (setq n (1- n))) (substring filename 0 (if (>= n 0) n (length filename))))) (defun LaTeX-add-word-to-index (&optional arg) "Index word(s) or group or, or just before, point, as \\X{..text..} X is replaced by whatever LaTeX-index-macro is set to, if it is not nil, or as ..text..% \\index{..text..} if LaTeX-index-macro is nil. An argument selects that many words, and is ignored for groups (just the group following point will be indexed). Bound to \\\\[LaTeX-add-word-to-index]." (interactive) (setq arg (internal-LaTeX-default arg 1)) (skip-chars-forward " \t\n") (if LaTeX-index-macro ;; then user wants short form: ;; \macro{..text..} (if (looking-at "{") ;then index a single group (progn (insert LaTeX-index-macro "{") (forward-sexp 1) (insert "}")) (progn ;else index ARG words (backward-word 1) ;make sure we are at start of word (insert LaTeX-index-macro "{") (forward-word arg) (insert "}"))) ;; else user wants verbose standard LaTeX form: ;; ..text..% ;; \\index{..text..} (let ((start nil) (end nil)) (if (looking-at "{") ;then index a single group (progn (setq start (point)) (forward-sexp 1) (setq end (point))) (progn ;else index ARG words (forward-word 1) ;make sure we are at start of word (backward-word 1) (setq start (point)) (forward-word arg) (setq end (point)))) (insert "%\n\\index{" (buffer-substring start end) "}") (if (not (looking-at "\n")) (progn (insert "\n") (delete-horizontal-space)))))) (defun LaTeX-angles (&optional arg) "Insert pair of angle brackets. With an argument, backslashed angle brackets (literal angle brackets) are generated. Bound to \\\\[LaTeX-angles]." (interactive) (if (and (null arg) (null current-prefix-arg)) (internal-LaTeX-delimiter-pair "<" ">" nil) (internal-LaTeX-delimiter-pair "\\<" "\\>" nil))) (defun LaTeX-begin-end-block (environment-name &optional arg) "Insert \\begin{...} ... \\end{...} block, prompting for the ENVIRONMENT-NAME. The indentation is set according to the current \\begin{} ... \\end{} nesting level. With an argument, helpful comments may be inserted. Bound to \\\\[LaTeX-begin-end-block]." (interactive (list (completing-read "Environment name: " (append LaTeX-standard-environments LaTeX-extra-environments) nil nil nil))) (setq arg (internal-LaTeX-default arg nil)) (internal-LaTeX-set-indentation) (let ((commentary) (environments (assoc environment-name (append LaTeX-standard-environments LaTeX-extra-environments))) (extra-args) (moveto)) (setq extra-args (eval (nth 1 environments))) (setq commentary (eval (nth 2 environments))) (setq moveto (nth 3 environments)) (if (> (current-column) 0) (progn (end-of-line) (newline))) (if (not (looking-at "\n")) (progn (newline) (forward-line -1))) (if (assoc environment-name (append LaTeX-standard-comment-delimited-environments LaTeX-extra-comment-delimited-environments)) (insert-string "%\n")) (if (not (assoc environment-name (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments))) (insert-char (SPACE) ;; [24-Apr-1999] Change to use just LaTeX-current-indentation ;; (+ LaTeX-current-indentation LaTeX-begin-end-indentation) LaTeX-current-indentation)) (insert "\\begin" (if LaTeX-space-after-begin-end (if (not (equal environment-name "verbatim")) " " "") "") "{" environment-name "}") (if extra-args (insert extra-args (if (and arg commentary) commentary ""))) (newline) (if (assoc environment-name (append LaTeX-standard-list-environments LaTeX-extra-list-environments)) (progn (if arg (progn (insert-char (SPACE) (+ LaTeX-current-indentation (if arg -2 0) LaTeX-begin-end-indentation LaTeX-item-indentation)) (insert "% \\item or item[label]"))))) (save-excursion (cond ((assoc environment-name (append LaTeX-standard-list-environments LaTeX-extra-list-environments)) (internal-LaTeX-repeat LaTeX-item-count '(LaTeX-item))) ((equal environment-name "thebibliography") (internal-LaTeX-repeat LaTeX-item-count ;generate \bibitem[]{} '(LaTeX-bibitem t)) ;instead of \bibitem{} (forward-line 1))) ;; NB: MUST use insert "\n" here and not newline, otherwise point ;; advances one during the save excursion. This seems to be an ;; GNU EMACS (version 18.49 or earlier) bug! ;; rms@prep.ai.mit.edu reports that it is no longer present at ;; 18.50, but doesn't recall fixing it. (insert "\n") (if (not (assoc environment-name (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments))) (insert-char (SPACE) ;; [24-Apr-1999] Change to use just LaTeX-current-indentation ;; (+ LaTeX-current-indentation LaTeX-begin-end-indentation) LaTeX-current-indentation)) (insert "\\end" (if LaTeX-space-after-begin-end (if (not (equal environment-name "verbatim")) " " "") "") "{" environment-name "}") (if (assoc environment-name (append LaTeX-standard-comment-delimited-environments LaTeX-extra-comment-delimited-environments)) (insert-string "\n%"))) ;end save-excursion (if (not (null moveto)) ;position point (funcall (eval moveto))) (if (assoc environment-name (append LaTeX-standard-list-environments LaTeX-extra-list-environments)) (progn ;; Somehow I'm getting an extra blank line before the first ;; \\item, and I cannot see why, sigh... This is a hack to ;; remove it. (forward-line -1) (delete-blank-lines) (end-of-line))))) (defun LaTeX-bibitem (&optional arg) "Insert \\bibitem indented according to enclosing \\begin{} or \\bibitem level. Without an argument, generate the \\bibitem{} form. With an argument, generate \\bibitem[]{} instead. Fill prefix is updated to match the bibitem text indentation. Bound to \\\\[LaTeX-bibitem]." (interactive) (let (col) (save-excursion (re-search-backward "\\\\bibitem\\|\\\\begin *{") (goto-char (match-beginning 0)) (setq col (current-column)) (if (looking-at "\\\\begin") (if (looking-at "\\\\begin *{thebibliography}") ;if thebibliography, (setq col (+ col LaTeX-item-indentation)) ;then reset indentation (ding) ;else leave indentation alone and warn (message ;user of possible error "WARNING: You may not be inside thebibliography environment")))) (if (and (null arg) (null current-prefix-arg)) (progn (internal-LaTeX-item col "\\bibitem{} ") (search-backward "}")) (progn (internal-LaTeX-item col "\\bibitem[]{} ") (search-backward "]"))))) (defun LaTeX-bibtag-with-completion (bibtag) "Insert a BibTeX BIBTAG with completion (on \\\\[LaTeX-bibtag-with-completion]). The citation tag completion list is created from the bibliography data base files by update-LaTeX-bibtags." (interactive (list (completing-read "BibTeX citation tag: " LaTeX-bibtags nil nil nil))) (insert bibtag)) (defun LaTeX-brace-words (&optional word-count) "Insert { ... } around next ARG words (on \\\\[LaTeX-brace-words])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (internal-LaTeX-wrap "{" "}" word-count)) (defun LaTeX-braces (&optional arg) "Insert pair of braces. With an argument, backslashed braces (literal braces) are generated. Bound to \\\\[LaTeX-braces]." (interactive) (if (and (null arg) (null current-prefix-arg)) (internal-LaTeX-delimiter-pair "{" "}" nil) (internal-LaTeX-delimiter-pair "\\{" "\\}" nil))) (defun LaTeX-brackets (&optional arg) "Insert pair of brackets. With an argument, backslashed brackets (displaymath mode) are generated. Bound to \\\\[LaTeX-brackets]." (interactive) (if (and (null arg) (null current-prefix-arg)) (internal-LaTeX-delimiter-pair "[" "]" nil) (internal-LaTeX-delimiter-pair "\\[" "\\]" nil))) (defun LaTeX-check-angle-balance (&optional allow-paragraph-breaks) "Starting at current point, check for unbalanced angle brackets, and angle bracket pairs separated by long strings. Backslashed angle brackets are ignored. With an argument, paragraph breaks are permitted between the matching angle brackets. Bound to \\\\[LaTeX-check-angle-balance]." (interactive) (internal-LaTeX-check-matching-character-balance ?\< ?\> "angle bracket" LaTeX-angle-interval allow-paragraph-breaks)) (defun LaTeX-check-brace-balance (&optional allow-paragraph-breaks) "Starting at current point, check for unbalanced braces, and brace pairs separated by long strings. Backslashed braces are ignored. With an argument, paragraph breaks are permitted between the matching braces. Bound to \\\\[LaTeX-check-brace-balance]." (interactive) (internal-LaTeX-check-matching-character-balance ?\{ ?\} "brace" LaTeX-brace-interval allow-paragraph-breaks)) (defun LaTeX-check-bracket-balance (&optional allow-paragraph-breaks) "Starting at current point, check for unbalanced brackets, and bracket pairs separated by long strings. Backslashed brackets are ignored. With an argument, paragraph breaks are permitted between the matching brackets. Bound to \\\\[LaTeX-check-bracket-balance]." (interactive) (internal-LaTeX-check-matching-character-balance ?\[ ?\] "bracket" LaTeX-bracket-interval allow-paragraph-breaks)) (defun LaTeX-check-dollar-balance () "Starting at current point, check for dollar pairs which are separated by long strings. Backslashed dollars are ignored. With an argument, paragraph breaks are permitted between the matching dollar signs. Bound to \\\\[LaTeX-check-dollar-balance]." (interactive) (let ((open-char-point nil) (start-point (point))) (while (re-search-forward "[^\\\\]\\$" nil t) (if open-char-point ;then we have closing dollar (progn (if (> (- (point) open-char-point) LaTeX-dollar-interval) (progn (push-mark open-char-point t) (error "More than %d chars in $...$ interval. Mark at opening $." LaTeX-dollar-interval)) (setq open-char-point nil))) (setq open-char-point (point)))) ;else we have opening dollar (if open-char-point ;then we are missing a closing one (progn (ding) (push-mark start-point t) (message "No closing dollar found for this one. Mark set at start of search")) (progn (message "[done] -- dollar balance check") (goto-char start-point))))) (defun LaTeX-check-parenthesis-balance (&optional allow-paragraph-breaks) "Starting at current point, check for unbalanced parentheses, and parenthesis pairs separated by long strings. Backslashed parentheses are ignored. With an argument, paragraph breaks are permitted between the matching parentheses. Bound to \\\\[LaTeX-check-parenthesis-balance]." (interactive) (internal-LaTeX-check-matching-character-balance ?\( ?\) "paren" LaTeX-parenthesis-interval allow-paragraph-breaks)) (defun LaTeX-cite (&optional arg) "Insert \\cite{ ... } at point. With an argument, generate \\cite[ ... ]{ ... } instead. Bound to \\\\[LaTeX-cite]." (interactive) (if (and (null arg) (null current-prefix-arg)) (internal-LaTeX-keyword "cite" " " " ") (internal-LaTeX-keyword "cite[]" " " " ") (backward-char 2))) (defun LaTeX-comma () "Insert a comma, and if the preceding characters are an italic correction at group end `\\/},', remove the italic correction. Bound to \\\\[LaTeX-comma]." (interactive) (if abbrev-mode (expand-abbrev)) (insert-string ",") (backward-char 1) (internal-LaTeX-maybe-remove-italic-correction) (forward-char 1)) (defun LaTeX-comment (&optional paragraph) "Comment out the current region or, with a prefix argument, paragraph. Point is left at the end of the region, or at the beginning of the next paragraph. M-x undo (on \\[undo]) will undo it. Bound to \\\\[LaTeX-comment]." (interactive "P") (let ((region (not paragraph))) (save-restriction (if region (progn (if (> (mark) (point)) ;ensure that (mark) <= (point) (exchange-point-and-mark)) (narrow-to-region (mark) (point))) (narrow-to-region (progn ;find first character of paragraph (backward-paragraph) (if (looking-at "\n") (forward-char)) (point)) (progn ;find last character of paragraph (forward-paragraph) (if (looking-at "\n") (backward-char)) (point)))) (goto-char (point-min)) (while (re-search-forward "^" (1- (point-max)) t) ;comment out lines (replace-match LaTeX-comment-prefix t t)) (goto-char (point-max))) ;end save-restriction (if (not region) ;position to start of next paragraph (progn (forward-paragraph) (backward-paragraph) (forward-char) (beginning-of-line))))) (defun LaTeX-counter (counter-name) "Insert COUNTER-NAME at point, using the standard values in LaTeX-standard-counters augmented by the values in the user-customizable LaTeX-extra-counter variable to offer name completion." (interactive (list (completing-read "Counter name: " (append LaTeX-standard-counters LaTeX-extra-counters) nil nil nil))) (insert counter-name)) (defun LaTeX-displaymath () "Insert \\begin{displaymath} ... \\end{displaymath}. This is required often enough that a key binding separate from that for LaTeX-begin-end-block is desirable. Bound to \\\\[LaTeX-displaymath]." (interactive) (LaTeX-begin-end-block "displaymath")) (defun LaTeX-dollar (&optional arg) "If the preceding character is a backslash, just put in a single dollar sign. Otherwise, insert a math mode environment. If point is in the middle of a line, or an argument is given, use a dollar pair or equivalent, according to the value of the variable LaTeX-math-option. If at beginning of line, insert a double dollar pair or equivalent, according to the value of the variable LaTeX-displaymath-option. Bound to \\\\[LaTeX-dollar]." (interactive) (setq arg (or arg current-prefix-arg)) (cond ((equal (preceding-char) ?\\) ;have backslash dollar (insert-string "$")) ((or arg (> (current-column) 0)) ;argument, or math mode in middle of line (cond ((equal LaTeX-math-option 2) ;then use \begin{math} ... \end{math} (newline) (LaTeX-begin-end-block "math")) ((equal LaTeX-math-option 1) ;then use \\( ... \\) (internal-LaTeX-delimiter-pair "\\(" "\\)" nil)) (t ;else use $ ... $ (internal-LaTeX-delimiter-pair "$" "$" nil)))) (t ;math mode at start of line (cond ((equal LaTeX-displaymath-option 2) (LaTeX-begin-end-block "displaymath")) ((equal LaTeX-displaymath-option 1) (internal-LaTeX-delimiter-pair "\\[\n" "\\]" t) (LaTeX-tab)) (t (internal-LaTeX-delimiter-pair "$$\n" "$$" t) (LaTeX-tab)))))) (defun LaTeX-dot () "Insert a dot (period, full stop), and then handle some special cases: [1] If the previous two characters are also dots, change all three of them to \\ldots{}. [2] If the previous characters are dotted abbreviations, like `e.g.' or `i.e.', which are defined as list elements of the variables LaTeX-standard-dotted-abbreviations and LaTeX-extra-dotted-abbreviations, supply a trailing string: if LaTeX-comma-after-dotted-abbreviation is nil, insert `\\ ' to mark a non-sentence-ending dot; otherwise insert a comma. Dotted abbreviations are recognized only if the character preceding them is not a letter. [3] If the previous characters are abbreviations defined as list elements of the variable LaTeX-standard-tied-abbreviations that should be tied to the following word with a single unbreakable space, insert a tilde to mark the tie. [4] If the preceding characters are an italic correction at group end `\\/}.', remove the italic correction. [5] If the dot is preceded by two or more upper-case letters, insert a sentence-ending `\\@' inserted before it. Bound to \\\\[LaTeX-dot]." (interactive) (if abbrev-mode (expand-abbrev)) (insert-char ?\. 1) (backward-char 1) (internal-LaTeX-maybe-remove-italic-correction) (forward-char 1) (let (old-case-fold-search case-fold-search) (setq case-fold-search nil) ;need exact case matching here (cond ;; . -> \@. ((string-match "[A-Z][A-Z]\\." (internal-LaTeX-preceding-buffer-substring 3)) (progn (backward-char 1) (insert "\\@") (forward-char 1))) ;; "..." -> "\ldots{}" ((string-equal "..." (internal-LaTeX-preceding-buffer-substring 3)) (progn (delete-char -3) (insert "\\ldots{}"))) ;; "i.e." -> "i.e.\ " or "i.e.," (for many such abbrevs) (t (catch 'EXIT (mapcar;; scan the list of dotted abbrevs (function (lambda (x) (let ((s (nth 0 x))) ; reduce ("i.e.") to "i.e." (if (and (not ; abbrev must not follow a letter (string-match "[A-Za-z]" (buffer-substring (max 1 (- (point) (length s) 1)) (max 1 (- (point) (length s)))))) (string-equal s ; does the abbrev match the buffer? (internal-LaTeX-preceding-buffer-substring (length s)))) (progn ; yes, so do the insertion, then (insert ; bail out, forgetting the ; rest of the abbrev list (if (assoc s (append LaTeX-standard-tied-abbreviations LaTeX-extra-tied-abbreviations)) "~" (if LaTeX-comma-after-dotted-abbreviation "," "\\ "))) (throw 'EXIT nil)))))) ;end if-let-lambda- function (append LaTeX-standard-dotted-abbreviations LaTeX-extra-dotted-abbreviations LaTeX-standard-tied-abbreviations LaTeX-extra-tied-abbreviations))))) ;end cond (setq case-fold-search old-case-fold-search))) ;restore old value (defun LaTeX-end () "\\Generate a \\end{...} to match a preceding \\begin{...}. This is handy if you didn't use LaTeX-begin-end-block (on \\[LaTeX-begin-end-block]) to generate a matched pair, but manually typed the \\begin{...} instead. Bound to \\[LaTeX-end]." (interactive) (let ((text (save-excursion (if (LaTeX-to-begin 1) (progn (beginning-of-line) (looking-at "\\( *\\)\\\\begin *{\\([^}\n]*\\)}") (let ((environment-name (buffer-substring (match-beginning 2) (match-end 2)))) (concat (buffer-substring (match-beginning 1) (match-end 1)) "\\end" (if LaTeX-space-after-begin-end (if (equal environment-name "verbatim") "" " ") "") "{" environment-name "}\n"))))))) (if text (progn (if (< 0 (current-column)) (insert "\n")) (insert text) (if (not (equal (preceding-char) (NEWLINE))) (newline))) (error "No preceding unmatched \\begin{...} found")))) (defun LaTeX-equation () "Insert \\begin{equation} ... \\end{equation}. This is required often enough that a key binding separate from that for LaTeX-begin-end-block is desirable. Bound to \\\\[LaTeX-equation]." (interactive) (LaTeX-begin-end-block "equation")) (defun LaTeX-font-bf (&optional word-count) "Insert {\\bf ... } around next ARG words (on \\\\[LaTeX-font-bf])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\textbf{" "}" word-count) (internal-LaTeX-wrap "{\\bf " "}" word-count))) (defun LaTeX-font-em (&optional word-count) "Insert {\\em ... \\/} around next ARG words (on \\\\[LaTeX-font-em])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\emph{" "}" word-count) (internal-LaTeX-wrap "{\\em " "\\/}" word-count) (internal-LaTeX-maybe-remove-italic-correction))) (defun LaTeX-font-it (&optional word-count) "Insert {\\it ... \\/} around next ARG words (on \\\\[LaTeX-font-it])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\textit{" "}" word-count) (internal-LaTeX-wrap "{\\it " "\\/}" word-count) (internal-LaTeX-maybe-remove-italic-correction))) (defun LaTeX-font-rm (&optional word-count) "Insert {\\rm ... } around next ARG words (on \\\\[LaTeX-font-rm])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\textrm{" "}" word-count) (internal-LaTeX-wrap "{\\rm " "}" word-count))) (defun LaTeX-font-sc (&optional word-count) "Insert {\\sc ... } around next ARG words (on \\\\[LaTeX-font-sc])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\textsc{" "}" word-count) (internal-LaTeX-wrap "{\\sc " "}" word-count))) (defun LaTeX-font-sf (&optional word-count) "Insert {\\sf ... } around next ARG words (on \\\\[LaTeX-font-sf])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\textsf{" "}" word-count) (internal-LaTeX-wrap "{\\sf " "}" word-count))) (defun LaTeX-font-sl (&optional word-count) "Insert {\\sl ... } around next ARG words (on \\\\[LaTeX-font-sl])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\textsl{" "}" word-count) (internal-LaTeX-wrap "{\\sl " "\\/}" word-count) (internal-LaTeX-maybe-remove-italic-correction))) (defun LaTeX-font-tt (&optional word-count) "Insert {\\tt ... } around next ARG words (on \\\\[LaTeX-font-tt])." (interactive) (setq word-count (internal-LaTeX-default word-count 1)) (if LaTeX-2e (internal-LaTeX-wrap "\\texttt{" "}" word-count) (internal-LaTeX-wrap "{\\tt " "}" word-count))) (defun LaTeX-footnote () "Insert \\footnote{ ... } at point (on \\\\[LaTeX-footnote]). If LaTeX-footnote-start-with-newline is non-nil, start the footnote on a newline. If LaTeX-footnote-end-with-newline is non-nil, end the footnote on a newline." (interactive) (internal-LaTeX-keyword "footnote" (if (and (> (current-column) 0) LaTeX-footnote-start-with-newline) "%\n" nil) " ") (save-excursion (search-forward "}") (if (and (not (looking-at "\n")) LaTeX-footnote-end-with-newline) (newline)))) (defun LaTeX-gripe () "Send mail to maintainer of LaTeX-mode with comments, gripes, and bug reports. Bound to \\\\[LaTeX-gripe]." (interactive) (mail-other-window) (goto-char (point-min)) ;[07-Aug-1991] suggested by ;Olaf Heimburger (beginning-of-line) (if (not (looking-at "^To: $")) (progn (goto-char (point-min)) (error "Trash in *mail* buffer--please clear it and try again")) (progn (end-of-line) (insert "beebe@math.utah.edu" ", " (or (and (boundp 'user-mail-address) user-mail-address) (concat (user-login-name) "@" (or (and (boundp 'mail-host-address) mail-host-address) (system-name))))) (end-of-line 2) (insert "LaTeX-mode gripe report {" LaTeX-mode-version "}") (goto-char (point-max))))) (defun LaTeX-index (&optional phrase) "Insert \\index{ ... } at point (on \\\\[LaTeX-index]). If a prefix argument is given, the string is prompted for, and inserted both as text and as an index entry, e.g. gnats and gnus\\index{gnats and gnus}. All horizontal space preceding \\index is removed to prevent an intervening page break causing an off-by-one page number error. If LaTeX-index-start-with-newline is non-nil, insert a percent to start a comment, then put \\index at the start of a following new line. If LaTeX-index-end-with-newline is non-nil, follow the entry with a new line." (interactive) (if (null current-prefix-arg) (internal-LaTeX-keyword "index" (if (and (> (current-column) 0) LaTeX-index-start-with-newline) "%\n" nil) " ") (progn (setq phrase (read-string "Phrase to index and insert: ")) (if (not (or (equal (buffer-substring (1- (point)) (point)) " ") (equal (buffer-substring (1- (point)) (point)) "\n"))) (insert " ")) (insert phrase) (internal-LaTeX-keyword "index" (if (and (> (current-column) 0) LaTeX-index-start-with-newline) "%\n" nil) " ") (insert phrase) (if (looking-at "\n") (delete-char 1)) ;kill any newline after phrase (search-forward "}") (if LaTeX-index-end-with-newline (newline) (insert " "))))) (defun LaTeX-item (&optional arg) "Insert \\item indented according to enclosing \\begin{} or \\item level (on \\\\[LaTeX-item). With an argument, insert \\item[] instead. The fill prefix is updated to match the item text indentation." (interactive) (let (col env) (save-excursion (if (LaTeX-to-begin 1) (progn (setq col (+ (current-column) LaTeX-item-indentation)) (setq env (buffer-substring (point) (progn (end-of-line) (point))))))) (if col (if (and (null arg) (null current-prefix-arg)) (internal-LaTeX-item col "\\item ") (internal-LaTeX-item col "\\item[] ") (backward-char 2)) (error "Not inside a \\begin{...}")))) (defun LaTeX-label () "Insert \\label{ ... } at point (on \\\\[LaTeX-label]). If LaTeX-label-start-with-newline is non-nil, insert a percent to start a comment, then put \\label at the start of a following new line." (interactive) (internal-LaTeX-keyword "label" (if (and (> (current-column) 0) LaTeX-label-start-with-newline) "%\n" nil) " ") (search-forward "}") (if LaTeX-label-end-with-newline (newline) (insert " ")) (search-backward "{") (forward-char 1)) (defun LaTeX-macro (&optional macro-name insert-comment) "Insert a LaTeX macro together with argument braces and brackets (on \\\\[LaTeX-macro]). With an argument, a short comment about the arguments is also inserted. Without an argument, the comment is displayed in the echo area instead." (interactive (list (completing-read "Macro name: " (append LaTeX-standard-macros (if LaTeX-2e LaTeX-2e-standard-macros) LaTeX-extra-macros) nil t nil))) (let ((the-font) (the-macro)) (setq the-font (assoc macro-name (append (if LaTeX-2e LaTeX-2e-standard-fonts LaTeX-standard-fonts) LaTeX-extra-fonts))) (setq the-macro (assoc macro-name (append LaTeX-standard-macros (if LaTeX-2e LaTeX-2e-standard-macros) LaTeX-extra-macros))) (if the-font (insert "{")) (insert "\\" (nth 0 the-macro)) (if (nth 1 the-macro) (progn ;then we have arguments to insert (save-excursion (insert (nth 1 the-macro)) (if (or (not (null current-prefix-arg)) (not (null insert-comment))) (insert " % " (nth 2 the-macro) "\n") (message (nth 2 the-macro)) (if LaTeX-newline-after-closing-delimiter (newline)))) ;end save-excursion (forward-char 1) ;always start insertion after first brace, (if LaTeX-newline-after-opening-delimiter (progn (newline) ;bracket, or paren, but leave space to enter text (backward-char 1)))) (progn ;else no arguments (if (or (not (null current-prefix-arg)) (not (null insert-comment))) (insert " % " (nth 2 the-macro)) (message (nth 2 the-macro))) (if the-font (progn (if LaTeX-newline-after-opening-delimiter (newline)) (if (assoc macro-name (append (if LaTeX-2e LaTeX-2e-standard-italic-fonts LaTeX-standard-italic-fonts) LaTeX-extra-italic-fonts)) (if (not LaTeX-2e) (insert "\\/"))) (insert "}") (if LaTeX-newline-after-opening-delimiter (search-backward "\n") (progn (re-search-backward "[a-zA-Z]") (forward-char 1))) (insert " "))))) (if (string-equal macro-name "item") (save-excursion (if (LaTeX-to-begin 1) (message (format " Inside %s" (buffer-substring (point) (progn (end-of-line) (point)))))))))) (defun LaTeX-mode () "Major editing mode for LaTeX and SLiTeX. \\ To create a new LaTeX document, use make-LaTeX-document (on \\[make-LaTeX-document]), or make-SLiTeX-document (on \\[make-SLiTeX-document]). With an argument, they will provide some additional helpful comments. The functions will prompt for document style and options. Type ? to see the standard ones; you can enter them with name completion. You can also enter your own, since it is possible to have private styles and options unknown to make-LaTeX-document or make-SLiTeX-document. If a document header already exists, this function will automatically set for editing in either LaTeX 2.09 or 2e style. If you wish, you can set the mode explicitly with M-x LaTeX-2e-mode or M-x LaTeX-2.09-mode. You may find it useful to bind these functions to file extensions in the auto-mode-alist in your $HOME/.emacs file. The most frequent LaTeX construct is the \\begin{}...\\end{} grouping; you can generate it by LaTeX-begin-end-block (on \\[LaTeX-begin-end-block]). With an argument, a helpful comment may be printed. Type ? to see the standard environments, or enter your own. If you type a \\begin{...} manually, you can later generate a matching \\end{...} with the function LaTeX-end (on \\[LaTeX-end]). Other common constructs are the insertion of labels, citations, cross-references, index entries, verbatim strings, and additional items in a list. The functions \\[LaTeX-add-word-to-index] LaTeX-add-word-to-index \\[LaTeX-bibitem] LaTeX-bibitem \\[LaTeX-cite] LaTeX-cite \\[LaTeX-counter] LaTeX-counter \\[LaTeX-footnote] LaTeX-footnote \\[LaTeX-index] LaTeX-index \\[LaTeX-item] LaTeX-item \\[LaTeX-label] LaTeX-label \\[LaTeX-macro] LaTeX-macro \\[LaTeX-pageref-with-completion] LaTeX-pageref-with-completion \\[LaTeX-protect] LaTeX-protect \\[LaTeX-ref-with-completion] LaTeX-ref-with-completion \\[LaTeX-verb] LaTeX-verb \\[make-LaTeX-document] make-LaTeX-document \\[make-SLiTeX-document] make-SLiTeX-document provide for these. LaTeX-tab (on \\[LaTeX-tab]) will indent a line to the current \\begin{}...\\end{} nesting level. Most major LaTeX macros can be entered by LaTeX-macro (on \\[LaTeX-macro]). This will supply the correct set of following braces, brackets, and parentheses, and with an argument, will insert a short comment about the expected command arguments. For SLiTeX, the function renumber-slides can be used to put a numbered comment on each slide environment for handy reference in the \\onlynotes{...} and \\onlyslides{...} commands. You can move over \\begin{} ... \\end{} groups with LaTeX-to-begin (on \\[LaTeX-to-begin]) and LaTeX-to-end (on \\[LaTeX-to-end]). Insertion of paired angle brackets, braces, square brackets, and parentheses is provided by \\[LaTeX-angles] LaTeX-angles \\[LaTeX-braces] LaTeX-braces \\[LaTeX-brackets] LaTeX-brackets \\[LaTeX-parentheses] LaTeX-parentheses With an argument, the last three insert backslash prefixes for literal braces, math mode, and displaymath mode. Unbalanced character pairs are found by \\[LaTeX-check-angle-balance] LaTeX-check-angle-balance \\[LaTeX-check-brace-balance] LaTeX-check-brace-balance \\[LaTeX-check-bracket-balance] LaTeX-check-bracket-balance \\[LaTeX-check-dollar-balance] LaTeX-check-dollar-balance \\[LaTeX-check-parenthesis-balance] LaTeX-check-parenthesis-balance You can test for undefined labels with check-LaTeX-labels, display the labels and their line numbers with show-LaTeX-labels, and fetch labels from an .aux file with update-LaTeX-labels. Environment nesting errors can be caught by check-LaTeX-nesting. Use indent-LaTeX-begin-end-groups to get environments nested for improved visibility. Use LaTeX-comment (on \\[LaTeX-comment]) to comment out the current paragraph (no arg) or region (arg); undo with M-x undo (\\[undo]). LaTeX-uncomment (on \\[LaTeX-uncomment]) is the inverse function. One or more words can be set in any standard LaTeX font using the commands \\[LaTeX-font-bf] LaTeX-font-bf \\[LaTeX-font-em] LaTeX-font-em \\[LaTeX-font-it] LaTeX-font-it \\[LaTeX-font-rm] LaTeX-font-rm \\[LaTeX-font-sc] LaTeX-font-sc \\[LaTeX-font-sf] LaTeX-font-sf \\[LaTeX-font-sl] LaTeX-font-sl \\[LaTeX-font-tt] LaTeX-font-tt Please report bugs, comments, and enhancements by e-mail to Beebe@math.utah.edu (Internet) LaTeX-gripe (on \\[LaTeX-gripe]) makes this easier. " (interactive) ; Check for LaTeX 2e or 2.09 (save-excursion (goto-char (point-min)) (if (search-forward "\\document" nil t) (setq LaTeX-2e (looking-at "class")))) (use-local-map LaTeX-mode-map) (setq indent-tabs-mode nil) ;tabs are BAD news in TeX documents (setq major-mode 'LaTeX-mode) (internal-LaTeX-set-mode-name) (make-local-variable 'indent-line-function) (setq indent-line-function 'internal-LaTeX-indent-line) ;; For LaTeX, paragraphs are delineated by blank lines, formfeeds, ;; initial \begin or \end, or comment lines, but NOT by a bare ;; backslash like tex-mode sets. (setq paragraph-start "^[ ]*$\\|\f\\|^[ ]*\\\\begin\\|^[ ]*\\\\end.*\n\\|^[ ]*\\\\item\\|^[ ]*\\\\bibitem\\|^[ ]*%.*$") (setq paragraph-separate paragraph-start) (setq local-abbrev-table LaTeX-mode-abbrev-table) (setq comment-end "") (setq comment-start "% ") (setq comment-start-skip "%+ *") ;; If a \documentstyle command appears as the first TeX macro in the ;; buffer that is by itself on the line, optionally preceded by ;; whitespace, construct an .aux file name from the buffer-file-name, ;; and if that file exists and is readable, invoke update-LaTeX-labels ;; and update-LaTeX-bibtags, so that LaTeX-aux-file-label-tags and ;; LaTeX-bibtags are set automatically. If the .aux file is not ;; readable, then update-LaTeX-bibtags on the current file. (goto-char (point-min)) (if (and (re-search-forward "^[ \t]*\\\\" nil t) (looking-at "documentstyle")) (let ((auxfile (concat (file-name-sans-extension buffer-file-name) ".aux"))) (setq LaTeX-aux-file-label-tags nil) (if (file-readable-p auxfile) (progn (if LaTeX-update-labels (update-LaTeX-labels auxfile)) (if LaTeX-update-bibtags (update-LaTeX-bibtags auxfile))) (if LaTeX-update-bibtags (update-LaTeX-bibtags buffer-file-name))))) (goto-char (point-min)) ;; Add emacs-19 (or later) mouse-based indexing bindings (if (not (string-lessp (substring emacs-version 0 2) "19")) (progn (local-set-key [S-down-mouse-3] 'x-LaTeX-index-start) (local-set-key [S-mouse-3] 'x-LaTeX-index-end))) (LaTeX-x-window-setup) ;; Finally, run the user mode hooks (run-hooks 'latex-mode-hook 'LaTeX-mode-hook)) (defun LaTeX-2.09-mode () "Call LaTeX-mode and then set for old-style LaTeX 2.09 editing." (interactive) (LaTeX-mode) (setq LaTeX-2e nil) (internal-LaTeX-set-mode-name)) (defun LaTeX-2e-mode () "Call LaTeX-mode and then set for new-style LaTeX 2e editing." (interactive) (LaTeX-mode) (setq LaTeX-2e t) (internal-LaTeX-set-mode-name)) (defun LaTeX-news () "View the latex.el file to see its revision history which documents changes in reverse chronological order. Bound to \\\\[LaTeX-news]." (interactive) (let ((the-file)) (catch 'DONE (mapcar (function (lambda (the-path) (setq the-file (concat the-path (if (string-equal (system-name) "vax-vms") "" "/") "latex.el")) (if (file-exists-p the-file) (progn (view-file the-file) (throw 'DONE nil))))) load-path)))) (defun LaTeX-2e-package () "Select one or more LaTeX packages." (interactive) (let ((loop t) (package nil) (package-list "")) (while loop (setq package (completing-read "Package name (RET when done): " (append LaTeX-2e-standard-packages LaTeX-2e-extra-packages) nil nil nil)) (if (equal package "") (setq loop nil) (setq package-list (format "%s\\usepackage[]{%s}\n" package-list package)))) (insert package-list))) (defun LaTeX-pageref () "Insert \\pageref{ ... } (on \\\\[LaTeX-pageref])." (interactive) (internal-LaTeX-keyword "pageref" "~" " ")) (defun LaTeX-pageref-with-completion (label-name) "Insert \\pageref{ ... } with completion on label tag (on \\\\[LaTeX-pageref-with-completion]). When this function is invoked, all currently-defined labels are collected dynamically by internal-LaTeX-make-label-list and used for the completion list. An undefined label name may be legally entered if required; presumably, you will soon generate a \\label{...} definition for it." (interactive (list (completing-read "LaTeX \\label{} tag name: " (internal-LaTeX-make-label-list) nil nil nil))) (internal-LaTeX-keyword "pageref" "~" " ") (insert label-name) (if (looking-at "\n") (delete-char 1)) (forward-char 1)) (defun LaTeX-parentheses (&optional arg) "Insert pair of parentheses. With an argument, backslashed parentheses (math mode) are generated. Bound to \\\\[LaTeX-parentheses]." (interactive) (if (and (null arg) (null current-prefix-arg)) (internal-LaTeX-delimiter-pair "(" ")" nil) (internal-LaTeX-delimiter-pair "\\(" "\\)" nil))) (defun LaTeX-path (&optional arg) "Insert \\path| ... | (on \\\\[LaTeX-path]). The delimiter character actually used is the current value of the variable LaTeX-path-delimiter." (interactive) (setq arg (internal-LaTeX-default arg nil)) (insert "\\path" LaTeX-path-delimiter (if LaTeX-newline-after-opening-delimiter "\n" "") LaTeX-path-delimiter (if LaTeX-newline-after-closing-delimiter "\n" "")) (search-backward (char-to-string LaTeX-path-delimiter)) (search-backward (char-to-string LaTeX-path-delimiter)) (forward-char 1)) (defun LaTeX-prettyprint-displaymath () "In the entire buffer, prettyprint display math environments marked by pairs of doubled dollar signs, in an effort to make the input file more readable." (interactive) ;; First, get rid of tabs and superfluous space that might ;; interfere with our prettyprinting. (untabify (point-min) (point-max)) (goto-char (point-min)) (replace-regexp "[ \t]+$" "") ;trim trailing space (goto-char (point-max)) (delete-blank-lines) ;trim trailing blank lines (goto-char (point-min)) (catch 'EXIT (let* ((comment-line-regexp "[ \t]*%") (display-math-mode-regexp "[^\\$]$$[^$]") (display-math-mode-separate (concat display-math-mode-regexp "\\|" LaTeX-prettyprint-paragraph-separate)) (punctuation "[.,:;!]") (start)) (while (re-search-forward display-math-mode-regexp nil t) (backward-char 3) ;move before opening $$ (delete-horizontal-space) (if (not (bolp)) ;and put it on a new line (insert "\n")) (setq start (point)) ;remember position before opening $$ (backward-char 1) ;do we have a comment line? (beginning-of-line) (if (looking-at comment-line-regexp) (goto-char start) ;no, move before opening $$ (goto-char start) ;yes, put separator before opening $$ (if (not (null LaTeX-display-math-comment-separator)) (insert LaTeX-display-math-comment-separator))) (forward-char 2) ;move over leading $$ (delete-horizontal-space) (if (not (eolp)) ;and start a newline if needed (insert "\n")) (delete-horizontal-space) ;; In order to prevent disasters from incorrect mismatching of ;; paired doubled dollar signs, we require that the closing ;; doubled dollars be in the same paragraph. If not, we bail ;; out with an error message. (re-search-forward display-math-mode-separate) ;find closing $ (goto-char (match-beginning 0)) ;and move to its start (if (looking-at LaTeX-prettyprint-paragraph-separate) (progn ;bail out if not a math mode match (message "ERROR: unclosed display math mode at paragraph end!") (ding) (throw 'EXIT nil))) (forward-char 1) ;move before closing $$ (delete-horizontal-space) ;and put it at start of a newline (if (not (bolp)) ;if not already there (insert "\n")) (forward-char 2) ;move over closing $$ (delete-horizontal-space) (if (looking-at punctuation) ;move over any following punctuation (progn (forward-char 1) (delete-horizontal-space))) (if (eolp) (forward-char 1) ;then move past newline (insert "\n")) ;else insert newline (delete-horizontal-space) (if (and (not (looking-at comment-line-regexp)) (not (null LaTeX-display-math-comment-separator))) (insert LaTeX-display-math-comment-separator)) (delete-horizontal-space) (backward-char 1)) ;because we need to look one char BEFORE $$ (internal-LaTeX-indent-math LaTeX-math-indentation-column)))) (defun LaTeX-prettyprint-math () "In the entire buffer, prettyprint inline math environments marked by pairs of single dollar signs, in an effort to make the input file more readable." (interactive) ;; First, get rid of tabs and superfluous space that might ;; interfere with our prettyprinting. (untabify (point-min) (point-max)) (goto-char (point-min)) (replace-regexp "[ \t]+$" "") ;trim trailing space (goto-char (point-max)) (delete-blank-lines) ;trim trailing blank lines (goto-char (point-min)) (catch 'EXIT (let* ((comment-line-regexp "[ \t]*%") (math-mode-regexp "[^\\$]$[^$]") (math-mode-separate (concat math-mode-regexp "\\|" LaTeX-prettyprint-paragraph-separate)) (punctuation "[.,:;!]") (start)) (while (re-search-forward math-mode-regexp nil t) (backward-char 2) ;move before opening $ (delete-horizontal-space) (if (not (bolp)) ;and put it on a new line (insert "\n")) (setq start (point)) ;remember position before opening $ (backward-char 1) ;do we have a comment line? (beginning-of-line) (if (looking-at comment-line-regexp) (goto-char start) ;no, move before opening $ (goto-char start) ;yes, put separator before opening $ (if (not (null LaTeX-math-comment-separator)) (insert LaTeX-math-comment-separator))) (forward-char 1) ;move over opening $ (delete-horizontal-space) (if (not (eolp)) ;and start a newline if needed (insert "\n")) (delete-horizontal-space) ;; In order to prevent disasters from incorrect mismatching of ;; paired dollar signs, we require that the closing dollar be ;; in the same paragraph. If not, we bail out with an error ;; message. (re-search-forward math-mode-separate) ;find closing $ (goto-char (match-beginning 0)) ;and move to its start (if (looking-at LaTeX-prettyprint-paragraph-separate) (progn ;bail out if not a math mode match (message "ERROR: unclosed math mode at paragraph end!") (ding) (throw 'EXIT nil))) (forward-char 1) ;move before closing $ (delete-horizontal-space) ;and put it at start of a newline (if (not (bolp)) ;if not already there (insert "\n")) (forward-char 1) ;move over closing $ (delete-horizontal-space) (if (looking-at punctuation) ;move over any following punctuation (progn (forward-char 1) (delete-horizontal-space))) (if (eolp) (forward-char 1) ;then move past newline (insert "\n")) ;else insert newline (delete-horizontal-space) (if (and (not (looking-at comment-line-regexp)) (not (null LaTeX-math-comment-separator))) (insert LaTeX-math-comment-separator)) (delete-horizontal-space) (backward-char 1)) ;because we need to look one char BEFORE $ (internal-LaTeX-indent-math LaTeX-displaymath-indentation-column)))) (defun LaTeX-protect () "Insert a \\protect (on \\\\[LaTeX-protect])." (interactive) (insert "\\protect")) (defun LaTeX-quote (arg) "Insert ``, '' or \" according to preceding character (on \\\\[LaTeX-quote]). With prefix argument, always insert \" characters." (interactive "P") (if arg (let ((count (prefix-numeric-value arg))) (if (listp arg) (self-insert-command 1) ;C-u always inserts just one (self-insert-command count))) (insert (cond ((or (bobp) (save-excursion (forward-char -1) (looking-at "[ \t\n]\\|\\s("))) "``") ((= (preceding-char) ?\\) ?\") (t "''"))))) (defun LaTeX-ref (&optional arg) "Insert \\ref{ ... } (on \\\\[LaTeX-ref]). With an argument, the reference gets parenthesized; this is handy for equation numbers." (interactive) (setq arg (or arg current-prefix-arg)) (if arg (progn (delete-horizontal-space) (insert "~()") (backward-char 1) (internal-LaTeX-keyword "ref" "" "")) (internal-LaTeX-keyword "ref" "~" " ")) (if (looking-at "\n") (delete-char 1))) (defun LaTeX-ref-with-completion (label-name &optional arg) "Insert \\ref{ ... } with completion on label tag (on \\\\[LaTeX-ref-with-completion]). When this function is invoked, all currently-defined labels are collected dynamically by internal-LaTeX-make-label-list and used for the completion list. An undefined label name may be legally entered if required; presumably, you will soon generate a \\label{...} definition for it. With an argument, the reference gets parenthesized; this is handy for equation numbers." (interactive (list (completing-read "LaTeX \\label{} tag name: " (internal-LaTeX-make-label-list) nil nil nil))) (setq arg (or arg current-prefix-arg)) (if arg (progn (delete-horizontal-space) (insert "~()") (backward-char 1) (internal-LaTeX-keyword "ref" "" "") (insert label-name)) (progn (internal-LaTeX-keyword "ref" "~" " ") (insert label-name))) (if (looking-at "\n") (delete-char 1)) (forward-char (if arg 2 0))) (defun LaTeX-set-indentation (&optional arg) "Set the indentation column to ARG, or if ARG is omitted, to the current column. You should rarely need this command, because environments generated by LaTeX-begin-end-block set their own indentation." (interactive) (setq LaTeX-current-indentation (internal-LaTeX-default arg (current-column))) (message (format "Indentation column set to %d" LaTeX-current-indentation))) (defun LaTeX-split-string (s regexp) "Return a list of strings from splitting S at the regular expression REGEXP. This function is patterned after the awk split() function." (if (or (null s) (null regexp)) ;then return nil if either s or regexp is nil nil (let ((p nil) (k 0)) ;else split the string and return a list of strings (while (and (< k (length s)) (string-match regexp s k)) (setq p (nconc p (list (substring s k (match-beginning 0))))) (setq k (match-end 0))) (setq p (nconc p (list (substring s k)))) p))) (defun LaTeX-subscript () "Insert a braced subscript, leaving the cursor in the braces. If the preceding character is a backslash, however, just insert an underscore." (interactive) (if (equal (preceding-char) ?\\) (insert-string "_") (internal-LaTeX-delimiter-pair "_{" "}" nil))) (defun LaTeX-superscript () "Insert a braced superscript, leaving the cursor in the braces. If the preceding character is a backslash, however, just insert a caret." (interactive) (if (equal (preceding-char) ?\\) (insert-string "^") (internal-LaTeX-delimiter-pair "^{" "}" nil))) (defun LaTeX-tab () ; author: Ashwin Ram "Indent to level of current \\begin{}...\\end nesting (on \\\\[LaTeX-tab])." (interactive) (let ((fail-point (point)) (nesting '()) (done nil)) (end-of-line) (while t (if (re-search-backward "\\\\\\(begin\\|end\\){\\([^}\n]*\\)}" (point-min) t) (let ((which (buffer-substring (match-beginning 1) (match-end 1))) (text (buffer-substring (match-beginning 2) (match-end 2)))) (if (equal which "end") (setq nesting (cons text nesting)) (if (null nesting) (let ((indentation (current-column))) (goto-char fail-point) (beginning-of-line) (indent-to (+ indentation LaTeX-begin-end-indentation)) (error "Inside \\begin{%s}" text)) (setq nesting (cdr nesting))))) (progn (goto-char fail-point) (error "Not inside a \\begin{...}")))))) (defun LaTeX-to-begin (&optional arg) "Move backward over ARG \\begin's (on \\\\[LaTeX-to-begin]). Return T on success, NIL on failure. A negative argument moves forward over \\end's. \\begin and \\end are recognized only if they are preceded on the line by nothing but whitespace, and followed by an open curly brace. Mark is set where the search began." (interactive) (setq arg (internal-LaTeX-default arg 1)) (push-mark (point) t) ;remember where we started (let ((level 0)) (catch 'EXIT (while (if (> arg 0) (re-search-backward "^[ \t]*\\\\begin *{\\|^[ \t]*\\\\end *{" nil t) (re-search-forward "^[ \t]*\\\\begin *{\\|^[ \t]*\\\\end *{" nil t)) (beginning-of-line) (if (looking-at "^[ \t]*\\\\begin *{") (setq level (1+ level)) (setq level (1- level))) ;; (message (format "arg = %d level = %d " arg level)) (sit-for 1) (if (= level arg) (throw 'EXIT t)) (if (< arg 0) (progn (forward-line))))) (skip-chars-forward " \t") (= level arg))) ;t on success, nil on failure (defun LaTeX-to-end (&optional arg) "Move forward over ARG (default 1) \\end{...}'s (on \\\\[LaTeX-to-end]). Return t on success, nil on failure. A negative argument moves backward over \\begin{...}'s instead. \\begin and \\end are recognized only if they are preceded on the line by nothing but whitespace, and followed by an open curly brace. Mark is set where the search began." (interactive) (setq arg (internal-LaTeX-default arg 1)) (LaTeX-to-begin (- arg))) (defun LaTeX-uncomment (&optional paragraph) "Remove leading comments from the current region, or, with a prefix argument, paragraph (on \\\\[LaTeX-uncomment]). Point is left at the end of the region, or the beginning of the next paragraph. M-x undo (on \\[undo]) will undo it. Comments must be of the form defined by the variable LaTeX-comment-prefix, and inserted by LaTeX-comment (on \\[LaTeX-comment]). NB: paragraph-separate is usually defined in LaTeX-mode to include lines which contain only comments. This means that a paragraph commented out by LaTeX-comment will NOT be recognized by this function. Mark the region you want uncommented, and invoke this function without an argument instead." (interactive "P") (let ((region (not paragraph))) (save-restriction (if region (narrow-to-region (mark) (point)) (narrow-to-region (progn ;find first character of paragraph (backward-paragraph) (if (looking-at "\n") (forward-char)) (point)) (progn ;find last character of paragraph (forward-paragraph) (if (looking-at "\n") (backward-char)) (point)))) (goto-char (point-min)) (while (re-search-forward (concat "^" LaTeX-comment-prefix) (point-max) t) ;uncomment lines (replace-match "" t t)) (goto-char (point-max))) ;end save-restriction (if (not region) ;position to start of next paragraph (progn (forward-paragraph) (backward-paragraph) (forward-char) (beginning-of-line))))) (defun LaTeX-verb (&optional arg) "Insert \\verb| ... | (on \\\\[LaTeX-verb]). With an argument, insert \\verb*| ... | which makes spaces in its argument visible. The delimiter character actually used is the current value of the variable LaTeX-verb-delimiter. " (interactive) (setq arg (internal-LaTeX-default arg nil)) (insert "\\verb" (if arg "*" "") LaTeX-verb-delimiter (if LaTeX-newline-after-opening-delimiter "\n" "") LaTeX-verb-delimiter (if LaTeX-newline-after-closing-delimiter "\n" "")) (search-backward (char-to-string LaTeX-verb-delimiter)) (search-backward (char-to-string LaTeX-verb-delimiter)) (forward-char 1)) (defun TeX-dollar () "Insert a math mode dollar pair, or if at beginning of line, a display math pair. If the preceding character is a backslash, however, just put in a single dollar sign." (interactive) (cond ((equal (preceding-char) ?\\) (insert-string "$")) ((> (current-column) 0) (progn (insert-string "$$") (backward-char 1))) (t (progn (insert-string "$$\n \n$$\n") (backward-char 4))))) (defun check-LaTeX-labels () "Search for undefined labels which are referenced by \\ref{} or \\pageref{}. Labels in LaTeX-aux-file-label-tags (set by update-LaTeX-labels) are included in the definition list. Execution terminates with point at the next undefined label, or if all labels are defined, with point unchanged." (interactive) (let ((labels (append LaTeX-aux-file-label-tags (internal-LaTeX-collect-labels))) (the-label)) (save-excursion ;; search for references to the labels and make sure they are ;; in the assoc list (goto-char (point-min)) (while (re-search-forward LaTeX-label-reference nil t) (setq the-label (concat "\"" (buffer-substring (match-beginning 1) (match-end 1)) "\"")) (if (not (assoc the-label labels)) (error "Undefined label %s" the-label))) (message "[done] all referenced labels are defined")))) (defun check-LaTeX-nesting () "Check for incorrect \\begin{foo} .. \\end{foo} nesting in a LaTeX file. Return t on nesting error, nil on success." (interactive) (let ((name-list nil) (point-list nil) (environment-name nil) (start-point (point))) (goto-char (point-min)) (while (re-search-forward "^[ \t]*\\\\begin *{\\|^[ \t]*\\\\end *{" nil t) (backward-char 1) (save-excursion (re-search-forward "{\\([^{}]*\\)}") (setq environment-name (buffer-substring (match-beginning 1) (match-end 1)))) (beginning-of-line) (skip-chars-forward " \t") (if (looking-at "\\\\begin *{") (progn (setq point-list (cons (point) point-list)) (setq name-list (cons environment-name name-list))) (progn ;else have \\end{...} (if (null name-list) (progn (error "This \\end has no previous matching \\begin"))) (if (not (string-equal environment-name (car name-list))) (progn (push-mark (car point-list) t) (error "This \\end{%s} is matched by preceding \\begin{%s} at mark." environment-name (car name-list)))) (setq point-list (cdr point-list)) (setq name-list (cdr name-list)))) (forward-line 1)) ;end while (if (car name-list) ;then we are missing one or more \\end (progn (push-mark start-point t) (mapcar 'push-mark (reverse point-list)) (goto-char (mark)) ;put point on last unmatched char (pop-mark) ;and leave rest on mark ring (error "%d unclosed \\begin{...}'s marked starting here." (length point-list))) (progn ;else all chars balance (message "[done] -- all \\begin{}-\\end{}'s balance") (goto-char start-point))) nil)) ;success return (defun convert-LaTeX-2.09-to-LaTeX-2e () "Convert LaTeX 2.09 constructs in the current buffer to LaTeX 2e syntax." (interactive) (save-excursion (internal-LaTeX-2e-convert-documentstyle) (internal-LaTeX-2e-convert-font "{\\em" "\\emph{") (internal-LaTeX-2e-convert-font "{\\bf" "\\textbf{") (internal-LaTeX-2e-convert-font "{\\it" "\\textit{") (internal-LaTeX-2e-convert-font "{\\sc" "\\textsc{") (internal-LaTeX-2e-convert-font "{\\sf" "\\textsf{") (internal-LaTeX-2e-convert-font "{\\sl" "\\textsl{") (internal-LaTeX-2e-convert-font "{\\tt" "\\texttt{") ; LaTeX 2e has no explicit italic corrections (goto-char (point-min)) (replace-string "\\/}" "}") (goto-char (point-min)) (if (search-forward "\\/" nil t) (error "Some unconverted italic corrections remain"))) ) (defun indent-LaTeX-begin-end-groups () "Indent \\begin{} ... \\end{} groups in entire buffer according to nesting level, placing them on separate lines. M-x undo (on \\[undo]) will undo the indentation. A check is made for incorrect nesting levels before starting, and the operation is aborted if there are nesting errors. On completion, the \\begin and \\end lines are shown in the *Occur* buffer. The nesting indentation level is taken from that of the first \\begin found, which will normally be the \\begin{document} at the start of a line. \\begin and \\end for environments listed in LaTeX-standard-unindented-environments and LaTeX-extra-unindented-environments will be moved to beginning-of-line. \\begin and \\end are recognized only if they are preceded on the line by nothing but whitespace, and followed by an open curly brace. Mark is set where the search began." (interactive) (if (not (check-LaTeX-nesting)) (let ((level 0) (environment-name nil)) (goto-char (point-min)) (if (re-search-forward "^[ \t]*\\\\begin" nil t) (progn ;set indentation level from first \\begin (beginning-of-line) (skip-chars-forward " \t") (setq level (/ (current-column) LaTeX-begin-end-indentation)))) (goto-char (point-min)) (while (re-search-forward "^[ \t]*\\\\begin *{\\|^[ \t]*\\\\end *{" nil t) (beginning-of-line) (delete-horizontal-space) (save-excursion (re-search-forward "{\\([^{}]*\\)}") (setq environment-name (buffer-substring (match-beginning 1) (match-end 1)))) (if (looking-at "\\\\begin *{") (progn (if (not (assoc environment-name (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments))) (insert-char (SPACE) (* level LaTeX-begin-end-indentation))) (setq level (1+ level))) (progn (setq level (1- level)) (if (not (assoc environment-name (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments))) (insert-char (SPACE) (* level LaTeX-begin-end-indentation))))) (forward-line 1)))) (goto-char (point-min)) (occur "^[ \t]*\\\\begin *{\\|^[ \t]*\\\\end *{")) (defun internal-LaTeX-calculate-indent () "Examine the surrounding text and try to figure out what the current indentation should be, then return the indentation column number." (let ((indent nil) (temp-indent nil)) (save-excursion (beginning-of-line) (skip-chars-forward " \t") (cond ; is there anything interesting on this line? ;; are we looking at a \begin? ((looking-at "\\\\begin") ;; look backwards for previous \begin and indent to its ;; indent + LaTeX-begin-end-indentation. (if (assoc (internal-LaTeX-which-environment) (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments)) (setq temp-indent 0) (setq temp-indent LaTeX-begin-end-indentation)) (if (re-search-backward "\\\\begin\\|\\\\end\\|\\\\item" 0 t) (cond ((looking-at "\\\\end") (setq indent (current-indentation))) ((looking-at "\\\\item") (setq indent (+ (current-indentation) LaTeX-item-info-indent))) ((looking-at "\\\\begin") (setq indent (+ (current-indentation) temp-indent)))) (setq indent 0))) ;; are we looking at an \end? ((looking-at "\\\\end") (LaTeX-to-begin) (setq indent (current-indentation))) ;; are we looking at an \item? ((looking-at "\\\\item") ;; look backwards for a previous \item and indent to it's level. ;; or for a \begin and indent to its ;; indentation + LaTeX-begin-end-indentation (LaTeX-to-begin) (setq indent (+ (current-indentation) LaTeX-item-indentation))) ;; there isn't anything special on the beginning of this line, so ;; check out the previous one. (t (forward-line -1) (beginning-of-line) (skip-chars-forward " \t") (cond ((looking-at "\\\\begin *{") (if (assoc (internal-LaTeX-which-environment) (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments)) (setq temp-indent 0) (setq temp-indent LaTeX-begin-end-indentation)) (setq indent (+ (current-indentation) temp-indent))) ;; There is an \item on the line above the one that we are ;; working on, so indent to be just past it. ((looking-at "\\\\item") (setq indent (+ (current-indentation) LaTeX-item-info-indent))) ((looking-at "\\\\end") (if (assoc (internal-LaTeX-which-environment) (append LaTeX-standard-unindented-environments LaTeX-extra-unindented-environments)) (setq temp-indent 0) (setq temp-indent LaTeX-begin-end-indentation)) (setq indent (- (current-indentation) temp-indent))) ;; nothing special anywhere, just indent the line like the ;; one above it. (t (setq indent (current-indentation)))))) indent))) (defun internal-LaTeX-check-matching-character-balance (open close name maxsep &optional allow-paragraph-breaks) "Starting at current point, check for unbalanced OPEN and CLOSE characters, and OPEN/CLOSE pairs suspiciously separated by long strings of more than MAXSEP characters. Backslashed OPEN/CLOSE characters are ignored. NAME (e.g. \"brace\") is used for message typeout. With an argument (i.e. a non-nil allow-paragraph-breaks), paragraph breaks are permitted between the matching OPEN/CLOSE characters. Paragraph breaks are considered to be at (a) empty lines, (b) lines containing only whitespace, or (c) formfeeds. The variable paragraph-separate is NOT used, because the usual setting LaTeX-mode includes characters that are likely to be balance-checked with this function." (if (not (null current-prefix-arg)) (setq allow-paragraph-breaks t)) (message "Checking %s balance%s" name (if allow-paragraph-breaks " allowing paragraph breaks" "")) (let* ( (open-char-list nil) ;; We need a private version of paragraph-separate here ;; to guarantee exclusion of control sequences that might ;; have braces in them (the standard one in LaTeX-mode does) (paragraph-regexp "^[ \t]*$\\|\f") (start-point (point)) (old-transient-mark-mode nil) (close-regexp (concat "[^\\\\]" (regexp-quote (char-to-string close)))) (open-regexp (concat "[^\\\\]" (regexp-quote (char-to-string open)))) ;; construct a regular expression to match an OPEN or a CLOSE ;; (provided they are not preceded by a backslash) and if an ;; argument is provided, to also match end-of-paragraph (match-string (concat open-regexp "\\|" close-regexp (if allow-paragraph-breaks "" (concat "\\|" paragraph-regexp ))))) (if (fboundp 'transient-mark-mode) ;transient mark mode prevents use (progn ;of mark stack (setq old-transient-mark-mode transient-mark-mode) (transient-mark-mode 0))) ;; The algorithm here is complex. We search forward for the ;; delimiter characters and paragraph breaks. ;; ;; If we match an open delimiter, we record its position at the ;; front of open-char-list and continue. ;; ;; If we match a closing delimiter, we check that the interval ;; between it and the last open delimiter does not exceed maxsep. ;; If it does, we raise an error and exit. We then discard the ;; front entry from open-char-list, since we know that we matched ;; it, even if the separation was long enough to force an message. ;; ;; If we match a paragraph break, and allow-paragraph-breaks is nil ;; (the usual case), then we raise an error message and exit if ;; open-char-list is not empty. Then we advance until we are not ;; looking at a paragraph break. This is necessary to ensure that ;; the outer while loop advances. (catch 'EXIT (if (> (point) (point-min)) (backward-char 1)) ;search looks at preceding char (while (and (< (1+ (point)) (point-max)) (re-search-forward match-string nil t)) (goto-char (match-beginning 0)) (cond ;check match possibilities ;; matched OPEN character ((looking-at open-regexp) ;at opening char (goto-char (match-end 0)) (setq open-char-list (cons (1- (point)) open-char-list)) (backward-char 1)) ;move back to restart search for "\\x" ;; matched CLOSE character ((looking-at close-regexp) ;at closing char (goto-char (match-end 0)) (cond ((null open-char-list) (ding) (backward-char 1) ;position on char (message "This closing %c has no matching open %c" close open) (throw 'EXIT nil)) ((> (- (point) (car open-char-list)) maxsep) (ding) (push-mark (car open-char-list) t) (message "More than %d chars between %c...%c." LaTeX-brace-interval open close) (throw 'EXIT nil))) (setq open-char-list (cdr open-char-list)) ;forget location of ;matching open (backward-char 1)) ;move back to restart search for "\\x" ;; matched end-of-paragraph (only get here if ;; allow-paragraph-breaks is set, or an argument was given) (t (goto-char (1- (match-end 0))) ;prepare to resume search (if (and (null allow-paragraph-breaks) (not (null open-char-list))) (progn (ding) (push-mark start-point t) (mapcar 'push-mark (reverse open-char-list)) (goto-char (mark)) ;put point on last unmatched char (pop-mark) ;and leave rest on mark ring (message "%d unclosed %c char%s%s" (length open-char-list) open (if (> (length open-char-list) 1) "s at paragraph break marked." " at paragraph break.")) ;end message (throw 'EXIT nil)))))) (if (car open-char-list) ;then we are missing a closing char (progn (ding) (push-mark start-point t) (mapcar 'push-mark (reverse open-char-list)) (goto-char (mark)) ;put point on last unmatched char (pop-mark) ;and leave rest on mark ring (message "%d unclosed open %s%s marked starting here." (length open-char-list) name (if (> (length open-char-list) 1) "s" ""))) (progn ;else all chars balance (message "[done] -- all %ss balance" name) (goto-char start-point)))) (if (fboundp 'transient-mark-mode) ;transient mark mode prevents use (setq transient-mark-mode old-transient-mark-mode)))) (defun internal-LaTeX-collect-bibtags (bibfilename) "Collect BibTeX tags from BIBFILENAME and return them as an alist with the BIBFILENAME as the second component in each alist entry." (interactive) (let ((tags nil) (tmpbuf)) (setq tmpbuf (generate-new-buffer "*internal-LaTeX-collect-bibtags*")) (save-excursion (set-buffer tmpbuf) ;local to this function only (insert-file-contents (expand-file-name bibfilename)) (goto-char (point-min)) (while (re-search-forward "^@[A-Za-z0-9 ]*{\\([^=,\n]*\\)," nil t) (let ((k1 (match-beginning 1)) (k2 (match-end 1))) (beginning-of-line) (if (not (or (looking-at "^@[Pp][Rr][Ee][Aa][Mm][Bb][Ll][Ee]") (looking-at "^@[Ss][Tt][Rr][Ii][Nn][Gg]"))) (setq tags (nconc tags (list (list (buffer-substring k1 k2) bibfilename))))) (forward-line 1))) (kill-buffer tmpbuf) tags))) (defun internal-LaTeX-collect-labels () "Collect an associative list ((\"tag1\" line byte) (\"tag2\" line byte) ... (\"tagn\" line byte)) of all cross-reference labels defined by \\label{...} in the current buffer and return it." (let ((labels ())) (save-excursion (goto-char (point-min)) (while (re-search-forward LaTeX-label-definition nil t) (setq labels (append labels (list (list (concat "\"" (buffer-substring (match-beginning 1) (match-end 1)) "\"") (count-lines (point-min) (point)) (match-beginning 1))))))) labels)) ;the returned assoc list (defun internal-LaTeX-2e-convert-document-options () "Convert a LaTeX 2.09 \\documentstyle option list to a LaTeX 2e option list, and return a string of \\usepackage{} commands. This function should be invoked with point at the open square bracket delimiting the option list." (let ((package-list "") (start (1+ (point))) (word nil)) (if (search-forward "]" nil t) (save-restriction (narrow-to-region start (1- (point))) ;; remove leading space (delete-horizontal-space) ;; change comma separators to blanks (goto-char (point-min)) (replace-string "," " ") ;; collapse multiple blanks to single blanks (goto-char (point-min)) (replace-regexp " +" " ") ;; remove trailing space (goto-char (point-max)) (delete-horizontal-space) ;; loop over option words, and convert them to package names ;; if they are not in LaTeX-2e-standard-options (goto-char (point-min)) (setq start (point)) (while (< (point) (point-max)) (forward-word 1) (backward-word 1) (setq start (point)) (forward-word 1) (setq word (buffer-substring start (point))) (if (not (assoc word LaTeX-2e-standard-options)) (progn (backward-delete-char (length word)) (setq package-list (format "%s\\usepackage{%s}\n" package-list word))))) (delete-horizontal-space) (goto-char (point-min)) (delete-horizontal-space) (replace-regexp " +" ",") (widen))) package-list)) (defun internal-LaTeX-2e-convert-documentstyle () "Convert a LaTeX 2.09 \\documentstyle[]{} command to LaTeX 2e \\documentclass[]{} and \\usepackage{} commands." (goto-char (point-min)) (if (search-forward "\\documentstyle" nil t) (let ((package-list "")) (delete-backward-char 5) (insert "class") (if (looking-at "\\[") (setq package-list (internal-LaTeX-2e-convert-document-options))) (forward-line 1) (insert package-list)))) (defun internal-LaTeX-2e-convert-font (old new) "Convert OLD font changes to NEW font changes in the current buffer." (goto-char (point-min)) (while (search-forward old nil t) (if (looking-at "[{ ]\\|$") (progn (delete-backward-char (length old)) (insert new) (delete-horizontal-space))))) (defun internal-LaTeX-default (value default-value) "Return a non-nil value from VALUE, current-prefix-arg, or DEFAULT-VALUE, in that order. Do (setq argvar (internal-LaTeX-default argvar 23)) to set &optional argvar to (a) argvar, if argvar is non-nil, else (b) current-prefix-arg, if that is non-nil, else (c) 23. This simplifies optional argument assignment in many functions." (cond ((not (null value)) ;do nothing if explicit arg value) ((not (null current-prefix-arg)) ;else use prefix arg if any (prefix-numeric-value current-prefix-arg)) (t ;else no arg at all, so use default default-value))) (defun internal-LaTeX-delimiter-pair (open close indent) "Insert a delimiter pair at point, leaving point after the OPEN delimiter. If LaTeX-newline-after-opening-delimiter is non-nil, they will be separated by a newline. If LaTeX-newline-after-closing-delimiter is non-nil, the CLOSE delimiter will be followed by a newline. If INDENT is t, supply leading spaces in front of both delimiters according to the value of LaTeX-current-indentation." (if indent (insert-char (SPACE) LaTeX-current-indentation)) (insert open) (let ((new-point (point))) (if LaTeX-newline-after-opening-delimiter (progn (delete-horizontal-space) (newline) (if indent (insert-char (SPACE) LaTeX-current-indentation)))) (insert close) (if (looking-at "[ \t]*$") ;remove white space at end-of-line (delete-horizontal-space)) (if LaTeX-newline-after-closing-delimiter (progn (delete-horizontal-space) (newline))) (goto-char new-point))) (defun internal-LaTeX-indent-line () "Indent current line as LaTeX stuff. Return amount that line was changed by." (let ((indent (internal-LaTeX-calculate-indent)) beg shift-amt (case-fold-search nil) (pos (- (point-max) (point)))) (beginning-of-line) (setq beg (point)) (skip-chars-forward " \t") (setq shift-amt (- indent (current-column))) (if (zerop shift-amt) (if (> (- (point-max) pos) (point)) (goto-char (- (point-max) pos))) (delete-region beg (point)) (indent-to indent) (if (> (- (point-max) pos) (point)) (goto-char (- (point-max) pos)))) shift-amt)) (defun internal-LaTeX-indent-math (column) "In the entire buffer, indent all math mode sections identified by dollar signs at beginning of line to column COLUMN. This function is intended for internal use by the prettyprint-*math functions, which can guarantee a well-formed buffer." (goto-char (point-min)) (let ((math-mode-regexp "^$[.,:;!]?$\\|^$$[.,:;!]?$")) (while (re-search-forward math-mode-regexp nil t) (forward-line 1) (while (not (looking-at math-mode-regexp)) (delete-horizontal-space) (insert-char ?\ column) (forward-line 1)) (forward-line 1)))) (defun internal-LaTeX-item (column keyword) "On a new line at column COLUMN, insert item or bibitem KEYWORD." (end-of-line) (or (save-excursion (backward-char 1) (looking-at "^$")) (newline)) (insert-char (SPACE) column) (insert keyword)) (defun internal-LaTeX-keyword (keyword &optional prefix suffix) "Remove surrounding space, then insert \\KEYWORD{ ... } at point. If PREFIX is specified, insert it before the \\KEYWORD. If SUFFIX is specified, insert it after the closing brace." (delete-horizontal-space) (internal-LaTeX-delimiter-pair (concat prefix "\\" keyword "{") (concat "}" suffix) nil)) (defun internal-LaTeX-label-string (element) "Print a string \"line: label\" from the associative list ELEMENT." (let ((the-marker (make-marker))) (set-marker the-marker (nth 2 element)) ;the-marker records byte position ;; (setq LaTeX-labels-occur-pos-list (cons the-marker LaTeX-labels-occur-pos-list)) (setq LaTeX-labels-occur-pos-list (cons the-marker LaTeX-labels-occur-pos-list)) (princ (format "%d: %s\n" (car (cdr element)) (car element))))) (defun internal-LaTeX-make-label-list () "Make a list of all \\label{...} values found in the buffer, add to it the contents of LaTeX-aux-file-label-tags, remove duplicates, and return it as the function result." (interactive) ;; Here is some hairy Lisp code: internal-LaTeX-collect-labels returns a ;; list like ;; ( ("\"tag-1\"" linenumber-1) ... ("\"tag-n\"" linenumber-n) ) ;; For each element of this list, the mapcar function uses ;; (read-from-string (car x)) to extract and return the unquoted ;; "tag-k" as a bare string which is then cons'ed onto the list of ;; strings in LaTeX-label-list as ;; ( ("tag-1") ... ("tag-n") ) ;; which is what we return. That form can be used by completing-read. (let ((k 0) (tags)) (setq tags (mapcar (function (lambda (x) (cons (car (read-from-string (car x))) nil))) (internal-LaTeX-collect-labels))) ;; Now add to tags those strings from LaTeX-aux-file-label-tags ;; which are not already in tags (setq k 0) (while (nth k LaTeX-aux-file-label-tags) (if (not (assoc (car (nth k LaTeX-aux-file-label-tags)) tags)) (setq tags (nconc tags (list (nth k LaTeX-aux-file-label-tags))))) (setq k (1+ k))) (internal-LaTeX-sort-alist tags))) ;function return value (defun internal-LaTeX-maybe-remove-italic-correction () "Remove any italic correction immediately preceding point, if the next character is a dot or a comma, leaving point unchanged." (if (looking-at "[.,]") (progn ;then we have dot or comma (backward-char 3) ;move in front of putative \/} (if (looking-at "\\\\/}") (progn ;then we have italic correction (delete-char 2) ;delete it (forward-char 1)) ;move after } (forward-char 3))))) ;else move to original position (defun internal-LaTeX-old-indent-line () "Indent current LaTeX line based on its contents and on previous lines. This is used by the standard function newline-and-indent (on \\[newline-and-indent])." (let ((prefix nil)) (save-excursion (beginning-of-line) (forward-line -1) (setq prefix (buffer-substring (point) (progn (re-search-forward "^[% \t]*") (point)))) (if (looking-at "\\\\item") ;indent under end of "\item " (setq prefix (concat prefix " "))) (if (looking-at "\\\\bibitem") ;indent under first of []{} (setq prefix (concat prefix " ")))) (delete-horizontal-space) (insert prefix))) (defun internal-LaTeX-preceding-buffer-substring (n) "Return as a string value the N or fewer characters in the buffer preceding point, taking care to avoid a buffer bounds violation." (buffer-substring (max 1 (- (point) n)) (point))) (defun internal-LaTeX-repeat (n proc) "Repeat N times the function PROC." (while (> n 0) (eval proc) (setq n (1- n)))) (defun internal-LaTeX-set-indentation () "Update LaTeX-current-indentation according to current \\begin{}...\\end{} level if at beginning of line, or else to current indentation value such that a new \\begin{}...\\end{} group will insert at that point." (if (> (current-column) 0) (setq LaTeX-current-indentation (current-column)) (save-excursion (if (re-search-backward "\\\\begin *{\\|\\\\end *{" nil t) (progn (setq LaTeX-current-indentation (current-column)) (if (looking-at "\\\\end *{") (setq LaTeX-current-indentation (- LaTeX-current-indentation LaTeX-begin-end-indentation)))))))) (defun internal-LaTeX-set-mode-name () "Set the mode name to reflect the current LaTeX version." (if LaTeX-2e (setq mode-name "LaTeX-2e") (setq mode-name "LaTeX 2.09"))) (defun internal-LaTeX-sort-alist (alist) "Sort the association list ALIST and return the result." (sort alist (function (lambda (a b) "Compare two a-lists A and B and return T if A < B, else NIL." (string-lessp (car a) (car b)))))) (defun internal-LaTeX-which-environment () "Call this with point sitting on a \begin or \end. It returns the type of the environment, e.g. tabular, or enumerate" (let (begin end) (save-excursion (search-forward "{") (setq begin (point)) (search-forward "}") (setq end (- (point) 1)) (buffer-substring begin end)))) (defun internal-LaTeX-wrap (prefix suffix word-count) "Wrap with PREFIX and SUFFIX the next WORD-COUNT words." (if (> word-count 0) ;do something only if word-count > 0 (progn (forward-word 1) (forward-word -1) ;position to start of next word (insert prefix) (forward-word word-count) (insert suffix)))) (defun internal-x-LaTeX-index-mark (start end) "Insert an index reference around the region START to END, where START < END." (goto-char end) (forward-word -1) ;ensure index entry ends at word boundary (forward-word 1) (if (not (equal (point) start)) ;then have something to index (let (index-text) (setq index-text (buffer-substring start (1+ end))) (insert "}") (if LaTeX-index-end-with-newline (progn (if (not (looking-at "[ \\t]*$")) (insert "\n")) (indent-for-tab-command))) (save-excursion (goto-char start) (if LaTeX-index-macro ;generate \X{foobar} (progn (if (and (> (current-column) 0) LaTeX-index-start-with-newline) (progn (if (not (looking-at "[ \\t]*$")) (insert "\n")) (indent-for-tab-command))) (insert LaTeX-index-macro "{")) (progn ;generate foobar%\n\index{foobar} (insert index-text) (delete-horizontal-space) (insert (if (and (> (current-column) 0) LaTeX-index-start-with-newline) "%\n" "") "\\index{"))))))) (defun make-LaTeX-document (LaTeX-style &optional LaTeX-option-list arg) "Select LaTeX-mode, then insert a template for a new LaTeX document, prompting for style and options. With an argument, some additional helpful comments are inserted. Any previous contents of the buffer are killed (and saved on the kill-ring). The default template header can be replaced by a customized one inserted by the function make-LaTeX-document-hook which is run with point at the beginning of the buffer. If LaTeX-2e is t, then a template is generated for LaTeX 2e instead of LaTeX 2.09." (interactive (list (completing-read (if LaTeX-2e "Document class: " "Document style: ") (append (if LaTeX-2e LaTeX-2e-standard-classes LaTeX-standard-styles) LaTeX-extra-styles) nil nil nil))) (setq arg (internal-LaTeX-default arg nil)) (let (loop) (if (eq major-mode 'LaTeX-mode) (LaTeX-mode)) (setq loop t) (if (null LaTeX-option-list) ;then prompt for missing option list (progn (setq LaTeX-option-list "") (while loop (let (LaTeX-option) (setq LaTeX-option (completing-read "Document option (RET when done): " (append (if LaTeX-2e LaTeX-2e-standard-options LaTeX-standard-options) LaTeX-extra-options) nil nil nil)) (if (equal LaTeX-option "") (setq loop nil) (setq LaTeX-option-list (format "%s,%s" LaTeX-option-list LaTeX-option))))) (if (not (eq 0 (length LaTeX-option-list))) (setq LaTeX-option-list (substring LaTeX-option-list 1))))) ; discard leading "," (if LaTeX-default-options ;prepend default options (setq LaTeX-option-list (if (or (null LaTeX-option-list) (string-equal "" LaTeX-option-list)) LaTeX-default-options (concat LaTeX-default-options "," LaTeX-option-list)))) (kill-region (point-min) (point-max)) (goto-char (point-min)) (if (boundp 'make-LaTeX-document-hook) (run-hooks 'make-LaTeX-document-hook) (progn (insert "% -*-latex-*-\n") ;must be lower-case for autoload (goto-char (point-max)) ;on find-file to work (insert "% Document name: " (if (null buffer-file-name) "unknown" buffer-file-name) "\n") (insert "% Creator: " (user-full-name) " [" (or (and (boundp 'user-mail-address) user-mail-address) (concat (user-login-name) "@" (or (and (boundp 'mail-host-address) mail-host-address) (system-name)))) "]\n") (insert "% Creation Date: " (current-time-string)) (if arg (insert " %------------------------------------------------------------------------ % EVERYTHING TO THE RIGHT OF A % IS A REMARK TO YOU AND IS IGNORED BY % LaTeX. % % WARNING! DO NOT TYPE ANY OF THE FOLLOWING 10 CHARACTERS AS NORMAL TEXT % CHARACTERS: % & $ # % _ { } ^ ~ \\ % % The following seven are printed by typing a backslash in front of them: % \$ \& \# \% \_ \{ and \}. %------------------------------------------------------------------------ ") (insert "\n")))) (goto-char (point-max)) (if (not (equal (buffer-substring (1- (point-max)) (point-max)) "\n")) (insert "\n")) (if LaTeX-2e (insert "\\documentclass[" LaTeX-option-list "]{" LaTeX-style "}\n") (insert "\\documentstyle[" LaTeX-option-list "]{" LaTeX-style "}\n")) (if LaTeX-2e (LaTeX-2e-package)) (newline) (or (null LaTeX-index-macro) (insert "\\newcommand{" LaTeX-index-macro "}[1]{#1\\index{#1}}\n")) (newline) (insert "\\begin" (if LaTeX-space-after-begin-end " " "") "{document}\n") (save-excursion (insert "\n\\end" (if LaTeX-space-after-begin-end " " "") "{document}\n")))) (defun make-SLiTeX-document (&optional LaTeX-option-list arg) "Select LaTeX-mode, then insert a template for a new SLiTeX document, prompting for style and options. With an argument, some additional helpful comments are inserted. Any previous contents of the buffer are killed (and saved on the kill-ring). The default template header can be replaced by a customized one inserted by the function make-SLiTeX-document-hook which is run with point at the beginning of the buffer. If LaTeX-2e is t, then a template is generated for LaTeX 2e instead of LaTeX 2.09." (interactive) (setq arg (internal-LaTeX-default arg nil)) (let (LaTeX-option loop) (if (eq major-mode 'LaTeX-mode) (LaTeX-mode)) (setq loop t) (if (null LaTeX-option-list) ;then prompt for missing option list (progn (setq LaTeX-option-list "") (while loop (setq LaTeX-option (completing-read "Document option (RET when done): " (append LaTeX-standard-options LaTeX-extra-options) nil nil nil)) (if (equal LaTeX-option "") (setq loop nil) (setq LaTeX-option-list (format "%s,%s" LaTeX-option-list LaTeX-option)))) (if (not (eq 0 (length LaTeX-option-list))) (setq LaTeX-option-list (substring LaTeX-option-list 1))))) (if LaTeX-default-options ;prepend default options (setq LaTeX-option-list (if (or (null LaTeX-option-list) (string-equal "" LaTeX-option-list)) LaTeX-default-options (concat LaTeX-default-options "," LaTeX-option-list)))) (kill-region (point-min) (point-max)) (goto-char (point-min)) (if (boundp 'make-SLiTeX-document-hook) ;then user customized header (run-hooks 'make-SLiTeX-document-hook) (progn ;else default header (insert "% -*-latex-*-\n") ;must be lower-case for autoload (goto-char (point-max)) ;on find-file to work (insert "% Document name: " (if (null buffer-file-name) "unknown" buffer-file-name) "\n") (insert "% Creator: " (user-full-name) " [" (or (and (boundp 'user-mail-address) user-mail-address) (concat (user-login-name) "@" (or (and (boundp 'mail-host-address) mail-host-address) (system-name)))) "]\n") (insert "% Creation Date: " (current-time-string)) (if arg (insert " %------------------------------------------------------------------------ % EVERYTHING TO THE RIGHT OF A % IS A REMARK TO YOU AND IS IGNORED BY % LaTeX. % % WARNING! DO NOT TYPE ANY OF THE FOLLOWING 10 CHARACTERS AS NORMAL TEXT % CHARACTERS: % & $ # % _ { } ^ ~ \\ % % The following seven are printed by typing a backslash in front of them: % \$ \& \# \% \_ \{ and \}. %------------------------------------------------------------------------ ") (insert "\n")))) (goto-char (point-max)) (if (not (equal (buffer-substring (1- (point-max)) (point-max)) "\n")) (insert "\n")) (if LaTeX-2e (insert "\\documentclass[" LaTeX-option-list "]{slides}\n") (insert "\\documentstyle[" LaTeX-option-list "]{slides}\n")) (insert "\\begin" (if LaTeX-space-after-begin-end " " "") "{document}\n" " \\onlyslides{1-9999}\n" " \\onlynotes{1-9999}\n" "% \\colors{} % {red,green,blue,etc.} colors to generate\n" "% \\colorslides{} % input file\n" " \\blackandwhite{} % input file\n" "\\end" (if LaTeX-space-after-begin-end " " "") "{document}\n") (search-backward "{}") (forward-char 1))) ;; This is a modification of occur-mode-goto-occurrence from emacs/lisp/replace.el ;; to support extended occur-pos-list structures (defun occur-mode-goto-occurrence () "Go to the line this occurrence was found in, in the buffer it was found in." (interactive) (if (or (null occur-buffer) (null (buffer-name occur-buffer))) (progn (setq occur-buffer nil occur-pos-list nil) (error "Buffer in which occurrences were found is deleted"))) (let* ((occur-number (save-excursion (beginning-of-line) (/ (1- (count-lines (point-min) (save-excursion (beginning-of-line) (point)))) (cond ((< occur-nlines 0) (- 2 occur-nlines)) ((> occur-nlines 0) (+ 2 (* 2 occur-nlines))) (t 1))))) (pos (nth occur-number occur-pos-list))) (setq occur-match-beginning nil) (setq occur-match-end nil) (cond ((listp pos) ;element == (marker begin end) (setq occur-match-beginning (nth 1 pos)) (setq occur-match-end (nth 2 pos)) (setq pos (nth 0 pos))) ((markerp pos)) ;element == marker ((null pos) (error "No occurrence on this line"))) ;element == nil (pop-to-buffer occur-buffer) (goto-char (marker-position pos)))) (defun occur-mode-extended-goto-occurrence () "Go to the line this occurrence was found in, in the buffer it was found in, and if possible, momentarily highlight the braced text at point. Although this function uses the occur-mode support code, it preserves any existing information from an *Occur* buffer." (interactive) (let ((occur-nlines occur-nlines) ;dynamic binding means we can (occur-buffer occur-buffer) ;create new values for these (occur-pos-list occur-pos-list)) ;while preserving old ones (cond ;bind new occur-xxx variables ((string-equal "*LaTeX Labels*" (buffer-name)) (setq occur-buffer LaTeX-labels-occur-buffer) (setq occur-nlines 0) (setq occur-pos-list LaTeX-labels-occur-pos-list))) (occur-mode-goto-occurrence) ;use standard occur-mode function ;; Finally, highlight the match, if possible and not suppressed (if (and (fboundp 'transient-mark-mode) (> occur-highlight-time 0)) (cond ((eq occur-pos-list LaTeX-labels-occur-pos-list) (let ((transient-mark-mode)) (push-mark (point)) (transient-mark-mode 1) (search-forward "}") (backward-char 1) (sit-for occur-highlight-time) (pop-mark))) ((and (not (null occur-match-beginning)) (not (null occur-match-end))) (let ((transient-mark-mode)) (push-mark occur-match-beginning) (transient-mark-mode 1) (goto-char occur-match-end) (sit-for occur-highlight-time) (pop-mark))))))) (defun occur-mode-mouse-goto (start-event) "Move point to the position of the mouse cursor in an occur-mode buffer, and then in a second window, go to the match closest to point." (interactive "e") (mouse-set-point start-event) (occur-mode-extended-goto-occurrence)) (defun renumber-figures (&optional arg) "Install a comment marking the figure number on each \\begin{figure}; any existing comment is replaced. An optional numeric argument is used as the figure starting number (default 1). Bound to \ \\\\[renumber-figures]. This command is useful for attaching figure numbers to the input file to make it easier to match it with the typeset output." (interactive) (setq arg (internal-LaTeX-default arg 1)) (save-excursion (goto-char (point-min)) (let ( (old-case-fold-search case-fold-search) (line) (number arg)) (unwind-protect (progn (setq case-fold-search nil) (while (re-search-forward LaTeX-begin-figure nil t) (setq line (buffer-substring (match-beginning 0) (match-end 0))) (zap-to-char 1 ?\n) ;remove rest of line (insert (format " %% figure number %d" number)) ;; In emacs 18, zap-to-char did not kill newline; it emacs 19, it does. ;; Thus, we check that we are at end of line, and if not, insert a newline. (if (not (string-equal (buffer-substring (point) (1+ (point))) "\n")) (insert "\n")) (setq number (1+ number)))) (setq case-fold-search old-case-fold-search))))) (defun renumber-slides (&optional arg) "Install a comment marking the slide number on each \\begin{note}, \\begin{overlay}{}, or \\begin{slide}{}; any existing comment is replaced. An optional numeric argument is used as the slide starting number (default 1). Bound to \\\\[renumber-slides]. Slides are numbered with ascending integers, like 1, 2, 3, ... Notes are numbered 3-1, 3-2, 3-3, ... with the corresponding slide number before the hyphen. Overlays are numbered 4-a, 4-b, 4-c, ... with the corresponding slide number before the hyphen. This command is useful for setting values in the \\onlyslides{} and \\onlynotes{} macros; the slide numbers inserted in the comments can be used as arguments to those macros. For notes and overlays, only the major slide number is used; the minor number or letter must not be specified in those macros." (interactive) (setq arg (internal-LaTeX-default arg 1)) (save-excursion (goto-char (point-min)) (let ( (last-note-number 0) (last-overlay-number 0) (line) (number arg)) (while (re-search-forward SLiTeX-begin-slide nil t) (setq line (buffer-substring (match-beginning 0) (match-end 0))) (zap-to-char 1 ?\n) ;remove rest of line (cond ((string-match "note" line) (setq last-note-number (1+ last-note-number)) (insert (format " %% note number %d-%d" (1- number) last-note-number))) ((string-match "overlay" line) (setq last-overlay-number (1+ last-overlay-number)) (insert (format " %% overlay number %d-%c" (1- number) (+ ?a last-overlay-number -1)))) ((string-match "slide" line) (setq last-note-number 0) (setq last-overlay-number 0) (insert (format " %% slide number %d" number)) (setq number (1+ number)))) ;; In emacs 18, zap-to-char did not kill newline; it emacs 19, it does. ;; Thus, we check that we are at end of line, and if not, insert a newline. (if (not (string-equal (buffer-substring (point) (1+ (point))) "\n")) (insert "\n")))))) (defun renumber-tables (&optional arg) "Install a comment marking the table number on each \\begin{table}; any existing comment is replaced. An optional numeric argument is used as the table starting number (default 1). Bound to \ \\\\[renumber-tables]. This command is useful for attaching table numbers to the input file to make it easier to match it with the typeset output." (interactive) (setq arg (internal-LaTeX-default arg 1)) (save-excursion (goto-char (point-min)) (let ((old-case-fold-search case-fold-search) (line) (number arg)) (unwind-protect (progn (setq case-fold-search nil) (while (re-search-forward LaTeX-begin-table nil t) (setq line (buffer-substring (match-beginning 0) (match-end 0))) (zap-to-char 1 ?\n) ;remove rest of line (insert (format " %% table number %d" number)) ;; In emacs 18, zap-to-char did not kill newline; it emacs 19, it does. ;; Thus, we check that we are at end of line, and if not, insert a newline. (if (not (string-equal (buffer-substring (point) (1+ (point))) "\n")) (insert "\n")) (setq number (1+ number)))) (setq case-fold-search old-case-fold-search))))) (defun show-LaTeX-bibtags () "Show a list of all bibtags. These are determined by update-LaTeX-bibtags." (interactive) (with-output-to-temp-buffer "*Bibtags*" (message (format "There are %d LaTeX bibtags for buffer %s" (length LaTeX-bibtags) (buffer-name (current-buffer)))) (display-completion-list (mapcar 'car LaTeX-bibtags)) (save-excursion (set-buffer "*Bibtags*") (goto-char (point-min)) (flush-lines ;remove extraneous lines "^Possible completions are:\\|^Click.*on a completion to select it\\|^ *$") (goto-char (point-max)) (newline) (toggle-read-only)))) (defun show-LaTeX-labels (&optional nosort) "Show a list of all \\label{...} values found in the buffer. These are normally displayed sorted alphabetically. An argument will suppress the sorting, causing the labels to be presented in their order in the buffer." (interactive) (setq nosort (internal-LaTeX-default nosort nil)) ;; initialize the global occur-mode variables that record the state ;; of the matches. LaTeX-labels-occur-pos-list is a list of elements of the ;; form #. (setq LaTeX-labels-occur-pos-list ()) ; initially no matches in list (setq LaTeX-labels-occur-buffer (current-buffer)) ; buffer in which matches were found ;; collect the labels, optionally sort them alphabetically, and ;; display in a temporary buffer (let ((labels)) (with-output-to-temp-buffer "*LaTeX Labels*" (save-excursion (set-buffer standard-output) (occur-mode) (local-set-key "\C-c\C-c" 'occur-mode-extended-goto-occurrence) (if (not (string-lessp (substring emacs-version 0 2) "19")) (local-set-key [mouse-2] 'occur-mode-mouse-goto))) (princ (format "LaTeX labels for buffer %s (in %s order). %sC-c C-c goes to label.\n" (buffer-name (current-buffer)) (if (null nosort) "alphabetical" "line-number") (if (string-lessp (substring emacs-version 0 2) "19") "" "Mouse-2 or "))) (setq labels (internal-LaTeX-collect-labels)) (if (null nosort) (setq labels (sort labels '(lambda (a b) (string-lessp (car a) (car b)))))) (mapcar 'internal-LaTeX-label-string labels))) (setq LaTeX-labels-occur-pos-list (nreverse LaTeX-labels-occur-pos-list)) ;; set for occur-mode in the label buffer, with our own function ;; for jumping to labels in the original buffer (save-excursion (set-buffer "*LaTeX Labels*") (toggle-read-only))) (defun update-LaTeX-bibtags (auxfilename) "Create a list of defined BibTeX citation tags from the bibliographies recorded in a \\bibdata{...} or \\bibliography{...} command, saving it in the variable LaTeX-bibtags, with duplicates removed. This function is automatically invoked by LaTeX-mode when a \\documentstyle{} command is found. If you work on a multi-file document, run this command manually on the master file so that LaTeX-bibtag-with-completion (on \\\\[LaTeX-bibtag-with-completion]) will have access to the complete set of defined tags, and can offer completion on them for you. Bibliography files are found by searching the colon-separated list of directories in the search path defined by the BIBINPUTS environment variable, or if that is not defined, the Emacs LaTeX-BIBINPUTS variable." (interactive ;prompt for an existing file (list (read-file-name (concat "Master .aux file (default " (file-name-sans-extension (file-name-nondirectory buffer-file-name)) ".aux) ") default-directory (concat (file-name-sans-extension buffer-file-name) ".aux") t))) (setq auxfilename (expand-file-name auxfilename)) (if (file-readable-p auxfilename) (progn (save-excursion (let ((tmpbuf) (bibfiles) (file) (k 1) (old-default-directory default-directory)) (setq tmpbuf (generate-new-buffer "*update-LaTeX-bibtags*")) (set-buffer tmpbuf) ;local to this function only (insert-file-contents (expand-file-name auxfilename)) ;; temporarily make "." mean the directory of the .aux file because ;; otherwise, it will be the global default directory which may not be ;; the one containing the .bib file(s) (setq default-directory (file-name-directory auxfilename)) (goto-char (point-min)) (if (re-search-forward "\\\\\\(bibliography\\|bibdata\\)[ \t]*{\\([^}]*\\)}" nil t) (progn (setq bibfiles (mapcar '(lambda (s) (concat s ".bib")) (LaTeX-split-string (buffer-substring (match-beginning 2) (match-end 2)) ","))) (setq LaTeX-bibtags nil) (while (and bibfiles (setq file (expand-file-name-in-path (or (getenv "BIBINPUTS") LaTeX-BIBINPUTS) (car bibfiles)))) (message "[%d] extracting BibTeX citation tags from %s" k file) (setq k (1+ k)) (setq LaTeX-bibtags (append LaTeX-bibtags (internal-LaTeX-collect-bibtags file))) (setq bibfiles (cdr bibfiles))) (setq LaTeX-bibtags (internal-LaTeX-sort-alist LaTeX-bibtags)))) (kill-buffer tmpbuf) (setq default-directory old-default-directory) (message "[done]")))))) (defun update-LaTeX-labels (auxfilename) "When multi-file documents are prepared, it is impractical to search each source file for \\label{} definitions, but the master .aux file has them recorded in \\newlabel{}{} commands. This command creates a list of defined \\label{} tags from the .aux file, adding it to the current contents of LaTeX-aux-file-label-tags, with duplicates removed. If you work on a multi-file document, run this command manually on the master file so that LaTeX-pageref-with-completion and LaTeX-ref-with-completion will have access to the complete set of defined tags, and can offer completion on them for you. Those functions automatically append the contents of LaTeX-aux-file-label-tags to the list obtained from the current buffer." (interactive ;prompt for an existing file (list (read-file-name (concat "Master .aux file (default " (file-name-sans-extension (file-name-nondirectory buffer-file-name)) ".aux) ") default-directory (concat (file-name-sans-extension buffer-file-name) ".aux") t))) ;; auxfilename comes back unexpanded, so normalize it immediately (setq auxfilename (expand-file-name auxfilename)) (if (file-readable-p auxfilename) ;; We load the .aux file into a temporary buffer, and delete all ;; but the lines with "\newlabel{..tag..}{{..sect..}{..page..}}" ;; in them. We remove everything but the tags, leaving them one ;; per line, and then loop over the buffer, picking them up and ;; adding new ones to LaTeX-aux-file-label-tags. Finally, we ;; sort the strings for the convenience of the user who looks at ;; the value of the variable. (progn (save-excursion (let ((tmpbuf) (bol)) (setq tmpbuf (generate-new-buffer "*update-LaTeX-labels*")) (set-buffer tmpbuf) ;local to this function only (insert-file-contents (expand-file-name auxfilename)) (goto-char (point-min)) (keep-lines "\\\\newlabel") ;remove all but \newlabel{}{} lines (goto-char (point-min)) ;then remove all but first arg == tag (replace-regexp "\\\\newlabel{\\([^{]*\\)}.*" "\\1") (goto-char (point-min)) (while (< (point) (point-max)) (setq bol (point)) (end-of-line) (if (not (assoc (buffer-substring bol (point)) LaTeX-aux-file-label-tags)) (setq LaTeX-aux-file-label-tags (nconc LaTeX-aux-file-label-tags (list (list (buffer-substring bol (point))))))) (forward-line 1)) (kill-buffer tmpbuf) (setq LaTeX-aux-file-label-tags (internal-LaTeX-sort-alist LaTeX-aux-file-label-tags))))))) ;;; ==================================================================== ;;; Function to put LaTeX indexing commands on mouse sweep. The index ;;; entry starts at mouse down, and ends at mouse up. If the ;;; mouse-down region is empty, no index is inserted. Following the ;;; convention of emacs/lisp/x*.el files, these functions and ;;; variables are prefixed by "x-". Note that we only try to load ;;; x-mouse if window-system is X and emacs is version 18 or earlier ;;; This avoids the load dying with a reference to an unbound variable ;;; window-system-version. (defvar x-LaTeX-index-start-pos nil "Position of start of phrase to be indexed. Set by x-LaTeX-index-start.") (if (string-lessp (substring emacs-version 0 2) "19") (progn ;; indexing functions and mouse binding for emacs 18 or earlier (if (and (boundp 'window-system) (equal window-system 'x) (not (boundp 'epoch::version)) (load "x-mouse" t t nil)) ;needed for following mouse-map bindings (progn (define-key mouse-map x-button-s-right 'x-LaTeX-index-start) (define-key mouse-map x-button-s-right-up 'x-LaTeX-index-end))) (defun x-LaTeX-index-start (arg) "Start a LaTeX index entry at the precise character where the mouse down action occurs. Normally bound to shift-right-button-down." (x-mouse-set-point arg) (message (format "Indexing: %s..." (buffer-substring (point) (+ 5 (point))))) (setq x-LaTeX-index-start-pos (point))) (defun x-LaTeX-index-end (arg) "End a LaTeX index entry at mouse up. The index entry is automatically extended to the end of the current word, so you don't have to be precise in mouse positioning. Normally bound to shift-right-button-up." (x-mouse-set-point arg) (cond ((< (point) x-LaTeX-index-start-pos) (internal-x-LaTeX-index-mark (point) x-LaTeX-index-start-pos)) ((> (point) x-LaTeX-index-start-pos) (internal-x-LaTeX-index-mark x-LaTeX-index-start-pos (point)))))) ;; indexing functions for emacs 19 or later (defun x-LaTeX-index-start (click) "Start a LaTeX index entry at the precise character where the mouse down action occurs. Normally bound to \\[x-LaTeX-index-start]." (interactive "e") (mouse-set-point click) (message (format "Indexing: %s..." (buffer-substring (point) (+ 5 (point))))) (setq x-LaTeX-index-start-pos (point))) (defun x-LaTeX-index-end (click) "End a LaTeX index entry at mouse up. The index entry is automatically extended to the end of the current word, so you don't have to be precise in mouse positioning. Normally bound to \\[x-LaTeX-index-end]." (interactive "e") (mouse-set-point click) (cond ((< (point) x-LaTeX-index-start-pos) (internal-x-LaTeX-index-mark (point) x-LaTeX-index-start-pos)) ((> (point) x-LaTeX-index-start-pos) (internal-x-LaTeX-index-mark x-LaTeX-index-start-pos (point)))))) ;; This function must come last since it may load ltxmenu which refers ;; symbols above; unless they are already defined, some of the menu ;; items become inoperative. (defun LaTeX-x-window-setup () "When a window system is available, provide pop-up menus attached to a mouse button (emacs 18 or earlier), or to the top-of-screen menu bar (emacs 19 or later). Otherwise, do nothing at all." (interactive) (if (and (not (boundp 'epoch::version)) (boundp 'window-system) window-system) (if (string-lessp (substring emacs-version 0 2) "19") (progn ;emacs 18 or earlier (load "latex-menu" t t nil) (LaTeX-x-environment) (message "Popup menus bound to Control-left-mouse-button")) (progn ;emacs 19 or later (load "ltxmenu" t t nil))))) ;;; latex.el ends here