Installing AUCTex with EmacsW32

Here is part two of my quest to make Emacs my default LaTex IDE on both windows and Linux. Installation and configuration of Emacs and the LaTex add-on AUCTex on Ubuntu was surprisingly easy and uneventful. On windows however I ran into little bit more difficulty.

Of course I could download the precompiled Emacs + AUCTex bundle from the AUCTex website but I wasn’t really thrilled about that. You see, I was already had a nice copy of Emacs on my system – on windows I’m using EmacsW32. What is the difference you ask?

Well, EmacsW32 comes with a nice MSI installer that adds all sorts of registry hooks that make it act as a first class Windows application. It also makes the GUI look more polished and native. I prefer it to other ways of getting Emacs on windows because I get an up to date binaries that work right out of the box.

AUCTex unfortunately does not ship binaries you could just “plug” into place so I had to download the sources and compile them. Compiling? From Source? On windows? Yup, that’s what I said. I can sees shock and disgust sweeping all over your faces. Before you run away let me assure you it’s easy as pie. Well, at least it was for me.

You will need a working copy of gcc and make. How do you get them on Windows? You could always get the MSYS from MinGW. Since I didn’t have MSYS but had a working Cygwin installation I used that. I simply pulled up my cygwin bash sell and did:

$ ./configure	--prefix='c:/Program Files/Emacs/emacs/' 
		--with-texmf-dir='c:/Program Files/MiKTeX 2.5' 
		--with-lispdir='c:/Program Files/Emacs/site-lisp'
$ make
$ make install

You may want to tweak the parameters for the configure script with appropriate paths. As you can see I’m using MiKTeX 2.5 on my machine. If you are using something else, you should probably change that line. Also, if you are not using EmacsW32 then you might need to change the –prefix and –with-lispdir lines to point them to your emacs installation directory. If you get an error, tweak the parameter or download dependencies and try again.

I really had no dependency problems or anything but I don’t remember what exactly did I have in my Cygwin install. It’s possible that you may need to download a package or two like maybe the cygwin Emacs version. Before you ask – I don’t use the cygwin version of Emacs because I don’t feel like running a full instance of X server for the GUI. Besides, EmacsW32 is much more responsive being that it is a native app and all.

Note that I’m using the Windows path notation with inverted searator specifying the drive as c:/ instead of the cygwin notation /cygdrive/c/. Your cygwin installation should be able to map C:/ to /cygdrive/c/. If not you may need to adjust this. If you installed your cygwin in C:\ instead of C:\cygwin then you can just use / to indicate the root drive. This is actually the “smart” way to use cygwin – Steve Yagge says so, and when Steve says something you better listen and take fucking notes.

The make install command should seamlessly slip AUCTex files into your EmacsW32 directory. Unfortunately, you will need to configure your emacs manually to use them. How to do this?

Open up your C:\Program Files\Emacs\site-lisp directory and edit site-start.el file. Add the following lines somewhere:

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(require 'tex-mik)
(eval-after-load 'info
       '(add-to-list 'Info-directory-list "c:/Program Files/Emacs/share/info"))
(setq TeX-auto-save t)
(setq TeX-parse-self t)

I actually got this snippet from Oliver Sturm who figured this configuration before me.

When I tried to use the inline preview feature of AUCTex it did not work for me. It game me some odd message saying that “gs” is not a recognized command or something like that. It turns out that it was right. On windws the default ghostscript binary is not called gs but gswin32c.exe. You will need to change this – simply open some LaTex file, pull down the Preview menu, go to Customize and find the GS Command option. Set it to: C:\Program Files\gs\gs8.54\bin\gswin32c.exe. Make sure you are not using the C:\Program Files\Ghostgum\gsview\gsview32.exe binary. That is the default windows DVI viewer which ships with Ghostscript and many people confuse the two.

All that was left was to add a command to convert the DVI files into PDF. AUCTex already ships with a DVI to PS script under Command called FILE (yeah, go figure why they called it that). I simply added the following to my .emacs:

