Upon @egreg's request, I try to be more verbose on this. I assume you are using GNU Emacs; if so, your OS shouldn't make a difference.
I suggest you install the latest version of AUCTeX from ELPA by doing M-x list-packages RET, move the cursor on auctex (version 11.88.4 as writing), hit i followed by x and you have the latest version installed (probably under
If installed from ELPA, you must not, I repeat, must not have this in your init file:
(load "auctex.el" nil t t)
AUCTeX is installed and should start as soon as you load a file with
AUCTeX's strength is in supporting basic LaTeX and contributed packages. Currently, more than 180 style files (jargon for "name-of-supported-LaTeX-package.el") are available. AUCTeX can parse your input file and load the right style if you put this in your init file:
(setq TeX-parse-self t)
Otherwise, you have to hit C-c C-n afterwards. Keep that in your init file.
AUCTeX manual suggests also:
(setq TeX-auto-save t)
(setq-default TeX-master nil)
It's up to you; I have only the second line in my
Now, you can hit C-c C-e and AUCTeX offers
lstlisting in completion and asks you for key-value options. Further, note that Emacs doesn't indent the content since spaces are significant:
a$ = b$ + c$;
The fontification (aka syntax highlighting) should work as well.