3

With (C-c C-e) AUCTeX allows to insert arbitrary environments. In my case I want to change the default aling-environment from

\begin{align}
  \label{eq:145}

\end{align}

to insert comments in order to obtain blank lines like

%
\begin{align}
  \label{eq:145}
  %

  %
\end{align}
%

Any suggestions?

Greetings,

R.

Karlo
  • 3,257
Robinaut
  • 1,061
  • 1
  • 9
  • 16

1 Answers1

3

You need to add a function that performs the insertion. It should be something like:

(LaTeX-add-environments
     '("align" LaTeX-env-with-preset "%" ""))
(defun LaTeX-env-with-preset (env pre post)
     (LaTeX-env-label env)
     (insert pre)
     (LaTeX-newline)
     (save-excursion (LaTeX-newline)
                     (insert post))
     (newline)
     (LaTeX-indent-line))

Note that LaTeX-add-environments only adds the environment to the list for the current buffer, so make sure this code is executed on the appropriate hook, as described at https://www.gnu.org/software/auctex/manual/auctex/Adding-Environments.html

Charles Stewart
  • 21,014
  • 5
  • 65
  • 121