Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with period in headings number (RTL languages) #213

Closed
seloumi opened this issue Nov 7, 2018 · 33 comments
Closed

Issue with period in headings number (RTL languages) #213

seloumi opened this issue Nov 7, 2018 · 33 comments

Comments

@seloumi
Copy link

seloumi commented Nov 7, 2018

Consider this example of writing arabic headings with tableofcontents

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\begin{document}

\tableofcontents

\section{عنوان أول}
\subsection{عنوان فرعي أول}
\subsection{عنوان فرعي ثان}
\section{عنوان ثان}
1.23
\end{document}

Which produce

capture

Numbers with period in headings are reversed, this is due to a code from bidi package which invert nembers containing a period but this is not desirable inside headings numbers.

A solution for this issue is to add \setnonlatin from bidi like this

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\setnonlatin

\begin{document}

\tableofcontents

\section{عنوان أول}
\subsection{عنوان فرعي أول}
\subsection{عنوان فرعي ثان}
\section{عنوان ثان}
1.23
\end{document}

My request is adding this solution when an RTL language is defined as main language, thanks a lot.

@seloumi seloumi closed this as completed Dec 30, 2018
@seloumi seloumi reopened this Jan 4, 2019
@seloumi
Copy link
Author

seloumi commented Jun 17, 2019

No reply !!!

@jspitz
Copy link
Collaborator

jspitz commented Sep 1, 2019

@seloumi can you please try if the following change in gloss-arabic produces the correct result in- and outside headings?

