Subject: Re: bug#65786: 13.2; Indentation problem when left brace is closed with null

From: Arash Esbati <[email-masked]>
Date: Fri, 08 Sep 2023 10:36:15 +0200

James Tappin <[email-masked]> writes:

> When, within an equation environment, a \left\{ is closed with a
> \right. as with a display of alternative cases, the \end{equation}
> leaves the input indented by one level.
>
> Example:
> cumulative sum of the point to point phase shifts, after these are
> mapped into $-\pi < \Delta \phi_i \le \pi$, i.e.:
> \begin{equation}
>   \label{eq:contiguation}
>   \phi^{\mathrm{(c)}}_{\mathrm{i}} = \left\{
>     \begin{array}[c]{lll}
>       \phi^{\mathrm{(c)}}_{\mathrm{i-1}} +
>       (\phi_{\mathrm{i}}-\phi_{\mathrm{i-1}}) & \mbox{if}
>       & -\pi < \phi_{\mathrm{i}}-\phi_{\mathrm{i-1}} \leqslant \pi \\
>       \phi^{\mathrm{(c)}}_{\mathrm{i-1}} +
>       (\phi_{\mathrm{i}}-\phi_{\mathrm{i-1}}) - 2 \pi & \mbox{if}
>       & \phi_{\mathrm{i}}-\phi_{\mathrm{i-1}} > \pi \\
>       \phi^{\mathrm{(c)}}_{\mathrm{i-1}} +
>       (\phi_{\mathrm{i}}-\phi_{\mathrm{i-1}}) + 2\pi & \mbox{if}
>       & \phi_{\mathrm{i}}-\phi_{\mathrm{i-1}} \leqslant -\pi 
>     \end{array}
>     \right. .
>   \end{equation}
>   This has the property that there are qualitative changes to the
>   behaviour if aliasing occurs.
>
> Not sure if it is as simple as not counting \{ when computing the
> indentation or if that would open a whole other can of worms.

I put your example in a .tex file, marked it and 'M-x indent-region RET'
looks like this for me:

--8<---------------cut here---------------start------------->8---
Example:
cumulative sum of the point to point phase shifts, after these are
mapped into $-\pi < \Delta \phi_i \le \pi$, i.e.:
\begin{equation}
  \label{eq:contiguation}
  \phi^{\mathrm{(c)}}_{\mathrm{i}} = \left\{
    \begin{array}[c]{lll}
      \phi^{\mathrm{(c)}}_{\mathrm{i-1}} +
      (\phi_{\mathrm{i}}-\phi_{\mathrm{i-1}}) & \mbox{if}
      & -\pi < \phi_{\mathrm{i}}-\phi_{\mathrm{i-1}} \leqslant \pi \\
      \phi^{\mathrm{(c)}}_{\mathrm{i-1}} +
      (\phi_{\mathrm{i}}-\phi_{\mathrm{i-1}}) - 2 \pi & \mbox{if}
      & \phi_{\mathrm{i}}-\phi_{\mathrm{i-1}} > \pi \\
      \phi^{\mathrm{(c)}}_{\mathrm{i-1}} +
      (\phi_{\mathrm{i}}-\phi_{\mathrm{i-1}}) + 2\pi & \mbox{if}
      & \phi_{\mathrm{i}}-\phi_{\mathrm{i-1}} \leqslant -\pi 
    \end{array}
  \right. .
\end{equation}
This has the property that there are qualitative changes to the
behaviour if aliasing occurs.
--8<---------------cut here---------------end--------------->8---

which looks correct.  Can you assemble an example starting with emacs -Q
exhibiting the issue?

Best, Arash