Subject: bug#57626: 13.1.4; cases* environment doesn't let me use $

From: Ikumi Keita <[email-masked]>
Date: Thu, 08 Sep 2022 02:13:41 +0900

Hi Wierdl and Arash,

> Wierdl Máté <[email-masked]> writes:
>> \begin{equation}
>> \label{eq:240}
>> Tx=
>> \begin{dcases*}
>> 1& if 
>> \end{dcases*}
>> \end{equation}
>> 
>> and after "if" a I try to enter a formula, but auctex says in the
>> minibuffer
>> 
>> "Math mode started with ‘equation’ cannot be closed with dollar"
>> 
>> I should be able to enter a $ in text mode.

Ah, it's the same as https://tex.stackexchange.com/questions/578900/auctex-math-mode-started-with-cannot-be-closed-with-dollar-in-cases
...
As written there, temporal workaround is to type C-u $ or C-q $ to
insert "$" in such a case.

>>>>> Arash Esbati <[email-masked]> writes:
> I think this a corner case where half of a environment is math and the
> other half text.  AUCTeX thinks that the entire environment is math and
> hence throws an error.  I don't have a strong opinion about this, we can
> add some entries like this to `texmathp-tex-commands-default':

>     ("cases*"   env-off)
>     ("dcases*"  env-off)
>     ("rcases*"  env-off) 
>     ("drcases*" env-off)

> What do others think?

In my opinion, `TeX-insert-dollar' is too patriarchal in this case. The
intention of `texmathp' is apparently to be "practical enough", not
"precise". It sometimes by design gives false positives and false
negatives, which we should anticipate.

How about to allow insertion of "$" (or anything according to
`TeX-electric-math') when `last-command' is `TeX-insert-dollar' in a
case like this issue? I suppose that most users would type "$" again
before seeing "Math mode started with `...' cannot be closed with
dollar" when "$" is refused unexpectedly.

Regards,
Ikumi Keita
#StandWithUkraine #StopWarInUkraine