Ads by Google

Sunday, March 30, 2008

Installing MikTeX with Emacs-22.1 and Cygwin

Since I decided to go with MikTeX, I downloaded and installed the base MikTeX package. The MikTeX install offers a net based install of additional packages that is easy to use. Install the additional packages that you'd generally use. Don't forget to refresh the FNDB to make sure that the package is registered with TeX (I think it's the equivalent of texhash.)

Open a cygwin prompt.

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/cygdrive/c/MiKTeX2.7/miktex/bin:

That will not help as the TeTeX binaries will be found before MikTeX. Change that by

$ PATH=/cygdrive/c/MiKTeX2.7/miktex/bin:$PATH
$export PATH
$ cd c:/gnu/elisp/auctex-11.85
$ ./configure --with-emacs=c:/gnu/emacs-22.1/bin/emacs --disable-preview \
--with-texmf-dir=c:/MiKTeX-2.7/miktex/tex/ --prefix=c:/gnu/ \
--with-lispdir=c:/gnu/emacs-22.1/site-lisp/
$ make
$make install

assuming that you have auctex tarball untarred already. You'd need to change the paths to point to your emacs, the MiKTeX tree and where you want the installation files to go. Obviously.

The configure script generates the Makefile and the echoed messages on the screen will tell where it is picking different binaries from. Check the Makefile carefully especially the installation paths of various auctex .el files.

I have these entries in my .emacs


(setq exec-path (cons "C:/gnu/bin/" exec-path))
(setq exec-path (cons "c:/cygwin/usr/bin" (cons "C:/cygwin/bin" exec-path)))
(setq exec-path (cons "C:/MiKTeX2.7/miktex/bin" exec-path))
(setenv "PATH" (concat "C:\\MiKTeX2.7\\miktex\\bin;C:\\cygwin\\bin;C:\\cygwin\\usr\\bin;
C:\\gnu\\bin\\;" (getenv "PATH")))

;; AUC TeX
(load "auctex.el" nil t t)
(require 'tex-mik)
;; ;;; some basic customizations
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; with AUCTeX LaTeX mode
(add-hook 'latex-mode-hook 'turn-on-reftex) ; with Emacs latex mode
(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)

Note that, I'm forcing emacs too, to look in the MikTeX distribution first for the respective binaries before looking under cygwin.

Testing these on a random tex file, it generated the output pdf.

Because I had both TeTeX and MikTeX installed, I wasn't sure which binaries would be picked up. The first time I tried, the PATH variable made TeTeX binaries as the values to various configure checks. I had to set the MikTeX path first to force it to choose MikTeX. And you get messages like this


checking for tex... /cygdrive/c/MiKTeX2.7/miktex/bin/tex
checking for pdftex... /cygdrive/c/MiKTeX2.7/miktex/bin/pdftex
checking for dvips... /cygdrive/c/MiKTeX2.7/miktex/bin/dvips
checking for perl... /usr/bin/perl
checking for makeinfo... /cygdrive/c/MiKTeX2.7/miktex/bin/makeinfo
checking for texi2html... /usr/bin/texi2html
checking for texi2dvi... /cygdrive/c/MiKTeX2.7/miktex/bin/texi2dvi
checking for texi2pdf... /usr/bin/texi2pdf
checking for install-info... /usr/bin/install-info
configure: creating ./config.status
config.status: creating Makefile
...
As you can see, there are binaries chosen from MikTeX as well as cygwin. If you have not chosen the TeTeX binaries during the cygwin install, there is a lot less to worry about. You'll have to force the configure script to find every binary it is looking for, from the MikTeX distribution.

And as far as possible, install the MikTeX in folders without spaces in the names. It would make things simpler.

That is pretty much it.