Ads by Google

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.


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
(add-to-list 'load-path "C:/gnu/elisp/auctexcvs/auctex/")
(load "auctex.el" nil t t)
(add-to-list 'load-path "C:/gnu/elisp/auctexcvs/auctex/preview/")
(load "preview-latex.el" nil t t)
;;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.


Evgeny said...

There is no official binary builds of emacs beyond version 23.3.

sivaram said...

The binaries have been pulled temporarily as some users have reported a virus infection by their malware detectors. The developers have taken things down till they figure it's a false positive or not.

Alexander said...

The installation went fine but preview is not working for me. Asking for preview creates circ.dvi (and I see in the log that preview.sty is loaded) but then says "LaTeX found no preview images". Do you know where the images are supposed to be created and which commands create them? Thanks.

sivaram said...

err...without the version and other log information, it's hard to tell. But there are a lot of google hits on the term 'LaTeX found no preview images'


Check that first.

Alexander said...

It turned out that instead of "Preview Document" I should have used "Preview Buffer" or "Preview Section". Those two did not produce the error but at first resulted in empty boxes which I got rid of by following an advice I found on stackexchange. I summarized the process here.