Professional Documents
Culture Documents
Using Emacs in Windows To Type Latex and Program R
Using Emacs in Windows To Type Latex and Program R
1. INSTALL
- Download and install Emacs-modified (ESS, AUCTeX, and Aspell are included) http://vgoulet.act.ulaval.ca/en/ressources/emacs/ ESS: a package that supports R in Emacs AUCTeX: a package that supports Latex in Emacs Aspell: a package that supports spells checking in Emacs - Set default folder for R and Tex file Why do you need to set default folder? Example 1: If you put a data.txt file in the default folder, you do not need to type in browse when reading that file in R. Example 2: When you open a file in Emacs, Emacs will start in the default folder first. How to set? 1. Creat Emacs shortcut on the Desktop 2. Right click on shortcut> Properties > Shortcut > Start in > browse to the default folder - Set default folder for Emacs. Every time Emacs run, it will load an initial file (.emacs file.) You can edit .emacs file to customize Emacs as you want. Where can it find .emacs file? You need to set default folder for Emacs, so it can find .emacs file. You will put your .emacs file in this folder. 1. My Computer>Properties>Advanced>Environment Variables>User variables 2. >HOME -> Any folder, example D:\Latex HOME is default folder for Emacs. - Help Emacs find Ghostscript and GSView. 1. My Computer>Properties>Advanced>Environment Variables>System variables 2. >Path -> add below line to Path ;C:\Program Files\gs\gs8.63\bin;C:\Program Files\gs\gs8.63\lib;C:\Program Files\Ghostgum\gsview - Download this .emacs file and copy to HOME folder
- Install cdlatex (autocomplete for Latex) Download and copy cdlatex.el to C:\Program Files\GNU Emacs\site-lisp Add this line to .emacs (I have done that in the attached .emacs file) (load "cdlatex.el") (autoload 'cdlatex-mode "cdlatex" "CDLaTeX Mode" t) (autoload 'turn-on-cdlatex "cdlatex" "CDLaTeX Mode" nil) (add-hook 'LaTeX-mode-hook 'turn-on-cdlatex) See http://github.com/kjhealy/emacs-starter-kit/blame/master/kjhealy.el - Inverse search in dvi mode http://www.emacswiki.org/emacs/AUCTeX > Using Yap under MikTeX - Log out of windows to finish installation. Log in and youre done.
R
ESS reference card: ess.r-project.org/refcard.pdf
AUCTeX
y Reference card: mirrors.usc.edu/pub/gnu/auctex/11.81-extra/tex-ref.pdf Note: Because we use Cdlatex, we must turn off math mode (default is off) of AUCTeX to avoid conflict. Many functions in the above reference card do not work when we install Cdlatex. Cdlatex use other keyboard shortcut for the same function. For example: to insert equation, AUCTeX use C-c C-e, but Cdlatex use equ-tab. y We will install Cdlatex to use a lot of function instead of using those of AUCTeX.
- cdlatex ref card http://www.kirp.chtf.stuba.sk/~fikar/texem/emacs/cdlatex.txt - Turn off math-mod of AuCTEX when using CDLatex. - If you type ( and want autocomplete for ), open cdlatex.nl by notepad, find and edit this line from (defcustom cdlatex-paired-parens "$[{" to (defcustom cdlatex-paired-parens "$[{(" y Some common use keyboard-combination:
- Tab: as in Emacs, press tab everywhere for autocomplete. - Preview C-c C-p C-p. Now move cursor to one of the formulas to toggle. - C-c C-c: compile latex code (default is latex, but you can type L, press tab to autocomplete to Latex, press enter to run), run BibTex (type B and press tab, enter) or viewer (type V and press tab, enter) - C-c C-v: view in dvi or pdf viewer - C-c C-t C-p : switch between pdf and dvi mode (pdf to dvi, or dvi to pdf)
- C-c %: add or remove % from the beginning of each line in the current paragraph. - C-c ;: Add or remove % from the beginning of each line in the current region.
bibtex tip
http://www.math.uiuc.edu/~hildebr/tex/bibliographies.html y - Install: Add this line to .emacs file (I have done that in the attached .emacs file, but you have to edit the following lines /PATH/TO/YOUR/TEX/DOCUMENTS// and /PATH/TO/YOUR/BIB/FILE/ RefTex
;;-------------------------------------------;; RefTeX ;;-------------------------------------------(add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq reftex-plug-into-AUCTeX t) (setq reftex-enable-partial-scans t) (setq reftex-save-parse-info t) (setq reftex-use-multiple-selection-buffers t) (setq reftex-texpath-environment-variables '("./inp:/PATH/TO/YOUR/TEX/DOCUMENTS//")) (setq reftex-bibpath-environment-variables '("/PATH/TO/YOUR/BIB/FILE/")) - Using See cdlatex reference card. For example, type ref and press tab. http://www.gnu.org/software/auctex/manual/reftex.html#SEC9
4. More
1. Emacs http://xahlee.org/emacs/emacs.html 2. ESS for R ESS user guide 3. AUCTeX