2

I'm using Emacs 23.1.1, with AUCTeX plugged in, to edit my .tex files, but I'm having a small problem with my amsmath environments.

The current document I'm editing is divided into multiple files. Only the main file contains the \usepackage{amsmath} command. When I'm editing the main file, auctex automatically detects amsmath, and so all commands work perfectly. When I'm editing one of the embedded files (which don't have amsmath loaded, they don't even have a preamble), AUCTeX does not implement any of the amsmath command.

For instance, if I press C-c C-e the environments available don't include any of the amsmath specific environments. Even if I manually type in "align", AUCTeX will open an align environment but won't label it. I know I can manually define environments for AUCTeX to remember and label in my .emacs file, but they still won't behave well with RefTeX (the M-RET key doesn't behave correctly).

Each embedded file has the following lines at the end of the file, but it didn't help:

%% Local Variables:
%% mode: LaTeX
%% tex-main-file: "../main.tex"
%% TeX-master: "../main.tex"
%% End 

Also, if I add the \usepackage{amsmath} line at the beginning of the embedded file, then auctex behaves exactly like it should. Obviously I can't just declare a package in the middle of the document, and LaTeX returns errors and doesn't compile.

Is there something I can do to get auctex to load amsmath-behavior for the embedded files? Or maybe I can just force AUCTeX to load amsmath on every file (even those that don't declare the package)?

EDIT: I failed to reproduce this at home. Since I'm testing with the same files I used at work, all seems to indicate the problem is with the .emacs file I use at work. I'll look through it and try to find what's causing the problem, or post it here if needed. Unfortunately, I'll only be able to access it by Monday (I think a power surge at my workplace might have shut down my machine there, cause my ssh attempts are having no success).

3
  • 1
    I can't reproduce this. AucTeX should indeed load the package style files from the master document in the chapter files, and it does so for a large document I'm editing. Can you build a minimal example?
    – Philipp
    Sep 24, 2010 at 21:54
  • I've been having this problem at work. I'm at home right now (and will be for the weekend). I'm trying to reproduce it here, but now it seems to be working ok. I actually thought auctex behaved like that by default.
    – Malabarba
    Sep 25, 2010 at 5:20
  • Yeah I've never noticed this problem with multiple files and auctex...
    – Seamus
    Sep 25, 2010 at 17:25

1 Answer 1

3

Turns out it was two issues at once, which is why I couldn't troubleshoot it myself at first. Initially, it was a typo in the file's local variable declaration (End : instead of End:), which is why it didn't work when I removed my .emacs file. While trying to troubleshoot, I eventually added a couple of lines to the .emacs file, and, because of them, the issue didn't go away when I finally spotted and corrected the typo.
That's also what made me think this wasn't bug, but a standard behavior.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .