1

I have autocomplete successfully working in auctex. It also works for included packages, so if I, for example, have \usepackage{url} in my preamble, I will get autocompletion while typing \url.

However, this is not the case for the physics package in latex.

One possible problem I can think of is that this package makes use of xparse, so there is no \def or \newcommand in physics.sty but instead commands like \DeclareDocumentCommand.

Is there a way to get autocomplete for physics.sty?

  • I'm not completely sure, but I think Auctex might not actually parse package .sty files (for reasons I don't know). If you check TeX-style-path, you'll find a path that contains Auctex style files like url.el, which has a comment that says "This file adds support for `url.sty'." So it seems like packages need an Auctex style file to work properly. – gsingh2011 Dec 31 '19 at 7:33
1

I ran into the same issue and asked on the mailing list.

Auctex uses elisp style files to know what symbols exist. For your own code, it auto generates these style files and stores them in the "auto" directory. For some libraries, it ships with style files (see the TeX-style-path variable to find where these are stored). But for other libraries it doesn't auto generate the style file.

You can manually generate the style file by running TeX-auto-generate on the physics.sty file that shipped with your TeX distribution. However, the parsing is very naive, so while you'll probably get all of the commands, they won't have the right arguments. You can modify the generated file yourself to set the number of arguments (and if you get a fully working style file feel free to commit it upstream).

  • Thanks. Even when creating the style files manually I run into the problem that physics.sty has some commands which can take variable number of arguments, which I don't think one can do in Auctex (see for example \pdv). Also I don't think TeX-auto-generate can handle physics.sty use of xparse (I don't use emacs for writing TeX at the moment, but might check it out later). – kalix 2 days ago

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.