Before installing AucTeX, when I would edit .tex files with emacs, it would automatically indent when I would press enter after typing a line such as \begin{equation}. Typing C-j would cause a linebreak without indenting. But after installing AucTeX, the behavior is now reversed - pressing enter breaks the line without indenting, and pressing C-j breaks the line and indents it.

First I wanted to confirm that it's not just me, and make sure it's not a problem with my installation of AucTeX. Second, I wanted to see how to get it so that AucTeX breaks and indents the line when I press enter.


You have to configure your .emacs the proper way. This is how auctex documentation explains it

You can explicitely indent single lines, usually by pressing , or marked regions by calling indent-region on it. If you have auto-fill-mode enabled and a line is broken while you type it, Emacs automatically cares about the indentation in the following line. If you want to have a similar behavior upon typing , you can customize the variable TeX-newline-function and change the default of newline which does no indentation to newline-and-indent which indents the new line or reindent-then-newline-and-indent which indents both the current and the new line.

You should put in your emacs something like:

(setq TeX-newline-function 'newline-and-indent)

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.