Closed bykhov closed 2 years ago
Is this with XeTeX or LuaTeX?
To answer myself: XeTeX. LuaTeX does not show the problem.
I checked out an old polyglossia version and see the same problem. So the bug seems to be in bidi
(where you also have reported the same issue without letting us know here; see https://github.com/tex-persian/bidi/issues/12)
I checked out an old polyglossia version and see the same problem. So the bug seems to be in
bidi
(where you also have reported the same issue without letting us know here; see tex-persian/bidi#12)
Sorry for not informing you.
Anyway, bidi
maintainer convinced me that it is not bidi
issue (polyglossia
one?).
Adding english
environment solves the problem, but it previously worked fine \setLR
and \setRL
I checked out an old polyglossia version and see the same problem.
It works fine for me with polyglossia
version 1.52
It works fine for me with
polyglossia
version 1.52
Sorry I cannot confirm this. I checkout out older revisions of polyglossia back to v. 1.47, and all show the same output. So it must be a change in another package (such as bidi
or maybe minted
) that cause this. This is not to say that this isn't a problem that can/should be addressed by polyglossia, but it is certainly not a bug introduced by polyglossia.
@jspitz This is caused by the fact that we pass the Hebrew Script feature to the font. Maybe we should ad an option to disable this for typewriter fonts, as they are often used for listings only.
the bidi
package has nothing to do with parenthesis, This is a feature of XeTeX, which applies the unicode BiDi algorithm on short chunks of text when system fonts are used, and is relying on stuff like the Script that is used to determine if parenthesis should be mirrored or not.
I was just trying to revive some old documents last week.
My workaround was \begin{english} ...\end{english}
for each code block.
Or, with some automation:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{minted,color}
\newminted{python}{}
\BeforeBeginEnvironment{pythoncode}{\setLR\begin{english}}
\AfterEndEnvironment{pythoncode}{\end{english}\setRL}
\usepackage{polyglossia,bidi}
\setmainlanguage{hebrew}
\setotherlanguage{english}
\setmainfont{Times New Roman}
\setmonofont{Courier New}
\begin{document}
\begin{english}
\begin{pythoncode}
x = [x ]
\end{pythoncode}
\end{english}
\end{document}
@jspitz This is caused by the fact that we pass the Hebrew Script feature to the font. Maybe we should ad an option to disable this for typewriter fonts, as they are often used for listings only.
This strikes me like an odd solution. IMHO the language needs to be reset for the listings. Ideally minted should deal with this.
This strikes me like an odd solution. IMHO the language needs to be reset for the listings. Ideally minted should deal with this.
I don't think it is odd. Typewriter fonts are often treated differently. For example, fontspec does not add to them Mapping=tex-text
or the +tlig
features like to sans serif or serif fonts. Imagine I have only hebrew in my document, I don't really want to load the english gloss just for listings, I don't need any of its features, not even hyphenation.
I don't think you need to load English. Setting language latex
would probably do.
Is this documented?
No.
After the recent update, the direction of parenthesis in minted environment is wrong.
Example:
Resulting file attached a.pdf