all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
@ 2022-11-10  6:11 Ihor Radchenko
  2022-11-10 12:40 ` Juan Manuel Macías
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-10  6:11 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I am trying to look into RTL language exports.

I tried the following simple-minded Org file:

#+title: Temp
#+LATEX_COMPILER: lualatex
#+LANGUAGE: HE

\begin{equation}
f(x) = \frac{8}{7}
\end{equation}

#+begin_src python :exports code
for i in range(3):
	print("hello")
#+end_src

And exported to pdf (C-c C-e l o).
Surprisingly, the output is in English.

Am I missing something?

Emacs  : GNU Emacs 28.1.90 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.16.0)
 of 2022-07-17
Package: Org mode version 9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)
-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-10  6:11 [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)] Ihor Radchenko
@ 2022-11-10 12:40 ` Juan Manuel Macías
  2022-11-11  2:04   ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-11-10 12:40 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko writes:

> I am trying to look into RTL language exports.
>
> I tried the following simple-minded Org file:
>
> #+title: Temp
> #+LATEX_COMPILER: lualatex
>
> #+LANGUAGE: HE
>
> \begin{equation}
> f(x) = \frac{8}{7}
> \end{equation}
>
> #+begin_src python :exports code
> for i in range(3):
> 	print("hello")
> #+end_src
>
> And exported to pdf (C-c C-e l o).
> Surprisingly, the output is in English.
>
> Am I missing something?

You need to explicitly load babel or polyglossia:

