bug-auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#65648: 13.2; indentation of nested environments


From: Paul Nelson
Subject: bug#65648: 13.2; indentation of nested environments
Date: Sun, 3 Sep 2023 13:30:52 +0200

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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]