0

I have written a short document in org and I have tried to export it to a PDF document for printing and readable formatting. I am facing some issues however since the document should include both English and Hebrew

trying to export the document using org-latex-export-to-pdf leaves me with a left justified file (as opposed to being right justified for Hebrew) and all Hebrew text is excluded.

Something notable that happens is that all hebrew is missing from the file but still shows up as headlines outside of the document itself:

1

I will also attach the original org file:

* אודות
קובץ זה נועד לשמש בתור חומר עזר לבחינות בתכנות מחשבים ב#C
הקובץ יכלול תכנים כמו הסברים על כל מושגים, תבניות, וכו'

*שימו לב כי הקובץ מרוכז סביב C#*

* תבניות
** (a, b)החלפה בין שני ערכים
#+begin_src csharp
  int a, b, temp;
  temp = a;
  a = b;
  b = temp;
#+end_src

** יצירת משתנה עם ערך אקראי
#+begin_src csharp
  Random rnd = new Random();
  // העצם שנוצר כעט אחראי ליצירת ערכים אקראים
  // כעט ניצור משתנה ואליו תעשה השמה של הערך האקראי החדש שניצור
  int num = rnd.Next(1,7);
  // הערך שנקבל במשתנה יהיה מספר בין 1 ל 6
#+end_src

although it's optional I would much prefer to right justify all text

1 Answer 1

2

You need to use the the enhanced ODT exporter ox-odt-9.5.3.456.tar or later (or simply, any version whose date is later than this comment's date).

The enhanced ODT backend is not available with standard Emacs or Org mode, and you need to install it separately. See Getting Started with ODT export (OpenDocument Text Exporter for Emacs’ Org Mode for instructions.

The snippet below has two numbers of COMMENT-ed headlines. If you uncomment and export you will get different outputs as seen below.

I have never used any of the RTL scripts.

Before typing out this reply I have looked at

  1. How to setup LibreOffice Right To Left Hebrew - English - Ask LibreOffice
  2. Changing back and forth, RTL and LTR - English - Ask LibreOffice

I have also tried typing the examples in (2) with LRE, LRM, RLE and PDF marks in Emacs, and from what I can see, the behaviour on the LibreOffice side, matches with what the author describes there.

(2) above is about what you type in the Emacs buffer, and the exporter has no control over it. (1) above is about how the LibreOffice prints the text runs. So, this response will focus on implementing (1), with enhanced ODT expoter.

That said, I am very much interested in improving the enhanced exporter, if there is a need, to support mixed-language texts, atleast the simple cases. Please file a bug report or start a discussion thread at The Authoritative fork of Org mode's ODT exporter

(Note: In screenshots below, TOC should be right aligned, but it is NOT because of LibreOffice Bug#149259: After updating a Table Of Contents, text alignment of toc entries is not preserved)

If you want this

Hebrew paragraphs are right aligned, while code blocks are left aligned

do this

Snippet - Add / Remove the COMMENT-s to produce different print rendering


#+odt_preferred_output_format: pdf

# * COMMENT Align all paragraphs to the Right
* Align all paragraphs to the Right

#+ATTR_ODT: :target "extra_styles"
#+begin_src nxml
<style:style style:name="Standard"
             style:family="paragraph"
             style:class="text"
             style:master-page-name="">
  <style:paragraph-properties fo:text-align="end"
                              style:justify-single-word="false"
                              style:page-number="auto">
    <style:tab-stops />
  </style:paragraph-properties>
</style:style>
#+end_src

# * COMMENT ... but align ~example~ blocks to the Left
* ... but align ~example~ blocks to the Left

#+ATTR_ODT: :target "extra_styles"
#+begin_src nxml
<style:style style:name="OrgFixedWidthBlock"
             style:parent-style-name="Preformatted_20_Text"
             style:family="paragraph"
             style:master-page-name="">
  <style:paragraph-properties fo:background-color="transparent"
                              fo:border="0.06pt solid #000000"
                              fo:padding="0.049cm"
                              fo:text-align="start"
                              style:justify-single-word="false"
                              style:page-number="auto"
                              style:shadow="none" />
</style:style>
#+end_src

* אודות
קובץ זה נועד לשמש בתור חומר עזר לבחינות בתכנות מחשבים ב#C
הקובץ יכלול תכנים כמו הסברים על כל מושגים, תבניות, וכו'

*שימו לב כי הקובץ מרוכז סביב C#*

* תבניות
** (a, b)החלפה בין שני ערכים
#+begin_src csharp
  int a, b, temp;
  temp = a;
  a = b;
  b = temp;
#+end_src

** יצירת משתנה עם ערך אקראי
#+begin_src csharp
  Random rnd = new Random();
  // העצם שנוצר כעט אחראי ליצירת ערכים אקראים
  // כעט ניצור משתנה ואליו תעשה השמה של הערך האקראי החדש שניצור
  int num = rnd.Next(1,7);
  // הערך שנקבל במשתנה יהיה מספר בין 1 ל 6
#+end_src


By un-COMMENT-ing you can get these renderings ...

What you get by default without any custom styles whatsoever What you get by default

What you get when all paragraphs are aligned to the right What you get when all paragraphs are aligned to the right

5
  • Is there a way to align the Table of Contents itself to the right? (not the end of the world)
    – qKweint
    May 24, 2022 at 9:29
  • You haven't tried my suggestion ... See LibreOffice Bug#149259: After updating a Table Of Contents, text alignment of toc entries is not preserved
    – user31220
    May 24, 2022 at 10:47
  • For some reason the export is stylized like this imgur.com/a/bZLxmiD I have checked that odt is using the enhanced version. and the comments you provided are uncommented (unless I misunderstood what to uncomment).
    – qKweint
    May 25, 2022 at 14:50
  • Also using both comments to align regular text to the right and code to the left does not work, all text is aligned to right
    – qKweint
    May 25, 2022 at 15:10
  • If a headline is COMMENT-ed then nxml block under it will not take effect. Standard style has fo:text-align="end" and OrgFixedWidthBlock has fo:text-align="start" in their definitions. In your case, the OrgFixedWidthBlock definition is not taking effect. I suggest that you look up for further help in COMMENT or Good Resources for learning LibreOffice
    – user31220
    May 27, 2022 at 2:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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