emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/


From: Richard Lawrence
Subject: Re: Bug: Math mode doesn't work if followed by a dash [9.4 (nil @ /home/gutin/.emacs.d/.local/straight/build/org-mode/)]
Date: Mon, 28 Sep 2020 20:42:25 +0200

Hi Gutin,

gutin <jkabrg@gmail.com> writes:

> What I meant is that if you type
>
>   $*$-algebra
>
> and hit C-c C-x C-l, then the "$*$" doesn't get replaced with a
> mathematical image. A similar problem happens when you export to Latex:
> The dollar signs get escaped.

I believe this is intentional. There are too many other uses of dollar
signs that people might want to use in Org documents that might be
broken if Org treated them as math mode delimiters; so the regexp that
matches math mode delimiters is deliberately limited in scope.

The recommended workaround is to use the \(...\) style of delimiter for
math mode instead, which is much less ambiguous. Here is a function that
makes this easy, by inserting these delimiters when you type "$". It's
been posted on this mailing list before, and I use a version of it
myself; it's very useful!

   ;; from Nicolas Richard <theonewiththeevillook@yahoo.fr>
   ;; Date: Fri, 8 Mar 2013 16:23:02 +0100
   ;; Message-ID: <87vc913oh5.fsf@yahoo.fr>
   (defun yf/org-electric-dollar nil
     "When called once, insert \\(\\) and leave point in between.
   When called twice, replace the previously inserted \\(\\) by one $."
          (interactive)
          (if (and (looking-at "\\\\)") (looking-back "\\\\("))
              (progn (delete-char 2)
                     (delete-char -2)
                     (insert "$"))
            (insert "\\(\\)")
            (backward-char 2)))
   (define-key org-mode-map (kbd "$") 'yf/org-electric-dollar

Hope that helps!

-- 
Best,
Richard



reply via email to

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