3

In the past (may be last year or so), I have used these three packages together successfully (and produced a conditionally colored long table). That tex file still compiles nicely; however, the following MWE produces errors if any of the % signs (from the table definition) is deleted.

More specifically, if the number of rows is greater than 19 or any of the line endings is marked as non-breakable -- i.e. \\* -- then each of such cases produces the following error:

! Missing \endgroup inserted.< inserted text > \endgroup x

where x is the line number.

Moreover, if the arydshln package is also loaded then the number of errors for each such case is triples and produces the following errors:

! Extra }, or forgotten \endgroup.< template > ... \endcollectcell \relax \d@llarend }\adl@colhtdp \unhbox \adl@... x 

! Missing \endgroup inserted.< inserted text >\endgroup x 

! Missing } inserted.< inserted text >} x

I suspected that the order of the packages might be the reason but that was not the case. Do you have any idea why this is happening or how I can fix it?

%MWE
\documentclass[12pt,a4paper]{report}
\usepackage{longtable}
\usepackage{collcell}
%\usepackage{arydshln}

\newcolumntype{R}{>{\collectcell\fbox}r<{\endcollectcell}}%

\begin{document}
\begin{longtable}[c]{R}
     \hline    
    $n$ \\
     \hline
\endhead
     \hline
\endfoot
    1 \\%*
    2 \\
    3 \\
    4 \\
    5 \\
    6 \\
    7 \\
    8 \\%*
    9 \\
    10 \\
    11 \\
    12 \\
    13 \\
    14 \\
    15 \\
    16 \\
    17 \\
    18 \\
    19 \\
%    20 \\
%    20 \\
%    20 \\
\end{longtable}
\end{document}
3

I have continued to look for a solution and found a "dirty" fix. Since I have spent 10+ hours in total, I just wanted to publish my solution in the hope that one day it may help someone. Please do write a new solution if you have a better fix or an explanation of the underlying issues.

The solution is to add a "dummy" column of default type (l, r, c) to the very end because the errors occur only if the last column is of custom type. Note that only updating the column specification list -- e.g., \begin{longtable}[c]{Rr} -- is not enough, one also needs to update all row endings and add an empty cell -- e.g., 1 & \\*.

2

The longtable mechanism processes table contents in chunks of a few lines. The \endgroup errors observed here occur at the ends of those chunks. The size of those chunks is determined by the value of the LaTeX counter LTchunksize; the default is 20 which So there’s the workaround of simply setting that counter to some value higher than the maximal number of lines occurring, e. g. by putting the line

\setcounter{LTchunksize}{1000}

in the preamble. TeX will need more memory but in somewhat up-to-date computers that should be no problem.

2
  • +1! Wel, for this particular case is sufficient if the the chunk size is for example 25 ;-)
    – Zarko
    Jan 28 '20 at 3:28
  • Thanks! And correct. I confess, I copied this from a recent project with slightly longer tables. However, there is no need to adjust the value to the size of the longtable, since the actual memory requirement depends only on the number of table rows read, not on the value of LTchunksize. Jan 29 '20 at 11:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.