Hi Zhao

On Sun, 21 May 2023 at 09:41, Hongyi Zhao <hongyi.z...@gmail.com> wrote:
> I want to convert `bla` to `$bla$` automatically when be highlighted
> and typeset a `$'.

I believe you want to look at `TeX-electric-math'
(https://www.gnu.org/software/auctex/manual/auctex/Quotes.html#index-TeX_002delectric_002dmath):

--8<---------------cut here---------------start------------->8---
TeX-electric-math is a variable defined in ‘tex.el’.

Its value is ("\\(" . "\\)")
Original value was nil
Local in buffer foo.tex; global value is nil

If non-nil, when outside math mode ‘TeX-insert-dollar’ will
insert symbols for opening and closing inline equation and put
the point between them.  If there is an active region,
‘TeX-insert-dollar’ will put around it symbols for opening and
closing inline equation and keep the region active, with point
after closing symbol.  If you press ‘$’ again, you can toggle
between inline equation, display equation, and no equation.

If non-nil and point is inside math mode right between a couple
of single dollars, pressing ‘$’ will insert another pair of
dollar signs and leave the point between them.

If nil, ‘TeX-insert-dollar’ will simply insert "$" at point,
this is the default.

If non-nil, this variable is a cons cell whose CAR is the string
to insert before point, the CDR is the string to insert after
point.  You can choose between "$...$" and "\(...\)".

  Automatically becomes buffer-local when set.
  You can customize this variable.
--8<---------------cut here---------------end--------------->8---

Bye,
Mosè

Reply via email to