GNU bug report logs -
#65648
13.2; indentation of nested environments
Previous Next
Reported by: Paul Nelson <ultrono <at> gmail.com>
Date: Thu, 31 Aug 2023 04:57:01 UTC
Severity: normal
Found in version 13.2
Done: Ikumi Keita <ikumi <at> ikumi.que.jp>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi Ikumi and Uwe,
Thanks to both of you for your feedback.
I agree that it's better to have begin/end line up when all else is
equal, but with the current state of AUCTeX (since this bug was
introduced), it is a severe user error to put \begin{array} on a line
following non-whitespace. The reason is the same as in my original
message, or in what one gets from Uwe's example by deleting the inner
aligned environment and applying M-x indent-region:
#+begin_src latex
\begin{equation}
n u m=\left[\begin{array}{ll}
2 & 25
\end{array}\right]
\end{equation}
#+end_src
In Uwe's criticism, the user already messed up (with the current state
of AUCTeX) by forgetting to put a newline before \begin{array}. Their
mistake is covered up because they were lucky enough to enclose the
array environment in an aligned environment, but this does not forgive
the mistake, and I'm not convinced by this example that AUCTeX's
current approach is superior to the proposed one. My ranking of the
available alternatives:
1. Some better proposal
2. My proposal
3. Current state
To emphasize, the user error is severe because the resulting
indentation errors propagate through the buffer, making indent-region
useless when applied globally. On the other hand, this user error is
committed repeatedly in every .tex file I encounter in practice.
Moreover, the underlying bug cannot always be circumvented just by
putting each \begin at the start of its own line, as the following
example shows:
#+begin_src latex
The matrix $\begin{pmatrix}
a & b \\
c & d
\end{pmatrix}$ has determinant
\begin{equation}
a d - b c.
\end{equation}
#+end_src
The "user workaround" here is to put the entire pmatrix environment on
one line. I've been using and automating such workarounds for years
-- writing my own linters that "fix" a tex buffer to avoid such "user
errors" -- but don't think new users should be forced to do so, and
can emphasize with some of Robert's comments in Ikumi's reference [1].
As a final remark, one can fix my original example by adjusting the
"equation" entry of LaTeX-indent-environment-list to
LaTeX-indent-tabular, but not this last example.
Thanks, best,
Paul
This bug report was last modified 1 year and 255 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.