auctex
[Top][All Lists]
Advanced

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

Re: Convert bla to $bla$ automatically when be highlighted and typeset a


From: Hongyi Zhao
Subject: Re: Convert bla to $bla$ automatically when be highlighted and typeset a $.
Date: Sun, 21 May 2023 19:05:21 +0800

On Sun, May 21, 2023 at 4:41 PM Hongyi Zhao <hongyi.zhao@gmail.com> wrote:
>
> Hi here,
>
> I want to convert `bla` to `$bla$` automatically when be highlighted
> and typeset a `$'.
>
> Currently, my observed result is `bla$$`, which is not consistent with
> the LaTeX math environment.

I tried the following, but failed to do the trick:

(defun my-insert-dollar ()
  "Insert pair of dollar signs around region or at point."
  (interactive)
  (if (use-region-p)
      (let ((beg (region-beginning))
            (end (region-end)))
        (goto-char end)
        (insert "$")
        (goto-char beg)
        (insert "$"))
    (insert "$")))

;; Add to your Emacs configuration file (~/.emacs or ~/.emacs.d/init.el)
(define-key LaTeX-mode-map "$" 'my-insert-dollar)

Regards,
Zhao



reply via email to

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