For polyglossia (`org-latex-guess-polyglossia-language'):

#+LaTeX_Header: \usepackage[AUTO]{polyglossia}

For babel (`org-latex-guess-babel-language'):

#+LaTeX_Header: \usepackage[bidi=basic]{babel}
#+LaTeX_Header: \babelprovide[import, main]{AUTO}

There was a discussion in an old thread about the possibility of loading
babel or polyglossia automatically (I think Maxim was in favor of it,
and brought up some possibilities). The problem is that babel's syntax
is somewhat more complex than polyglossia's, and admits many variants.
Also in babel there are languages that are loaded using the new ini file
system with the command \babelprovide. Currently,
org-latex-guess-babel-language supports babelprovide, but you need to
load the command explicitly:

#+LaTeX_Header: \babelprovide[options]{AUTO}

BTW I've noticed that the value of #+language is not case-agnostic. You
should put "he". Should it be case-agnostic? In the previous
implementation, when there were two language lists for babel and
polyglossia, neither was it.

Best regards,

Juan Manuel 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-10 12:40 ` Juan Manuel Macías
@ 2022-11-11  2:04   ` Ihor Radchenko
  2022-11-11 15:08     ` Juan Manuel Macías
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-11  2:04 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: emacs-orgmode

Juan Manuel Macías <maciaschain@posteo.net> writes:

>> And exported to pdf (C-c C-e l o).
>> Surprisingly, the output is in English.
>>
>> Am I missing something?
>
> You need to explicitly load babel or polyglossia:
>
> For polyglossia (`org-latex-guess-polyglossia-language'):
>
> #+LaTeX_Header: \usepackage[AUTO]{polyglossia}

Aha! I missed that part in the newer manual.

Note that the manual only talks about setting
`org-latex-packages-alist'. Not the keyword.

Maybe we can add the #+LATEX_HEADER example to the manual.

> BTW I've noticed that the value of #+language is not case-agnostic. You
> should put "he". Should it be case-agnostic? In the previous
> implementation, when there were two language lists for babel and
> polyglossia, neither was it.

I think that it is a good idea. I do not recall common language
abbreviations to be case-sensitive in other software.

---------

Now, let me continue to act like an ordinary user and follow your
suggestion :)

I tried to add the header:

#+title: Temp
#+LATEX_COMPILER: lualatex
#+LANGUAGE: he
#+LaTeX_Header: \usepackage[AUTO]{polyglossia}

\begin{equation}
f(x) = \frac{8}{7}
\end{equation}

#+begin_src python :exports code
for i in range(3):
	print("hello")
#+end_src

Then, C-c C-e l o

And I get an error...

Rc files read:
  NONE
Latexmk: This is Latexmk, John Collins, 29 September 2020, version: 4.70b.
Rule 'lualatex': File changes, etc:
   Changed files, or newly in use since previous run(s):
      'bug.tex'
------------
Run number 1 of rule 'lualatex'
------------
------------
Running 'lualatex  -interaction=nonstopmode -recorder -output-directory="."  "bug.tex"'
------------
Set environment variable BIBINPUTS='.:'
Set environment variable TEXINPUTS='.:'
Latexmk: applying rule 'lualatex'...
This is LuaHBTeX, Version 1.13.0 (TeX Live 2021 Gentoo Linux) 
 restricted system commands enabled.
(./bug.tex
LaTeX2e <2020-10-01> patch level 4
 L3 programming layer <2021-02-18>
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class

[clipped]

(/usr/share/texmf-dist/tex/luatex/luatexbase/luatexbase.sty
(/usr/share/texmf-dist/tex/luatex/ctablestack/ctablestack.sty))
(/usr/share/texmf-dist/tex/latex/polyglossia/gloss-latex.ldf))
(/usr/share/texmf-dist/tex/latex/polyglossia/gloss-hebrew.ldf

! LaTeX Error: File `luabidi.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name: 
! Emergency stop.
<read *> 
   
l.3 \RequireBidi
              
 440 words of node memory still in use:
   3 hlist, 1 rule, 1 dir, 3 kern, 1 glyph, 4 attribute, 58 glue_spec, 4 attrib
ute_list, 1 if_stack, 1 write nodes
   avail lists: 2:13,3:2,4:1,5:2,7:2,9:2
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on bug.log.
Latexmk: Missing input file: 'luabidi.sty' from line
  '! LaTeX Error: File `luabidi.sty' not found.'
Failure to make 'bug.pdf'
Collected error summary (may duplicate other messages):
  lualatex: Command for 'lualatex' gave return code 1
      Refer to 'bug.log' for details
Latexmk: Examining 'bug.log'
=== TeX engine is 'LuaHBTeX'
Latexmk: Errors, in force_mode: so I tried finishing targets


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-11  2:04   ` Ihor Radchenko
@ 2022-11-11 15:08     ` Juan Manuel Macías
  2022-11-13  4:09       ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-11-11 15:08 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Hi, Ihor,

I start by comment the error that you get when compiling. Is it possible
that you have an incomplete TeX Live installation? Distro repositories
usually offer TeX live in a modular way. On Arch Linux and its
derivatives, the texlive-lang and texlive-lang-extra packages should be
installed for non-Latin language support (this would include the luabidi
package). In the Ubuntu/Debian family I think the required package is
called texlive-lang-arabic. Anyway, I recommend installing TeX live in
its entirety (the drawback is that it takes up more space). I think that
in Ubuntu and family the meta-package is called texlive-full. Another
possibility that I recommend, especially on distros that package older
versions of TeX live, is to install the official TeX live distribution:
https://tug.org/texlive/acquire.html (this has the advantage of being
able to update everything more regularly via TeX live's own package
manager). If you want to keep the official packages of your distro, but
also want to try new things, it is also possible to create a portable
installation of TeX live on a pen drive:
https://tug.org/texlive/archive/portable-anchor.html

Ihor Radchenko writes:

> Aha! I missed that part in the newer manual.
>
> Note that the manual only talks about setting
> `org-latex-packages-alist'. Not the keyword.
>
> Maybe we can add the #+LATEX_HEADER example to the manual.

There are examples included in 'LaTeX header and sectioning structure'.
Perhaps it would be nice to add some more examples in the case of Bidi
languages, Chinese, Japanese, etc.? In the case of CJK languages, I
think additional LaTeX packages are required.

>> BTW I've noticed that the value of #+language is not case-agnostic. You
>> should put "he". Should it be case-agnostic? In the previous
>> implementation, when there were two language lists for babel and
>> polyglossia, neither was it.
>
> I think that it is a good idea. I do not recall common language
> abbreviations to be case-sensitive in other software.
>

I totally agree: that's something I missed when I made the previous
patch...

Best regards,

Juan Manuel 



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-11 15:08     ` Juan Manuel Macías
@ 2022-11-13  4:09       ` Ihor Radchenko
  2022-11-13 13:27         ` Juan Manuel Macías
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-13  4:09 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: emacs-orgmode

