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:
Error message:
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*.The following code works with no errors (added $a$ before tabularx environment):
By commenting out lines 36--40 of lltjdefs.sty (definition of Japanese math font family), you can also avoid the error.