(eval-after-load "tex"
  '(add-to-list 'TeX-command-list
                '("DVI to PDF" "dvipdfm %d" TeX-run-command t t) t))

This will add a DVI to PDF option in the Command menu which will let you generate pdf files.

So, was this really hard? I thought it was a piece of cake, compared to for example setting up that nethack server.

Happy Emacsing everyone!

[tags]emacs, emacsw32, auctex, windows[/tags]

This entry was posted in Uncategorized. Bookmark the permalink.



11 Responses to Installing AUCTex with EmacsW32

  1. mks COSTA RICA Mozilla Firefox Windows says:

    Hi.

    When i try to run the ./configure…. appears this message:

    checking for make... no
    configure:error:make not found, aborting!

    i don’t know what is the problem.

    Thanks a lot.

    PD: Sorry for my English.

    Reply  |  Quote
  2. Luke Maciak UNITED STATES Mozilla Firefox Windows Terminalist says:

    It meeds you need to install the make package – you know, the one you use to build software from source. ;)

    If you are on Ubuntu/Debian you can just try:

    aptitude install make

    or

    apg-get install make

    On Fedora/Red Hat you can do:

    yum install make

    On Mandriva you can do:

    urpmi make

    I’m pretty sure you are not on Gentoo because then you would have to have make installed by default for emerge to even work properly. :)

    These commands will download and install the package and dependencies for you. There might be quite a few. In fact you will likely find more errors like this when running configure – it just means you need to track down the necessary packages and install them prior to compiling. :)

    Reply  |  Quote
  3. Luke Maciak UNITED STATES Mozilla Firefox Windows Terminalist says:

    Oh, wait… Are you using Cygwin? I thought this was the Linux based thread. If you are using Cygwin then you have to use Setup.exe (the same one you used to install it initially – or you can re-download it from the website) and then just pick make from the list of packages.

    Reply  |  Quote
  4. mks COSTA RICA Mozilla Firefox Windows says:

    Hi, again

    I installed de make package, but now appears this.

    checking if C:\Programs......\Emacs\emacs\bin is XEmacs... cat ./conftest -1648: No such file or directory
    configure:error:Unable to run C:\Programs....\Emacs\emacs\bin, aborting!
    

    I am using cygwin, with ghostscript and Miktex 2.5. Besides, I putted bin’s directions (Miktex, Ghostscript and emacs) in the path of windows.

    Thanks a lot.

    Reply  |  Quote
  5. Luke Maciak UNITED STATES Mozilla Firefox Windows Terminalist says:

    Have you tried pointing it to C:\Program Files\Emacs\emacs instead? I’m guessing it wants the path to the emacs installation folder, not to the bin folder.

    Are you using these attributes for running configure?

    $ ./configure	--prefix='c:/Program Files/Emacs/emacs/' 
    		--with-texmf-dir='c:/Program Files/MiKTeX 2.5' 
    		--with-lispdir='c:/Program Files/Emacs/site-lisp'

    Also, make sure that EmacsW32 is indeed installed in C:\Program Files\Emacs. :)

    Reply  |  Quote
  6. Pingback: Installing AUCTex with EmacsW32 [ Terminally Incoherent ] CANADA PHP

  7. U Avalos UNITED STATES Opera Linux says:

    Hi Luke, I just installed this beast on my windows box too. However, I’m using the version of emacs they recommend and I also tried NTemacs. Unfortunately, the rendered equations are all over the place — that’s not how it’s supposed to work right? The rendered equations are supposed to replace the LaTex code, right?

    Reply  |  Quote
  8. U Avalos UNITED STATES Mozilla Firefox Windows says:

    Wierd. It seems that “Preview at point” is what doesn’t work. “Preview document” works fine but when I “preview at point”, the images are put everywhere but the right place. Does “preview at point” work for you?

    Again, running the “official” emacs version AucTex recommends and also NTemacs… hoping that perhaps emacsw32 works better…

    Reply  |  Quote
  9. najmi MALAYSIA Mozilla Firefox Windows says:

    Hello,

    I’ve several tune up apart from your helpful writings.

    since using C:\ is rather “Windowish”, we may simply use:

    ./configure –prefix=/cygdrive/c/Program\ Files/Emacs/emacs/ –with-texmf -dir=/cygdrive/c/Program\ Files/MiKTeX\ 2.6/ –with-lispdir=/cygdrive/c/Program\ Files/Emacs/site-lisp/

    which will work the same way.

    Also, for the GS viewer, the location might as well at ;

    /cygdrive/c/Program\ Files/GPLGS/gswin32c.exe

    Reply  |  Quote
  10. Jisang Yoo REPUBLIC OF KOREA Google Chrome Windows says:

    I think I found a way to use the precompiled AUCTeX with EmacsW32. But first, I’ll explain why installation by compilation didn’t work for me.

    The cygwin way didn’t work for me. First error was that make was not found, like mks said above. So I installed cygwin’s make. But then another error: autoconf not found. So I installed autoconf. But then yet another error: (X)Emacs not found. At that moment, I gave up cygwin approach and tried with MSYS, as mentioned in the AUXTeX homepage.

    But MSYS compilation gave the same error: autoconf not found.

    So I downloaded the precompiled AUCTeX and decompressed the zip, and after reading el files in it and, I decided I had to add the following in my emacs initialization file:

    (load “c:/auctex-11.85-e23.1-msw/site-lisp/site-start.el”)
    (require ‘tex-mik)
    (eval-after-load ‘info
    ‘(add-to-list ‘Info-directory-list “c:/Program Files/Emacs/share/info”))
    (setq TeX-auto-save t)
    (setq TeX-parse-self t)

    It is the same initialization code in this blog post except for the load part. The path in the (load …) points to the site-start.el file in the precompiled AUCTEX files.

    Reply  |  Quote
  11. Thanks. That helped me sort out preview-mode on Windows. (Linux has always been easier for me.)

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *