When composing a bilingual document that combines a right-to-left language, such as Hebrew, with a left-to-right language, such as English, is there a way to force the left- or right alignment of a line of text in the Emacs GUI when the text in that line contains no letters of either alphabet. For example, when writing a mathematical text in Hebrew, intended to be typeset by the TeX system, the following display-mode equation may occur: $$ x+y=z $$ In this case the Emacs GUI would align the initial $$ along the buffer's right margin, whereas the next two lines would be aligned along the left margin. This causes a disruption of the logical cohesiveness of the LaTeX code. Is there a way that I could indicate to the Emacs GUI to align the initial $$ along the left margin?
Evan Aad <oddeveneven@gmail.com> writes: > For example, when writing a mathematical text in Hebrew, intended to > be typeset by the TeX system, the following display-mode equation may > occur: > $$ > x+y=z > $$ This is not related to your question, but if you're using LaTeX and not plain TeX, don't use $$ for display-math. Check this for the reason: https://texfaq.org/FAQ-dolldoll Best, Arash
On Mon, Nov 14 2022, Evan Aad wrote:
> When composing a bilingual document that combines a right-to-left
> language, such as Hebrew, with a left-to-right language, such as
> English, is there a way to force the left- or right alignment of a
> line of text in the Emacs GUI when the text in that line contains no
> letters of either alphabet.
>
> For example, when writing a mathematical text in Hebrew, intended to
> be typeset by the TeX system, the following display-mode equation may
> occur:
> $$
> x+y=z
> $$
>
> In this case the Emacs GUI would align the initial $$ along the
> buffer's right margin, whereas the next two lines would be aligned
> along the left margin. This causes a disruption of the logical
> cohesiveness of the LaTeX code. Is there a way that I could indicate
> to the Emacs GUI to align the initial $$ along the left margin?
See (info "(emacs) Bidirectional Editing") for this.
If the text were all Hebrew, you could set the variable
`bidi-paragraph-direction` to `right-to-left` and have all text start at the
right margin. Otherwise, I think all you can do is insert the special Unicode
character LEFT-TO-RIGHT MARK at the beginning of the relevant line. I don't know
what your TeX system will do with that character, though.
The character $ has 'weak directionality', meaning that (as stated in the Elisp
manual) it "take[s] on the directionality of surrounding text".[1] It seems that
"surrounding text" in this case means "preceding text", which probably makes
sense in most cases, but not necessarily in your particular case, where $
follows a blank line (assuming you have blank lines surrounding $$...$$). Though
perhaps someone more knowledgeable than me can shed some light on this.
HTH
Joost
Footnotes:
[1] (info "(elisp) Bidirectional Display")
--
Joost Kremers
Life has its moments
On Tue, Nov 15, 2022 at 1:33 PM Joost Kremers wrote:
> I think all you can do is insert the special Unicode character LEFT-TO-RIGHT MARK at the beginning of the relevant line. I don't know what your TeX system will do with that character, though.
I have solved the problem using the following workaround: I have added
the comment "%LTR" immediately after the second dollar sign. Now that
the line contains letters from the English alphabet, Emacs' bidi
algorithm recognizes it as English text, and therefore justifies it to
the left of the buffer. However, since this is a TeX comment, it is
ignored by the TeX compiler, and therefore affects the processing, and
the resulting typeset PDF file, in no way.