Juan Manuel Macías <maciaschain@posteo.net> writes:

> I start by comment the error that you get when compiling. Is it possible
> that you have an incomplete TeX Live installation? Distro repositories
> usually offer TeX live in a modular way. On Arch Linux and its
> derivatives, the texlive-lang and texlive-lang-extra packages should be
> installed for non-Latin language support (this would include the luabidi
> package). In the Ubuntu/Debian family I think the required package is
> called texlive-lang-arabic. Anyway, I recommend installing TeX live in
> its entirety (the drawback is that it takes up more space). I think that
> in Ubuntu and family the meta-package is called texlive-full. Another
> possibility that I recommend, especially on distros that package older
> versions of TeX live, is to install the official TeX live distribution:
> https://tug.org/texlive/acquire.html (this has the advantage of being
> able to update everything more regularly via TeX live's own package
> manager). If you want to keep the official packages of your distro, but
> also want to try new things, it is also possible to create a portable
> installation of TeX live on a pen drive:
> https://tug.org/texlive/archive/portable-anchor.html

Thanks for the detailed explanation! We may put something similar (or
shorter) into the manual (maybe as a footnote).

On Gentoo, the required package is dev-texlive/texlive-langarabic.

However, installing the package is not yet enough!

With the same file, I am getting missing font errors:

Setting \if@calendar@hebrew
(/usr/share/texmf-dist/tex/latex/polyglossia/babel-hebrewalph.def)) (./bug.aux

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.19 \selectlanguage *{hebrew}
                            
) (/usr/share/texmf-dist/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf-dist/tex/context/base/mkii/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texmf-dist/tex/latex/epstopdf-pkg/epstopdf-base.sty
(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
(/usr/share/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texmf-dist/tex/latex/refcount/refcount.sty)
(/usr/share/texmf-dist/tex/generic/gettitlestring/gettitlestring.sty))
(./bug.out) (./bug.out)

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.25 \begin{document}
                   
(/usr/share/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texmf-dist/tex/latex/amsfonts/umsb.fd)

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.28 \tableofcontents
                   
(./bug.toc

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.1 \selectlanguage *{hebrew}
                           
)

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.32 \end{equation}
                 

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.34 \begin{verbatim}
                   

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.34 \begin{verbatim}
                   

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.38 \end{document}
                 

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.38 \end{document}
                 
[1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./bug.aux

! Package polyglossia Error: The current latin font  does not contain the "Hebr
ew" script!
(polyglossia)                Please define \hebrewfont with \newfontfamily comm
and.

See the polyglossia package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.19 \selectlanguage *{hebrew}
                            
))
(see the transcript file for additional information)
 537 words of node memory still in use:
   6 hlist, 2 vlist, 2 rule, 2 glue, 4 kern, 1 glyph, 8 attribute, 61 glue_spec
, 8 attribute_list, 1 write nodes
   avail lists: 2:132,3:70,4:3,5:46,6:14,7:406,8:20,9:104,10:2
</usr/share/texmf-dist/fonts/opentype/public/lm/lmmono10-regular.otf></usr/shar
e/texmf-dist/fonts/opentype/public/lm/lmroman10-regular.otf></usr/share/texmf-d
ist/fonts/opentype/public/lm/lmroman12-bold.otf></usr/share/texmf-dist/fonts/op
entype/public/lm/lmroman12-regular.otf></usr/share/texmf-dist/fonts/opentype/pu
blic/lm/lmroman17-regular.otf></usr/share/texmf-dist/fonts/type1/public/amsfont
s/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb
>
Output written on bug.pdf (1 page, 28185 bytes).
Transcript written on bug.log.
Latexmk: Log file says output to 'bug.pdf'
Latexmk: Summary of warnings from last run of *latex:
  =====Latex reported missing or unavailable character(s).
=====See log file for details.
Collected error summary (may duplicate other messages):
  lualatex: Command for 'lualatex' gave return code 1
      Refer to 'bug.log' for details
