1

I'm using Emacs + Auctex to edit and compile file .tex with xelatex at present. I want put those auxiliary files(created during compile) in another directory, e.g. /tmp. So I have the following code in my init.el. But it does not work - auxilary files still are in root directory. What's wrong with my code and anyone can help me with this?

(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil  t))
(setq TeX-command-default "XeLaTeX -aux-directory=./tmp")
1

To add XeLaTeX explicitly in the TeX-command-list might get things to work (I haven't tried), but it is certainly not very "AUCTeXy", so to speak.

AUCTeX tries to guess the correct engine to be used (say, if you load fontspec it will ask you about it), and lets you set it for the current file easily, with local variables.

As to your use of TeX-command-default, as far as I understand, that is not what is expected there.

I suggest you make use of local variables to set this, instead of fiddling with your init file. And let AUCTeX do the hard work, as it does well.

You can add local variables to your file with M-x add-file-local-variable. You can add two: TeX-engine and TeX-command-extra-options. (You will be asked if these options should be run when you open the file, you may choose to save the option). You should end with something like the following at the bottom of your file:

% Local Variables:
% TeX-engine: xetex
% TeX-command-extra-options: "-aux-directory=./tmp"
% End:

(assuming "-aux-directory=./tmp" works. I can't test it here, I believe this is a MikTeX only option. It does work though with "-output-directory=./tmp".)

With that in place, build your document LaTeX (and whatever else is needed).

  • Thank you for your helpful proposal!! And if I want the name of directory which is used to store those auxilary files is the same as the name of master tex file, not just ./tmp, what shall I do? – lyl Mar 8 at 1:53
  • Well, per default, the aux files and output files will end up in the same directory as your .tex file. So, if you want that, simply do not use the option -aux-directory. – gusbrs Mar 8 at 1:58
  • Oh, I guess now I understand. Just put the name of the directory there, instead of tmp. – gusbrs Mar 8 at 2:00
  • Yes, if my master file names myname.tex, I want all the auxilary files are put in a directory named myname under the current path. Can I get this? – lyl Mar 8 at 4:16
  • I'd simply put there "-aux-directory=myname". It should work if you used "-aux-directory=%s", but you'd still would have to create the said myname manually, so I don't see the point in using the flag. – gusbrs Mar 8 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.