[Tex/LaTex] Emacs Indentation Problem


I started using Emacs/AUCTeX for writing my LaTeX documents. I now have an

  \item An Item
  \item an other Item
  \item this is an item, too !

environment. But I can't indent the \items nor using the TAB Key nor by using the indent-region command mentioned here

Is it possible to 'auto indent' the LaTeX Code using AUCTeX.

And how do I indent this Code?

This is my .emacs file:

(load "auctex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq TeX-PDF-mode t) ;; .pdf statt .dvi per default:
;; Removed to turn off 'auto-fill-mode'
;;(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)
;;Syntax Higlight
(add-hook 'LaTeX-mode-hook 'turn-on-font-lock)
;; Mathe Modus
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
;; Reftex einflechten und laden
(setq reftex-plug-into-AUCTeX t)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
;; Satzende ". " statt ". ". " f¨ur M-k: l¨oschen bis Satzende usw.
(setq sentence-end "[.?!][]\"’)}]*\\($\\| \\| \\)[
;;]*") ;; Da ist ein "Newline in der Zeile!"
(setq sentence-end-double-space nil)
;;direkte Rechtschreib Korrektur:
;;(add-hook 'LaTeX-mode-hook 'flyspell-mode)
;; Nur benutzen falls Auctex > 11.81 mit preview-latex:
(load "preview-latex.el" nil t t)
;; aspell ist besser als ispell.
;; Zeile kommentieren, falls nicht installiert:
(setq-default ispell-program-name "aspell")
;; Deutsche Rechtschreibung falls \usepackage{ngerman}
;; oder german benutzt wird
(add-hook 'TeX-language-de-hook
(function (lambda () (ispell-change-dictionary "german8"))))

Best Answer

As mentioned by @giordano in the comments above \item is not indented by default. If you read carefully the AUCTeX manual section about indenting you cited you will see that the second paragraph explains the settings for indenting (LaTeX-indent-level) and the special one used for item indenting (LaTeX-item-indent). They have default values of 2 and -2 respectively.

What is not made clear in the above referenced documentation is how they work together. LaTeX-item-indent is extra indentation given to \items. So by default an item is indented (+ 2 -2) or 0.

If you want \items to be indented set LaTeX-item-indent appropriately according to this 'formula':

LaTeX-indent-level + LaTeX-item-indent = desired-indent-amount


LaTeX-item-indent = desired-indent-amount - LaTeX-indent-level

You can set this variable like any other with the setq function in Elisp.