5

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

\begin{inparaenum}[(1)]
  \item An Item
  \item an other Item
  \item this is an item, too !
\end{inparaenum}

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?

EDIT: 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:
2;;Zeilenumbruch
;; 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"))))
2
  • 6
    \items are not intended to be indented. If you want to indent them add (setq LaTeX-item-indent 0) to your .emacs. That variable is mentioned in the link you provided.
    – giordano
    Jan 3, 2014 at 16:55
  • @giordano that looks like an answer, rather than a comment, but worth an upvote either way ;)
    – Tyler
    Jan 6, 2014 at 20:51

1 Answer 1

5

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

or

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

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

2
  • 2
    C-h v LaTeX-item-indent RET gives Extra indentation for lines beginning with an item. What is not clear?
    – giordano
    Jan 11, 2014 at 22:06
  • The texinfo doc says "Also, items of an ‘itemize-like’ environment are indented by the value of LaTeX-item-indent, default -2." which did not make it clear to me that it is in addition to the LaTeX-indent-level I agree with you that the variable documentation is quite clear.
    – verdammelt
    Jan 11, 2014 at 22:14

You must log in to answer this question.

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