## Wednesday, February 1, 2012

### Installing AucTeX and Preview LaTeX on Windows

So, I upgraded my Emacs to the latest version and went through the steps of compiling my elisp packages on my Windows XP laptop and promptly struggled a bit on getting Auctex and Preview LaTeX to work.  I've decided on documenting it; well, only the key steps with a lot of hand waving and assumptions thrown in.

Namely,

Cygwin toolchains are installed(that's what I have)
MiKTeX is installed(whatever version)
Win32 Emacs from the official GNU site (I used 23.4)
Ghostscript is installed too (I used the cygwin based one)

In the cygwin terminal, either checkout the cvs version of Auctex or download the tarballs and untar it somewhere.  Presumably you have MiKTeX and Emacs installed already somewhere; preferably in a folder path that doesn't contain spaces in it's name(It should work with spaces in the path name but I haven't and daren't try that; I really don't need that aggravation).

First you run configure to generate the Makefile

./configure --with-emacs=c:/gnu/emacs-23.4/bin/emacs --prefix=c:/gnu --with-texmf-dir=c:/MiKTeX2.9

If you haven't got all the build tools needed (make, install, latex,perl..) it will stop.  Fix each one of them by installing the necessary packages by using the cygwin package manager setup.exe. Of course, you need to adjust the paths above.

By default, the preview build is enabled by default, which, you can disable by adding the option --disable-preview to configure above, if you don't want to preview your latex document that's got figures and maths.

When the Makefile is generated, run make.  Do not do a make install.  You can use the files in situ by following the instructions of Tassilo Horn here.   You'd probably need to add the following to get the correct info files of Auctex.

;; AUC TeX
;;set the path to info files of auctex
(setq Info-default-directory-list
(cons "c:/gnu/elisp/auctexcvs/auctex/doc" Info-default-directory-list))
I prefer it this way as this does not change the directory structure of a stock install of Emacs on Windows.  Easier to share the folders for someone to copy without borking something.

Navigate to the preview folder and load the circ.tex and compile it.  It should hopefully do so.

For preview you need the png or jpeg image support with Emacs. I've used the dlls mentioned in the Emacs README.w32 that are hosted on the GTK website. Specifically, the png and zlib ones that I downloaded and just dumped  in the Emacs bin directory.  Added the following to my .emacs

(setq preview-image-type 'png)

Ran the preview command on the circ.tex buffer and it showed the equations and images inline which is what it's supposed to do.  If you want jpeg support you'd have to get the jpeg dlls for win32 somewhere(the install files mentions gnuwin32 site)

Which is where I stop now as it all works fine and dandy for me.  The various install files tell you not to mix the cygwin paths and normal DOS paths and other such warnings.  But I haven't seen anything that has knackered my installation or borked my usage of them with different bits of win32 and cygwin tied together with AucTeX

So far.