1

One of the great features of Emacs is its ability to handle bidirectional support for the right-to-left languages (like Hebrew, Arabic and Persian). Note that even in these languages mathematical formulae are written from left-to-right. So when typing a mathematical formula (usually between $ $) in a right-to-left line, it would be desirable to temporary force the direction left-to-right. For example in the following line I have written $V^*$ but Emacs shows it in reverse.

enter image description here

I know the setting (setq bidi-paragraph-direction 'left-to-right) can be used to change to the correct direction. Also the variable texmathp can be used to determine if the cursor is in a math environment (see how to detect if inside a LaTeX math environment? and https://emacs.stackexchange.com/a/548/2609).

But I don't know to put these altogether. So my question is

How to force the direction from right-to-left in a math environment?

1

The variable bidi-paragraph-direction is not the answer to your problem, since it affects the whole buffer. Instead if you want to change the directionality of a particular piece of text, you'll need to insert special control characters.

E.g. you could insert an LRM (see https://en.wikipedia.org/wiki/Left-to-right_mark) character just before the opening $ and another just after the closing $.

I don't know what TeX will do with such characters, tho. AFAIK there is currently no way in Emacs to insert such characters only for the display via something like a display property or an after-string overlay (i.e. not as part of the buffer's content). You might like to M-x report-emacs-bug requesting a new feature for that.

  • Thank you for your answer. I think Emacs can insert LR mark using quail package for example by setting ("‎" ?\u200E) when using a particular input-method. Perhaps I make a mistake. – Name Dec 28 '14 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.