1. Why in \longtable package for end of line used two commands - @tabularcr and \lt@tabularcr. Because for my package \ command should use once for one line. Yes, I cannot redefine \lt@tabularcr command, and left only @tabularcr command, but it is very interesting for me to understand why for new line two commands calls. 2. How can I redefine \caption command for longtable. When I try to do it, I get an error:

    ! Extra alignment tab has been changed to \cr.

Why does this happen? Thanks everybody very much for the help.

\cs_new_eq:NN\LTX@LT@tabularcr \LT@tabularcr
\cs_new_eq:NN\original@caption \caption
\cs_new_eq:NN\LTX@tabularcr \@tabularcr
\RenewDocumentCommand \LT@tabularcr{s o}{
\IfBooleanT {#1} { * } \IfValueT {#2} { [#2]}
\RenewDocumentCommand \@tabularcr{s o}{
\IfBooleanT {#1} { * } \IfValueT {#2} { [#2]}
\RenewDocumentCommand\caption{s o m}{
\IfBooleanT {#1} { * } \IfValueT {#2} { [#2]}
\caption{test of long tables}
  • 2
    \caption acts like \multicolumn{..}{....} so must expand to the tex primitive column span, you can not have \message{ or even \relax or {} or anything non expandable at the start. – David Carlisle Dec 23 '20 at 20:47
  • 1
    similarly you can not have \message{new~tabularcr~line} at that point in your \\ redefinition as that will stop \multicolumn, or \hline working following `\` as they must be teh first thing in the row. – David Carlisle Dec 23 '20 at 21:42
  • 1
    sorry I don't understand your question about (lt)@tabularcr as I say one is the original version from tabular and isn't defined in the longtable package at all, the other is an extended version from longtable that allows page breaking but calls the original internally. – David Carlisle Dec 23 '20 at 22:06
  • 2
    your caption command is looking for an optional argument, that is not expandable, so that breaks column spanning, – David Carlisle Dec 23 '20 at 22:07
  • 1
    you should have known not to add \message and that \@tabularcr comes from tabular as you had a long answer about exactly those things here tex.stackexchange.com/a/570114/1090 – David Carlisle Dec 24 '20 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.