Latexmk: Examining 'bug.log'
=== TeX engine is 'LuaHBTeX'
Latexmk: Errors, in force_mode: so I tried finishing targets

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-13  4:09       ` Ihor Radchenko
@ 2022-11-13 13:27         ` Juan Manuel Macías
  2022-11-14  2:38           ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-11-13 13:27 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko writes:

> On Gentoo, the required package is dev-texlive/texlive-langarabic.
>
> However, installing the package is not yet enough!
>
> With the same file, I am getting missing font errors:
>
> Setting \if@calendar@hebrew
> (/usr/share/texmf-dist/tex/latex/polyglossia/babel-hebrewalph.def)) (./bug.aux
>
> ! Package polyglossia Error: The current latin font  does not contain the "Hebr
> ew" script!
> (polyglossia)                Please define \hebrewfont with \newfontfamily comm
> and.

hmm, yes, I forgot to mention it before... It is necessary to load a
font that has support for Hebrew script, via fontspec package, otherwise
it will return an error, both with Polyglossia and with Babel. It should
be added:

\usepackage{fontspec}
\setmainfont{FreeSerif}

FreeSerif would work, if we do the test with otfinfo:

┌────
│ otfinfo -s /path/to/FreeSerif.ttf
│ 
│ DFLT            Default
│ arab            Arabic
│ beng            Bengali
│ bng2            Bengali v.2
│ copt            Coptic
│ cyrl            Cyrillic
│ dev2            Devanagari v.2
│ glag            Glagolitic
│ goth            Gothic
│ grek            Greek
│ hano            Hanunoo
│ hebr            Hebrew
│ latn            Latin
│ latn.NLD        Latin/Dutch
│ latn.TRK        Latin/Turkish
│ mlym            Malayalam
│ taml            Tamil
│ thai            Thai
└────

The use of the fontspec package (https://www.ctan.org/pkg/fontspec) is
ubiquitous in LuaTeX or XeTeX as long as one wants to have control
over fonts and use extended languages and characters. LuaTeX and XeTeX
use by default (for debatable historical reasons[1]) a Unicode variant
of the Computern Modern font, which has limited language coverage. I
remember that it was commented in a previous thread the possibility of
offering (for example, through a series of variables), a minimum
coverage of fonts to ensure that the documents, at least, are compiled
well and are readable. The user could redefine those variables to use
their preferred fonts. Or have the option that this part of the
preamble is not created, to have full control. I remember that I
proposed this, but there were other interesting proposals. For
example, Timothy commented on the possibility of using fontsets.

In LuaTeX you can define fallback fonts at a low level, using
luaotfload, for example:

┌────
│ \directlua
│ {luaotfload.add_fallback
│   ("myfallback",
│   {
│     "freeserif:mode=harf;script=grek",
│     "freeserif:mode=harf;script=cyrl",
│     "freeserif:mode=harf;script=arab",
│     "freeserif:mode=harf;script=hebr",
│   }
│   )
│ }
│ 
│ \setmainfont{latinmodernroman}[RawFeature={fallback=myfallback}]
└────

In the example above, it is defined Free Serif as fallback font for
Cyrillic, Greek, Arabic and Hebrew scripts. And HarfBuzz is used as
the OpenType rendering engine. As an example, it is valid, although it
is still a typographical aberration, since Free Serif and Latin Modern
are incompatible by design. But that is already an aesthetic issue :-) 

I think that doing something similar in Org would be a bit complicated,
since it would be necessary to guess what languages and scripts are used
in each document. But a number of basic variables like
’defaultromanfont’, ’defaultmonofont’, etc. could be enough. But leaving
the possibility for the user with advanced knowledge of LuaTeX or XeTeX
to have full control, since the configuration of fonts and languages can
become very complex and extensive in multilingual documents.

[1] My admiration for Donald Knuth is limitless, but in the case of the
Computern Modern font I think Knuth (IMHO) was not inspired. It is a
font with many design flaws, difficult to read on the screen. I
understand that it is hard to get rid of such a TeX hallmark as
Computern Modern, but it would be necessary, especially now that TeX
can use truetype and opentype fonts and metafont has been obsolete. The
CM font is also the reason why many people who have never used LaTeX
think that all LaTeX documents look alike.
 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-13 13:27         ` Juan Manuel Macías
@ 2022-11-14  2:38           ` Ihor Radchenko
  2022-11-14 22:25             ` Juan Manuel Macías
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-14  2:38 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1160 bytes --]

Juan Manuel Macías <maciaschain@posteo.net> writes:

>> ! Package polyglossia Error: The current latin font  does not contain the "Hebr
>> ew" script!
>> (polyglossia)                Please define \hebrewfont with \newfontfamily comm
>> and.
>
> hmm, yes, I forgot to mention it before... It is necessary to load a
> font that has support for Hebrew script, via fontspec package, otherwise
> it will return an error, both with Polyglossia and with Babel. It should
> be added:
>
> \usepackage{fontspec}
> \setmainfont{FreeSerif}

Ok. Now, I am at least able to get the pdf. Hooray! :)

#+title: Temp
#+LATEX_COMPILER: lualatex
#+LANGUAGE: he
#+LaTeX_Header: \usepackage[AUTO]{polyglossia}
#+LaTeX_Header: \setmainfont{FreeSerif}

\begin{equation}
f(x) = \frac{8}{7}
\end{equation}

#+begin_src python :exports code
for i in range(3):
    print("hello")
#+end_src

However, the PDF (see the attached) is erroneous:
1. Title "Temp" is written RTL
2. Year and date (numbers!) are written RTL
3. The python code is written RTL!!

Just the equation is rendered LTR as expected and the ordinary Hebrew
text is rendered RTL.


[-- Attachment #2: bug.pdf --]
[-- Type: application/pdf, Size: 26980 bytes --]

[-- Attachment #3: Type: text/plain, Size: 1266 bytes --]


> The use of the fontspec package (https://www.ctan.org/pkg/fontspec) is
> ubiquitous in LuaTeX or XeTeX as long as one wants to have control
> over fonts and use extended languages and characters. LuaTeX and XeTeX
> use by default (for debatable historical reasons[1]) a Unicode variant
> of the Computern Modern font, which has limited language coverage. I
> remember that it was commented in a previous thread the possibility of
> offering (for example, through a series of variables), a minimum
> coverage of fonts to ensure that the documents, at least, are compiled
> well and are readable. The user could redefine those variables to use
> their preferred fonts. Or have the option that this part of the
> preamble is not created, to have full control. I remember that I
> proposed this, but there were other interesting proposals. For
> example, Timothy commented on the possibility of using fontsets.

I hope that it can be implemented some day.
For now, we should detail important things, like setting suitable font,
in the manual.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-14  2:38           ` Ihor Radchenko
@ 2022-11-14 22:25             ` Juan Manuel Macías
  2022-11-15  2:46               ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Juan Manuel Macías @ 2022-11-14 22:25 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko writes:

> However, the PDF (see the attached) is erroneous:
> 1. Title "Temp" is written RTL
> 2. Year and date (numbers!) are written RTL
> 3. The python code is written RTL!!
>
> Just the equation is rendered LTR as expected and the ordinary Hebrew
> text is rendered RTL.

I'd say that's expected behavior. Note that if you declare Hebrew as the
main language, the LaTeX classes (in this case article.cls) will put
whatever is necessary in Hebrew and use the Hebrew (and RTL) typographic
rules where necessary, and that includes the title, the date, and the
various literal strings as the table of contents, figure counters,
captions, etc.

To use Hebrew in another context, it would have to be declared as a
secondary language. The latest versions of Babel allow you to associate
languages to scripts when it comes to non-Latin alphabets (Cyrillic,
Greek, Arabic, etc.), and also to associate fonts. In this way it would
not be necessary to indicate the language explicitly by means of a
\selectlanguage{} or \foreignlanguage{}{}. For example, suppose that my
document has Spanish as its main language, but I also add parts in
Hebrew, which would be automatically recognized by Babel, by putting
this:

#+LaTeX_Header: \usepackage{fontspec}
#+LaTeX_Header: \setmainfont{FreeSerif}
#+LaTeX_Header: \usepackage[AUTO,bidi=basic]{babel}
#+LaTeX_Header: \babelprovide[onchar=ids,import]{hebrew}
#+language: es

(...And curiously I just realized with this example that it is necessary
to fix `org-latex-guess-babel-language', because in the current state it
returns an error if a string other than AUTO is put as argument of
babelprovide. I'll open another thread to submit a patch to fix that).

>> The use of the fontspec package (https://www.ctan.org/pkg/fontspec) is
>> ubiquitous in LuaTeX or XeTeX as long as one wants to have control
>> over fonts and use extended languages and characters. LuaTeX and XeTeX
>> use by default (for debatable historical reasons[1]) a Unicode variant
>> of the Computern Modern font, which has limited language coverage. I
>> remember that it was commented in a previous thread the possibility of
>> offering (for example, through a series of variables), a minimum
>> coverage of fonts to ensure that the documents, at least, are compiled
>> well and are readable. The user could redefine those variables to use
>> their preferred fonts. Or have the option that this part of the
>> preamble is not created, to have full control. I remember that I
>> proposed this, but there were other interesting proposals. For
>> example, Timothy commented on the possibility of using fontsets.
>
> I hope that it can be implemented some day.
> For now, we should detail important things, like setting suitable font,
> in the manual.

Perhaps a FONTS item could be added in "LaTeX specific export settings"?

Best regards,

Juan Manuel 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)]
  2022-11-14 22:25             ` Juan Manuel Macías
@ 2022-11-15  2:46               ` Ihor Radchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2022-11-15  2:46 UTC (permalink / raw)
  To: Juan Manuel Macías; +Cc: emacs-orgmode

