如何使用 for 循环将孟加拉语序列号放在空表中?

如何使用 for 循环将孟加拉语序列号放在空表中?

在此处输入图片描述

\documentclass{article}
\usepackage{forloop}
\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{bengali}
\setmainlanguage{bengali}
\setotherlanguage{english}
\newfontfamily\bengalifont[Script=Bengali]{Akaash}
\usepackage[a4paper,left=0cm,top=0cm,bottom=0cm]{geometry}
\newcommand{\aline}{\\\hline \arabic{theyflines} &&&&&&&\rule{0cm}{0.5cm}}
\begin{document}
\pagenumbering{gobble}
\newcounter{theyflines}
%\begin{center}
%Extension - 1
%\end{center}
\noindent
\begin{tabular}{|p{0.15cm}|p{6cm}|p{1.5cm}|p{1.3cm}|p{1cm}|p{1.5cm}|p{4.5cm}|p{3cm}|}
\hline
{\tiny ক্রমিক} নং & নাম & রুম নং & ডিপার্টমেন্ট & বর্ষ & সেশন & মোবাইল নং & জেলা
\forloop{theyflines}{1}{\value{theyflines} < 40}{\aline}\\
\hline
\end{tabular}
\end{document}

因为我的文件是用孟加拉语写的,所以我想用孟加拉语১,২,৩,৪,৫...来输入序列号,而不是1,2,3,4,5.....

答案1

该宏\bengaliNum以 LaTeX 计数器的名称作为参数(与\value{theyflines}您可以使用的类似\bengaliNum{theyflines})并以孟加拉语打印数字。

\documentclass[]{article}

\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{bengali}
\setmainlanguage{bengali}
\setotherlanguage{english}
\newfontfamily\bengalifont[Script=Bengali]{Ekushey Amar Desh}

\makeatletter
\newcommand\bengaliNum[1]
  {%
    \expandafter\@bengaliNum\csname c@#1\endcsname
  }
\newcommand\@bengaliNum[1]
  {%
    \expandafter\bengaliNum@a\the#1\end@bengaliNum
  }
\newcommand\bengaliNum@a{}
\def\bengaliNum@a#1#2\end@bengaliNum
  {%
    \ifcase#1 ০%
    \or ১%
    \or ২%
    \or ৩%
    \or ৪%
    \or ৫%
    \or ৬%
    \or ৭%
    \or ৮%
    \or ৯%
    \fi
    \if\relax\detokenize{#2}\relax
      \expandafter\@gobble
    \else
      \expandafter\@firstofone
    \fi
    {\bengaliNum@a#2\end@bengaliNum}%
  }
\makeatother

\newcounter{testcounter}

\begin{document}
\loop\ifnum\value{testcounter}<20
  \makebox[1em][r]{\thetestcounter:} \bengaliNum{testcounter}\par
  \stepcounter{testcounter}
\repeat
\end{document}

孟加拉数字 0 至 19

使用您的 MWE(我没有调整任何间距):

\documentclass[]{article}

\usepackage{forloop}
\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{bengali}
\setmainlanguage{bengali}
\setotherlanguage{english}
\newfontfamily\bengalifont[Script=Bengali]{Ekushey Amar Desh}

\makeatletter
\newcommand\bengaliNum[1]
  {%
    \expandafter\@bengaliNum\csname c@#1\endcsname
  }
\newcommand\@bengaliNum[1]
  {%
    \expandafter\bengaliNum@a\the#1\end@bengaliNum
  }
\newcommand\bengaliNum@a{}
\def\bengaliNum@a#1#2\end@bengaliNum
  {%
    \ifcase#1 ০%
    \or ১%
    \or ২%
    \or ৩%
    \or ৪%
    \or ৫%
    \or ৬%
    \or ৭%
    \or ৮%
    \or ৯%
    \fi
    \if\relax\detokenize{#2}\relax
      \expandafter\@gobble
    \else
      \expandafter\@firstofone
    \fi
    {\bengaliNum@a#2\end@bengaliNum}%
  }
\makeatother


\usepackage[a4paper,left=0cm,top=0cm,bottom=0cm]{geometry}
\newcommand{\aline}{\\\hline \bengaliNum{theyflines} &&&&&&&\rule{0cm}{0.5cm}}

\begin{document}
\pagenumbering{gobble}
\newcounter{theyflines}
\noindent
\begin{tabular}{|p{0.15cm}|p{6cm}|p{1.5cm}|p{1.3cm}|p{1cm}|p{1.5cm}|p{4.5cm}|p{3cm}|}
\hline
{\tiny ক্রমিক} নং & নাম & রুম নং & ডিপার্টমেন্ট & বর্ষ & সেশন & মোবাইল নং & জেলা
\forloop{theyflines}{1}{\value{theyflines} < 40}{\aline}\\
\hline
\end{tabular}
\end{document}

表中的孟加拉语数字

相关内容