3

I am writing a document which is mainly in Bengali but also contains English. I have been able to change the section and subsection numbers to Bengali using the method described here by Davislor. However, this doesn't change the numbering style to Bengali for nested lists.

As can be seen from the image, for the inner list of the nested list, as the numbering style, English alphabets are used. I want to replace those with the Bengali alphabets (ক, খ, গ, etc). How can this be done?

Here is a minimal working example.

% !TeX program = xelatex
\documentclass[12pt]{article}

\usepackage{babel}

\babelprovide[maparabic]{bengali} \babelfont{rm}{Shonar Bangla} \babelfont[english]{rm}{Times New Roman}

\begin{document} \section{প্রথম অধ্যায়} Foo bar \begin{enumerate} \item ফু \begin{enumerate} \item বার \item ফু \end{enumerate} \item বার \end{enumerate} \end{document}

I am using MiKTeX and XeLaTeX.

Mico
  • 506,678
Imran
  • 3,096

1 Answers1

3

Glad you found that helpful. Short answer: add the option alph=alphabetic to babelprovide. Longer answer (which enables compatibility with LuaLaTeX and adds a few bells and whistles):

% Recommended with LuaLaTeX in TeX Live 2020 or later,
% but also works with XeLaTeX.
\documentclass[12pt]{article}
\tracinglostchars=2 % Warn if the current font lacks a character.
\usepackage{iftex}

\ifluahbtex % Includes LuaLaTeX in TeX Live 2020. \usepackage[bidi=basic, layout=sectioning.counters]{babel} \usepackage{fontspec} %% Will auto-detect the language on LuaLaTeX: \defaultfontfeatures{ Renderer=HarfBuzz, Ligatures=TeX, Scale=MatchLowercase } \babelprovide[onchar=ids fonts]{english} \else % Another Unicode engine, such as XeLaTeX. \usepackage[bidi=default, layout=sectioning.counters, english]{babel} \usepackage{fontspec} \defaultfontfeatures{ Ligatures=TeX, Scale=MatchLowercase } \fi

\babelprovide[import, main, maparabic, alph=alphabetic ]{bengali}

\babelfont{rm} [Scale=1.0, Language=Default]{Shonar Bangla} \babelfont[english]{rm} [Ligatures=Common]{Times New Roman}

\begin{document} \section{প্রথম অধ্যায়} Foo bar \begin{enumerate} \item ফু \begin{enumerate} \item বার \item ফু \end{enumerate} \item বার \end{enumerate} \end{document}

Shonar Bangla font sample

On LuaLaTeX, this document will automatically detect when you type in English and change languages, so you will see English text in Times New Roman and get hyphenation patterns, ligatures and so on.

XeTeX will treat all text as the default language unless you explicitly change it, which you can do by adding the command \babeltags{english=english} and writing \textenglish{Foo bar}. Otherwise, your English text will appear as Shonar Bengla. This would be more noticeable if your Bengali font did not support the Latin alphabet or if you were switching between LTR and RTL.

Davislor
  • 44,045
  • The long answer works perfectly with LuaLaTeX. But when I compile it with XeLaTeX, it shows error. Also, the short answer didn't work for me. Why these are happening? Is it because I use MiKTeX? – Imran Sep 22 '20 at 09:21
  • 1
    @Imran No, it’s because I made a typo. Fixed now. – Davislor Sep 22 '20 at 09:28
  • Got it. And the reason that the short answer didn't work, maybe not adding main and import options to babelprovide. After adding them, it works fine. – Imran Sep 22 '20 at 09:36
  • @Imran I’m surprised it worked without them before. In any case, I’ve added the code to auto-detect what language you’re typing in on LuaLaTeX. You’d still need to manually tag English words in XeLaTeX. – Davislor Sep 22 '20 at 10:02
  • But I didn't manually tag English words and yet it worked with XeLaTeX. However, the output was not shown in the embedded viewer of TeXstudio. I had to open it with acrobat reader every time. Why that might happen? – Imran Sep 22 '20 at 12:14
  • 1
    @Imran You displayed the English words in your Bengali font. – Davislor Sep 22 '20 at 12:19