help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get xetex/xelatex option in the Emacs menu?


From: Teemu Likonen
Subject: Re: How to get xetex/xelatex option in the Emacs menu?
Date: Fri, 23 Apr 2010 21:23:20 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.96 (gnu/linux)

* 2010-04-23 10:54 (-0700), Tariq wrote:

> I would like to include in one of these menus (preferably under the
> Command menu) the option to run xetex/xelatex also so that I can use
> Emacs to compile XeLaTeX files.

You could do it with hook:


    (add-hook 'LaTeX-mode-hook #'my-latex-mode-hook)

    (defun my-latex-mode-hook ()
      (add-to-list 'TeX-command-list
                   '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t)))


The following is a fancier version of the hook. It sets XeLaTeX the
default compiler when it finds fontspec or mathspec package being loaded
with \usepackage{}.


    (defun my-latex-mode-hook ()
      (add-to-list 'TeX-command-list
                   '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
      (setq TeX-command-default
            (save-excursion
              (save-restriction
                (widen)
                (goto-char (point-min))
                (let ((re (concat "^\\s-*\\\\usepackage\\(?:\\[.*\\]\\)?"
                                  "{.*\\<\\(?:font\\|math\\)spec\\>.*}")))
                  (if (re-search-forward re 3000 t)
                      "XeLaTeX"
                    "LaTeX"))))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]