\forloop 问题(未定义的控制序列)

\forloop 问题(未定义的控制序列)
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/local/texlive/2018/texmf-dist/tex/latex/l3kernel/l3xdvipdfmx.def)))
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec-xetex.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2018/texmf-dist/tex/latex/base/tuenc.def))
(/usr/local/texlive/2018/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
(/usr/local/texlive/2018/texmf-dist/tex/generic/oberdiek/ifluatex.sty))
(/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
 9.

(/usr/local/texlive/2018/texmf-dist/tex/latex/polyglossia/gloss-english.ldf)
(./hallJimmaderListBlank.aux) ABD: EveryShipout initializing macros
*geometry* driver: auto-detecting
*geometry* detected driver: xetex
! Undefined control sequence.
l.22 \forloop
             {theyflines}{1}{\value{theyflines} < 20}{\hline}
?

代码

  \documentclass{article}
\usepackage{pgffor}
 \usepackage{forloop}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage[a4paper,left=1cm,top=1cm,bottom=0cm,right=0cm]{geometry}
%\newcommand{\aline}{\\\hline \arabic{theyflines} &&&&&&&&&&&&&&&&\rule{0cm}{0.4cm}}
%\newfontfamily\englishfont[Scale=MatchLowercase]{Linux Biolinum O}

\begin{document}
\newcounter{theyflines}
\begin{center}
fajajf
\end{center}
\centering
\begin{tabular}{|c|c|c|c|c|}
A & B & C & D & E\\
\toprule
\forloop{theyflines}{1}{\value{theyflines} < 20}{\hline}\\
%\forloop{theyflines}{1}{\value{theyflines} < 52}{\aline}\\
\end{tabular}
\end{document}

我没有发现问题所在。

答案1

forloop添加包后,我收到不同的错误:

! Misplaced \noalign.
\hline ->\noalign 
                  {\ifnum 0=`}\fi \hrule \@height \arrayrulewidth \futurelet...
l.19 ...lines}{1}{\value{theyflines} < 20}{\hline}
                                                  \\

\\这是当您没有在水平线( 、 等)之前插入制表符新行( )\hline\toprule发生的错误。

你的循环说:

\forloop{theyflines}{1}{\value{theyflines} < 20}{\hline}\\

或者更明确地说,

\forloop{theyflines}{1}{\value{theyflines} < 20}{\hline}%
\\

插入 20\hline秒,然后插入 a \\,从而出现Misplaced \noalign错误。

要解决此问题,只需移动\\ \hline

\documentclass{article}
\usepackage{pgffor}
\usepackage{forloop}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage[a4paper,left=1cm,top=1cm,bottom=0cm,right=0cm]{geometry}
%\newcommand{\aline}{\\\hline \arabic{theyflines} &&&&&&&&&&&&&&&&\rule{0cm}{0.4cm}}
%\newfontfamily\englishfont[Scale=MatchLowercase]{Linux Biolinum O}

\begin{document}
\newcounter{theyflines}
\begin{center}
fajajf
\end{center}
\centering
\begin{tabular}{|c|c|c|c|c|}
A & B & C & D & E\\
\toprule
\forloop{theyflines}{1}{\value{theyflines} < 20}{\\ \hline}
%\forloop{theyflines}{1}{\value{theyflines} < 52}{\aline}\\
\end{tabular}
\end{document}

在此处输入图片描述

相关内容