[Tex/LaTex] Problem setting master file to current file with Emacs/AucTeX

auctexemacs

I have a TeX file containing these few lines at the end:

%%% Local Variables:                                                    
%%% mode: latex                                                         
%%% TeX-master: t                                                       
%%% End:

The TeX document only consists of that file, so I want it to be the master file. When I compile it with errors, trying to debug with C-c ` opens an empty buffer on top of the compilation log buffer. I think that the top buffer should be the current file.

A dired on the top buffer however shows that it is in the non-existent folder /folder/of/my/tex/Tex Live 2012/.

I have tried changing the Tex-Master variable to the absolute path of the TeX file, but the problem stays the same.

How can I have my TeX file as the top buffer in the debugging window?

Best Answer

This is a problem with the way AUCTeX parses the log file. It finds files based on parentheses, and the first "file" it finds is "Tex Live 2012". Part of the problem is that AUCTeX saves the first file it found if the error occurs outside of a file (or what AUCTeX thinks is outside of a file). For more details on the problem and a few semi-solutions see this answer of mine on StackOverflow. You might also want to try using the latest AUCTeX if you're not already.

That said, the best way to fix this is to invoke LaTeX with -file-line-error-style. This gives AUCTeX a much better chance of finding the right spot. One way to do this can be found on this question.

Sorry for so many links to my own answers, but they are the ones I knew how to find.

Related Question