Pense-W3ete du LAMI-MANTRA


Configuring Xemacs for Latex at Lami/Mantra

There are a few definitions you should add to your ~/.emacs file to make xemacs work properly in LaTeX-mode with our system configuration. All the following definitions should be added toward the end of the ~/.emacs file; in any case, after the following lines:

	;; ============================
	;; End of Options Menu Settings

  • Loading AucTex: AucTex is the package that adds support for LaTeX to xemacs. Load it with:
    (require 'tex-site)			;AucTex
    

    You may perhaps also wish to load other useful packages, such as Version Control support:
    (require 'vc)				; require version control support
    


  • Font Lock Configuration: If you wish LaTeX documents, once loaded, were automatically shown in colours, add the following lines:
    
    (add-hook   'LaTeX-mode-hook       	'turn-on-font-lock)        
    (add-hook   'TeXinfo-mode-hook     	'turn-on-font-lock)        
    (add-hook   'bibtex-mode-hook       	'turn-on-font-lock)       
    (add-hook   'tex-mode-hook             	'turn-on-font-lock)    
    (font-lock-use-default-maximal-decoration)
    


  • Outline mode: In xemacs, you can view LaTeX documents in outline mode, that is, with only sectioning lines such as \section, \subsection, etc. visible and not the text body. Selectively, you can "open" the sections and view/edit the text. To add support for this mode when loading a LaTeX file:
    
    					; use outline minor mode in LaTeX mode
    (add-hook 'TeXinfo-mode-hook 'outline-minor-mode)
    (add-hook 'LaTeX-mode-hook 'outline-minor-mode)
    
    I implemented a function to shrink completely a file and see only the outline the way I like:
    
    					; further function in outline
    (defun hide-all-leaves ()
      "Hide all leaves in the whole document."
      (interactive)
      (save-excursion
        (show-all)
        (goto-char (point-min))
        (while (outline-next-heading)
          (hide-leaves))
        (goto-char (point-max))
        (search-backward "^L" nil t) 
        (show-entry)
        (goto-char (point-min))
        )
      )
    

    (WARNING: in the search-backward command above there is a true control-L. If pasting from this screen, replace ^L in xemacs with C-q C-l.)
    Then, I like to open all LaTeX files automatically in "shrinked" mode and open up parts only if I wish (using function keys F1 to F4). Some people do not like this, but you may try it:
    
    					; use hide all leaves in LaTeX mode
    (add-hook 'TeXinfo-mode-hook 'hide-all-leaves)
    (add-hook 'LaTeX-mode-hook 'hide-all-leaves)
    
    (defun outline-minor-mode-personal ()
      "Outline Minor Mode personal key bindings."
      (define-key outline-minor-mode-map 'f1 'hide-leaves)
      (define-key outline-minor-mode-map 'f2 'show-entry)
      (define-key outline-minor-mode-map 'f3 'hide-all-leaves)
      (define-key outline-minor-mode-map 'f4 'show-all)
      )
    					; there is no outline-mode-hook ?!
    					; let's use the AucTeX ones, then
    (add-hook 'TeXinfo-mode-hook 'outline-minor-mode-personal)
    (add-hook 'LaTeX-mode-hook 'outline-minor-mode-personal)
    

    A final word concerning the way to write your LaTeX file. If you precede your sectioning command with a comment line, you get a more compact outline. Typically, you may write:
    
    %---------------------------------------------------------------------------
    \section{My beautiful section} \label{sec:beautiful}
    
    which also helps identifying sectioning commands in nonoutlined
    documents.
    


  • Configuring the printers: You should tell AucTex of the printers available at LAMI/MANTRA:
    
    (setq TeX-printer-list
          '(
    	("mantra")
    	("dilaser") 
    	("chagall")
    	("picasso")
    	("renoir")
    	("vangogh")
    	)
          )
    
    (setq TeX-printer-default "dilaser")
    

    Of course, you can change TeX-printer-default at your will.

  • Better comments: I prefer LaTeX comments to start with "% " instead of simply "%". For this:
    
    					; better TeX comments
    (defun set-TeX-comment-start ()
      "Overrides the contents of the variable comment-start in TeX documents."
      (setq comment-start "% ")
      )
    (add-hook 'TeXinfo-mode-hook 'set-TeX-comment-start)
    (add-hook 'LaTeX-mode-hook 'set-TeX-comment-start)
    


  • Ispell Configuration: Of course, this is not AucTex specific, but one often uses ispell with LaTeX files. Besides, I like M-s to check the spelling of the word under the cursor:
    
    					; ispell dictionaries definitions
    (setq ispell-dictionary-alist
          '(
    	(nil 
    	 "[A-Za-z]" "[^A-Za-z]" "[']" nil
    	 ("-B")
    	 nil)
    	("american" 
    	 "[A-Za-z]" "[^A-Za-z]" "[']" nil
    	 ("-B" "-d" "american")
    	 nil)
    	("english" 
    	 "[A-Za-z]" "[^A-Za-z]" "[']" nil
    	 ("-B")
    	 nil)
    	("british" 
    	 "[A-Za-z]" "[^A-Za-z]" "[']" nil
    	 ("-B" "-d" "british")
    	 nil)
    	("francais" 
    	 "[A-Za-zÀÂÆÇÈÉÊËÎÏÔÙÛÜàâçèéêëîïôùûü]" 
    	 "[^A-Za-zÀÂÆÇÈÉÊËÎÏÔÙÛÜàâçèéêëîïôùûü]" "[---']" t 
    	 nil 
    	 "~list")
    	("francais-tex" 
    	 "[A-Za-zÀÂÆÇÈÉÊËÎÏÔÙÛÜàâçèéêëîïôùûü\\]" 
    	 "[^A-Za-zÀÂÆÇÈÉÊËÎÏÔÙÛÜàâçèéêëîïôùûü\\]" "[---'^`\"]" t 
    	 ("-d" "francais")
    	 "~tex")
    	)
          )
    
          
    (define-key global-map '(meta s) 'ispell-word)
    
    

    American, British, and International English are self-explaining. There are two French dictionaries depending on the character set you are using. If you use the basic LaTeX way of coding accents (e.g., \'e for e acute), you must select "francais-tex". If you use the novel standard way of defining latin1 encoding in a LaTeX2e file (on a Sun, type Compose ' e for e acute), use "francais" dictionary. ispell does not support both types of codes in the same document. Just as a reminder, to use latin1 encoding in LaTeX2e document, add in the preamble of the LaTeX document:
    
    \usepackage[latin1]{inputenc}
    
  • Webster configuration Again, this is not AucTex specific, but the Webster is useful with LaTeX files. Similar to the M-s for ispell defined above, I like M-w to search in the Webster:
    
    					; webster definitions
    (define-key global-map '(meta w) 'webster)
    (defun webster-set-variables () 
      "Set Webster variables from WEBSTER_PATH in the shell environment." 
      (interactive)
      (string-match "\\([^@]*\\)@\\([^:]*\\)" (getenv "WEBSTER_PATH"))
      (setq webster-port (match-string 1 (getenv "WEBSTER_PATH")))
      (setq webster-host (match-string 2 (getenv "WEBSTER_PATH"))))
    (webster-set-variables)
    


  • Miscellanea: It is often useful to see in the bottom control bar of xemacs the current line number. For this:
    
    (setq line-number-mode t)
    


  • Multiple Latex file support: AucTex provides support for LaTeX documents whose sources spans over several files (theses, for instance... ;^) . It is nice to be able to do a C-c C-c (LaTeX command) in any dependent file and run the command on the primary file instead. To do this, add at the end of ALL .tex dependent files of a primary LaTeX document (named, for example, thesis.tex) the following lines:
    
    ^L
    % Local Variables:
    % TeX-master: "thesis.tex"
    % End:
    

    (WARNING: before the first line above there is a true control-L. If pasting from this screen, replace ^L in xemacs with C-q C-l.)

  • Further information You can read about all latex related commands in xemacs with:
    	C-h a latex RET
    

    Pour des commentaires et modifications adressez-vous à : Paolo Ienne López