I am attempting to use a plain TeX format, say, foo.fmt (based on XeTeX), with Emacs/AUCTeX (actually Aquamacs with built-in AUCTeX). I'm unable to get AUCTeX to recognize the custom format. In TeXShop I would simply say:

% !TS-program=foo

I have tried various "Local Variables" such as

%%% Local Variables:
%%% TeX-engine: foo
%%% End:

followed by C-c C-n. But so far nothing seems to work. TeXing stops with an error for an undefined command that was defined in foo.fmt. The format file is findable with kpsewhich. What am I missing?


The problem is that AUCTeX will use this kind of call:

Running `TeX' on `testfmt' with ``xetex  -file-line-error  --synctex=1 -interaction=nonstopmode "\input" testfmt.tex''

Due to the \input a first line %&foo to use foo.fmt format file is ignored, for example with this file:

% Local variables:
% TeX-engine: xetex;
% End:

where macro \foo was defined in the dumped foo.fmt.

You can see it originates in "%'" in TeX-expand-list-builtin and its usage in TeX-command-list

("TeX" "%(PDF)%(tex) %(file-line-error) %(extraopts) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil
  (plain-tex-mode ams-tex-mode texinfo-mode)
  :help "Run plain TeX")

I have customized the variable to contain this other entry

("texfmt" "%(PDF)%(tex) %(file-line-error) %(extraopts) %S%(PDFout)%(mode) %t" TeX-run-TeX nil
  :help "Fait (xe|lua|pdf)tex")

The only difference is I removed the %'. edit: I also removed the %` whose elisp definition makes it look like it is to be used paired with %' but this would need confirmation by AUCTeX people.

Then when I open a buffer with file above I see in the menu "Command" a new entry texfmt. I choose that and xetex is run and uses the foo.fmt.

Running `texfmt' on `testfmt' with ``xetex  -file-line-error   -interaction=nonstopmode testfmt.tex''
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=foo)
 restricted \write18 enabled.
entering extended mode
(./testfmt.tex [1] )
Output written on testfmt.pdf (1 page).
Transcript written on testfmt.log.

TeX Output finished at Thu Apr 19 00:11:19

À propos formats with xelatex, not xetex, see this for a difficulty.

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.