6

I want to make a enumerated list in Bangla. I am using babel package for Bangla support. My code is given below:

\documentclass{book}

\usepackage[english]{babel} \babelprovide[import, onchar = fonts ids]{bengali} % \babelfont[bengali]{rm}[Renderer=Harfbuzz]{FreeSerif} \babelfont[bengali]{rm}[Renderer=Harfbuzz,AutoFakeBold,AutoFakeSlant=0.3]{Kalpurush} \babelcharproperty{`।}{locale}{bengali}

% draw figures \usepackage{tikz}

% circled numbering \usepackage{enumitem} \newcommand*\circled[1]{\tikz[baseline=(char.base)]{% \node[shape=circle,fill=black!20,inner sep=2pt] (char) {#1};}}

% bangla numerals \babelprovide[maparabic,alph=alphabetic]{bengali}

\begin{document}

\subsubsection*{গণিতের চারটি নিয়ম}

\begin{enumerate}[label=\protect\circled{\arabic*}] \item যোগের জন্য দেওয়া সংখ্যাগুলোর যেকোন একটিকে অথবা দুটিকেই কাছাকাছি কোন রাউন্ড ফিগার করে নিই। কোন সংখ্যাকে রাউন্ড করতে হলে তার সাথে অন্য একটি ছোট সংখ্যা যোগ বা বিয়োগ করে তাকে ১০ এর গুণিতক আকারে লিখি। \item এবার রাউন্ড করা সংখ্যার সাথে অন্য সংখ্যাটি সহজেই যোগ করে ফেলি। যোগের সময় রাউন্ড করতে নেওয়া অতিরিক্ত সংখ্যাটি আলাদা রাখি। \item এখন প্রাপ্ত যোগফলের সাথে অতিরিক্ত সংখ্যাটি যোগ বা বিয়োগ (যেখানে যেটা লাগবে) করে দিই। তাহলে, আমরা পেয়ে গেলাম আমাদের নির্ণেয় যোগফল। \end{enumerate}

\end{document}

Using this code I got the following output. You will see the text is not showing.

enter image description here

But I want something like this:

enter image description here

How can I achieve my desired output?

mmr
  • 2,249
  • 5
  • 22
  • You may want to have a look a the circledsteps package. –  Oct 30 '21 at 18:59
  • This is to be compiled using LuaTeX, I assume. – Jasper Habicht Oct 30 '21 at 19:30
  • 2
    Very strangely, the \circled macro or maybe the fact that it is protected seems to interfere with the language that is currently selected. I found that if you place \selectlanguage{bengali} inside your definition of the \circled macro or after the very first occurence of \item inside the enumerate environment, the text of the entries reappears. But I don't fully understand why this is. – Jasper Habicht Oct 30 '21 at 21:20
  • 1
    It seem related to https://github.com/latex3/babel/issues/99 . tikz uses a dirty trick to store information based on selecting a null font, which is not recognized by the onchar algorithm. – Javier Bezos Oct 31 '21 at 11:57

1 Answers1

5

Edited. I’ve extended point 2 with a full example, and revised point 1 because it poses a problem. Anyway, for large spans of text, selecting explicitly the language is better.

My guess in the comments above was correct. It’s related to a hack in tikz/pgf, which switches to a null font. There are two options:

1. I’m not sure why the following workaround (which is basically what @JasperHabicht suggested) shows the font, and at the same time renders incorrectly some characters.

\begin{enumerate}[label=\foreignlanguage{bengali}\protect\circled{\arabic*}}]

It might work with other scripts, but in this case it’s not the solution.

2. Write the following piece of code just before \begin{document}:

\makeatletter
\AtBeginDocument{%
 \def\bbl@mapdir#1{%
   {\def\languagename{#1}%
    \let\bbl@ifrestoring\@firstoftwo % To avoid font warning
    \bbl@switchfont
    \ifnum\fontid\font>\z@
      \directlua{
        Babel.locale_props[\the\csname bbl@id@@#1\endcsname]%
              ['/\bbl@prefontid'] = \fontid\font\space}%
    \fi}}}%
\makeatother

Here is the full example:

\documentclass{book}

\usepackage[english]{babel} \babelprovide[import, onchar = fonts ids]{bengali} % \babelfont[bengali]{rm}[Renderer=Harfbuzz]{FreeSerif} \babelfont[bengali]{rm}[Renderer=Harfbuzz,AutoFakeBold,AutoFakeSlant=0.3]{Kalpurush} \babelcharproperty{`।}{locale}{bengali}

% draw figures \usepackage{tikz}

% circled numbering \usepackage{enumitem} \newcommand*\circled[1]{\tikz[baseline=(char.base)]{% \node[shape=circle,fill=black!20,inner sep=2pt] (char) {#1};}}

% bangla numerals \babelprovide[maparabic,alph=alphabetic]{bengali}

\makeatletter \AtBeginDocument{% \def\bbl@mapdir#1{% {\def\languagename{#1}% \let\bbl@ifrestoring@firstoftwo % To avoid font warning \bbl@switchfont \ifnum\fontid\font>\z@ \directlua{ Babel.locale_props[\the\csname bbl@id@@#1\endcsname]% ['/\bbl@prefontid'] = \fontid\font\space}% \fi}}}% \makeatother

\begin{document}

\subsubsection*{গণিতের চারটি নিয়ম}

\begin{enumerate}[label=\protect\circled{\arabic*}] \item যোগের জন্য দেওয়া সংখ্যাগুলোর যেকোন একটিকে অথবা দুটিকেই কাছাকাছি কোন রাউন্ড ফিগার করে নিই। কোন সংখ্যাকে রাউন্ড করতে হলে তার সাথে অন্য একটি ছোট সংখ্যা যোগ বা বিয়োগ করে তাকে ১০ এর গুণিতক আকারে লিখি। \item এবার রাউন্ড করা সংখ্যার সাথে অন্য সংখ্যাটি সহজেই যোগ করে ফেলি। যোগের সময় রাউন্ড করতে নেওয়া অতিরিক্ত সংখ্যাটি আলাদা রাখি। \item এখন প্রাপ্ত যোগফলের সাথে অতিরিক্ত সংখ্যাটি যোগ বা বিয়োগ (যেখানে যেটা লাগবে) করে দিই। তাহলে, আমরা পেয়ে গেলাম আমাদের নির্ণেয় যোগফল। \end{enumerate}

\end{document}

enter image description here

Javier Bezos
  • 10,003