6

I would like AUCTeX (that is, Emacs with auctex loaded) to suggest more LaTeX macros when using completion (M-Tab or C-Ret) than it does by default. I would like to have macros from packages I have downloaded on CTAN and macros I have written. I would also like it if it would complete \section or other macros that can be accessed via C-c C-s, C-c C-e etc.

Solution: I could not make the code quoted by AUCTeX wiki work. i get an error on loading emacs but did not looked much further in because I ca bear the nuisance of appending a few lines to my files.

The link given by Ben (Automatic add of private macros contains a working solution, thus I accept his answer. I had come across this page in my researchs but somehow messed up things. What eventually worked for me was using TeX-auto-generate TEX AUTO to create a bunch of .el files in the ~/.emacs.d/auctex/auto direcoty. Note that this directory must be created beforhand. For some reasons TeX-macro-private did not achieve the wanted result.

1 Answer 1

6

AUCTeX has to be configured to parse files so that it can extract the macros you want. Make sure you have the variable TeX-parse-self set to t, so that it scans the current file for macros defined there, set TeX-auto-regexp-list to TeX-auto-full-regexp-list so it looks for as many macros as it can, and TeX-auto-parse-length to 999999 so it handles long files. These can be set in your .emacs file, and overridden as needed as file-local variables in your individual projects if they give you trouble. You should also try adding

%%% Local Variables:
%%% TeX-master: "your-main-filename"
%%% End:

to the bottom of all files belonging to your project, so that AUCTeX knows how to get back from one included file to the main one, and then to the other included files.

With all that done, it should be finding pretty much all the macros in your project.

EDIT

According to the AUCTeX wiki, you can avoid the TeX-master local variable by asking AUCTeX to guess the master file; they post the necessary elisp code to do this.

To check additional directories worth of style files, add the directories to the TeX-macro-private lists (see here).

4
  • 1
    It woks for the macros defined inside the document. That's already something, but I would like auctex to know about macros defined in .sty files stored in my local latex files directories. I reckon it has something to do with TeX-macro-global or the likes but I don't know what.I'll clarify my question.
    – M. Toya
    Mar 9, 2012 at 15:58
  • 2
    @AlfredM., presumably these are .sty files that you're including via usepackage or include? If you are, and it's not working, then I'm surprised. If you aren't, then I'm not, since there would be no way for AUCTeX to know that those files are relevant to your document :)
    – Ben Lerner
    Mar 9, 2012 at 16:53
  • It is. Sometimes I have nested usepackage but that should not pose any problem, right?
    – M. Toya
    Mar 9, 2012 at 17:41
  • When the .sty files are in the directory of the .tex files, it wokrks all right. I reckon I have to add the path to my .sty files directory somewhere.
    – M. Toya
    Mar 9, 2012 at 17:49

You must log in to answer this question.

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