# AUCTeX indenting after \newcommand

If I use a command that begin a new block (according to AUCTeX), e.g.:

\newcommand\Test{\begin{abstract}}


And then I start my document:

\begin{document}


AUCTeX will indent my code as if I typed:

\begin{abstract}
\begin{document}


Is there a way to tell AUCTeX to not consider command in newcommand for indentation?

Note: It may looks silly to declare a new command for \begin{abstract} but my real code is not about such command (simplified for the example). Actually the problem occurred while using the algorithm packages, and I wanted to define a new command such as IfAny (\newcommand\IfAny[1]{\If{\textbf{any} #1}) which does not really involved an environment.

Full example code after C-x h M-x indent-region:

\documentclass{article}
\newcommand\Test{\begin{abstract}}

\begin{document}
\end{document}


The exact command concerns the algorithm and algpseudocode packages:

\newcommand\IfAny[1]{\If{\textbf{any }#1}}


Use like:

\IfAny{}
\State ...
\EndIf


Which cannot be made into an environment (\newenvironment) unfortunately.

• I've added a full example for reconstruction. It also shows the effect. – Tobias Mar 10 '16 at 9:27
• A moderator deleted my not-quite-answer. The OP made a comment to that answer which I think should be visible to others, so I copy it here: “Actually the problem occurred while using the algorithm packages, and I wanted to define a new command such as IfAny (\newcommand\IfAny[1]{\If{\textbf{any} #1} ) which does not really involved an environment.” – Harald Hanche-Olsen Mar 10 '16 at 10:46
• And more generally, TeX/LaTeX is such a flexible language, allowing all kinds of constructs that really clash with basic usage, that designing really robust automatic indentation support is a near impossible task. You'll either have to work around problems as they pop up due to bending the rules, or give up on using automated indentation altogether. – Harald Hanche-Olsen Mar 10 '16 at 10:53
• What might have been nice, perhaps, is a pair of magic comments causing AUCTeX to not apply its indentation rules to stuff between them. Perhaps that's a reasonable feature request for the AUCTeX team? – Harald Hanche-Olsen Mar 10 '16 at 11:05