! 在表格最后一个单元格中使用 \centering 时出现 \noalign 错误问题

! 在表格最后一个单元格中使用 \centering 时出现 \noalign 错误问题
(/usr/local/texlive/2018/texmf-dist/tex/latex/polyglossia/gloss-bengali.ldf
(/usr/local/texlive/2018/texmf-dist/tex/latex/polyglossia/devanagaridigits.sty)
 (/usr/local/texlive/2018/texmf-dist/tex/latex/polyglossia/bengalidigits.sty))

Package polyglossia Warning: gloss-bengali.ldf is already loaded! on input line
 5.

(/usr/local/texlive/2018/texmf-dist/tex/latex/polyglossia/gloss-english.ldf)
(/usr/local/texlive/2018/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifvtex.sty))
(./notYet3daysList.aux)
*geometry* driver: auto-detecting
*geometry* detected driver: xetex

Overfull \hbox (6.22787pt too wide) in paragraph at lines 19--19
[]\TU/Akaash(0)/m/n/5 ক্রমিক

Overfull \hbox (3.89633pt too wide) in paragraph at lines 19--19
\TU/Akaash(0)/m/n/10 নং| 
! Misplaced \noalign.
\hline ->\noalign 
                  {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.20 ...lines}{1}{\value{theyflines} < 25}{\aline}
                                                  \\
?

代码

\documentclass{article}
\usepackage{forloop}
\usepackage{polyglossia}
\setmainlanguage[numerals=Devanagari]{bengali}
\setmainlanguage{bengali}
\setotherlanguage{english}
\newfontfamily\bengalifont[Script=Bengali]{Akaash}
\usepackage[a4paper,left=0.1cm,right=0.1cm,top=0.1cm,bottom=0.1cm]{geometry}
\newcommand{\aline}{\\\hline \arabic{theyflines} &&&&&&&\rule{0cm}{1cm}}
\begin{document}
\begin{center}
যাদেরকে আমরা এখন পর্যন্ত ৩ দিনের জন্য বের করতে পারি নাই, তাদের নামের তালিকা 
\end{center}
\pagenumbering{gobble}
\newcounter{theyflines}
\noindent
\begin{tabular}{|p{0.15cm}|p{5.2cm}|p{1.5cm}|p{1.3cm}|p{1cm}|p{1.4cm}|p{4cm}|p{2.9cm}|}
\hline
{\tiny \centering ক্রমিক} নং & \centering নাম & \centering রুম নং & \centering ডিপার্টমেন্ট & \centering বর্ষ & \centering সেশন & \centering মোবাইল নং & \centering জেলা 
\forloop{theyflines}{1}{\value{theyflines} < 25}{\aline}\\
\hline
\end{tabular}
\end{document}

如果不使用\centering\centering জেলা它可以工作,但是当我放在它\centering之前时জেলা会导致错误。

在此处输入图片描述

答案1

注意,如果这样做,{\tiny \centering ক্রমিক}&在段落结束前关闭组时,单元格不会居中。如果希望整个单元格居中,可以删除,{}但如果只是部分文本,请\par在之前添加一个空白行或}

并添加\arraybackslash以避免出现问题,如果单元格以\\so结尾

{\tiny \centering\arraybackslash ক্রমিক \par} নং &

\arraybackslash如果单元格以 结尾&(或位于组内),则不需要{},仅当它以 结尾时才需要\\,但在之后的所有表格单元格中使用它并不会造成任何损害\centering

答案2

加载

\usepackage{ragged2e}

并将其替换\centering\Centering(大写 C)。但是,

\newcolumntype{P}[1]{>{\Centering}p{#1}}

然后使用P{0.15cm}才有意义;不需要\Centering

相关内容