[texhax] tabu* and LuaTeX

Arno Trautmann Arno.Trautmann at gmx.de
Mon Nov 14 22:12:13 CET 2011


Paul Isambert wrote:
> Le 14/11/2011 12:22, Arno Trautmann a écrit :
>> Hi all,
>>
>> I have troubles using the tabu* environment from the tabu package to
>> typeset verbatim material using LuaLaTeX. The following example:
>>
>> \documentclass{minimal}
>> \usepackage{tabu}
>>
>> \begin{document}
>>
>> \begin{tabu*}{Xl}
>> \verb+\test+
>> & test \\
>> \end{tabu*}
>> \end{document}
>>
>> results in an error:
>>
>> ./test.tex:10: Extra }, or forgotten $.
>> <recently read> \egroup
>>
>> l.10 \end{tabu*}
>>
>>
>> ?
>>
>> I think I could isolate the error to \scantokens.
>
> Could you elaborate on that? It'd help.

Taken from tabu.sty:
l. 621:
\expandafter\def\csname tabu*\endcsname{\tabuscantokenstrue \tabu}

l. 1302:
\def\tabu at shorttrial {\setbox\tabu at box \hbox\bgroup \tabu at seteverycr
     \ifx \tabu at savecounters\relax \else
                 \let\tabu at savecounters \relax \tabu at clckpt \fi
     $\iftabuscantokens \tabu at rescan \else \expandafter\@secondoftwo \fi
        \expandafter{\expandafter \tabuthepreamble
                          \the\tabu at thebody
                          \csname tabu at adl@endtrial\endcsname
                          \endarray}$\egroup             % got \tabu at box
}% \tabu at shorttrial

l. 124
\def\tabu at rescan {\tabu at verbatim \scantokens  }

So the difference between tabu and tabu* shouldbe that additional 
\tabu at verbatim and \scantokens. Taking \scantokens off that definition, 
there is no error (but also no verbatim).

>> This is used by tabu, and the above example works (!) with pdfLaTeX as
>> well as XeLaTeX.
>
> The difference I see between LuaTeX and pdfTeX is that in the former a $
> is encountered, opening a math group, so the following end-of-group
> character is out of place (hence the error). But I don't know where this
> math-shift comes from.

Me neither …

>> So I consulted the LuaTeX manual and found 2.7.4 about \scantextokens.
>> Well, I tried to be very “clever” and
>> \let\scantokens\luatexscantextokens, but the error remains. (Of course
>> XeTeX and pdfTeX now fail)
>
> \scantokens should have its legacy behvior in LuaTeX.

And tabu* /should/ work without throwing errors ;)

Ok, taking your statement serious, it boils down to the math shift. Then 
it must be something in the second-to-last line with
\endarray}$\egroup

Unfortunately, I cannot figure out what exactly that code does – and if 
it is the right place to look at in the end …

cheers
Arno


More information about the texhax mailing list