Subject: Re: bug#78006: Improving `TeX-electric-math' behavior

From: "Paul D. Nelson" <[email-masked]>
Date: Sat, 03 May 2025 10:31:38 +0200

Hi Arash,

Thanks, sounds good.  I'll plan to send these commands as a separate bug
(and have no further comments on the current bug).  Some responses:

>> ;;;###autoload
>> (defun czm-tex-edit-make-equation-inline ()
>>   "Convert LaTeX equation environment at point to inlined math.
>> Format LaTeX environment at point by surrounding the math
>> environment with dollar signs, removing any leading or trailing
>> text."
>
> I think this will break if the equation environment has a \label{eq:x}?

It will indeed break (i.e., put the \label{...} inside the $...$) if the
\label{...} does not occur on the same line as \begin{...}.  Perhaps we
could kill any labels first.

A related issue is ampersands alignment characters (e.g., in align
environments) that should not exist when we convert to inline, but
ampersands occur in other ways (e.g., matrices), so it seems tricky to
get this right.  Personally, I use the command only when the displayed
expression is simple enough, which restricts the possible edge cases.

Thanks, best,

Paul