0% found this document useful (0 votes)
316 views

Using Emacs in Windows To Type Latex and Program R

This document provides instructions for configuring Emacs for LaTeX editing and R programming in Windows. It describes downloading and installing Emacs, AUCTeX, ESS, and other packages. It also explains how to set environment variables and default folders to allow Emacs to find files and customize settings. The document then provides a quick user guide summarizing common commands and functions for Emacs, AUCTeX, ESS, RefTeX, and spell checking.

Uploaded by

Trung Ha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
316 views

Using Emacs in Windows To Type Latex and Program R

This document provides instructions for configuring Emacs for LaTeX editing and R programming in Windows. It describes downloading and installing Emacs, AUCTeX, ESS, and other packages. It also explains how to set environment variables and default folders to allow Emacs to find files and customize settings. The document then provides a quick user guide summarizing common commands and functions for Emacs, AUCTeX, ESS, RefTeX, and spell checking.

Uploaded by

Trung Ha
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Using Emacs in Windows for Latex editing and R programming Suppose that you have R, Ghostscript, gsview, and

Miktek on your computer.

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.

2. QUICK USER GUIDE


Emacs
Note that C means Ctrl key, M means Alt key, RET means Return key, SPC means Space key. - Visual reference: http://www.stevenchan.us/files/Notesheet-Emacs.pdf - Auto-complete: press Tab Example: 1. C-x C-f (sometime, you can hold C, press x and then press f). Now Emacs starts in default folder for R and Tex file, and lets you choose a folder. Suppose that you have subfolder Learning in the default folder. 2. type Le 3. press Tab, Emacs will automatically complete Le, and you get Learning. - How do I swap CapsLock and Control? You use Ctrl key a lots in Emacs. Some people feel that it is more convenient to use CapsLock as Ctrl. http://www.gnu.org/software/emacs/windows/Installing-Emacs.html

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

Aspell (to check spelling)


- Install How to set aspell as default in .emacs (I have done that) http://aspell.net/man-html/Using-Aspell-withother-Applications.html How to set path to aspell in emacs http://xahlee.org/emacs/emacs_mswin.html "C:/Program Files/GNU Emacs/aspell/bin" You have to change browser for aspell in attached .emacs file. - Using http://www.gnu.org/software/emacs/manual/html_node/emacs/Spelling.html

4. More
1. Emacs http://xahlee.org/emacs/emacs.html 2. ESS for R ESS user guide 3. AUCTeX

http://www.gnu.org/software/auctex/manual/auctex.html For Emacs, ESS, AUCTeX and everything http://www.emacswiki.org/

You might also like