Switching from xelatex to latex under AUCTeX

143 views
Skip to first unread message

Haines Brown

unread,
May 26, 2012, 2:39:17 PM5/26/12
to latexus...@googlegroups.com
This is a very simple question, but so far have not found an answer.

In .emacs, if I have the line (setq TeX-engine 'xetex), I can run the
C-c C-c latex command on a xetex file, but I can't run C-c C-c latex
on a file marked up for LaTeX. If I comment that line, I can run C-c
C-c latex on a LaTeX file, but AUXTeX now does not understand a
xelatex command and a latex command produces errors.

If I run latex and xelatex commands on the two kinds of file from a
terminal, there's no problem.

How do I initialize emacs so that under AUCTeX I can run the latex
command on a file marked up as LaTeX and xelatex on a file marked up
as XeTeX without editing the .emacs file and reloading emacs?

Haines Brown

Peter Flynn

unread,
May 26, 2012, 5:29:24 PM5/26/12
to latexus...@googlegroups.com

It would depend on how you are asking (or expecting) Emacs to recognise the markup (ie, how to distinguish between a LaTeX document and a XeTeX document). I don't know enough about XeTeX to be able to tell the difference. If there is some machine-readable metadata — like the way a LaTeX document begins with \documentclass — then it should be possible to add something to your .emacs to do it.

However, I have had very bad experiences indeed with AUCTeX. It performs some very deep surgery indeed on your system, irrecoverably overwriting large parts of your Emacs settings (that is, you can't retreat from it simply by uninstalling it), and usurping the keystrokes which enable normal LaTeX processing. I think the only people who would be able to do what you are asking are the Emacs gureaux who wrote AUCTeX itself.

///Peter

Haines Brown

unread,
May 27, 2012, 6:00:27 AM5/27/12
to latexus...@googlegroups.com
On Sat, May 26, 2012 at 10:29:24PM +0100, Peter Flynn wrote:
> On Sat, May 26, 2012 at 7:39 PM, Haines Brown <hai...@histomat.net> wrote:
>
> > How do I initialize emacs so that under AUCTeX I can run the latex
> > command on a file marked up as LaTeX and xelatex on a file marked
> > up as XeTeX without editing the .emacs file and reloading emacs?

> It would depend on how you are asking (or expecting) Emacs to
> recognise the markup (ie, how to distinguish between a LaTeX
> document and a XeTeX document).

Thanks, Peter, but I'm not so ambitious. Nice idea, but I don't expect
emacs or AUCTeX to distinguish a LaTeX and XeTeX document, but only to
act on whichever command I issue, whether it be latex or xelatex.
Surely there are others who need to process both LaTeX and XeLaTeX documents.

It seems the default Tex-engine value is latex. It can be changed to
xelatex in the .emacs init file with (setq TeX-engine 'xetex). What I'm
after is something that would have the effect of (setq TeX-engine 'none).

In AUCTeX configuration, for TeX Engine, there is a choice of Default,
LuaTeX, Omega, XeTeX. But I don't want AUCTeX or .emacs init to decide
what engine is used, but simply to use the engine I call with C-c C-c.
Here, again, I'd choose "none" if it were in the list.

Haines

Peter Flynn

unread,
May 27, 2012, 7:45:02 AM5/27/12
to latexus...@googlegroups.com
On Sun, May 27, 2012 at 11:00 AM, Haines Brown <hai...@histomat.net> wrote:
On Sat, May 26, 2012 at 10:29:24PM +0100, Peter Flynn wrote:
> On Sat, May 26, 2012 at 7:39 PM, Haines Brown <hai...@histomat.net> wrote:
>
> > How do I initialize emacs so that under AUCTeX I can run the latex
> > command on a file marked up as LaTeX and xelatex on a file marked
> > up as XeTeX without editing the .emacs file and reloading emacs?

> It would depend on how you are asking (or expecting) Emacs to
> recognise the markup (ie, how to distinguish between a LaTeX
> document and a XeTeX document).

Thanks, Peter, but I'm not so ambitious. Nice idea, but I don't expect
emacs or AUCTeX to distinguish a LaTeX and XeTeX document, but only to
act on whichever command I issue, whether it be latex or xelatex.
Surely there are others who need to process both LaTeX and XeLaTeX documents.

Sorry, my misunderstanding. As I understood it from Ulrike on c.t.t, the problem is that AUCTeX itself is conflating the latex and xelatex commands, so the place to solve this is in the auctex.el code.

This is nastily reminiscent of my scream of pain last week on discovering that Emacs under Ubuntu 12.04 (well, debian, really) has stomped all over xml-mode and equated it to nxml-mode, which is not suitable for text document work.

Try opening a LaTeX document, typing M-x tex-mode RET, closing the document and then re-opening it and typing M-x latex-mode RET and see if that brings the old binding back into play. This "reversion" method worked with sgml-mode and xml-mode, because the new association with nxml-mode could be overridden with the association to sgml-mode, which invoked the old psgml-mode (where xml-mode lives) without touching the new binding. There may be some similar kludge to get you back into distinguishing between latex and xelatex.
 
It seems the default Tex-engine value is latex. It can be changed to
xelatex in the .emacs init file with (setq TeX-engine 'xetex). What I'm
after is something that would have the effect of (setq TeX-engine 'none).

In AUCTeX configuration, for TeX Engine, there is a choice of Default,
LuaTeX, Omega, XeTeX. But I don't want AUCTeX or .emacs init to decide
what engine is used, but simply to use the engine I call with C-c C-c.
Here, again, I'd choose "none" if it were in the list.

You mean you want to type C-c C-c and then type in the engine you want used for that particular occasion (or have a prompt appear)?  That should certainly be doable in the .emacs file by a suitably cunning elisp hacker.

Have they left C-c C-f untouched from latex-mode, I wonder? I do truly hate what AUCTeX does to the interface...

///Peter

Haines Brown

unread,
May 27, 2012, 10:57:47 AM5/27/12
to latexus...@googlegroups.com
On Sun, May 27, 2012 at 12:45:02PM +0100, Peter Flynn wrote:
> On Sun, May 27, 2012 at 11:00 AM, Haines Brown <hai...@histomat.net> wrote:
>
> > On Sat, May 26, 2012 at 10:29:24PM +0100, Peter Flynn wrote:
> > > On Sat, May 26, 2012 at 7:39 PM, Haines Brown <hai...@histomat.net>
> > wrote:
> > >
> > > > How do I initialize emacs so that under AUCTeX I can run the latex
> > > > command on a file marked up as LaTeX and xelatex on a file marked
> > > > up as XeTeX without editing the .emacs file and reloading emacs?

> Try opening a LaTeX document, typing M-x tex-mode RET, closing the document
> and then re-opening it and typing M-x latex-mode RET and see if that brings
> the old binding back into play.

This only worked to the extent that while the default engine can be
specified to be xelatex and I can run the latex command despite that,
AUCTeX no longer knows the xelatex command.

However, subsequently I may have solved the problem: I simply
customized AUCTeX by adding xelatex to the command list. An initial
test shows I can now run the latex command on a latex file and the
xelatex command on a xelated file.

Sorry to have inadvertantly raised an issue about AUCTeX rather than
TeX markup.

Haines Brown

Peter Flynn

unread,
May 27, 2012, 5:53:49 PM5/27/12
to latexus...@googlegroups.com
On Sun, May 27, 2012 at 3:57 PM, Haines Brown <hai...@histomat.net> wrote:
[...]

However, subsequently I may have solved the problem: I simply
customized AUCTeX by adding xelatex to the command list. An initial
test shows I can now run the latex command on a latex file and the
xelatex command on a xelated file.

Sorry to have inadvertantly raised an issue about AUCTeX rather than
TeX markup.

On the contrary, it's always good to learn about how other people do things.
I had no idea that AUCTeX had a command list, in that sense.

///Peter

Reply all
Reply to author
Forward
0 new messages