Juan Manuel Macías <maciaschain@posteo.net> writes:

> Ihor Radchenko writes:
>
>> However, the PDF (see the attached) is erroneous:
>> 1. Title "Temp" is written RTL
>> 2. Year and date (numbers!) are written RTL
>> 3. The python code is written RTL!!
>>
>> Just the equation is rendered LTR as expected and the ordinary Hebrew
>> text is rendered RTL.
>
> I'd say that's expected behavior. Note that if you declare Hebrew as the
> main language, the LaTeX classes (in this case article.cls) will put
> whatever is necessary in Hebrew and use the Hebrew (and RTL) typographic
> rules where necessary, and that includes the title, the date, and the
> various literal strings as the table of contents, figure counters,
> captions, etc.

I agree about year, title, and date. However, not the code. I'd expect
code snippets to use LTR by default. Maybe with an export flag to switch
to RTL.

> To use Hebrew in another context, it would have to be declared as a
> secondary language. The latest versions of Babel allow you to associate
> languages to scripts when it comes to non-Latin alphabets (Cyrillic,
> Greek, Arabic, etc.), and also to associate fonts. In this way it would
> not be necessary to indicate the language explicitly by means of a
> \selectlanguage{} or \foreignlanguage{}{}. For example, suppose that my
> document has Spanish as its main language, but I also add parts in
> Hebrew, which would be automatically recognized by Babel, by putting
> this:
>
> #+LaTeX_Header: \usepackage{fontspec}
> #+LaTeX_Header: \setmainfont{FreeSerif}
> #+LaTeX_Header: \usepackage[AUTO,bidi=basic]{babel}
> #+LaTeX_Header: \babelprovide[onchar=ids,import]{hebrew}
> #+language: es

Should we allow #+language to have multiple values like

#+language: es en ru uk

with first value defining primary language and the rest being secondary?

Also, what does bidi=basic do?

Finally, may it be useful to provide a syntax (affiliated keyword) that
will set a language for specific paragraph?

> Perhaps a FONTS item could be added in "LaTeX specific export settings"?

Do we have #+FONTS setting? I'd say that it is worth adding.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-15  2:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-10  6:11 [BUG] LaTeX export in non-English language [9.6-pre (release_9.5.5-1087-g620a96.dirty @ /home/yantar92/.emacs.d/straight/build/org/)] Ihor Radchenko
2022-11-10 12:40 ` Juan Manuel Macías
2022-11-11  2:04   ` Ihor Radchenko
2022-11-11 15:08     ` Juan Manuel Macías
2022-11-13  4:09       ` Ihor Radchenko
2022-11-13 13:27         ` Juan Manuel Macías
2022-11-14  2:38           ` Ihor Radchenko
2022-11-14 22:25             ` Juan Manuel Macías
2022-11-15  2:46               ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.