\def\arabicnumber#1{%
  \ifeastern@numerals
    \arabicdigits{\number#1}%
  \else
    \RL{\number#1}%
  \fi}

Just replace the existing \arabicnumber definition with this.

@jspitz
Copy link
Collaborator

jspitz commented Sep 1, 2019

or even better

\def\arabicnumber#1{%
  \ifeastern@numerals
    \arabicdigits{\number#1}%
  \else
    \@ensure@dir{\number#1}%
  \fi}

@seloumi
Copy link
Author

seloumi commented Sep 1, 2019

Yes this solve the problem

@jspitz jspitz closed this as completed in 6e0adbd Sep 1, 2019
@jspitz
Copy link
Collaborator

jspitz commented Sep 1, 2019

Thanks for testing. Fixed.

@seloumi
Copy link
Author

seloumi commented Sep 1, 2019

@jspitz But for mashriq option of numerals the issue still exists

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=mashriq]{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\begin{document}

\tableofcontents

\section{عنوان أول}
\subsection{عنوان فرعي أول}
\subsection{عنوان فرعي ثان}
\section{عنوان ثان}
١.٢٣
\end{document}

image

@seloumi seloumi changed the title Issue with period in headings number (arabic language) Issue with period in headings number (RTL languages) Sep 1, 2019
@seloumi
Copy link
Author

seloumi commented Sep 1, 2019

I think the issue can be solved either for maghrib or mashriq form with

\def\arabicnumber#1{%
\ifeastern@numerals
\@ensure@dir{\arabicdigits{\number#1}}%
\else
\@ensure@dir{\number#1}%
\fi}

@jspitz
Copy link
Collaborator

jspitz commented Sep 1, 2019

OK, done.

@seloumi
Copy link
Author

seloumi commented Sep 1, 2019

Thanks a lot

@jspitz
Copy link
Collaborator

jspitz commented Sep 2, 2019

I've reverted the fixes. It turned out \set[non]latin is the way to go.

See bidi-tex/bidi#5

@jspitz jspitz reopened this Sep 2, 2019
@jspitz jspitz closed this as completed in 65084d6 Sep 3, 2019
@jspitz
Copy link
Collaborator

jspitz commented Sep 3, 2019

Re-fixed with \setlatin/\setnonlatin.
@seloumi please test.

@seloumi
Copy link
Author

seloumi commented Sep 3, 2019

@jspitz This solve the issue but another problem appear with numerals=maghrib numbering of equation still in mashriq form !
There are also warnings of hyphenation from latex-gloss.sty

\documentclass{article}
\usepackage{amsmath}
\usepackage{polyglossia}
\setdefaultlanguage[numerals=maghrib]{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\begin{document}

\tableofcontents

\section{عنوان أول}
\subsection{عنوان فرعي أول}
\subsection{عنوان فرعي ثان}
\section{عنوان ثان}

\begin{equation}
a=\frac{dx}{dt}
\end{equation}

\end{document}

Capture

@jspitz
Copy link
Collaborator

jspitz commented Sep 3, 2019

@jspitz This solve the issue but another problem appear with numerals=maghrib numbering of equation still in mashriq form !

Fixed.

There are also warnings of hyphenation from latex-gloss.sty

Yes, this is known.

@seloumi
Copy link
Author

seloumi commented Oct 30, 2019

@jspitz with version 1.45 the issue persists for eastern numerals form (numbers for subsection heading still reversed)

\documentclass[12pt]{article}
\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic]{Amiri}

\begin{document}

\section{عنوان}
\subsection{عنوان فرعي أول}
\subsection{عنوان فرعي ثاني}

\end{document}

image

jspitz added a commit that referenced this issue Oct 31, 2019
@jspitz
Copy link
Collaborator

jspitz commented Oct 31, 2019

Should be fixed at 4eb6cf5. Please test.

@bykhov
Copy link

bykhov commented Jan 2, 2020

Since I have recently updated to 1.46, I have problems in Hebrew text with ordinary numbers when both numbers with period and section numbering reverted. Example follows.

\documentclass[12pt]{article}
\usepackage{polyglossia,bidi}
\setmainlanguage{hebrew}
\setotherlanguage{english}
\setmainfont{David}
\setmonofont{Courier New}
\begin{document}
 בדיקה 1.23
\begin{english}
Test 1.23
\end{english}
\section{א}
\subsection{א}
\subsection{א}
\end{document}

image

See also bidi-tex/bidi#11

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

Thanks, this should be fixed in 4c3eb54

@bykhov
Copy link

bykhov commented Jan 2, 2020

Thanks, it has fixed English text. However, Hebrew one and section numbering are still reverted.
image

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

And they shouldn't? If so, this needs to be fixed in gloss-hebrew.

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

Please try after 038ba03

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

Please try after 038ba03

No, this does not work.

@seloumi
Copy link
Author

seloumi commented Jan 2, 2020

@jspitz I thought the numbering in headings for all RTL languages should be RTL !
Since all numbers need to be LTR in hebrew I think a \setlatin command at the beginning is sufficient to solve the issue.

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

@jspitz I thought the numbering in headings for all RTL languages should be RTL !
Since all numbers need to be LTR in hebrew I think a \setlatin command at the beginning is sufficient to solve the issue.

But doesn't this re-introduce issues with Arabic?

@bykhov
Copy link

bykhov commented Jan 2, 2020

Since all numbers need to be LTR in hebrew I think a \setlatin command at the beginning is sufficient to solve the issue.

Excellent with Hebrew!!!
image
Unfortunately, I don't know about Arabic.

@seloumi
Copy link
Author

seloumi commented Jan 2, 2020

\setlatin can't be added in gloss-hebrew?

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

\setlatin can't be added in gloss-hebrew?

No, only globally for all RLL languages or not.

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

Please try 57b17b3

@seloumi
Copy link
Author

seloumi commented Jan 2, 2020

Also with \setlatin parentheses for equation numbering in RTL context become inverted (if amsmath package is added).

@jspitz
Copy link
Collaborator

jspitz commented Jan 2, 2020

\setlatin is semantically wrong for Hebrew, as Hebrew is not an LTR script (and this is how the Latin conditional is defined). The only issue is with numbers, and this is now worked around in gloss-hebrew. The general problem is that the bidi package is very much focused on Arabic script (as opposed to other RTL scripts).

@bykhov
Copy link

bykhov commented Jan 2, 2020

Please try after 038ba03

Also with \setlatin parentheses for equation numbering in RTL context become inverted.

This is how it works now with equation numbering and \setlatin. It looks exactly how it is supposed to be.

\documentclass[12pt,leqno]{article}

\usepackage{amsmath}
\usepackage{polyglossia,bidi}
\setmainlanguage{hebrew}
\setotherlanguage{english}
\setmainfont{David}
\setmonofont{Courier New}
\setlatin
%fix equation numbering for formulas
\makeatletter
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}}
\makeatother
\begin{document}
בדיקה 1.23

\begin{english}
Test 1.23
\end{english}

\section{א}
\subsection{א}
\subsection{א}
משוואה \eqref{eq}
\begin{equation}\label{eq}
A = \sin(x)
\end{equation}
\end{document}

image

@jspitz
Copy link
Collaborator

jspitz commented Jan 3, 2020

Can you please try after try after 038ba03 without \setlatin and your formula numbering tweak? It should not be needed

@bykhov
Copy link

bykhov commented Jan 5, 2020

Can you please try after try after 038ba03 without \setlatin and your formula numbering tweak? It should not be needed

Without \setlatin the problem is with numbering inside Hebrew text and sections.
image

With \setlatin fixes the problem above and arise the problem with numbering of equations (parenthesis).
image

Please try 57b17b3

Seem to work perfect without \setlatin.
image

\documentclass[12pt,leqno]{article}

\usepackage{amsmath}
\usepackage{polyglossia,bidi}
\setmainlanguage{hebrew}
\setotherlanguage{english}
\setmainfont{David}
\setmonofont{Courier New}
\begin{document}
בדיקה 1.23
\begin{english}
Test 1.23
\end{english}
\section{א}
\subsection{א}
\subsection{א}
משוואה \eqref{eq}, 
\eqref{eq1}
\begin{subequations}\label{eq1}
\begin{align}
A &= \cos(x) \label{eq}\\
V &= \cos(x)
\end{align}
\end{subequations}
\appendix
\section{בדיקה}
\subsection{בדיקה}
\end{document}

jspitz added a commit that referenced this issue May 11, 2023
also for Kurdish, Persian, Syriac, and Urdu (amend #213)
@jspitz
Copy link
Collaborator

jspitz commented May 11, 2023

It turned out \ensure@LTR was needed with Eastern Arabic numerals rather than \ensure@dir to get the proper direction with LuaTeX (XeTeX is unaffected). This has been fixed for 1.63 for Arabic, Kurdish, Persian, Syriac, and Urdu in the abovementioned two commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants