The cause of the error is at line 86 of tabularx.sty (1999/01/07 v2.07):
...
When luatexja is loaded, this \toks@ seems to be empty. Therefore, the next \csname is passed as the second argument to \tabular*.
\toks@ (=\toks0) was resetted by
\edef\math@fonts{\math@fonts\ltjsetparameter{%
jatextfont={#1,\textfont@name},%
jascriptfont={#1,\scriptfont@name},%
jascriptscriptfont={#1,\font@name}}}%
at the definition of \ltj@@ja@getanddefine@fonts (in lltjfont.sty).
\ltjsetparameter (or \setkeys) destroys \toks@.
\ltj@@ja@getanddefine@fonts is called when new Japanese math font is needed. So, the reason that added $a$ before tabularx environment works fine is that Japanese math fonts were already defined before \begin{tabularx}, because of $a$.
Fixed in the commit e07553c (kitagawa_test branch).
luatexja-core.sty:
\protected\def\ltj@setpar@global{%
\ifnum\globaldefs>0\directlua{luatexja.isglobal='global'}\else\directlua{luatexja.isglobal=''}\fi
}
lltjfont.sty:
\ltj@temptoks{\ltj@@set@stackfont}
\edef\math@fonts{\math@fonts\ltj@setpar@global%
\the\ltj@temptoks#1,\textfont@name:{mjtext}%
\the\ltj@temptoks#1,\scriptfont@name:{mjscr}%
\the\ltj@temptoks#1,\font@name:{mjss}%
}%
Fixed in the commit e07553c (kitagawa_test branch).
The example code works fine now. Thanks.
(MaQiYuanさんからの報告を受けて調査しました.英語で書きます.)
A minimal example:
\documentclass{article} \usepackage{tabularx,luatexja} \begin{document} \begin{tabularx}{3cm}{l} a \end{tabularx} \end{document}Error message:
! Package array Error: Illegal pream-token (\csname): `c' used. See the array package documentation for explanation. Type H <return> for immediate help. ... l.13 \end{tabularx} ?The cause of the error is at line 86 of tabularx.sty (1999/01/07 v2.07):
\csname tabular*\expandafter\endcsname\expandafter\TX@target \the\toks@ \csname endtabular*\endcsname}%When luatexja is loaded, this \toks@ seems to be empty. Therefore, the next \csname is passed as the second argument to \tabular*.The following code works with no errors (added $a$ before tabularx environment):
\documentclass{article} \usepackage{tabularx,luatexja} \begin{document} $a$ \begin{tabularx}{3cm}{l} a \end{tabularx} \end{document}By commenting out lines 36--40 of lltjdefs.sty (definition of Japanese math font family), you can also avoid the error.