reutenauer / polyglossia

An alternative to Babel for XeLaTeX and LuaLaTeX
http://www.ctan.org/pkg/polyglossia
MIT License
190 stars 51 forks source link

Numbering problem with latest version of polyglossia for Kannada #622

Closed alaymari closed 7 months ago

alaymari commented 9 months ago

I am using texlive 2023 updated as of 2023-12-27. When I compiled a file with lualatex, I get the following error message:

...
 ! Missing number, treated as zero.
 <to be read again> 
\c@CHAPTER 
l.62 \chapter
            {ಪರಿಣಾಮ}
? 
...

Ignoring the error, I got the final pdf. But the chapter and page numbers in the table of contents are wrong. They are all set to one fixed value. The page numbers and chapters are fine in the actual text.

The same file compiles fine without any error on a previous version of polyglossia.sty (2023/06/10 v1.63).

Here is the MWE:

\documentclass{book}

\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{fancyhdr}

% polyglossia says configure languages after all packages loaded
\setdefaultlanguage{kannada}
\setotherlanguage{english}% or american or whatever
\setmainfont[Script=Kannada]{Noto Sans Kannada}
\setmonofont[Script=Kannada]{Noto Sans Kannada}

%
\newcommand{\kannadanumeral}[1]{%
  \kannadadigits{\number\csname c@#1\endcsname}}
%

\renewcommand{\thechapter}{\localnumeral*{chapter}}
\renewcommand{\thesection}{\localnumeral*{section}}
\renewcommand{\thepage}{\localnumeral*{page}}
\renewcommand{\theenumi}{\localnumeral*{enumi}}
\renewcommand{\theenumii}{\localnumeral*{enumii}}

% We will define some fancy page styles here
\pagestyle{fancy}
\fancyhf{}          % Empty every style
\fancyhead[LO, LE]{\leftmark}

\fancypagestyle{plain}{%
  \fancyhf{}%
  \renewcommand{\headrulewidth}{0pt}%
  \renewcommand{\footrulewidth}{0.4pt}%
  \rfoot{\thepage}%
}

\begin{document}
\renewcommand{\contentsname}{ಪರಿವಿಡಿ} 
\frontmatter
  \pagenumbering{roman}
  \renewcommand*{\thepage}{\textenglish{\roman{page}}}

\tableofcontents

\chapter{ಮುನ್ನುಡಿ}

ಕರ್ನಾಟಕ ನಾಡು ಮತ್ತು ಆ ನಾಡಿನ ಜನ ಹಾಗೂ ಅವರಾಡುವ ಭಾಷೆ. 

\clearpage
\mainmatter
  \pagenumbering{arabic}
  \renewcommand*{\thepage}{\localnumeral*{page}}

\chapter{ಇತಿಹಾಸ}

ಅಶೋಕನ ಬ್ರಾಹ್ಮೀ ಲಿಪಿ ಉತ್ತರಕ್ಕೆ ಕಾಲಸಿ ಮತ್ತು ಭಾರತ-ನೇಪಾಲ ಗಡಿಯಲ್ಲಿರುವ ರುಮ್ಮಿಂದೈಯಿಂದ ದಕ್ಷಿಣಕ್ಕೆ
ಮೈಸೂರುವರೆಗೂ ಪೂರ್ವಕ್ಕೆ ಒರಿಸ್ಸದಿಂದ ಪಶ್ಚಿಮಕ್ಕೆ ಜುನಾಗಢ ಮತ್ತು ಮುಂಬಯಿವರೆಗೂ ದೊರೆತ ಅಶೋಕ ಸಾಮ್ರಾಟನ
ಧರ್ಮಶಾಸನಗಳಲ್ಲಿ ಕಂಡುಬರುತ್ತದೆ. ಈ ಲಿಪಿಯು ಅಶೋಕನ ಕಾಲದಲ್ಲಿ ಪ್ರಚಲಿತವಿದ್ದ ಪಾಕೃತ ಬಾಷೆಯಾಗಿ
ಉಪಯೋಗಿಸಲ್ಪಟ್ಟಿದೆ.

\textenglish{This is some text in English.}

\chapter{ಪರಿಣಾಮ}

ಕನ್ನಡ ಲಿಪಿಯ ಒಂದು ವೈಶಿಷ್ಟ್ಯವೆಂದರೆ ಪ್ರಾಚೀನಕಾಲದಿಂದಲೂ ಕಾಗುಣಿತಾಕ್ಷರದ ಹೃಸ್ವ ಮತ್ತು ದೀರ್ಘ ಎ
ಮತ್ತು ಏ ಕಾರಗಳನ್ನು ಹಾಗೂ ಒ ಮತ್ತು ಓ ಕಾರಗಳನ್ನು ಒಂದೇ ಸಂಜ್ಞೆಯಿಂದ ಸೂಚಿಸುತ್ತಿದ್ದು ಅವುಗಳಲ್ಲಿಯ
ಹೃಸ್ವ ಮತ್ತು ದೀರ್ಘ ವರ್ಣಗಳ ಭೇದವನ್ನು ಸಂದರ್ಭಾನುಸಾರವಾಗಿ ತಿಳಿದುಕೊಳ್ಳಬೇಕಾಗಿತ್ತು.

\chapter{ಕನ್ನಡದ ಶುದ್ಧಾಕ್ಷರಗಳ ವಿಧಗಳು}

ಕೇಶಿರಾಜನ ಪ್ರಕಾರ ಕನ್ನಡ ಶುದ್ಧಗೆಯಲ್ಲಿ ಐದು ವಿಧಗಳು. ಅವುಗಳು ಕ್ರಮವಾಗಿ : ಸ್ವರ ಅಕ್ಷರಗಳು,
ವರ್ಗೀಯ ವ್ಯಂಜನ ಅಕ್ಷರಗಳು, ಅವರ್ಗೀಯ ವ್ಯಂಜನ ಅಕ್ಷರಗಳು, ಯೋಗವಾಹ ಅಕ್ಷರಗಳು, ದೇಶಿಯ ಅಕ್ಷರಗಳು.
ಆದರೆ ಕನ್ನಡ ಪಠ್ಯಾನುಸಾರ ಪ್ರಾಥಮಿಕ ಮತ್ತು ಮಾಧ್ಯಮಿಕ ತರಗತಿಯ ವಿದ್ಯಾರ್ಥಿಗಳು ಒಟ್ಟು ಕನ್ನಡ
ಅಕ್ಷರಗಳನ್ನು ಈ ಕೆಳಗಿನಂತೆ ಗ್ರಹಿಸಿಕೊಂಡಿದ್ದಾರೆ. 

\end{document}
jspitz commented 9 months ago

Thanks for the report. @Udi-Fogiel bisect points to 26cb857dd2fd3df

Udi-Fogiel commented 9 months ago

This is a case changing problem again.

@alaymari until the next release can add the line \AddToNoCaseChangeList\localnumeral to the preamble as a workaround.

Udi-Fogiel commented 9 months ago

@jspitz BTW, wouldn't \localenumeral make more sense?

Udi-Fogiel commented 9 months ago

It did not fix the problem with the values in the table of contents. For that expansion is a must, but I don't like the fact that \localnumeral needs to be protected if the lang parameter is not local, and has to be expandable otherwise.

alaymari commented 9 months ago

Tried the suggestion and as already noted, does not work.

jspitz commented 9 months ago

@jspitz BTW, wouldn't \localenumeral make more sense?

Maybe, but we do not want to change that now that it's used for quite a while.

Udi-Fogiel commented 9 months ago

@alaymari I've pushed a fix to the master branch, can you pleas test it?

Udi-Fogiel commented 9 months ago

I don't like the fact that \localnumeral needs to be protected if the lang parameter is not local, and has to be expandable otherwise.

since 5b56b61 \foreignlanguage is protected, so the problem I had in the case where lang is not local is gone.

Udi-Fogiel commented 9 months ago

@jspitz BTW, wouldn't \localenumeral make more sense?

Maybe, but we do not want to change that now that it's used for quite a while.

Ok!

alaymari commented 9 months ago

@alaymari I've pushed a fix to the master branch, can you pleas test it?

Checked the new version. It is working as expected. Thanks a lot for giving a solution so fast.

Udi-Fogiel commented 9 months ago

Thanks for testing!