Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question already has an answer here:

I have been puzzling over this for the past few hours and can't quite figure it out. I am using AUCTeX 11.87 and MiKTeX 2.9 on Emacs 24.2 (obtained from Vincent Goulet with AUCTeX pre-packaged):

I am having trouble getting AUCTeX to compile my LaTeX file on windows 7 and throws me into a blank screen with a cryptic message of 'Error after last TeX file closed". Even though same file compiles on my set-up on Ubuntu 12.1. From my searching this site and Google I seem to have tracked the problem to the need to use the -file-line-error flag when pdfTeX gets called. I read through the code for AUCTeX but it gets very convoluted and I can't figure out where I would need to insert -file-line-error in any of the customizable options.

Any suggestions on how to proceed would be welcome. I would prefer not to manually change any configuration files as I came across an admonishment not to do so in the pdfTeX manual.

share|improve this question

marked as duplicate by giordano, yo', Papiro, LaRiFaRi, T. Verron Nov 27 at 10:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers 3

up vote 2 down vote accepted

The easiest way is M-x customize-variable RET LaTeX-command RET, then add -file-line-error to the command, and Save for Future Sessions. You may also have to do the same for other engines e.g. by customizing TeX-command. You can have more control over which engines you want to use by customizing the TeX-engine-alist.

share|improve this answer

In recent versions of auctex, it looks like it'll be more reliable to set TeX-command-extra-options, which is designed for just this purpose, and doesn't make you override the various forms of TeX-command. So this is a nice, non-destructive way of adding options without interfering with changes down the line -- like switching between TeX flavors, enabling synctex, etc.

As I understand it (might be wrong about this), the value can't be set globally, but must be set for each file. You can do this with a hook. I have the following in my .emacs:

(add-hook 'TeX-mode-hook
  (lambda ()
    (setq TeX-command-extra-options "-file-line-error -shell-escape")
  )
)

[Also note that synctex can now be turned on with (setq TeX-source-correlate-mode t), rather than being included in the command line. This can be set globally, so it should go outside that hook.]

share|improve this answer

Any suggestions on how to proceed would be welcome. I would prefer not to manually change any configuration files as I came across an admonishment not to do so in the pdfTeX manual.

I never bothered to repair this kind of misbehaviour of Emacs, because if I encounter "TeX exited abnormally", I have a quick look at the output. You get it in a fraction of a second with "C-c C-l". Change into this buffer: "C-x o" and search for the first error.

share|improve this answer

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