I have defined a new environment, argument. I would now like to include "argument" as one of the possible completions after hitting C-c C-e, and upon selecting it, be prompted for an optional argument.

Unfortunately, I cannot even get to the first of these two steps, adding "argument" as one of the possible completions, never mind being prompted.

I've added the following into my .emacs file, minimally adapting the example from the manual.

(add-hook 'LaTeX-mode-hook
   (lambda ()
       '("argument" LaTeX-env-label))))

But after re-loading the configuration file, I hit C-c C-e and I don't get "argument" as one of the options.

  • How do you define your new environment argument, with \newenvironment in the preamble of your .tex file? Commented Jan 20, 2021 at 11:08
  • @ArashEsbati: Just about: I've got it in a style file that I load.
    – Bernhard
    Commented Jan 21, 2021 at 15:24

1 Answer 1


The usual practice for getting completion for hand written LaTeX packages is to write a corresponding AUCTeX style file. Suppose your LaTeX file looks like this:



\begin{argument}[Optional argument}

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

And you have your environment argument defined in myenvs.sty. The AUCTeX style myenvs.el should look like this:

 (lambda ()
    '("argument" [ "argument" ])))

Save this file in a directory which is stored in the variable TeX-style-private, e.g. something like this in your init file or use customize:

(setq TeX-style-private (expand-file-name "~/.emacs.d/auctex-styles"))

Make sure you also have TeX-parse-self to t. Now restart Emacs and open your .tex file again.

You must log in to answer this question.

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